[英]why "cmd_$@" is the previous command when build linux kernel
within linux kernel source repo, there is Makefile.build under /scripts, which is called many times when building src.在 linux kernel source repo 中,/scripts 下有 Makefile.build,构建 src 时会调用多次。 there is some target: prerequisite like this:
有一些目标:先决条件是这样的:
$(obj)/%.i: $(src)/%.c FORCE
$(call if_changed_dep,cpp_i_c)
and if_changed_dep is if_changed_dep 是
if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
newer-prereqs is quite straightforward but cmd-check is a bit obsecure. newer-prereqs 非常简单,但 cmd-check 有点不安全。
cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
$(subst $(space),$(space_escape),$(strip $(cmd_$1))))
I know that $(cmd_$1) will be expanded to cmd_cpp_i_c
, which is the current compiling command我知道 $(cmd_$1) 将扩展为
cmd_cpp_i_c
,这是当前的编译命令
and $(cmd_$@) will be expanded to $(cmd_$(obj)/%.i). $(cmd_$@) 将扩展为 $(cmd_$(obj)/%.i)。 for instance if it compiles i2c-core-base.c, it will be $(cmd_i2c-core-base.i) (I omit $(obj))
例如,如果它编译 i2c-core-base.c,它将是 $(cmd_i2c-core-base.i)(我省略了 $(obj))
https://flylib.com/books/en/2.860.1.84/1/ says it is the previous command when compiling. https://flylib.com/books/en/2.860.1.84/1/说是编译时的前一条命令。
my question is where I am able to find the evidence since I could not find where cmd_$@ is defined.我的问题是我在哪里可以找到证据,因为我找不到 cmd_$@ 的定义位置。
Thanks a lot for any comments.非常感谢任何评论。
After executing the command, the macro cmd_and_savecmd, records the command line into the file..cmd.执行命令后,宏cmd_and_savecmd,将命令行记录到文件..cmd中。
In /scripts/Kbuild.include在 /scripts/Kbuild.include
cmd_and_savecmd = \
$(cmd); \
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd
As make is invoked again during a rebuild, it will include those.*.cmd files.由于在重建期间再次调用 make,它将包含那些.*.cmd 文件。
In /Makefile在/生成文件中
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
So, cmd_$@ is used to keep tracks of what command has already been done last time when building a file.因此,cmd_$@ 用于跟踪上次构建文件时已经完成的命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.