I will start from the second example:
Noel Yap <address@hidden> writes:
But if it's changed to:
.PHONY: all
all: aoeu/aoeu.mk
%.mk: %.m
cp $(<) $(@)
%/.:
mkdir -p $(@)
aoeu/aoeu.mk: aoeu.m | aoeu/.
The output becomes:
$ gmake
mkdir -p aoeu/.
If you run this with 'make -r -d' you will see that make
didn't find any rules for 'aoeu/aoeu.mk'. The reason why
make didn't complain about it is because make has this
habit of imagining that targets "somehow" get updated.
If I run my -bk-patched make with --no-implicit-phony flag
I get the following:
make: *** No rule to make target `aoeu/aoeu.mk', needed by `all'. Stop.
See
http://mail.gnu.org/archive/html/help-make/2004-02/msg00028.html
for more information.
Now let's go to your first example which is quite interesting:
.PHONY: all
all: aoeu/aoeu.mk
%.mk: %.mk
cp $(<) $(@)
%/.:
mkdir -p $(@)
aoeu/aoeu.mk: aoeu.mk | aoeu/.
The output is:
$ gmake
gmake: Circular aoeu/aoeu.mk <- aoeu/aoeu.mk dependency dropped.
gmake: Circular aoeu.mk <- aoeu.mk dependency dropped.
mkdir -p aoeu/.
cp aoeu.mk aoeu/aoeu.mk
Again, let's run 'make -r -d' on it. Here is the relevant part of
the output:
Considering target file `all'.
File `all' does not exist.
Considering target file `aoeu/aoeu.mk'.
File `aoeu/aoeu.mk' does not exist.
Looking for an implicit rule for `aoeu/aoeu.mk'.
Trying pattern rule with stem `aoeu'.
Trying rule prerequisite `aoeu/aoeu.mk'.
Found an implicit rule for `aoeu/aoeu.mk'.
Here make found satisfying implicit rule which looks like this:
aoeu/aoeu.mk: aoeu/aoeu.mk
cp $(<) $(@)
But then make drops circular dependency:
make: Circular aoeu/aoeu.mk <- aoeu/aoeu.mk dependency dropped.
Which makes this rules looks like this:
aoeu/aoeu.mk:
cp $(<) $(@)
And, finally, make adds dependencies that you specified by hand:
aoeu/aoeu.mk: aoeu.mk | aoeu/.
cp $(<) $(@)
Now $< is bound to 'aoeu.mk', $@ - to 'aoeu/aoeu.mk' and you get
cp aoeu.mk aoeu/aoeu.mk.
The funny part is that you would expect '%.mk' to end up in $<
but because make dropped it 'aoeu.mk' took its place which
happened to be what you actually wanted.
hth,
-boris
_______________________________________________
Help-make mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/help-make