在内核 Makefile 中,我找到了如下代码:
ctags CTAGS CSCOPE: $(HEADERS) $(SOURCES)
$(ETAGS) $(ETAGSFALGS) $(HEADERS) $(SOURCES)
$(call cmd, ctags)
另外,我在哪里可以找到宏或功能?
在内核 Makefile 中,我找到了如下代码:
ctags CTAGS CSCOPE: $(HEADERS) $(SOURCES)
$(ETAGS) $(ETAGSFALGS) $(HEADERS) $(SOURCES)
$(call cmd, ctags)
另外,我在哪里可以找到宏或功能?
如果您运行make -p
它,它将打印所有变量、规则等的整个数据库,其中包含上次定义它们的行号。
在内核 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 $@ $<