[Top][All Lists]

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

Re: How to use wildcard for different 'stem' values

From: Paul D. Smith
Subject: Re: How to use wildcard for different 'stem' values
Date: Wed, 10 Sep 2003 03:04:41 -0400

%% address@hidden writes:

  hpvl> %process/gen.out : $(addprefix %, $(wildcard cmd/*.tcl)) 
  hpvl>         commands... 

As I mentioned before, all variables and functions in target and
prerequisite lists (for all types of rules) are expanded _FIRST_, and
only once, as the makefile is read in.

Patterns are evaluated later, while make is attempting to find rules to
satisfy a target build requirement.

Information on when variables and functions are expanded is available in
the GNU make manual section "How 'make' Reads A Makefile".

So, in the above example $(wildcard cmd/*.tcl) is expanded immediately,
then the prefix "%" is appended to the results of that expansion.

  hpvl> What I would achieve is to have the wildcard command done for
  hpvl> each value of %.  So for each value of % the dependency could be
  hpvl> different.  Does someone know how I can do that?

This is not easy at all.  You will have to have a different explicit
rule for each possible target.  So, you will have to either write them
out by hand or find a way to automatically generate them.

There are two ways to do the latter: the "old" way, which works with
almost any version of GNU make, is to write a rule that generates a
makefile fragment containing the targets you want, then include that
fragment.  GNU make has a special feature where it tries to remake every
included makefile and, if it succeeds, it will re-exec itself to read
that new makefile.

The "new" way is to use the $(eval ...) function, which is only
available in GNU make 3.80, and in that version has some bugs that
require patching (or using the latest source from CVS).

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]