Compiling – Kbuild
The kernel build system, Kbuild
, is a set of make
scripts that take the configuration information from the .config
file, work out the dependencies, and compile everything that is necessary to produce a kernel image. This kernel image contains all the statically linked components, possibly a device tree binary, and possibly one or more kernel modules. The dependencies are expressed in makefiles that are in each directory with buildable components. For instance, the following two lines are taken from drivers/char/Makefile
:
obj-y += mem.o random.o obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o
The obj-y
rule unconditionally compiles a file to produce the target, so mem.c
and random.c
are always part of the kernel. In the second line, ttyprintk.c
is dependent on a configuration parameter. If CONFIG_TTY_PRINTK
is y
, it is compiled as a built-in; if it is m
, it is built as a module; and if the parameter is undefined, it is not compiled at all.
For most targets...