|
From: | David Kilroy |
Subject: | Re: How can I derive a dependency filename from a stem value? |
Date: | Wed, 19 Nov 2003 12:17:26 -0000 |
continuing a (seemingly unresolved) thread from a couple weeks ago...
http://mail.gnu.org/archive/html/help-make/2003-11/msg00002.html
... and wanting to put a possible solution in the archives:
I have a similar issue, and have been searching for a fix. In particular I wanted to do:
$(MODULES): %: %/%.elf
... the purpose being to allow a 'make module' instead of the longer 'make module/module.elf'.
After searching the archives, and not finding a satisfactory solution, I resolved this using the following construct (based on the example on the info page for the eval function):
define MOD_template
$(1): $(1)/$(1).elf
endef
$(foreach module,$(MODULES),$(eval $(call MOD_template,$(module))))
Of course this requires you have a list of all possible MODULES, which usually isn't too hard. In the specific case of the original poster, something like:
MODULE := MODULE1 MODULE2 MODULE3
define DB_template
$(1) : $(2)cmd/$(2)_constr.tcl
endef
$(foreach module, $(MODULES), $(eval $(call DB_template, \
$(addprefix ../../, $(addsuffix ddb/generic.db, $(MODULES)) \
$(module))))
%ddb/generic.ddb : %cmd/dc_setup.tcl
commands
Notice that the commands don't have to be included in the template: it can just be used to add prerequisites to existing targets, which is what was attempted.
An alternative solution is obviously to use a submake (which I don't like). Apologies if there's an obvious well-known solution already kicking about.
HTH,
dave.
[Prev in Thread] | Current Thread | [Next in Thread] |