kernel文件结构,makefile与kconfig机制分析

kernel文件结构,makefile与kconfig机制分析


  以下分析均来自于kernel 2.6.35.7版本

一、目录结构
Name Description
arch 架构相关
block 块设备管理
crypto 加密算法
drivers 驱动
firmware 固件
fs 文件系统
include 头文件
init 初始化
ipc 进程间通讯
kernel 内核
lib 相关库
net 网络
mm 内存管理
scripts 脚本
security 安全
sound 音频处理
tools 常用工具
usr 与linux内核启动相关
virt 内核虚拟机
二、配置

  配置分为三步进行

x210ii_qt_defconfig

  根据特定架构利用arch/$ARCH/configs/${PLATFORM}_defconfig在根目录中创建.config

"make defconfig"   
	Create a ./.config file by using the default symbol values from either arch/$ARCH/defconfig or arch/$ARCH/configs/${PLATFORM}_defconfig, depending on the architecture.

  .config文件是编译的关键。

"make menuconfig"  
	Text based color menus, radiolists & dialogs.
三、Kconfig

  几乎所有文件夹下都有Kconfig这个文件。那么这个文件究竟用来做什么呢?
  这与menuconfig有关。scriptskconfiglxdialog目录下的一些c文件就是用来提供menuconfig的那些程序源代码。而menuconfig中的配置项全部来自于每个目录下的Kconfig。

文件格式
menuconfig NETDEVICES
	default y if UML
	depends on NET
	bool "Network device support"
	---help---
	  You can say N here if you don't intend to connect your Linux box to
	  any other computer at all.

	  You'll have to say Y if your computer contains a network card that
	  you want to use under Linux. If you are going to run SLIP or PPP over
	  telephone line or null modem cable you need say Y here. Connecting
	  two machines with parallel ports using PLIP needs this, as well as
	  AX.25/KISS for sending Internet traffic over amateur radio links.

	  See also "The Linux Network Administrator's Guide" by Olaf Kirch and
	  Terry Dawson. Available at <http://www.tldp.org/guides.html>.

	  If unsure, say Y.

# All the following symbols are dependent on NETDEVICES - do not repeat
# that for each of the symbols.
if NETDEVICES

config IFB
	tristate "Intermediate Functional Block support"
	depends on NET_CLS_ACT
	---help---
	  This is an intermediate driver that allows sharing of
	  resources.
	  To compile this driver as a module, choose M here: the module
	  will be called ifb.  If you want to use more than one ifb
	  device at a time, you need to compile this driver as a module.
	  Instead of 'ifb', the devices will then be called 'ifb0',
	  'ifb1' etc.
	  Look at the iproute2 documentation directory for usage etc

  menuconfig表示当前显示的目录层级,属于bool中的字符串。
Network device support
  config表示当前目录下的可配置项。
  tristate表示三态,bool表示两态。
  depends表示依赖关系

关系

  menuconfig中的菜单项来自于Kconfig中的配置。经过menuconfig后,被修改的选项会保存到.config中,最终导致Makefile的编译变化。

原文地址:https://www.cnblogs.com/0nism/p/12380608.html