在内核makefile $(call cmd,tags)中,这里的cmd是指什么? [英] In Kernel makefile $(call cmd, tags) what is the cmd here refers to?

查看:747
本文介绍了在内核makefile $(call cmd,tags)中,这里的cmd是指什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Kernel Makefile i found the code like below:

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

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

$(call cmd, ctags)

此外,我在哪里可以找到宏或函数?

Also, where can i find the Macro or function ?

推荐答案

在内核v4.1上使用MadScientist的方法:

Using MadScientist's method on kernel v4.1:

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

我们发现:

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

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

scripts/Kbuild.include is included on the top level Makefile. It also contains:

echo-cmd = $(if $($(quiet)cmd_$(1)),\
    echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)

  • quiet:根据V的值设置在顶层makefile中.

    • quiet: set at the top level makefile, depending on the value of V.

      将是:

      • quiet_打印CC file.c
      • 空以在V=
      • 上打印命令
      • silent_不能在make -s
      • 上打印任何内容
      • quiet_ to print CC file.c
      • empty to print the command on V=
      • silent_ to not print anything on make -s

      escsq定义为:

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

      它转义单引号,以便echo '$(call escsq,Letter 'a'.'可以在sh中正确打印.

      It escapes single quotes so that echo '$(call escsq,Letter 'a'.' will print properly in sh.

      echo-why:在Kbuild.include处进一步定义.

      它用于make V=2,并说明了为什么要重制目标.

      It is used for make V=2, and says why a target is being remade.

      make tags的设置在Makefile中完成:

      quiet_cmd_tags = GEN     $@
            cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
      
      tags TAGS cscope gtags: FORCE
          $(call cmd,tags)
      

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

      Which shows the typical usage pattern for calling commands on kbuild:

      quiet_cmd_XXX = NAME     $@
            cmd_XXX = actual-command $@
      
      target: prerequisites
          $(call cmd,tags)
      

      Makefile的注释说明了如何完成所有这些操作以使make输出更漂亮:

      A comment on the Makefile explains how all of this is done to make the make output prettier:

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

      这篇关于在内核makefile $(call cmd,tags)中,这里的cmd是指什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆