我试图强制 make 文件显示下一个字符串:
"Please execute next commands:
setenv PATH /usr/local/greenhills/mips5/linux86:$PATH"
问题出在“$PATH”
。命令
@echo "setenv PATH /usr/local/greenhills/mips5/linux86:$PATH"
导致结果
"setenv PATH /usr/local/greenhills/mips5/linux86:ATH"
转义字符、引号、"$(shell echo "
的任何组合都没有得到所需的结果...
有什么建议吗?
最佳答案
在 manual for GNU make ,他们在描述 value
函数时讨论了这个具体示例:
The value function provides a way for you to use the value of a variable without having it expanded. Please note that this does not undo expansions which have already occurred; for example if you create a simply expanded variable its value is expanded during the definition; in that case the value function will return the same result as using the variable directly.
The syntax of the value function is:
$(value variable)
Note that variable is the name of a variable; not a reference to that variable. Therefore you would not normally use a ‘$’ or parentheses when writing it. (You can, however, use a variable reference in the name if you want the name not to be a constant.)
The result of this function is a string containing the value of variable, without any expansion occurring. For example, in this makefile:
FOO = $PATH all: @echo $(FOO) @echo $(value FOO)
The first output line would be ATH, since the “$P” would be expanded as a make variable, while the second output line would be the current value of your $PATH environment variable, since the value function avoided the expansion.
关于makefile - 使文件回显显示 "$PATH"字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3707517/