在核心的makefile $(调用CMD,标记)什么是CMD这里指的是?(In Kernel mak

2019-10-20 04:03发布

在核心的makefile,我发现的代码如下图所示:

ctags CTAGS CSCOPE: $(HEADERS) $(SOURCES) 

$(ETAGS) $(ETAGSFALGS) $(HEADERS) $(SOURCES)

$(call cmd, ctags)

另外,我在哪里可以找到宏或功能?

Answer 1:

内核V4.1使用MadScientist的方法:

make -p | grep -B1 -E '^cmd '

我们发现:

# makefile (from `scripts/Kbuild.include', line 211)
cmd = @$(echo-cmd) $(cmd_$(1))

scripts/Kbuild.include被包含在顶层Makefile 。 它还包含:

echo-cmd = $(if $($(quiet)cmd_$(1)),\
    echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
  • quiet :设置在顶层makefile文件,这取决于值V

    将为以下之一:

    • quiet_打印CC file.c
    • 空到打印命令V=
    • silent_不打印任何东西make -s
  • escsq定义为:

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

    它避开了单引号,这样echo '$(call escsq,Letter 'a'.'将在正常打印sh

  • echo-why :再往下的定义Kbuild.include

    它是用于make V=2 ,并说为什么一个目标正在重塑。

的设置make tags在做Makefile

quiet_cmd_tags = GEN     $@
      cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@

tags TAGS cscope gtags: FORCE
    $(call cmd,tags)

其中显示了调用命令kbuild的典型使用模式:

quiet_cmd_XXX = NAME     $@
      cmd_XXX = actual-command $@

target: prerequisites
    $(call cmd,tags)

在注释Makefile解释这一切是如何做是为了使make输出漂亮:

# 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 $@ $<


Answer 2:

如果运行make -p将打印的所有变量,规则,整个数据库等方面与他们在那里最后确定的行号。



文章来源: In Kernel makefile $(call cmd, tags) what is the cmd here refers to?