linux 的 Makefile总是出现 $(Q)$(MAKE) $(build) 具体什么含义呢?

linux 的 Makefile总是出现 ( Q ) (Q) (Q)(MAKE) $(build) 具体什么含义呢?

linux-6.6.8/Makefile

$(origin V) 返回 变量来源

Makefile

ENV=xxx
override SHELL = /bin/sh
all:
        @echo $(origin V)   
        @echo $(origin PATH)   环境变量
        @echo $(origin CC)
        @echo $(origin ENV)   本文件定义的变量
        @echo $(origin SHELL) 通过override命令重新定义的变量
        @echo $(origin @)     自动变量(如 @,@,< 等)

输出结果:
undefined
environment
default
file
override
automatic

$(build) 的含义

build的变量定义保存在 Kbuild.include
Makefile中包含 Kbuild.include

366 include $(srctree)/scripts/Kbuild.include

Kbuild.include中build 赋值如下:

110 ###
111 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
112 # Usage:
113 # $(Q)$(MAKE) $(build)=dir
114 build := -f $(srctree)/scripts/Makefile.build obj

因此下面代码展开:
696 %config: outputmakefile scripts_basic FORCE
697 ( Q ) (Q) (Q)(MAKE) $(build)=scripts/kconfig $@
( Q ) (Q) (Q)(MAKE) $(build)=scripts/kconfig $@

@ make build := -f $(srctree)/scripts/Makefile.build obj=scripts/kconfig $@
$@ 会解析为目标,这里为menuconfig

$(Q) 含义

60 # Beautify output
61 # ---------------------------------------------------------------------------
62 #
63 # Most of build commands in Kbuild start with "cmd_". You can optionally define
64 # "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from
65 # that command is printed by default.
66 #
67 # e.g.)
68 #    quiet_cmd_depmod = DEPMOD  $(MODLIB)
69 #          cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)
70 #
71 # A simple variant is to prefix commands with $(Q) - that's useful
72 # for commands that shall be hidden in non-verbose mode.
73 #
74 #    $(Q)$(MAKE) $(build)=scripts/basic
75 #
76 # If KBUILD_VERBOSE contains 1, the whole command is echoed.
77 # If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed.
78 #
79 # To put more focus on warnings, be less verbose as default
80 # Use 'make V=1' to see the full commands
81 
82 ifeq ("$(origin V)", "command line")    
83   KBUILD_VERBOSE = $(V)
84 endif
85 
86 quiet = quiet_
87 Q = @
88 
89 ifneq ($(findstring 1, $(KBUILD_VERBOSE)),)
90   quiet =
91   Q =
92 endif
93 

其中Q 代表 quiet,如果KBUILD_VERBOSE为1 则会打印所有命令直接过程
而KBUILD_VERBOSE可以从命令行的变量V里获取

menuconfig 目标分析

( Q ) (Q) (Q)(MAKE) $(build)=scripts/kconfig $@ 依赖 696 %config: outputmakefile scripts_basic FORCE

682 ifdef config-build
683 # ===========================================================================
684 # *config targets only - make sure prerequisites are updated, and descend
685 # in scripts/kconfig to make the *config target
686 
687 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
688 # KBUILD_DEFCONFIG may point out an alternative default configuration
689 # used for 'make defconfig'
690 include $(srctree)/arch/$(SRCARCH)/Makefile
691 export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
692 
693 config: outputmakefile scripts_basic FORCE
694 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
695 
696 %config: outputmakefile scripts_basic FORCE
697 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
698 
699 else #!config-build

  • 11
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值