Liz*_*Liz 4 variables makefile append
我有一个带有一些定义的definitions.mk文件:
define some-method
if [ ! -f <some file> ] ; then
MYVAR += text_to_append
Run Code Online (Sandbox Code Playgroud)
与MYVAR的关系是我的问题.它认为MYVAR是一个命令.我怎样才能让它意识到它是我所指的变量MYVAR(它也存在于其他make文件中)?
提前感谢任何输入!
您不能在Makefile中使用shell样式的"if"语句.您需要使用GNU make条件语法.
就像是:
ifneq ($(wildcard some_file),)
# File exists
MYVAR += text_to_append
endif
Run Code Online (Sandbox Code Playgroud)
另外,不要在Makefile中使用制表符进行缩进,它们对Make具有特殊含义.