[Top][All Lists]

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

Re: Static Pattern Rules: target, stem, and prerequisite issue

From: Paul D. Smith
Subject: Re: Static Pattern Rules: target, stem, and prerequisite issue
Date: Fri, 7 Jul 2006 00:01:31 -0400

%% "Martin Gaarde Lund" <address@hidden> writes:

  mgl> $(C_OBJ_LIST_BUILD): %.o: $(subst $(OBJDIR)/,,%.c)

  mgl> At start I was a bit puzzled why it did not replace correctly. I read
  mgl> in the documentation and I think this is because patterns are not
  mgl> expanded at the right time when the makefile is read.

Well, they are replaced at the _right_ time--just not at the time you
expected :-).

  mgl> Question is if there is any way to make this static pattern rule
  mgl> work as I intend it to or if it need to be entirely rewritten??

You don't specify what version of GNU make you're using.  When asking
for help _always_ include the version of the software, the operating
system and version of the OS you're using, as well as command lines,
sample code, and output information (which you did, thanks!)

If you're using GNU make 3.81, you can use secondary expansion for this.

You have to enable it first (note if you have prerequisites with literal
dollar signs in them you'll have to add an extra level of quoting when
you do that), then you can write:

    $(C_OBJ_LIST_BUILD): %.o: $$(subst $(OBJDIR)/,,%.c)

which I think will do what you want.

See the documentation for secondary expansion.

 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]