Skip to content

Commit b75b0a8

Browse files
committed
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: Masahiro Yamada <masahiroy@kernel.org>
1 parent 4066162 commit b75b0a8

File tree

12 files changed

+50
-43
lines changed

12 files changed

+50
-43
lines changed

Documentation/kbuild/kconfig-language.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ applicable everywhere (see syntax).
229229
which can modify the behaviour of the menu entry and its config
230230
symbol. These options are currently possible:
231231

232-
- "defconfig_list"
233-
This declares a list of default entries which can be used when
234-
looking for the default configuration (which is used when the main
235-
.config doesn't exists yet.)
236-
237232
- "modules"
238233
This declares the symbol to be used as the MODULES symbol, which
239234
enables the third modular state for all config symbols.

Documentation/kbuild/kconfig.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ KCONFIG_CONFIG
4141
This environment variable can be used to specify a default kernel config
4242
file name to override the default name of ".config".
4343

44+
KCONFIG_DEFCONFIG_LIST
45+
----------------------
46+
47+
This environment variable specifies a list of config files which can be used
48+
as a base configuration in case the .config does not exist yet. Entries in
49+
the list are separated with whitespaces to each other, and the first one
50+
that exists is used.
51+
4452
KCONFIG_OVERWRITECONFIG
4553
-----------------------
4654
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not

init/Kconfig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
config DEFCONFIG_LIST
3-
string
4-
depends on !UML
5-
option defconfig_list
6-
default "/lib/modules/$(shell,uname -r)/.config"
7-
default "/etc/kernel-config"
8-
default "/boot/config-$(shell,uname -r)"
9-
default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
10-
112
config CC_VERSION_TEXT
123
string
134
default "$(CC_VERSION_TEXT)"

scripts/kconfig/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ ifeq ($(quiet),silent_)
1313
silent := -s
1414
endif
1515

16+
export KCONFIG_DEFCONFIG_LIST :=
17+
ifneq ($(SRCARCH),um)
18+
kernel-release := $(shell uname -r)
19+
KCONFIG_DEFCONFIG_LIST := \
20+
/lib/modules/$(kernel-release)/.config \
21+
/etc/kernel-config \
22+
/boot/config-$(kernel-release) \
23+
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
24+
endif
25+
1626
# We need this, in case the user has it in its environment
1727
unexport CONFIG_
1828

scripts/kconfig/confdata.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,28 +360,46 @@ int conf_read_simple(const char *name, int def)
360360
if (name) {
361361
in = zconf_fopen(name);
362362
} else {
363-
struct property *prop;
363+
char *env;
364364

365365
name = conf_get_configname();
366366
in = zconf_fopen(name);
367367
if (in)
368368
goto load;
369369
sym_add_change_count(1);
370-
if (!sym_defconfig_list)
370+
371+
env = getenv("KCONFIG_DEFCONFIG_LIST");
372+
if (!env)
371373
return 1;
372374

373-
for_all_defaults(sym_defconfig_list, prop) {
374-
if (expr_calc_value(prop->visible.expr) == no ||
375-
prop->expr->type != E_SYMBOL)
376-
continue;
377-
sym_calc_value(prop->expr->left.sym);
378-
name = sym_get_string_value(prop->expr->left.sym);
379-
in = zconf_fopen(name);
375+
while (1) {
376+
bool is_last;
377+
378+
while (isspace(*env))
379+
env++;
380+
381+
if (!*env)
382+
break;
383+
384+
p = env;
385+
while (*p && !isspace(*p))
386+
p++;
387+
388+
is_last = (*p == '\0');
389+
390+
*p = '\0';
391+
392+
in = zconf_fopen(env);
380393
if (in) {
381394
conf_message("using defaults found in %s",
382-
name);
395+
env);
383396
goto load;
384397
}
398+
399+
if (is_last)
400+
break;
401+
402+
env = p + 1;
385403
}
386404
}
387405
if (!in)

scripts/kconfig/expr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ struct file *lookup_file(const char *name);
287287

288288
extern struct symbol symbol_yes, symbol_no, symbol_mod;
289289
extern struct symbol *modules_sym;
290-
extern struct symbol *sym_defconfig_list;
291290
extern int cdebug;
292291
struct expr *expr_alloc_symbol(struct symbol *sym);
293292
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);

scripts/kconfig/lexer.l

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ n [A-Za-z0-9_-]
9999
"def_bool" return T_DEF_BOOL;
100100
"def_tristate" return T_DEF_TRISTATE;
101101
"default" return T_DEFAULT;
102-
"defconfig_list" return T_DEFCONFIG_LIST;
103102
"depends" return T_DEPENDS;
104103
"endchoice" return T_ENDCHOICE;
105104
"endif" return T_ENDIF;

scripts/kconfig/lkc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
9696
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
9797
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
9898
void menu_add_option_modules(void);
99-
void menu_add_option_defconfig_list(void);
10099
void menu_add_option_allnoconfig_y(void);
101100
void menu_finalize(struct menu *parent);
102101
void menu_set_type(int type);

scripts/kconfig/menu.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,6 @@ void menu_add_option_modules(void)
219219
modules_sym = current_entry->sym;
220220
}
221221

222-
void menu_add_option_defconfig_list(void)
223-
{
224-
if (!sym_defconfig_list)
225-
sym_defconfig_list = current_entry->sym;
226-
else if (sym_defconfig_list != current_entry->sym)
227-
zconf_error("trying to redefine defconfig symbol");
228-
sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
229-
}
230-
231222
void menu_add_option_allnoconfig_y(void)
232223
{
233224
current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;

scripts/kconfig/parser.y

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static struct menu *current_menu, *current_entry;
5353
%token T_COMMENT
5454
%token T_CONFIG
5555
%token T_DEFAULT
56-
%token T_DEFCONFIG_LIST
5756
%token T_DEF_BOOL
5857
%token T_DEF_TRISTATE
5958
%token T_DEPENDS
@@ -223,11 +222,6 @@ config_option: T_OPTION T_MODULES T_EOL
223222
menu_add_option_modules();
224223
};
225224

226-
config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
227-
{
228-
menu_add_option_defconfig_list();
229-
};
230-
231225
config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
232226
{
233227
menu_add_option_allnoconfig_y();

0 commit comments

Comments
 (0)