I can use the following command to create a Linux kernel .config
file based on a specified architecture default for a custom ARM-based board:
ARCH=arm make defconfig KBUILD_DEFCONFIG=var_som_mx6_android_defconfig
I thought that this command more or less copies ./arch/arm/configs/var_som_mx6_android_defconfig
to ./.config
. However the resulting .config
file isn't exactly a copy:
$ diff --unified arch/arm/configs/var_som_mx6_android_defconfig .config
--- arch/arm/configs/var_som_mx6_android_defconfig 2017-01-20 12:10:51.891515984 -0800
+++ .config 2017-01-26 15:31:29.000000000 -0800
@@ -407,6 +407,7 @@
CONFIG_ARM_ERRATA_751472=y
CONFIG_ARM_ERRATA_794072=y
CONFIG_ARM_ERRATA_761320=y
+CONFIG_ARM_ERRATA_845369=y
# CONFIG_ARM_ERRATA_753970 is not set
CONFIG_ARM_ERRATA_754322=y
# CONFIG_ARM_ERRATA_754327 is not set
@@ -2683,7 +2684,6 @@
CONFIG_AUTOFS4_FS=y
CONFIG_FUSE_FS=y
# CONFIG_CUSE is not set
-CONFIG_AUFS_FS=y
#
# Caches
@@ -2759,6 +2759,21 @@
# CONFIG_PSTORE is not set
# CONFIG_SYSV_FS is not set
# CONFIG_UFS_FS is not set
+CONFIG_AUFS_FS=y
+CONFIG_AUFS_BRANCH_MAX_127=y
+# CONFIG_AUFS_BRANCH_MAX_511 is not set
+# CONFIG_AUFS_BRANCH_MAX_1023 is not set
+# CONFIG_AUFS_BRANCH_MAX_32767 is not set
+CONFIG_AUFS_SBILIST=y
+# CONFIG_AUFS_HNOTIFY is not set
+# CONFIG_AUFS_RDU is not set
+# CONFIG_AUFS_PROC_MAP is not set
+# CONFIG_AUFS_SP_IATTR is not set
+# CONFIG_AUFS_SHWH is not set
+# CONFIG_AUFS_BR_RAMFS is not set
+# CONFIG_AUFS_BR_FUSE is not set
+CONFIG_AUFS_BDEV_LOOP=y
+# CONFIG_AUFS_DEBUG is not set
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3=y
I don't understand where the extra lines are coming from, and I have always found the internal workings of the kernel configuration, makefiles, and build scripts to be difficult to understand. Can anyone explain where those lines in the .config
might be coming from?
Motivation
The
.config
file is not simply copied from yourdefconfig
file. The motivation for storingdefconfig
in such a format is next: indefconfig
we can only specify options with non-default values (i.e. options we changed for our board). This way we can keep it small and clear. Every new kernel version brings a bunch of new options, and this way we don't need to update ourdefconfig
file each time the kernel releases. Also, it should be mentioned that kernel build system keeps very specific order of options indefconfig
file, so it's better to avoid modifying it by hand. Instead you should usemake savedefconfig
rule.Simplified explanation
When
.config
file is being generated, kernel build system goes through allKconfig
files (from all subdirs), checking all options in thoseKconfig
files:defconfig
, build system puts that option into.config
with value chosen indefconfig
defconfig
, build system puts that option into.config
using its default value, specified in correspondingKconfig
Check scripts/kconfig/Makefile and scripts/kconfig/conf.c files to see how it's actually done.
More precise and detailed explanation
From "Kbuild: the Linux Kernel Build System" by Javier Martinez:
Useful commands
You can use simpler syntax for
make defconfig
, like:See the full list of available defconfigs with:
If you need to do reverse action (i.e. create a neat small
defconfig
from extensive.config
), you can usesavedefconfig
rule:Also, as 0andriy mentioned, you can use
diffconfig
script to see changes from one.config
to another one:It also generate
include/generated/autoconf.h
.This header file is included by C source file. On the other hand,
.config
is for Makefile system.Build system generate two files, and keep them consistent.