Makefile中的四个美元符号
我正在阅读GNU Make的文档.这是一个例子
I am reading the document of GNU Make. Here is an example
%.d:%.c
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed ’s,\($*\)\.o[ :]*,\1.o $@ : ,g’ < $@.$$$$ > $@; \
rm -f $@.$$$$
我在C ++程序上尝试过此操作,并获得了文件列表
I tried this on a C++ program, and got the list of files
init3d.d init3d.d.18449 input.d input.d.18444 main.d main.d.18439
init3d.d init3d.d.18449 input.d input.d.18444 main.d main.d.18439
这是我发现的内容,但在同一文档
Here is what I found but don't understand in the same document
如果启用了二次扩展,并且想要在先决条件列表中使用美元符号,则实际上必须写四个美元符号("$$$$").
If you have enabled secondary expansion and you want a literal dollar sign in the prerequisites list, you must actually write four dollar signs (‘$$$$’).
我想知道四个美元符号"$$$$"的实际含义是什么?他们如何18449、18444或18439?
I wonder what the four dollar signs "$$$$" mean actually? How do they 18449, 18444 or 18439?
感谢和问候!
如果启用了二次扩展",则需要$$$$
才能在实际输出中生成单个$
. $
通常用于扩展变量,调用make函数等.$$
启用了辅助扩展的功能还有其他功能,否则会在输出中生成实际的$
.
If make "secondary expansion" is enabled, $$$$
is required in order to generate a single $
in the actual output. $
is normally used to expand variables, call make functions, etc. $$
with secondary expansion enabled does something else, but otherwise it generates an actual $
in the output.
用于在类Unix系统上执行命令行的shell通常将$$
解释为扩展为shell进程ID.因此,在未启用辅助扩展的情况下,$$$$
会在输出中变成$$
,shell会将其扩展为进程ID.
The shell that make uses to execute command-lines on Unix-like systems normally interprets $$
as expand to shell process ID. So, without secondary expansion enabled, $$$$
will turn into $$
in the output, which the shell will expand to the process ID.
(使用Shell进程ID作为后缀是一种尝试确保临时文件的文件名唯一的简单方法.)
(Using the shell process ID as a suffix is a simple way of trying to guarantee uniqueness of file name for a temporary file.)