help-make
[Top][All Lists]
Advanced

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

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


From: Martin Gaarde Lund
Subject: Re: Static Pattern Rules: target, stem, and prerequisite issue
Date: Fri, 7 Jul 2006 09:36:18 +0200

Thanks for the quick reply.

Here are some more information.

On 7/7/06, Paul D. Smith <address@hidden> wrote:
%% "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!)

Im using a GNU make w32 binary version 3.79.1 running windows xp.


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.

I tried the following and failed with version 3.79.1. And of course it fails.

.SECONDEXPANSION:
$(C_OBJ_LIST_BUILD): %.o: $$(subst $(OBJDIR)/,,%.c)
    $(CC) $(C_INCLUDE) $(C_FLAGS) $< -o $(*D)/$(*F).o

gmake: *** No rule to make target `$(subst)', needed by `build/obj/psi/src/safeboot.o'.  Stop.
 
I should get version 3.81 as instructed but I cant currently find a w32 binary anywhere and I have no means of building it myself. So if anyone out there knows where to find this dont hesitate to tell me :o)


See the documentation for secondary expansion.

--
-------------------------------------------------------------------------------
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]