help-make
[Top][All Lists]
Advanced

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

Simple Second Expansion Help


From: Anthony Clark
Subject: Simple Second Expansion Help
Date: Thu, 23 Aug 2018 23:17:44 -0400

All,

Upon reading the official help for .SECONDEXPANSION: here,
https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html,
My simple makefile below isn't doing what I expect - it could be from my
weird `$(eval ...)` use...

I'm expecting to be able to append to $(OBJECTS) in the `foo` rule and have
the final value be used in the `all` target. I know this might seem
anti-idiomatic as I see no reference for this technique anywhere.

---- Begin Makefile ----

.PHONY: foo all
.SECONDEXPANSION:

OBJECTS := obj/first

all: foo $$(OBJECTS) ; $(info OBJECTS=$(OBJECTS))

foo:
    @$(eval OBJECTS += obj/second)
    @echo "in foo, OBJECTS=$(OBJECTS)"

obj/%:
    @echo "obj rule => $@"

---- End Makefile ----

---- Begin Output ----

$ make
in foo, OBJECTS=obj/first obj/second
obj rule => obj/first
OBJECTS=obj/first obj/second

---- End Output ----

---- Begin Expected Output ----

$ make
in foo, OBJECTS=obj/first obj/second
obj rule => obj/first
obj rule => obj/second
OBJECTS=obj/first obj/second

---- End Expected Output ----

-- 
Anthony G. Clark


reply via email to

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