|
From: | John Graham-Cumming |
Subject: | Re: Preconditions vs. Dependencies |
Date: | Tue, 22 Nov 2005 07:16:16 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104 |
natch wrote:
I'm having a dependency problem that I can't find a good solution to. I want to create files inside a directory other than that in which make is executing. The easy solution is that the files depend on the directory they are in, so make will not try to create the files unless the directory is created first. However, if more than one file is created in that directory, the timestamp on the directory is updated, and make considers that prerequisite newer than the target. Consider the following makefile:DIR=outdir FILES=$(DIR)/a $(DIR)/b $(DIR)/c $(DIR): mkdir $@ $(FILES): $(DIR) touch $@
A simple way to make this work is to have a file in each directory that is used to indicate the existence of the directory and can be safely used as a prerequisite in Make avoiding the remaking problems that you are seeing.
For example, every directory you create could have a file called '.f' in it made with a rule like this:
$(DIR)/.f: mkdir (@D) touch $@ and then you could have the $(FILES) depend on that file: $(FILES): $(DIR)/.f If you are creating different directories then you can use a pattern rule: %/.f: mkdir $* touch $@ John. -- John Graham-Cumming address@hidden Home: http://www.jgc.org/ POPFile: http://getpopfile.org/ GNU Make Standard Library: http://gmsl.sf.net/ Fast, Parallel Builds: http://www.electric-cloud.com/ Sign up for my Spam and Anti-spam Newsletter at http://www.jgc.org/ PGP key: http://www.jgc.org/pgp/
[Prev in Thread] | Current Thread | [Next in Thread] |