Makefile目标中的等号



是否有一种在Makefile的目标名称中使用等号的好方法?

如果我写一个像一样的Makefile

test=file:
touch test=file

我得到

Makefile:2: *** recipe commences before first target.  Stop.

我找到的唯一方法就是做

NAME = test=file
$(NAME):
touch test=file

这是可行的,但为每个文件名定义一个变量会有点麻烦。有没有更好的方法可以做到这一点,直接引用/转义=

除了使用变量隐藏=之外,没有其他方法。当然,你不必把整个文件名放在你可以使用的变量中:

EQ = =
test$(EQ)file: ; touch $@

或者,如果您将其放入一个单字母变量中,则不需要():

E = =
test$Efile: ; touch $@

如果你愿意的话。

最新更新