Linux Kernel Architecture

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

Appendix B: Working with the Source Code


#define CONFIG_PCMCIA_FMVJ18X_MODULE 1
...
#define CONFIG_USB_SERIAL_SIERRAWIRELESS_MODULE 1
#define CONFIG_VIDEO_SAA711X_MODULE 1
#define CONFIG_SATA_INIC162X_MODULE 1
#define CONFIG_AIC79XX_RESET_DELAY_MS 15000
#define CONFIG_NET_ACT_GACT_MODULE 1
...
#define CONFIG_USB_BELKIN 1
#define CONFIG_NF_CT_NETLINK_MODULE 1
#define CONFIG_NCPFS_PACKET_SIGNING 1
#define CONFIG_SND_USB_AUDIO_MODULE 1
#define CONFIG_I2C_I810_MODULE 1
#define CONFIG_I2C_I801_MODULE 1

The configuration symbols are again prefixed withCONFIG_. Each option selected is defined as 1 .Module
options (m) are likewise defined as 1 ,butthe_MODULEstring is also appended to the pre-processor symbol.
Configuration entries that are not selected are explicitly marked as undefined withundef.Numeric
values and character strings are replaced with the value selected by the user.

This enables queries (as they appear throughout this book) to be inserted in the source text. For example:

#ifdef CONFIG_SYMBOL
/* Code if SYMBOL is set */
#else
/* Code if SYMBOL is not set */
#endif

B.3 Compiling the Kernel with Kbuild


After the kernel has been configured, the sources must be compiled to generate the kernel image and
to obtain the module binaries. The kernel uses GNU Make to do this. It employs a complex system
of Makefiles to satisfy special requirements that arise when building kernels but not when building
normal applications. Deep insight into the box ofmaketricks is needed to fully understand how this
mechanism works, so this appendix doesn’t go into detail but simply examines system use from
the viewpoint of end users and kernel programmers (not from the viewpoint of Kbuild developers).
Documentation/kbuild/makefiles.txtcontains the detailed system documentation on which this
section is partly based.

B.3.1 Using the Kbuild System


Thehelptarget was introduced during the development of 2.5 to display allmaketargets available to
users. It outputs a list of targets in which a distinction is made between architecture-dependent and
architecture-independent variants. On UltraSparc systems, for example, it displays the following list:

wolfgang@ultrameitner>make help
Cleaning targets:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
Free download pdf