[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Antwort: Re: Feature request: meta files & wildcards (once again)
From: |
Alexandre Duret-Lutz |
Subject: |
Re: Antwort: Re: Feature request: meta files & wildcards (once again) |
Date: |
Wed, 08 May 2002 18:07:22 +0200 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu) |
Bruce> GEN_LIST = foo.h bar.h baz.h
Bruce> $(GEN_LIST) : gen-stamp
Bruce> gen-stamp : <predecessor-list>
Bruce> <generator-command> && touch $@
adl> Yes, it's just the same: you can pick any file in GEN_LIST and
adl> use it in lieu of gen-stamp.
bernd> No it's not (I think).
bernd>
bernd> $ cat >Makefile
bernd> GEN_LIST = foo.h bar.h baz.h
bernd>
bernd> all: foo.h bar.h baz.h
bernd>
bernd> xyzzy:
bernd> touch xyzzy
bernd>
bernd> foo.h: xyzzy
bernd> touch $(GEN_LIST)
bernd> ^D
bernd> $ make
bernd> touch foo.h bar.h baz.h
bernd> $ rm -f bar.h # oops, I edited a generated file
bernd> $ make
bernd> make: *** No rule to make target `bar.h', needed by `all'. Stop.
bernd>
bernd> Is this what you meant?
Almost. Your Makefile lacks the `bar.h baz.h: foo.h' dependency.
| GEN_STAMP = foo.h
| GEN_OTHERS = bar.h baz.h
| GEN_LIST = $(GEN_STAMP) $(GEN_OTHERS)
|
| all: $(GEN_LIST)
|
| xyzzy:
| touch xyzzy
|
| $(GEN_STAMP): xyzzy
| touch $(GEN_LIST)
|
| $(GEN_OTHERS): $(GEN_STAMP)
What I was saying is that Bruce is just using the same scheme
with an additional file:
GEN_STAMP = gen-stamp
GEN_OTHERS = foo.h bar.h baz.h
In both cases, you're right to complain that these rules can't
recover from the deletion of a file in GEN_OTHERS:
~/tmp % make 18:00 #374
touch xyzzy
touch foo.h bar.h baz.h
~/tmp % rm foo.h 18:00 #375
~/tmp % make 18:00 #376
touch foo.h bar.h baz.h
~/tmp % rm bar.h 18:00 #377
~/tmp % make 18:00 #378
make: Nothing to be done for `all'.
~/tmp % make bar.h 18:00 #379
make: Nothing to be done for `bar.h'.
~/tmp % ls -l bar.h 18:00 #380
ls: bar.h: No such file or directory
~/tmp % Err 1 #381
bernd> This seems similar to AM_YFLAGS = -d where removing
bernd> either the parser or its definitions can cause build
bernd> failures virtually requiring one to re-untar the source
bernd> to fix them.
There is a solution to this. It is used in the rule for
config.h, probably it should be used for the Yacc rules too:
| GEN_STAMP = foo.h
| GEN_OTHERS = bar.h baz.h
| GEN_LIST = $(GEN_STAMP) $(GEN_OTHERS)
|
| all: $(GEN_LIST)
|
| xyzzy:
| touch xyzzy
|
| $(GEN_STAMP): xyzzy
| touch $(GEN_LIST)
|
| $(GEN_OTHERS): $(GEN_STAMP)
| @if test ! -f $@; then \
| rm -f $(GEN_STAMP); \
| $(MAKE) $(GEN_STAMP); \
| else :; fi
~/tmp % make 18:04 #384
touch xyzzy
touch foo.h bar.h baz.h
~/tmp % rm foo.h 18:04 #385
~/tmp % make 18:04 #386
touch foo.h bar.h baz.h
~/tmp % rm bar.h 18:04 #387
~/tmp % make 18:04 #388
make[1]: Entering directory `/home/adl/tmp'
touch foo.h bar.h baz.h
make[1]: Leaving directory `/home/adl/tmp'
~/tmp % 18:04 #389
--
Alexandre Duret-Lutz