Hi, I've run into this problem twice (because I forgot the first time) and spent some time debugging my code only to find I'd followed the gnu make manual's example, which appears to have a bug in it. Or, eval() or the define directive has a bug, I'm not sure which. (Appendix A in the manual appears to suggest that a define should work identically with our without an equals sign.)
The example for eval() in section 8.9 has the line: define PROGRAM_template = But I have never seen this work, and it does run for me if I remove the "=" (equals sign). I'm currently on OSX, but I'm "pretty sure" I've seen this same behavior on both Linux and Cygwin. Here's an example makefile, pruned down from the manual's example: PROGRAMS = server client server_OBJS = server server_priv server_access client_OBJS = client client_api client_mem .PHONY: all all: $(PROGRAMS) define PROGRAM_template = ALL_OBJS += $$($(1)_OBJS) endef $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog)))) $(info "all objs:" $(ALL_OBJS)) > make "all objs:" make: *** No rule to make target `server', needed by `all'. Stop. PROGRAMS = server client server_OBJS = server server_priv server_access client_OBJS = client client_api client_mem .PHONY: all all: $(PROGRAMS) define PROGRAM_template ALL_OBJS += $$($(1)_OBJS) endef $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog)))) $(info "all objs:" $(ALL_OBJS)) > make "all objs:" server server_priv server_access client client_api client_mem make: *** No rule to make target `server', needed by `all'. Stop. David Hart Limnu --- https://limnu.com
_______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make