简体   繁体   English

为什么“cmd_$@”是构建时的前一个命令 linux kernel

[英]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.

相关问题 Linux /为什么su命令在CMD上有效但在脚本上无效? - Linux/ Why su command is working from CMD but not from script? 在Linux中更改上一个命令 - Changing the previous command in linux 在Linux内核Makefile中构建变量 - build variable in Linux kernel Makefile 如果作为外部模块进行构建,Linux Char设备驱动程序将不起作用,但是如果针对运行中的内核进行构建,则Linux Char设备驱动程序将起作用。 - Linux Char device driver not working if build as external module but worked if build as against running kernel.But why? C Linux 内核页面干扰先前的变量 - C Linux Kernel page interfere with previous variable 为什么在编译Linux内核和uBoot时使用arm-linux-gnueabi-gcc而不是arm-none-eabi-gcc? - Why arm-linux-gnueabi-gcc and not arm-none-eabi-gcc when compiling Linux kernel and uBoot? Linux / Ubuntu命令类似于Windows cmd“启动”吗? - Linux / Ubuntu command similar to Windows cmd “start”? 将编译标志附加到Linux内核版本 - Attaching a compilation flag to a Linux kernel build 原生编译&构建linux内核嵌入式系统 - native compilation & build linux kernel embedded system 如何为powerpc构建Linux内核并在qemu上启动它? - How to build the Linux kernel for powerpc and boot it on qemu?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM