简体   繁体   English

在Linux内核Makefile中构建变量

[英]build variable in Linux kernel Makefile

I am currently trying to understand the build process for the Linux kernel. 我目前正在尝试了解Linux内核的构建过程。 While looking through the Makefiles, I found several rules in the form 在查看Makefile时,我发现以下形式的一些规则

scripts_basic:
    $(Q)$(MAKE) $(build)=scripts/basic
    $(Q)rm -f .tmp_quiet_recordmcount

which all recursively call other make processes and also pass the directory to process. 所有这些都递归调用其他make进程,并将目录传递给process。 Simultaneously, there seems to be a variable, which is passed, indicating what to do with the subdirectory (the $(build) part. 同时,似乎传递了一个变量,该变量指示如何处理子目录( $(build)部分)。

Looking at the make process, as far as I can see, this always seems to be obj , I cannot find any other value for this variable so far during the make process. 就我所知,看一下make进程,这似乎总是obj ,到目前为止,在make进程中我找不到该变量的任何其他值。 Also, I cannot seem to find any place where this variable is set. 另外,我似乎找不到设置此变量的任何地方。

So what exactely is this variable for and how is it used (eg, where is set and processed). 因此,该变量的确切含义以及如何使用(例如,在何处设置和处理)。

Not exactly. 不完全是。 The relevant bit is in scripts/Kbuild.include , where it says 相关位在scripts/Kbuild.include ,它说

build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

What this means is that if $(KBUILD_SRC) is not empty, the path to scripts/Makefile.build is given as an absolute path (or at least with a path that can be found from the working directory) by prepending the path to the top of the kernel source tree. 这意味着如果$(KBUILD_SRC)不为空,则将scripts/Makefile.build $(KBUILD_SRC)的路径作为路径的绝对路径(或至少具有可从工作目录找到的路径)作为绝对路径。内核源代码树的顶部。 As far as I can tell, this is to make the sub-makes all use the same Makefile and avoid having the same make code several dozen times. 据我所知,这是使所有子make使用相同的Makefile,并避免使用相同的make代码数十次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM