Linux内核源码的scripts目录,其作用主要存储内核编译和配置相关脚本。这里主要介绍两个常用脚本:scripts/config和scripts/kconfig/merge_config.sh功能如下:
scripts/config
用于操作.config 文件脚本:
使用方式:
Usage:
$myname options command ...
commands:
--enable|-e option Enable option
--disable|-d option Disable option
--module|-m option Turn option into a module
--set-str option string
Set option to "string"
--set-val option value
Set option to value
--undefine|-u option Undefine option
--state|-s option Print state of option (n,y,m,undef)
--enable-after|-E beforeopt option
Enable option directly after other option
--disable-after|-D beforeopt option
Disable option directly after other option
--module-after|-M beforeopt option
Turn option into module directly after other option
commands can be repeated multiple times
options:
--file config-file .config file to change (default .config)
--keep-case|-k Keep next symbols' case (dont' upper-case it)
$myname doesn't check the validity of the .config file. This is done at next
make time.
By default, $myname will upper-case the given symbol. Use --keep-case to keep
the case of all following symbols unchanged.
$myname uses 'CONFIG_' as the default symbol prefix. Set the environment
variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
常见使用方式,为.config 文件新增或屏蔽CONFIG选项。
注意:新增或屏蔽CONFIG选项必须在原.config下是存在的选项,否则无法进行控制
举例eg:
./scripts/config --file build/.config \ #生成.config 文件到build/.config
-d CONFIG_HZ_100\ #失能CONFIG_HZ_100选项
-e CONFIG_HZ_250\ #使能CONFIG_HZ_100选项
--set-val CONFIG_NR_CPUS 4 \ #CONFIG_NR_CPUS 设置为4
--set-str CONFIG_INITRAMFS_SOURCE "test" # CONFIG_INITRAMFS_SOURCE 设置为"test"
scripts/kconfig/merge_config.sh
目的是将两个deconfig进行merge一个新的deconfig,对于arm64, deconfig 文件通常位于arch/arm64/configs
/下。
用法:
echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
echo " -h display this help text"
echo " -m only merge the fragments, do not execute the make command"
echo " -n use allnoconfig instead of alldefconfig"
echo " -r list redundant entries when merging fragments"
echo " -y make builtin have precedence over modules"
echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead."
echo " -s strict mode. Fail if the fragment redefines any value."
echo
echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable."
举例eg:合并build/.config和arch/arm64/configs/demo_deconfig生成的新的.config 位于build/下。
./scripts/kconfig/merge_config.sh -m -O \
./build/ \ #合并后生成路径
./build/.config \ #被merge的config1
./arch/arm64/configs/demo_deconfig # #被merge的config2