%% "e. boasson" <[EMAIL PROTECTED]> writes:
eb> I believe I have found a bug in the sequencing of dependencies
eb> resulting from include statements: the following self-contained
eb> makefile builds file "b" with $^ empty, whereas - in my opionion -
eb> it should have been "a".
This is not straightforward, but it's not a bug. This happens because
of the way your makefile is written.
The way make's include file rebuilds work, all the included files (that
can be rebuilt) are rebuilt first, then make re-execs itself and tries
again.
Your makefile contains the following:
eb> include a.d b.d
eb> b: ; echo "$^" > $@
eb> %.d: % ; echo "$@: $<" > $@
So, make will read the makefile and try to build a.d and b.d.
When it tries to build "b.d", it sees an implicit rule (the last line
above) that tells it how to build a "b.d" from a "b". So, it tries to
figure out how to build a "b".
It finds the explicit rule above, and executes it. When this happens,
it hasn't yet re-exec'd so it hasn't yet read in the new "b.mk" that
defines the "b: a" dependency, so $^ is empty.
If you want this to work you're going to have to force make to re-exec
twice: once after building "b.mk" so it reads the "b: a" dependency,
then again after building b.d.
The only way to do that is move the "include b.d" into the b.mk makefile
you build. That way, the first time through make will build b.mk. Then
it won't find anything else to build (makefile-wise) so it re-execs.
This time it reads b.mk, and finds an "include b.d" and tries to build
that, then re-exec. This time when b.d is built, the "b: a" dependency
is there:
$ cat Makefile
all: a b ; cat $^ > $@
clean: ; rm -f all a a.d b b.mk b.d
include a.d
include b.mk
b.mk: a ; echo "b: $^" > $@; echo "include b.d" >> $@
b: ; echo "$^" > $@
%.d: % ; echo "$@: $<" > $@
a: ; echo "$@" > $@
$ make
13.mk:4: a.d: No such file or directory
13.mk:5: b.mk: No such file or directory
echo "a" > a
echo "b: a" > b.mk; echo "include b.d" >> b.mk
echo "a.d: a" > a.d
b.mk:2: b.d: No such file or directory
echo "a" > b
echo "b.d: b" > b.d
cat a b > all
Note we now see ``echo "a" > b''.
HTH.
--
-------------------------------------------------------------------------------
Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at:
http://www.gnu.org http://www.ultranet.com/~pauld/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist