开发者

Force variable expansion in GNU Make

开发者 https://www.devze.com 2023-04-12 17:45 出处:网络
How do I force GNU Make variables to evaluate immediately? Consider the following example: TARGET:=fred

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号