help-make
[Top][All Lists]
Advanced

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

Re: Pattern rule dependencies order?


From: Paul D. Smith
Subject: Re: Pattern rule dependencies order?
Date: Wed, 28 Mar 2001 00:28:48 -0500

%% "Majeed, Zartaj" <address@hidden> writes:

  mz> When there is just % as a dependency in a pattern rule, it is
  mz> processed before other preceding dependencies in the rule.

This is not what's happening.

What's happening is that make handles any prerequisites with explicit
rules first, before it builds chained prerequisites.

If you change your makefile to look like this:

 $ cat tester.mk
 %/a: %/b %/c %/d
         @echo $@: $^

 %/b:
         @echo target: $@
 %/c:
         @echo target: $@
 x/d:
         @echo target: $@

You'll see that x/d is still created first, even though the prerequisite
is "%/d", not just "%":

 $ make x/a -f tester.mk
 target: x/d
 target: x/b
 target: x/c
 x/a: x/b x/c x/d

Likewise, if you change your makefile like this:

 $ cat tester.mk
 %/a: %/b %/c %/d
         @echo $@: $^

 %/b:
         @echo target: $@
 %/c:
         @echo target: $@
 %/d:
         @echo target: $@

So that x/d is created with an implicit rule instead of an explicit
rule, you'll see that x/d is built last:

 $ make x/a -f tester.mk
 target: x/b
 target: x/c
 target: x/d
 x/a: x/b x/c x/d

I don't know if that behavior is correct or not (I can't find anything
in the manual that relates to this), but this is how it's currently
done, and has been for a long time AFAICT.

  mz> Is % not allowed as a dependency?

Definitely it is.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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