History

kconfig: add defconfig_list/module option

This makes it possible to change two options which were hardcoded sofar. 1. Any symbol can now take the role of CONFIG_MODULES 2. The more useful option is to change the list of default file names, which kconfig uses to load the base configuration if .config isn't available.

Roman Zippel committed 20 years ago

Commit face4371 parent f6a88aa8 files · +61 −24Browse files

Unified · Split

8 files
  1. init/Kconfig +8 −0
  2. scripts/kconfig/confdata.c +11 −15
  3. scripts/kconfig/expr.h +1 −0
  4. scripts/kconfig/lkc.h +1 −0
  5. scripts/kconfig/menu.c +14 −0
  6. scripts/kconfig/symbol.c +8 −7
  7. scripts/kconfig/zconf.tab.c_shipped +9 −1
  8. scripts/kconfig/zconf.y +9 −1
init/Kconfig+8−0
@@ -1,3 +1,11 @@
1+config DEFCONFIG_LIST
2+ string
3+ option defconfig_list
4+ default "/lib/modules/$UNAME_RELEASE/.config"
5+ default "/etc/kernel-config"
6+ default "/boot/config-$UNAME_RELEASE"
7+ default "arch/$ARCH/defconfig"
8+
19 menu "Code maturity level options"
210
311 config EXPERIMENTAL
scripts/kconfig/confdata.c+11−15
@@ -25,15 +25,6 @@ const char conf_def_filename[] = ".config"; · 24 unmodified lines
2525
2626 const char conf_defname[] = "arch/$ARCH/defconfig";
2727
28−const char *conf_confnames[] = {
29− ".config",
30− "/lib/modules/$UNAME_RELEASE/.config",
31− "/etc/kernel-config",
32− "/boot/config-$UNAME_RELEASE",
33− conf_defname,
34− NULL,
35−};
36−
3728 static void conf_warning(const char *fmt, ...)
3829 {
3930 va_list ap;
@@ -98,16 +89,21 @@ int conf_read_simple(const char *name, int def) · 58 unmodified lines
9889 if (name) {
9990 in = zconf_fopen(name);
10091 } else {
101− const char **names = conf_confnames;
102− name = *names++;
103− if (!name)
104− return 1;
92+ struct property *prop;
93+
94+ name = conf_def_filename;
10595 in = zconf_fopen(name);
10696 if (in)
10797 goto load;
10898 sym_change_count++;
109− while ((name = *names++)) {
110− name = conf_expand_value(name);
99+ if (!sym_defconfig_list)
100+ return 1;
101+
102+ for_all_defaults(sym_defconfig_list, prop) {
103+ if (expr_calc_value(prop->visible.expr) == no ||
104+ prop->expr->type != E_SYMBOL)
105+ continue;
106+ name = conf_expand_value(prop->expr->left.sym->name);
111107 in = zconf_fopen(name);
112108 if (in) {
113109 printf(_("#\n"
scripts/kconfig/expr.h+1−0
@@ -156,6 +156,7 @@ struct file *lookup_file(const char *name); · 155 unmodified lines
156156
157157 extern struct symbol symbol_yes, symbol_no, symbol_mod;
158158 extern struct symbol *modules_sym;
159+extern struct symbol *sym_defconfig_list;
159160 extern int cdebug;
160161 struct expr *expr_alloc_symbol(struct symbol *sym);
161162 struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
scripts/kconfig/lkc.h+1−0
@@ -104,6 +104,7 @@ const char *str_get(struct gstr *gs); · 103 unmodified lines
104104 /* symbol.c */
105105 void sym_init(void);
106106 void sym_clear_all_valid(void);
107+void sym_set_all_changed(void);
107108 void sym_set_changed(struct symbol *sym);
108109 struct symbol *sym_check_deps(struct symbol *sym);
109110 struct property *prop_alloc(enum prop_type type, struct symbol *sym);
scripts/kconfig/menu.c+14−0
@@ -154,6 +154,20 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) · 153 unmodified lines
154154
155155 void menu_add_option(int token, char *arg)
156156 {
157+ struct property *prop;
158+
159+ switch (token) {
160+ case T_OPT_MODULES:
161+ prop = prop_alloc(P_DEFAULT, modules_sym);
162+ prop->expr = expr_alloc_symbol(current_entry->sym);
163+ break;
164+ case T_OPT_DEFCONFIG_LIST:
165+ if (!sym_defconfig_list)
166+ sym_defconfig_list = current_entry->sym;
167+ else if (sym_defconfig_list != current_entry->sym)
168+ zconf_error("trying to redefine defconfig symbol");
169+ break;
170+ }
157171 }
158172
159173 static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
scripts/kconfig/symbol.c+8−7
@@ -31,6 +31,7 @@ struct symbol symbol_yes = { · 30 unmodified lines
3131 };
3232
3333 int sym_change_count;
34+struct symbol *sym_defconfig_list;
3435 struct symbol *modules_sym;
3536 tristate modules_val;
3637
@@ -352,10 +353,13 @@ void sym_calc_value(struct symbol *sym) · 315 unmodified lines
352353 sym->curr.val = sym_calc_choice(sym);
353354 sym_validate_range(sym);
354355
355− if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
356+ if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
356357 sym_set_changed(sym);
357− if (modules_sym == sym)
358− modules_val = modules_sym->curr.tri;
358+ if (modules_sym == sym) {
359+ sym_set_all_changed();
360+ modules_val = modules_sym->curr.tri;
361+ }
362+ }
359363
360364 if (sym_is_choice(sym)) {
361365 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
@@ -449,11 +453,8 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val) · 87 unmodified lines
449453 }
450454
451455 sym->def[S_DEF_USER].tri = val;
452− if (oldval != val) {
456+ if (oldval != val)
453457 sym_clear_all_valid();
454− if (sym == modules_sym)
455− sym_set_all_changed();
456− }
457458
458459 return true;
459460 }
scripts/kconfig/zconf.tab.c_shipped+9−1
@@ -2112,7 +2112,9 @@ void conf_parse(const char *name) · 2111 unmodified lines
21122112
21132113 sym_init();
21142114 menu_init();
2115− modules_sym = sym_lookup("MODULES", 0);
2115+ modules_sym = sym_lookup(NULL, 0);
2116+ modules_sym->type = S_BOOLEAN;
2117+ modules_sym->flags |= SYMBOL_AUTO;
21162118 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
21172119
21182120 #if YYDEBUG
@@ -2122,6 +2124,12 @@ void conf_parse(const char *name) · 3 unmodified lines
21222124 zconfparse();
21232125 if (zconfnerrs)
21242126 exit(1);
2127+ if (!modules_sym->prop) {
2128+ struct property *prop;
2129+
2130+ prop = prop_alloc(P_DEFAULT, modules_sym);
2131+ prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
2132+ }
21252133 menu_finalize(&rootmenu);
21262134 for_all_symbols(i, sym) {
21272135 sym_check_deps(sym);
scripts/kconfig/zconf.y+9−1
@@ -481,7 +481,9 @@ void conf_parse(const char *name) · 480 unmodified lines
481481
482482 sym_init();
483483 menu_init();
484− modules_sym = sym_lookup("MODULES", 0);
484+ modules_sym = sym_lookup(NULL, 0);
485+ modules_sym->type = S_BOOLEAN;
486+ modules_sym->flags |= SYMBOL_AUTO;
485487 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
486488
487489 #if YYDEBUG
@@ -491,6 +493,12 @@ void conf_parse(const char *name) · 3 unmodified lines
491493 zconfparse();
492494 if (zconfnerrs)
493495 exit(1);
496+ if (!modules_sym->prop) {
497+ struct property *prop;
498+
499+ prop = prop_alloc(P_DEFAULT, modules_sym);
500+ prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
501+ }
494502 menu_finalize(&rootmenu);
495503 for_all_symbols(i, sym) {
496504 sym_check_deps(sym);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t