merge_config.sh
config fragments
$ cd linux
$ git checkout v4.9
$ make x86_64_defconfig
$ grep -E 'CONFIG_(DEBUG_INFO|GDB_SCRIPTS)[= ]' .config
# CONFIG_DEBUG_INFO is not set
$ # GDB_SCRIPTS depends on CONFIG_DEBUG_INFO in lib/Kconfig.debug.
$ cat <<EOF >.config-fragment
> CONFIG_DEBUG_INFO=y
> CONFIG_GDB_SCRIPTS=y
> EOF
$ # Order is important here. Must be first base config, then fragment.
$ ./scripts/kconfig/merge_config.sh .config .config-fragment
$ grep -E 'CONFIG_(DEBUG_INFO|GDB_SCRIPTS)[= ]' .config
CONFIG_DEBUG_INFO=y
CONFIG_GDB_SCRIPTS=y
Process substitution does not work unfortunately:
./scripts/kconfig/merge_config.sh arch/x86/configs/x86_64_defconfig \
<( printf 'CONFIG_DEBUG_INFO=y\nCONFIG_GDB_SCRIPTS=y\n' )
because of: https://unix.stackexchange.com/a/164109/32558
merge_config.sh
is a simple front-end for the make alldefconfig
target.
When cross compiling, ARCH
must be exported when you run merge_config.sh
, e.g.:
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make defconfig
./scripts/kconfig/merge_config.sh .config .config-fragment
The merged output file can be specified explicitly with the KCONFIG_CONFIG
environment variable; otherwise it just overwrites .config
:
KCONFIG_CONFIG=some/path/.config ./scripts/kconfig/merge_config.sh .config .config-fragment
Buildroot automates it with BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES
: How do I configure the Linux kernel within Buildroot?
Related: https://unix.stackexchange.com/questions/19905/how-to-non-interactively-configure-the-linux-kernel-build Migrated 20 days earlier :-)