%% "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