将openwrt的script/conf目录拷被出来,进入到目录执行make,生成conf和mconf两个可执行文件,前者是命令行交互模式配置,mconf是图形化交互模式。
本文用的配置选项:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | $ cat Config.inmainmenu "openwrt configuration"choice ARCH prompt "select arch"config X86 bool "X86" select netifdconfig ARM bool "ARM" select busyboxendchoiceconfig netifd bool "netifd"config busybox bool "busybox"config uhttpd bool "uhttpd" default y |
make menuconfig就是调用mconf执行配置。
1 2 | menuconfig: ./scripts/config/mconf Config.in |
mconf默认读写.config文件。如果一项配置在.config中不存在,那么会显示NEW。存在是值要么被设置了,如果没被设置也要:
# CONFIG_ARM is not set
比如,当.config不存在时,执行上述命令:
对于choice,默认选中第一个,选中了X86,会select netifd。其它两个选项是新的,所以显示NEW。且由于uhttpd默认选中,所以其是选中的状态。
对于新选项,mconf会按照默认值去设置选项。没有默认值的选项不会选择。
当我切换到ARM时,netifd又会变成未选中状态:
结论:
由select选中的选项,当其父选项没被选中的时候,select的选项会变成原来的状态。
使用方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Usage: ./config/conf [-s] [option] <kconfig-file>[option] is _one_ of the following: --listnewconfig List new options --oldaskconfig Start a new configuration using a line-oriented program --oldconfig Update a configuration using a provided .config as base --silentoldconfig Same as oldconfig, but quietly, additionally update deps --olddefconfig Same as silentoldconfig but sets new symbols to their default value --oldnoconfig An alias of olddefconfig --defconfig <file> New config with default defined in <file> --savedefconfig <file> Save the minimal current configuration to <file> --allnoconfig New config where all options are answered with no --allyesconfig New config where all options are answered with yes --allmodconfig New config where all options are answered with mod --alldefconfig New config with all symbols set to default --randconfig New config with random answer to all options |
--oldaskconfig
用法:./config/conf --oldaskconfig Config.in
基于命令行创建一个新的配置,它不会去读取.config,每次都重新开始一个新配置。
1 2 3 4 5 6 7 8 9 10 11 | $ ./config/conf --oldaskconfig Config.in ** openwrt configuration*select arch> 1. X86 (X86) (NEW) 2. ARM (ARM) (NEW)choice[1-2]: 2netifd (netifd) [N/y] (NEW) busybox (busybox) [Y] (NEW) yuhttpd (uhttpd) [Y/n] (NEW) y |
只有一个选项的,比如选中了ARM,就select了busybox,那么只有个Y,它会自动帮你选y,有多个的话,直接回车默认选第一个,有默认值的,默认值在候选项第一个。
--oldconfig
用法:它会读取.config,然后其它和--oldaskconfig类似,对于没有配置的新选项,会让你选择。
--olddefconfig
用法:它会读取.config,然后对于不存在的选项,根据默认值去自动设置,没有默认的值,则不选中。
--defconfig
用法:./config/conf --defconfig=.config Config.in
它需要指定一个文件,这个文件必须存在,可以为空文件,然后这个配置文件不存在的配置,按默认配置来设置。生成结果保存到.config
--olddefconfig
用法: ./config/conf --olddefconfig Config.in
读取.config,对与新选项,配置为默认值。
--savedefconfig
没选中的,新的全部删掉,必然被选中的也会被删掉。比如选中了ARM,那么busybox是必然被选中的,那么也被删掉。
allyes/no/def/config
对于新符号,设置为yes,no,默认。