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
[EMAIL PROTECTED]
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/
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make