[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: implicit rules

From: Noel Yap
Subject: Re: implicit rules
Date: Mon, 26 Apr 2004 14:50:07 -0400
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

I see.  You wouldn't happen to have a patch that'll allow make to use the 
implicit rule for the former example, would you?


Boris Kolpackov wrote:

I will start from the second example:

Noel Yap <address@hidden> writes:

But if it's changed to:

.PHONY: all
all: aoeu/ %.m
        cp $(<) $(@)

        mkdir -p $(@)

aoeu/ 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/'. 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/', needed by `all'.  Stop.


for more information.

Now let's go to your first example which is quite interesting:

.PHONY: all
all: aoeu/
        cp $(<) $(@)

        mkdir -p $(@)

aoeu/ | aoeu/.

The output is:

$ gmake
gmake: Circular aoeu/ <- aoeu/ dependency dropped.
gmake: Circular <- dependency dropped.
mkdir -p aoeu/.
cp aoeu/

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/'.
   File `aoeu/' does not exist.
   Looking for an implicit rule for `aoeu/'.
   Trying pattern rule with stem `aoeu'.
   Trying rule prerequisite `aoeu/'.
   Found an implicit rule for `aoeu/'.

Here make found satisfying implicit rule which looks like this:

aoeu/ aoeu/
        cp $(<) $(@)

But then make drops circular dependency:

make: Circular aoeu/ <- aoeu/ dependency dropped.

Which makes this rules looks like this:

        cp $(<) $(@)

And, finally, make adds dependencies that you specified by hand:

aoeu/ | aoeu/.
        cp $(<) $(@)

Now $< is bound to '', $@ - to 'aoeu/' and you get

cp aoeu/

The funny part is that you would expect '' to end up in $<
but because make dropped it '' took its place which
happened to be what you actually wanted.


Help-make mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]