Force variable expansion in GNU Make
How do I force GNU Make variables to evaluate immediately? Consider the following example:
TARGET:=fred
wilma:
mkdir -p $(TARGET)
TARGET:=barney
betty:
mkdir -p $(TARGET)
all: one two
.PHON开发者_如何学CY: one two all
With make all
, Make will only create "barney", because the recipe strings are evaluated only after the makefile was read and the final value ("barney") was assigned.
I need to create both "fred" and "barney" in this instance.
wilma: TARGET:=fred
betty: TARGET:=barney
wilma betty:
mkdir -p $(TARGET)
精彩评论