/********************************************************************** * make命令回顯Makefile執行腳本命令 * 說明: * 當我們拿到別人的源代碼的時候,如果是用Makefile組織的,同時希望能夠 * 跟蹤一下源代碼的編譯架構,從而建立對源代碼的組織架構的全局理解,可以通 * 過傳入V=1打開執行回顯功能,當然要源代碼的Makefile支持這個功能。 * * 2018-6-29 深圳 寶安西鄉 曾劍鋒 *********************************************************************/ 一、參考文檔: https://github.com/ZengjfOS/Buildroot/blob/fsl_uboot_L4.1.15_from_TP/Makefile 二、Makefile Help # Beautify output # --------------------------------------------------------------------------- # # Normally, we echo the whole command before executing it. By making # that echo $($(quiet)$(cmd)), we now have the possibility to set # $(quiet) to choose other forms of output instead, e.g. # # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< # # If $(quiet) is empty, the whole command will be printed. # If it is set to "quiet_", only the short version will be printed. # If it is set to "silent_", nothing will be printed at all, since # the variable $(silent_cmd_cc_o_c) doesn't exist. # # A simple variant is to prefix commands with $(Q) - that's useful # for commands that shall be hidden in non-verbose mode. # # $(Q)ln $@ :< # # If KBUILD_VERBOSE equals 0 then the above command will be hidden. # If KBUILD_VERBOSE equals 1 then the above command is displayed. # # To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands ifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V) endif ifndef KBUILD_VERBOSE KBUILD_VERBOSE = 0 endif ifeq ($(KBUILD_VERBOSE),1) quiet = Q = else quiet=quiet_ Q = @ endif 三、命令解析 1. %config: [...省略] %config: scripts_basic outputmakefile FORCE $(Q)$(MAKE) $(build)=scripts/kconfig $@ [...省略] 2. 添加調試信息: [...省略] %config: scripts_basic outputmakefile FORCE $(info zengjf $@ $(Q)) $(Q)$(MAKE) $(build)=scripts/kconfig $@ [...省略] 3. $(info zengjf $@ $(Q))輸出信息: zengjf mx6dlsabresd_defconfig @ 4. 可知:$(Q) = @ 5. 從上面Makefile Help中可以,Makefile中的Q變量和KBUILD_VERBOSE有關,KBUILD_VERBOSE和make執行的時候V變量有關; 6. 所以執行make相關的命令,加入V=1就可以回顯make命令執行的流程了。
