mrs*_*rsk 6 kernel makefile linux-kernel kbuild
在内核 Makefile 中我发现了如下代码:
ctags CTAGS CSCOPE: $(HEADERS) $(SOURCES)
$(ETAGS) $(ETAGSFALGS) $(HEADERS) $(SOURCES)
$(call cmd, ctags)
Run Code Online (Sandbox Code Playgroud)
另外,我在哪里可以找到宏或函数?
在内核 v4.1 上使用 MadScientist 的方法:
make -p | grep -B1 -E '^cmd '
Run Code Online (Sandbox Code Playgroud)
我们发现:
# makefile (from `scripts/Kbuild.include', line 211)
cmd = @$(echo-cmd) $(cmd_$(1))
Run Code Online (Sandbox Code Playgroud)
scripts/Kbuild.include包含在顶层Makefile。它还包含:
echo-cmd = $(if $($(quiet)cmd_$(1)),\
echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
Run Code Online (Sandbox Code Playgroud)
quiet:在顶层 makefile 中设置,具体取决于 的值V。
将是:
quiet_打印CC file.cV=silent_不打印任何东西make -sescsq定义为:
squote := '
escsq = $(subst $(squote),'\$(squote)',$1)
Run Code Online (Sandbox Code Playgroud)
它转义单引号,以便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)
Run Code Online (Sandbox Code Playgroud)
其中显示了在 kbuild 上调用命令的典型使用模式:
quiet_cmd_XXX = NAME $@
cmd_XXX = actual-command $@
target: prerequisites
$(call cmd,tags)
Run Code Online (Sandbox Code Playgroud)
的评论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 $@ $<
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2106 次 |
| 最近记录: |