First, How does the Linux kernel organize the files in each directory tree and compile them? and build a kernel with specific features as needed?
in theLinuxin the kernel, there are two types of files:Makefile,Kconfig. The two files are distributed in the various levels of the kernel directory (each level corresponds to each), distributed at various levels ofKconfigdetermines the kernel to implement a function, each step of how to go, eachKconfigdescribes the source document of the owning directory. kernel configuration menu, that is we do make Menuconfig command after the resulting configuration menu, this menu contains (connect) multiple layers, each level is by the various directories in the kconfig ". Config " file. Finally in the execution makefile config
Second, Kconfig
1 , Structure + format:
Menu " Menu Description "
Config XXXXXX
bool " Specific Function Description The--- type definition
depends on conditions
default x (According to bool/int/hex/tristate/string )
Help
Explanatory notes
Endmenu
2 , variable definition:
BOOL(Boolean type) y/n int string Span style= "font-family: Song body; Font-size:medium "", Core; tristate n/m/y (remove / module / built-in)
Config HAHA
BOOL "HAHA Test Module"
BOOL type can only be selected and unchecked;
tristate : One more compiled into a module, when compiled into a kernel module, will be .config config_ Haha=m If built directly into the kernel -- in .config inside generation config_haha=y
3 , Reliance depends on
which is a restrictive condition, consciousness is whether the appearance of this menu depends on another definition
The effect is: if The menu does not appear if the dependent menu is not selected
4 , Help explains how the menu functions
IV, config
for the kernel, the execution of . config is the first step in compiling. the . config file is located at the root of the source code and describes all kernel configuration options. You can use the Kernel Configuration tool to select these options. Each kernel configuration option has a corresponding name and variable value of --n/m/y. When the match is y it will be compiled into the kernel Code (System), and when equipped with m will be compiled into the kernel in the form of a module.
Code has a distinction: corresponding to the menu
All configurations will be generated in the menu above.
V. Add a program to your own kernel
1 : File Preparation
1.1 , copy the written source code to the The appropriate directory for the Linux kernel source code.
1.2 , in this directory , in the Add the compilation configuration options for the source code in the Kconfig file
1.3 , in this directory , in the Makefile The compiler statement that adds the letter code to the file
2 , in Add directories and subdirectories to the linux kernel drivers/directory
mydriver$ Tree
|–kconfig
|–makefile
|–key
| |–kconfig
| |–makefile
| ' –key.c
|–led
| |–kconfig
| |–makefile
| ' –LED.C
'-test.c
Linux kernel makefile and kconfig, and how to add your own code to the kernel