我试图动态地填充变量的一些命令,我有在我的Makefile。然而,我不确定为什么命令变成一个空字符串,而不是在字符串中运行它。
的例子:
test:
echo "hello $(cat foo.txt)"
输出:
$ make test
echo "hello "
hello
首选输出:
$ make test
echo "hello (contents of foo.txt)"
hello (contents of foo.txt)
使用2美元:
test:
echo "hello $$(cat foo.txt)"
参见"双美元符号的含义"bash/Makefile吗?
注意你可以添加@
来防止make打印它是什么你不需要指定test
目标特别是因为第一个总是会运行:
test:
@echo "hello $$(cat foo.txt)"
运行:
$ make
hello a b c
d e f