为什么在食谱中使用 $(MAKE) 制作 '--dry-运行' 会导致错误?
Why make '--dry-run' with $(MAKE) in a recipe result in an error?
当我运行make --dry-run
在
all:
false # $(MAKE)
使用 GNU Make 4.2.1,我收到以下错误。为什么?
false # make all
make: *** [Makefile:2: all] Error 1
https://www.gnu.org/software/make/manual/make.html#Instead-of-Execution:
The -n
, -t
, and -q
options do not affect recipe lines that begin with +
characters or contain the strings $(MAKE)
or ${MAKE}
.
(--dry-run
是 -n
的别名。)
https://www.gnu.org/software/make/manual/make.html#MAKE-Variable:
subsystem:
cd subdir && $(MAKE)
[...]
As a special feature, using the variable MAKE
in the recipe of a rule alters the effects of the -t
(--touch
), -n
(--just-print
), or -q
(--question
) option. Using the MAKE
variable has the same effect as using a +
character at the beginning of the recipe line.
[...]
Consider the command make -t
in the above example. (The -t
option marks targets as up to date without actually running any recipes; see Instead of Execution.) Following the usual definition of -t
, a make -t
command in the example would create a file named subsystem and do nothing else. What you really want it to do is run cd subdir && make -t
; but that would require executing the recipe, and -t
says not to execute recipes.
The special feature makes this do what you want: whenever a recipe line of a rule contains the variable MAKE
, the flags -t
, -n
and -q
do not apply to that line. Recipe lines containing MAKE
are executed normally despite the presence of a flag that causes most recipes not to be run.
您的食谱包含 $(MAKE)
,因此尽管 --dry-run
仍会执行。 false
returns 退出状态 1,被 make
视为错误。
当我运行make --dry-run
在
all:
false # $(MAKE)
使用 GNU Make 4.2.1,我收到以下错误。为什么?
false # make all
make: *** [Makefile:2: all] Error 1
https://www.gnu.org/software/make/manual/make.html#Instead-of-Execution:
The
-n
,-t
, and-q
options do not affect recipe lines that begin with+
characters or contain the strings$(MAKE)
or${MAKE}
.
(--dry-run
是 -n
的别名。)
https://www.gnu.org/software/make/manual/make.html#MAKE-Variable:
subsystem: cd subdir && $(MAKE)
[...]
As a special feature, using the variable
MAKE
in the recipe of a rule alters the effects of the-t
(--touch
),-n
(--just-print
), or-q
(--question
) option. Using theMAKE
variable has the same effect as using a+
character at the beginning of the recipe line.[...]
Consider the command
make -t
in the above example. (The-t
option marks targets as up to date without actually running any recipes; see Instead of Execution.) Following the usual definition of-t
, amake -t
command in the example would create a file named subsystem and do nothing else. What you really want it to do is runcd subdir && make -t
; but that would require executing the recipe, and-t
says not to execute recipes.The special feature makes this do what you want: whenever a recipe line of a rule contains the variable
MAKE
, the flags-t
,-n
and-q
do not apply to that line. Recipe lines containingMAKE
are executed normally despite the presence of a flag that causes most recipes not to be run.
您的食谱包含 $(MAKE)
,因此尽管 --dry-run
仍会执行。 false
returns 退出状态 1,被 make
视为错误。