kbuild is the build system used by the Linux kernel.
kbuild is a build framework based on GNU make and a standard set of cross platform tools. It was originally developed for the Linux Kernel, but is now used in other projects such as crosstool-ng, buildroot, ltib, etc.
kbuild is extremely powerful and tries to hide most of its complexity in templates so that the actual makefiles are relatively easy to understand and write. There are two distinct parts of kbuild; A set of tools and languages for describing configuration variables and Gnu make template code to drive the actual build process.
There are stock documentation for different topics,
- kbuild.rst - documents variables in Makefiles.
- kconfig-language.rst - documents the kconfig language.
- kconfig.rst - configuring the kernels with Kbuild.
- makefiles.rst - using Kbuild driven make files.
- modules.rst - specific information for people building modules.
The Gnu make harness for the Linux kernel is in the main Makefile and Kbuild.include. The tools for configuring variable (and processing the Kconfig language) are in a kconfig directory. Obviously other projects such as buildroot, and crosstool-ng use modified versions.
The two aspects are found in files within the kernel source. They are a Kconfig file defining variables that can be defined by the tools. The second portion is a Makefile, which uses the Kconfig output (usually .config
) to guide the build process through normal Gnu make rules, templates and macros.