在内核编译时,主Makefile调用 .config文件来获取用户的选择。
.config的内容是基于各个Kconfig配置文件以及平台配置文件,由 make menuconfig 和 make firefly_deconfig 的结果。
每个Kconfig描述了所属目录的源文件的相关内核配置;
每个平台配置文件描述了该平台所支持到基本配置;
Kconfig 菜单项类型:
1. bool 布尔类型 选择是或非;
2. tristate 三态 内建,模块,移除;
3. string 字符串 hex十六进制 integer 整型;
以drivers/rtc/Kconfig 中的源码为例:
/* bool 类型,默认选择是 */
config RTC_HCTOSYS
bool "Set system time from RTC on startup and resume"
default y
help
If you say yes here, the system time (wall clock) will be set using
the value read from a specified RTC device. This is useful to avoid
unnecessary fsck runs at boot time, and to network better.
/*rk808 模块配置*/
config RTC_DRV_RK808
tristate "Rockchip RK808 RTC"
depends on MFD_RK808
help
If you say yes here you will get support for the
RTC of RK808 PMIC.
This driver can also be built as a module. If so, the module
will be called rk808-rtc.
在编译内核的模块时,将模块的编译划分为三类,对应于Kconfig 中 tristate类,内建,模块,移除
在Makefile文件中:
obj-y 代表以静态的方式编译进内核中
obj-m 代表模块化编译进内核
obj- 代表不被编译(一般不作配置默认为不编译该模块)
其中,obj -y +=rk808.o 相当于 obj -$(RTC_DRV_RK808) +=rk808.o (Makefile中模块的编译)
总结:
.config 基于 Kconfig 和 平台配置文件生成 ,Makefile 调用 .config 编译内核,三者之间的宏都打开才能被编译。
下面贴出一个编译脚本来体现内核编译步骤:
#!/bin/bash
export ARCH=arm
export PATH=$PATH:/opt/arm-eabi-4.8/bin
export CROSS_COMPILE=arm-eabi-
make firefly_deconfig /* 先编译平台配置文件 */
make firefly.img