|
Makefile 对应内核版本:2.6.35.13
echo_cmd 和 cmd 都定义在 Kbuild.include 中:
[code=Makefile]# 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)';)
# printing commands
cmd = @$(echo-cmd) $(cmd_$(1))
[/mw_shl_code]
上面的 $(quiet) 变量定义在顶层 Makefile 中:
[code=Makefile]ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet=quiet_
Q = @
endif
# If the user is running make -s (silent mode), suppress echoing of
# commands
ifneq ($(findstring s,$(MAKEFLAGS)),)
quiet=silent_
endif
export quiet Q KBUILD_VERBOSE
[/mw_shl_code]
在编译内核时,当不指定 V 变量时,$(quiet) 就为 quiet_ 。一般的,编译的每个命令都定义有 quiet_xxx 这种样式,比如在顶层 Makefile 中可以看到:
[code=Makefile]quiet_cmd_as_o_S = AS $@
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<[/mw_shl_code]
所以,在 quiet_ 模式下(V != 1),echo 出来的命令是缩写形式的,如:AS arch/x86/kernel/entry_32.o 当在编译时,命令行中指定 V=1 时,那么 $(quiet) 为空,即此时此时会采用上面的 cmd_as_o_S 样式,这样编译时会输出完整的编译信息:gcc -Wp,-MD,arch/x86/kernel/.entry_32.o.d -nostdinc -isystem /usr/lib/gcc/i686-redhat-linux/4.4.4/include -I/home/beyes/linux-2.6.35.13/arch/x86/include -Iinclude -include include/generated/autoconf.h -D__KERNEL__ -D__ASSEMBLY__ -m32 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -c -o arch/x86/kernel/entry_32.o arch/x86/kernel/entry_32.S
当在编译的目标列表 $(MAKEFLAGS) 中含有 s 时,quiet=silent_ ,一般的编译命令都没有定义 silent_xxxx 样式,所以在 echo_cmd 时会输出为空。
注意到 echo_cmd 变量的定义后面有一个分号,这表示可以后接一个命令,所以,
cmd = @$(echo-cmd) $(cmd_$(1))
表示在 echo 出要执行的命令后,会接着执行 $(cmd_s(1) 具体命令。
另外,$(echo-why) 一般不会用到,可以不用关注。 |
|