1

在内核 Makefile 中,我找到了如下代码:

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

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

$(call cmd, ctags)

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

4

2 回答 2

1

如果您运行make -p它,它将打印所有变量、规则等的整个数据库,其中包含上次定义它们的行号。

于 2014-05-21T11:59:53.123 回答
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 tagsMakefile

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 $@ $<
于 2015-08-15T10:33:29.950 回答