注:Kconfig 文件的最终目的就是在.config 文件中生成以“CONFIG_”开头的变量。

名称

详解

mainmenu

主菜单   例如:mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"   在主界面将显示该提示

source "xxx/Kconfig" 

xxx 为具体的目录名,相对路径         调用其他子目录中的 Kconfig 文件类似于C语言的#include

menu/endmenu

menu 用于生成菜单,endmenu 就是菜单结束标志,这两个一般是成对出现的

config

“config xxxx”的代码块就是菜单的具体配置项

样式:

config UEVENT_HELPER_PATH
     string "path to uevent helper"
     depends on UEVENT_HELPER
     default ""
     help
        To disable user space helper program execution at by default
        specify an empty string here. This setting can still be altered
        via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper
        later at runtime.

config STANDALONE
     bool "Select only drivers that don't need compile-time external firmware"
     default y
     help
        Select this option if you don't have magic firmware for drivers that need it.

string”为变量类型,可以是  booltristatestringhexint , 最常用的是 bool、tristate 和 string 这三种 ,bool 类型有两种值:y 和 n,当为 y 的时候表示使能这个配置项,当为 n 的时候就禁止这个配置项。tristate 类型有三种值:y、m 和 n,其中 y 和 n 的涵义与 bool 类型一样,m 表示将这个配置项编译为模块。string 为字符串类型,所以 LOCALVERSION 是个字符串变量,用来存储本地字符串。

变量类型后面的参数将在配置界面显示出来

help 表示帮助信息,告诉我们配置项的含义,当我们按下“h”或“?”弹出来的帮助界面就是 help 的内容。

default y”表示默认值就是 y,所以这一行默认会被选中。

depends on  说明依赖关系,只有依赖项选中当前项才会被选中

select”表示方向依赖,即当前项选中后依赖的项也会被选中

range” 用于限制int或hex的输入范围,例如 range 0 12 表示输入范围为0-12

choice/endchoice

定义了一组可选择项, 将多个类似的配置项组合在一起,供用户单选或者多选。

样式:

choice
      prompt "Selected region size"
      default CMA_SIZE_SEL_MBYTES

      config CMA_SIZE_SEL_MBYTES
      bool "Use mega bytes value only"

      config CMA_SIZE_SEL_PERCENTAGE
      bool "Use percentage value only"

      config CMA_SIZE_SEL_MIN
      bool "Use lower value (minimum)"

      config CMA_SIZE_SEL_MAX
      bool "Use higher value (maximum)"

endchoice

prompt  为这个选项的提示

default 为默认选中项

menuconfig

是个带选项的菜单

样式:

menuconfig MODULES  
     bool "菜单"
     if MODULES
         ...
     endif # MODULES

只有选中了MODULES之后,后面的if包含的东西才能显示出来,即改菜单会有下一级

comment

用于注释,会在图形化界面中显示一行注释

if/endif

用于定义一个条件块,只有该条件成立后,后面的选项才可显示出来

文章作者: 孙毅鹏
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 孙毅鹏个人博客
嵌入式Linux
喜欢就支持一下吧