linux kconfig command line interface

1.9k views Asked by At

My goal is to change kbuild configs using the command line without messing up dependencies.

For this I've created a 'reference' config by editing my default .config with make menuconfig. The 'only' thing I've changed was changing from 64 bit to 32 bit.

Now I took my original config and applied the following command (from the linux kernel root directory)

scripts/kconfig/merge_config.sh original.conf 32bit.conf

The content of 32bit.conf is simply CONFIG_64=n.

After diffing the two .configs from make menuconfig and my command I see that almost every change from make menuconfig is also present in the other file. But only almost every change.

$ diff .config.mkmenuconfig .config.command
104d103
< # CONFIG_NO_HZ_FULL is not set
112d110
< # CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
327d324
< # CONFIG_MPSC is not set
330d326
< # CONFIG_GENERIC_CPU is not set
345c341,342
< # CONFIG_HPET_TIMER is not set
---
> CONFIG_HPET_TIMER=y
> CONFIG_HPET_EMULATE_RTC=y

Where are these differences from and is there an official way to manipulate kbuild .configs via command line?

1

There are 1 answers

0
John Greene On

As of 5.2+ Linux kernel, CONFIG can take in a second file of .config and auto-merge them into a final .config.

But first, on a slightly related note on differences of config file, to show differences from your old .config to what is newly issued by the Linux kernel, execute:

make listnewconfig
(outputs a list of CONFIG_* that are newly added over old .config)

List of Config Files

Use the 'KCONFIG_DEFCONFIG_LIST' shell define to be read by make utility which containing a list of files, each separated by whitespace.

config.network would be in the same directory as the Makefile of Linux kernel.

CONFIG_BRIDGE=y
CONFIG_ARP=y
CONFIG_IP=y
CONFIG_IP6=y

and config.notebook-toshiba may have

CONFIG_SCSI=y
CONFIG_AHCI=y
CONFIG_RTC_INTF_DEV=y

then execute:

KCONFIG_DEFCONFIG_LIST="config.network config.notebook-toshiba" make bzImage modules

Miniconfig Method

(partially based on lkml email from/by Rob Landley, re: miniconfig)

The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also use the environment variable KCONFIG_ALLCONFIG as a flag or a filename that contains config symbols that the user requires to be set to a specific value.

If KCONFIG_ALLCONFIG is used without a filename where KCONFIG_ALLCONFIG == “” or KCONFIG_ALLCONFIG == “1”, make *config checks for a file named “all{yes/mod/no/def/random}.config” (corresponding to the *config command that was used) for symbol values that are to be forced.

If this file is not found, it checks for a file named “all.config” to contain forced values.

This enables you to create “miniature” config (miniconfig) or custom config files containing just the config symbols that you are interested in. Then the kernel config system generates the full .config file, including symbols of your miniconfig file.

This ‘KCONFIG_ALLCONFIG’ file is a config file which contains (usually a subset of all) preset config symbols. These variable settings are still subject to normal dependency checks.

Examples:

KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig

or:

KCONFIG_ALLCONFIG=mini.config make allnoconfig

or:

make KCONFIG_ALLCONFIG=mini.config allnoconfig

These examples will disable most options (allnoconfig) but enable or disable the options that are explicitly listed in the specified mini-config files.

Reference