makefile - 使文件回显显示 "$PATH"字符串

标签 makefile gnu-make

我试图强制 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/

相关文章:

makefile - make 将其缓存存储在哪里?

makefile - GNU make : run a target after all others, 不管失败?

makefile - GNU 制作 : variable for command line arguments

linux - 在 makefile 中检查 java 版本

java - JNI 应用程序的可移植 Makefile

c - Automake + 库工具 : pattern rule for per-object CFLAGS?

c - gmake (Gnu) to make (Cygwin) - 验证我的实现 [只有 3 个语句]

linux - Make 找不到当前的交叉编译器

c - makefile 文件格式无法识别

c - valgrind 给出错误但无法找到位置