我在 shell 脚本中有一个构建文件,它有一个变量 VAR,必须导出到一个 makefile。
在构建文件中,
if [ "$arg" == "something" ]; then
export VAR=$arg
fi
make
现在在 makefile 中,我需要在条件语句中使用该变量:
ifeq ( $(VAR),something)
CONFIGURE_OPTIONS = abcdef
else
CONFIGURE_OPTIONS = ghijkl
endif
但条件永远不会以这种方式检查。我如何使用这个导出的变量?
最佳答案
在 shell 脚本中,
export VAR=hello
make all
在生成文件中,
all :
ifeq ($(VAR),hello)
$(eval var1:="hello world in if block")
else
$(eval var1:="hello world in else block")
endif
@echo "$(var1)"
关于linux - 如何在 makefile 中使用导出的变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26113233/