make V=1

make V=1

69 ifeq ("$(origin V)", "command line")
70 KBUILD_VERBOSE = $(V)
71 endif
72 ifndef KBUILD_VERBOSE
73 KBUILD_VERBOSE = 0
74 endif
75
76 ifeq ($(KBUILD_VERBOSE),1)
77 quiet =
78 Q =
79 else
80 quiet=quiet_
81 Q = @
82 endif

V=1

KBUILD_VERBOSE=1

quiet=空
Q=空

V=0或者命令行不定义V

KBUILD_VERBOSE=0

quiet= quiet_

Q= @

在命令前加上@就不会在终端输出命令了。

有些命令会有两个版本

quiet_cmd_copy = COPY $@
cmd_copy = cp $< $@

$(call if_changed,copy)

# Execute command if command has changed or prerequisite(s) are updated.
#
if_changed = $(if $(strip $(any-prereq) $(arg-check)),        #判断条件
@set -e;     #表示如果命令执行有错那么命令停止执行并退出。
$(echo-cmd) $(cmd_$(1));   #详细分析
printf '%s ' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)   #将上面执行的命令写入一个叫 $(dot-target).cmd 的文件中

$(echo-cmd) :

# echo command.

# Short version is used, if $(quiet) equals `quiet_', otherwise full one.

echo-cmd = $(if $($(quiet)cmd_$(1)),

echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)

###

# Escape single quote for use in echo statements

escsq = $(subst $(squote),'$(squote)',$1)

squote  := '

就是显示quiet_cmd_copy = COPY $@ 或 cmd_copy = cp $< $@ 根据quiet的定义而不同。

然后就是执行cmd_copy

set -e 表示如果命令执行有错那么命令停止执行并退出。
原文地址:https://www.cnblogs.com/idyllcheung/p/13409963.html