help-make
[Top][All Lists]
Advanced

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

Re: Using the target of a pattern rule as a prerequisite


From: Noel Yap
Subject: Re: Using the target of a pattern rule as a prerequisite
Date: Thu, 03 Jun 2004 13:31:46 -0400
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

Paul D. Smith wrote:

%% Bram <address@hidden> writes:
  b> Something like this:

  b> %.cc: $(dir $@)
  b>     echo "Pre:" $^

  b> %.cc: $(dir %.cc)
  b>     echo "Pre:" $^

Variables (and functions) in targets and prerequisites are expanded as
the makefile is read in, long before either automatic variables like $@
exist or patterns like %.cc have been matched.

In general it's not a good idea (IMO) to depend on a directory anyway:
it will cause your code to rebuild in many situations where it's not
necessary.  The GNU make manual has an alternate suggestion on how to
get directories created by the build system.

If you're using GNU make 3.80, you can use order rules for this purpose.

HTH,
Noel




reply via email to

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