[Top][All Lists]

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

Re: Static pattern usage

From: Paul D. Smith
Subject: Re: Static pattern usage
Date: Fri, 3 Oct 2003 17:26:54 -0400

%% Sam Ravnborg <address@hidden> writes:

  sr> Is there any other way to get the name of the target
  sr> to be used in the prerequisite list?
  sr> Other make implementation expands $* to the name of
  sr> the target when listed in the prerequisites, but not gnu make.

No make expands $* in the prerequisites list to the name of the target.

Some makes support a feature where $$@ (note two $'s!) in the
prerequisites list will expand to the name of the target.  GNU make also
supports this syntax (see the GNU make manual).

However, this won't help you because again, the $$@ is not expanded
until _after_ all the other variables are expanded.  This is true even
for other versions of make which support this syntax.

The only way to do what you want is to use the $(eval ...) function to
declare extra dependencies.  Something like:

  OBJS = foo.o
  deps_foo.o := foo.h

  $(foreach target,$(OBJS),$(eval $(target): $$(deps_$(target))))

(note, this is untested).

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