On Wed, 2012-03-21 at 09:09 -0700, DrDavey wrote: > $(patsubst %,%_all,$(TARGETS)): $(patsubst %_all,%,$@)
Things like this cannot work. The GNU make manual on automatic variables (like "$@") makes clear that they have valid values ONLY WITHIN THE RECIPE. You cannot use them like that in the prerequisites list as they have no value at that time: this line is expanded when make is reading/parsing the makefile. It's not until much later, when make is trying to build specific targets, that make will match the pattern rule against a real target and thus have a value for $@... by then it's too late. In your case you can just use static pattern rules: $(TARGETS): % : %_rel $(TARGETS): % : %_deb $(patsubst %,%_all,$(TARGETS): %_all : % $(patsubst %,%_clean,$(TARGETS): %_clean : %_clean_rel $(patsubst %,%_clean,$(TARGETS): %_clean : %_clean_deb etc. Or, you can use a define rule and eval to do it all for each target: define build_target $1 : $1_rel $1_deb $1_all : $1 $1_clean: $1_clean_rel $1_clean_deb ... endef $(foreach T,$(TARGETS),$(eval $(call build_target,$T))) Note that if your define contains other variables, than $1, you'll probably have to escape them. Eval is very powerful but can be difficult to get your head around at first. _______________________________________________ Help-make mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-make
