Commit b75b0a81 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

kconfig: change defconfig_list option to environment variable



"defconfig_list" is a weird option that defines a static symbol that
declares the list of base config files in case the .config does not
exist yet.

This is quite different from other normal symbols; we just abused the
"string" type and the "default" properties to list out the input files.
They must be fixed values since these are searched for and loaded in
the parse stage.

It is an ugly hack, and should not exist in the first place. Providing
this feature as an environment variable is a saner approach.

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 40661621
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -229,11 +229,6 @@ applicable everywhere (see syntax).
  which can modify the behaviour of the menu entry and its config
  symbol. These options are currently possible:

  - "defconfig_list"
    This declares a list of default entries which can be used when
    looking for the default configuration (which is used when the main
    .config doesn't exists yet.)

  - "modules"
    This declares the symbol to be used as the MODULES symbol, which
    enables the third modular state for all config symbols.
+8 −0
Original line number Diff line number Diff line
@@ -41,6 +41,14 @@ KCONFIG_CONFIG
This environment variable can be used to specify a default kernel config
file name to override the default name of ".config".

KCONFIG_DEFCONFIG_LIST
----------------------

This environment variable specifies a list of config files which can be used
as a base configuration in case the .config does not exist yet. Entries in
the list are separated with whitespaces to each other, and the first one
that exists is used.

KCONFIG_OVERWRITECONFIG
-----------------------
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
+0 −9
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
config DEFCONFIG_LIST
	string
	depends on !UML
	option defconfig_list
	default "/lib/modules/$(shell,uname -r)/.config"
	default "/etc/kernel-config"
	default "/boot/config-$(shell,uname -r)"
	default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"

config CC_VERSION_TEXT
	string
	default "$(CC_VERSION_TEXT)"
+10 −0
Original line number Diff line number Diff line
@@ -13,6 +13,16 @@ ifeq ($(quiet),silent_)
silent := -s
endif

export KCONFIG_DEFCONFIG_LIST :=
ifneq ($(SRCARCH),um)
kernel-release := $(shell uname -r)
KCONFIG_DEFCONFIG_LIST := \
	/lib/modules/$(kernel-release)/.config \
	/etc/kernel-config \
	/boot/config-$(kernel-release) \
	arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
endif

# We need this, in case the user has it in its environment
unexport CONFIG_

+28 −10
Original line number Diff line number Diff line
@@ -360,28 +360,46 @@ int conf_read_simple(const char *name, int def)
	if (name) {
		in = zconf_fopen(name);
	} else {
		struct property *prop;
		char *env;

		name = conf_get_configname();
		in = zconf_fopen(name);
		if (in)
			goto load;
		sym_add_change_count(1);
		if (!sym_defconfig_list)

		env = getenv("KCONFIG_DEFCONFIG_LIST");
		if (!env)
			return 1;

		for_all_defaults(sym_defconfig_list, prop) {
			if (expr_calc_value(prop->visible.expr) == no ||
			    prop->expr->type != E_SYMBOL)
				continue;
			sym_calc_value(prop->expr->left.sym);
			name = sym_get_string_value(prop->expr->left.sym);
			in = zconf_fopen(name);
		while (1) {
			bool is_last;

			while (isspace(*env))
				env++;

			if (!*env)
				break;

			p = env;
			while (*p && !isspace(*p))
				p++;

			is_last = (*p == '\0');

			*p = '\0';

			in = zconf_fopen(env);
			if (in) {
				conf_message("using defaults found in %s",
					 name);
					     env);
				goto load;
			}

			if (is_last)
				break;

			env = p + 1;
		}
	}
	if (!in)
Loading