内核Kbuild-Makefile-Kconfig之间的关系

来源:互联网 发布:mac照片如何复制粘贴 编辑:程序博客网 时间:2024/05/16 09:44

参见/Documentation/kbuild:

The Makefiles have five parts:


    Makefile        the top Makefile.
    .config         the kernel configuration file.
    arch/$(ARCH)/Makefile   the arch Makefile.
    scripts/Makefile.*  common rules etc. for all kbuild Makefiles.
    kbuild Makefiles    there are about 500 of these.


The top Makefile reads the .config file, which comes from the kernel
configuration process.


The top Makefile is responsible for building two major products: vmlinux
(the resident kernel image) and modules (any module files).
It builds these goals by recursively descending into the subdirectories of
the kernel source tree.
The list of subdirectories which are visited depends upon the kernel
configuration. The top Makefile textually includes an arch Makefile

with the name arch/$(ARCH)/Makefile. The arch Makefile supplies
architecture-specific information to the top Makefile.


Each subdirectory has a kbuild Makefile which carries out the commands
passed down from above. The kbuild Makefile uses information from the
.config file to construct various file lists used by kbuild to build
any built-in or modular targets.


scripts/Makefile.* contains all the definitions/rules etc. that
are used to build the kernel based on the kbuild makefiles.


Makefile
Makefile总共包含五个部分,分别为:①顶层Makefile文件,②内核配置文件,③在各个体系结构下的makefile,在目录arch/$(ARCH)中,④一系列用于kbuild Makefile的通用规则,这些文件主要在scripts目录中,⑤kbuild Makefiles,这类文件大约有500个左右。
顶层Makefile读取.config文件,该文件主要在内核的配置过程中生成。有关内核的具体配置可参见这里。顶层的Makefile主要用来构造两个最主要的文件:vmlinux——固定内核映像,以及任意的模块,这种构造过程是通过递归进入内核源代码树的子目录而完成的。需要访问的子目录列表依据内核的配置而定。顶层Makefile包含一个具体体系结构下的Makefile文件,该文件主要向顶层Makefile提供指定体系结构的信息。
每一个子目录都包含kbuild Makefile,其用来执行由上级目录传递下来的一些命令。kbuild Makefile通过使用.config文件中包含的信息来构造各种各样的文件清单,最终kbuild根据这些文件清单构造任一内置的或模块化的目标。
而scripts目录中包含的一些Makefile.*文件中则包含了一系列的定义或是规则,这些规则根据kbuild makefile构造内核。

0 0
原创粉丝点击