The main process of compiling the Linux kernel: configuration, compilation, and installation .
- The configuration is mainly done by
Kconfig
providing a graphical interface - The compilation is mainly based on
Kbuild
the compilation system, and the executionmake
completes the compilation - The installation is mainly based on
Kbuild
the script provided, and then executemake
to complete the installation
Kconfig
Kconfig
For the configuration of the kernel, make menuconfig
the displayed menu comes from Kconfig
.
make menuconfig
The menu includes multiple layers, and each layer is Kconfig
generated correspondingly in each directory. After the configuration is selected, the configuration result will be saved to .config
the file.
When executed Makefile
, the compilation of the kernel Makefile
will be .config
realized according to the result of .
Kconfig syntax
Kbuild
Kbuild
That is Kernel build
, it is a compilation system for the kernel.
In simple terms, Kbuild
it is Makefile
an extension of grammatical functions.
For example, kbuild
many useful variables are defined such as obj-m`` obj-y
, -objs
etc., as long as the user assigns values to these variables, kbuild
the code will be automatically compiled into the kernel or compiled into a module.
Linux
When the kernel is kbuild
compiled, it will scan twice Linux
: Makefile
first read the top-level file, and then read the kbuild file for the second time to compile the kernel Makefile
according to the read content .Makefile
Linux
The kernel Makefile
consists of five parts:
Information through train: Linux kernel source code technology learning route + video tutorial kernel source code
Learning through train: Linux kernel source code memory tuning file system process management device driver/network protocol stack
Makefile
The top level Makefile
is the compiled entry, let’s analyze the top level Makefile
file.
The top level Makefile
will pass some information to each subdirectory Makefile
, some variables, for example , are not only defined and assigned vmlinux-dirs
in the top level , but also expanded.Makefile
arch/*/Makefile