make 默认
The default target of make
is the first target. But can I change the default target in Makefile
and how to change the default target of make
?
make
的默认目标是第一个目标。 但是我可以在Makefile
中更改默认目标吗?如何更改make
的默认目标?
The default goal of make
is the first target whose name does not start with ‘.’ if .DEFAULT_GOAL
is not set. Ref: make manual.
make
的默认目标是名称不以“。” 开头的第一个目标。 如果未设置.DEFAULT_GOAL
。 参考: 制作手册 。
To set the default target to ‘default’ as an example being not the first target in the Makefile, you have at least 2 ways.
要将默认目标设置为“默认”而不是Makefile中的第一个目标的示例,您至少有两种方法。
Way 1. Set the .DEFAULT_GOAL
special variable to ‘default’.
方法1.将.DEFAULT_GOAL
特殊变量设置为“默认”。
.DEFAULT_GOAL := default
# other targets ...
default:
@ echo default target
Way 2. clear the .DEFAULT_GOAL
special variable before the ‘default’ target so that ‘default’ turns to the first target after .DEFAULT_GOAL
is not set.
方法2.清除“默认”目标之前的.DEFAULT_GOAL
特殊变量,以便在未设置.DEFAULT_GOAL
之后将“默认”转换为第一个目标。
# other targets ...
.DEFAULT_GOAL :=
# no target starting with '.' should be here
# between .DEFAULT_GOAL and 'default'
default:
@ echo default target
翻译自: https://www.systutorials.com/how-to-change-the-default-target-of-make/
make 默认