[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #51292] Handling make rules where prerequisites are determined by f
From: |
Paul D. Smith |
Subject: |
[bug #51292] Handling make rules where prerequisites are determined by functions for specific targets lists |
Date: |
Sun, 2 Jul 2017 13:00:13 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0 |
Update of bug #51292 (project make):
Status: None => Wont Fix
Open/Closed: Open => Closed
_______________________________________________________
Follow-up Comment #4:
You can easily add the suffix as part of the static pattern rule:
targets ::= foo bar
$(targets:=.o): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
-vebatim-
If you want a "callback"-like setup you can already do it with eval and call:
# Function to generate a new rule.
# Call syntax: $(call new_rule,<target>,<callback_fn_name>)
define new_rule
$1 : $$(call $2,$1)
$$(CC) -c $$(CFLAGS) $$< -o $$@
endef
# Example use
targets = foo bar biz
foo_prereq = foo1 foo2 foo3
bar_prereq = $(addsuffix .xx,$1)
biz_prereq = $(addprefix $1,.a .b .c)
$(foreach T,$(targets),$(eval $(call new_rule,$T,$T_prereq)))
You can of course also add other callbacks, for the target, recipe, etc.
Personally I'm not convinced this is useful in general... it's certainly a lot
less readable (to me). But if you had one set of global makefiles that
defined all the templates, etc. then used data-driven variable assignments to
do the rest I suppose it might be useful.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51292>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #51292] Handling make rules where prerequisites are determined by functions for specific targets lists,
Paul D. Smith <=