Makefile 如何为gmake变量添加前缀

Makefile 如何为gmake变量添加前缀,makefile,gnu-make,Makefile,Gnu Make,我有一个包含另一个Makefile的Makefile,比如CommonMakefile。有一个变量,我想用一个值作为前缀(参见使用+=追加),保持其余值不变 V = value1 # set in CommonMakefile that is included V = value0 $(V) # I want to prefix value0 to V # rule defined in CommonMakefile that is included whatsV: ech

我有一个包含另一个Makefile的Makefile,比如CommonMakefile。有一个变量,我想用一个值作为前缀(参见使用
+=
追加),保持其余值不变

V = value1    # set in CommonMakefile that is included

V = value0 $(V)  # I want to prefix value0 to V

# rule defined in CommonMakefile that is included
whatsV:
     echo $V   # first char is a <TAB> here
实际:

$ gmake whatsV
Makefile:3: *** Recursive variable `V' references itself (eventually).  Stop.
PS:我不能/不想更改CommonMakefile

这行不通:

V = value0 $(V)
因为这里的
V
是一个,不能用它本身来定义。但将其更改为一个简单的扩展变量:


V:=value0$(V)#感谢@Beta提供的答案和链接。此外,在链接中,该部分有一条注释:对于追加运算符“+=”,如果变量先前设置为简单变量(“:=”),则右侧视为立即变量,否则将延迟。
V = value0 $(V)
V := value0 $(V) # <-- Note the colon