在内核makefile $(call cmd,tags)中,这里的cmd是指什么? [英] In Kernel makefile $(call cmd, tags) what is the cmd here refers to?
问题描述
在内核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 ofV
.将是:
-
quiet_
打印CC file.c
- 空以在
V=
上打印命令
-
silent_
不能在make -s
上打印任何内容
quiet_
to printCC file.c
- empty to print the command on
V=
silent_
to not print anything onmake -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 insh
.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 themake
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屋!
-