当我进入时在 shell 中
echo $demoPath
打印
/usr/local/demo
如何在 makefile 中获取此变量 $demoPath
的值?
最佳答案
如果您已导出环境变量:
export demoPath=/usr/local/demo
您可以简单地在 makefile
中通过名称引用它(make
导入您设置的所有环境变量):
DEMOPATH = ${demoPath} # Or $(demoPath) if you prefer.
如果您尚未导出环境变量,则在导出之前无法访问它,或者除非您在命令行上显式传递它:
make DEMOPATH="${demoPath}" …
如果您使用的是 C shell 衍生版本,请将 setenv demoPath/usr/local/demo
替换为 export
命令。
关于shell - 如何在makefile中获取shell环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28890634/