Kconfig学习记录

Kconfig  – Makefile一起决定编译哪些文件,宏的设置。最后生成.config文件。

 

在内核的Documentation/kbuild/目录下就格式说明。

 

主要有三部分组成:

变量

依赖

帮助

 

变量类型

 "bool"/"tristate"/"string"/"hex"/"int"

 

每一个config选项都必须有一个类型。

Bool – 2种取值 y,n

Tristate – 3种取值 y, n, m

String – 字符串

Hex – 16进制数据

Int – 10进制数据

 

依赖

depends on OFTREE

depends on来定义此菜单的出现是否依赖于另一个定义。可以用 || && 等符号。

 

帮助

help来定义帮忙,如下

 

关键字

menu 用于生成菜单

menu "Bus support"

 

config 生成配置选项

 

default 默认值

 

select 自动选择,当这一项被选择后,select后跟的项也会被自动选上。

 

source 读入另一个Kconfig文件

 

文档示例:

可以用./mconf Kconfig来执行,以下内容为Kconfig内容

#

# For a description of the syntax of this configuration file,

# see Documentation/kbuild/kconfig-language.txt.

#

 

#===================================================================

#主菜单,显示在最上方

#===================================================================

mainmenu "kconfig_notes/ARM KERNELVERSION Configuration mainmenu"

 

#===================================================================

#菜单, menu开始, endmenu结束

#===================================================================

menu "This is menu A"

 

#===================================================================

#一个字符串的变量

#===================================================================

config ARM

       string " this is a string type "

 

#===================================================================

#这是一个注释,最终也会体现到.config文件中     

#comment选项只可以是deponds on

#===================================================================

comment "this is a comment"      

 

#===================================================================

#选择项,相当于是列表,choice开始,encchoice结束   

#prompt 就是提示符,在menuconfig中看到的字符串

#===================================================================

choice

       prompt "menuA type"

      

config MENUA_TYPE_1

       bool "MENUA_TYPE_1"

      

config MENUA_TYPE_2

       bool "MENUA_TYPE_2"

      

config MENUA_TYPE_3

       bool "MENUA_TYPE_3"

 

endchoice

 

#===================================================================

#本级菜单结束    

#===================================================================

endmenu

 

#===================================================================

#另一个菜单

#===================================================================

menu "This is menu B"

 

config MB_CONFIG_A

       bool "MB_CONFIG_A bool type"

       default n

      

#===================================================================

#depends on,表示这个变量是否可见,依赖于某个变量的设置

#===================================================================

config MB_CONFIG_B

       bool "MB_CONFIG_B bool type"

       default n

       depends on MB_CONFIG_A

      

#===================================================================

#select - 当该选项被选择时,也会自动选择select后的项

#===================================================================

config MB_CONFIG_C

       bool "MB_CONFIG_C "

       default y

       select MB_CONFIG_B

 

#===================================================================

#菜单中的菜单

#===================================================================

menu "submenu of B"

 

#===================================================================

#hex 16进制型变量, default是默认值

#===================================================================

config S_MB_CONFIG_A

       hex "S_MB_CONFIG_A hex"

       default 10

      

#===================================================================

#range 表示范围,输入的值必须在这范围内

#===================================================================

       range 0x10 0x20

 

#===================================================================

#int 整型变量

#help 帮助说明     help相当于注释一样,在给编辑Kconfig文件的人看的,

#这样可以保持其可读性

#===================================================================

config S_MB_CONFIG_B

       int "S_MB_CONFIG_B int"

       default 10

       help

              it is a int type.

endmenu

      

#===================================================================

#tristate 三态,可以是y,n,m      

#===================================================================

config MB_CONFIG_D

       tristate "MB_CONFIG_D "

      

endmenu

 

 

#===================================================================

#source 包含另一个Kconfig文件

#===================================================================

source subdir/Kconfig

 

 

subdir下的Kconfig内容:

config SUBK_A

       prompt "SUBKconfig A"

       bool

       default n

      

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值