Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer runapp02.tex V2 - 09/04/2008 6:09pm Page 1144

Appendix B: Working with the Source Code


B.2 Configuration with Kconfig


As you know, the kernel must be configured prior to compilation. By referring to a list of options,
users can decide which functions they want to include in the kernel, which they want to compile as
modules, and which they want to leave out. With this in mind, developers must provide a system that
indicates which features are available. To this end, the kernel employs a configuration language known as
Kconfig, which is discussed throughout the remainder of this section.

The configuration language must address the following issues:

❑ Components can be permanently compiled into the kernel, compiled as modules, or simply
ignored (because it may not be possible to compile some components as modules in certain cir-
cumstances).
❑ There may be mutual dependencies between configuration options. In other words, some
options can be selected only in combination with one or more other options.
❑ It must be possible to show a list of alternative options from which users may select one. There
are also situations in which users are prompted to enter numbers (or similar values).
❑ It must be possible to arrange the configuration options hierarchically (in a tree structure).
❑ The configuration options differ from architecture to architecture.
❑ The configuration language should not be over-complicated because writing configuration
scripts is not exactly what most kernel programmers prefer to do.

The configuration information is spread throughout the entire source tree so that there is no need for a
gigantic, central configuration file that would be difficult to patch. There must be a configuration file in
each subdirectory whose code contains configurable options. The following subsection uses an example
to illustrate the proper syntax of a configuration file.

The following discussion deals only with the way in which the configuration options are specified. How
the options are implemented in the kernel sources is not important at the moment.

B.2.1 A Sample Configuration File


The syntax of the configuration files is not especially complicated as the following (slightly modified)
example taken from the USB subsystem shows:

drivers/usb/Kconfig
#
# USB device configuration
#

menuconfig "USB support"
bool "USB support"
depends on HAS_IOMEM
default y
---help---
This option adds core support for Universal Serial Bus (USB).
You will also need drivers from the following menu to make use of it.
Free download pdf