bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Documentation for eval() has a bug


From: David Hart
Subject: Re: Documentation for eval() has a bug
Date: Sat, 28 Nov 2015 12:31:31 -0700

Ah, nevermind, I just saw this. http://stackoverflow.com/questions/13260396/gnu-make-3-81-eval-function-not-working

--
David.


David Hart
Limnu --- https://limnu.com

On Sat, Nov 28, 2015 at 12:21 PM, David Hart <address@hidden> wrote:

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]