|
From: | David Hart |
Subject: | Re: Documentation for eval() has a bug |
Date: | Sat, 28 Nov 2015 12:31:31 -0700 |
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 clientserver_OBJS = server server_priv server_accessclient_OBJS = client client_api client_mem.PHONY: allall: $(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 clientserver_OBJS = server server_priv server_accessclient_OBJS = client client_api client_mem.PHONY: allall: $(PROGRAMS)define PROGRAM_templateALL_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_memmake: *** No rule to make target `server', needed by `all'. Stop.
[Prev in Thread] | Current Thread | [Next in Thread] |