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 @@
1config 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
1menu "Code maturity level options"9menu "Code maturity level options"
2 10
3config EXPERIMENTAL11config EXPERIMENTAL
scripts/kconfig/confdata.c+11−15
@@ -25,15 +25,6 @@ const char conf_def_filename[] = ".config"; · 24 unmodified lines
25 25
26const char conf_defname[] = "arch/$ARCH/defconfig";26const char conf_defname[] = "arch/$ARCH/defconfig";
27 27
28const 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
37static void conf_warning(const char *fmt, ...)28static void conf_warning(const char *fmt, ...)
38{29{
39 va_list ap;30 va_list ap;
@@ -98,16 +89,21 @@ int conf_read_simple(const char *name, int def) · 58 unmodified lines
98 if (name) {89 if (name) {
99 in = zconf_fopen(name);90 in = zconf_fopen(name);
100 } else {91 } else {
101 const char **names = conf_confnames;92 struct property *prop;
102 name = *names++;93
103 if (!name)94 name = conf_def_filename;
104 return 1;
105 in = zconf_fopen(name);95 in = zconf_fopen(name);
106 if (in)96 if (in)
107 goto load;97 goto load;
108 sym_change_count++;98 sym_change_count++;
109 while ((name = *names++)) {99 if (!sym_defconfig_list)
110 name = conf_expand_value(name);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);
111 in = zconf_fopen(name);107 in = zconf_fopen(name);
112 if (in) {108 if (in) {
113 printf(_("#\n"109 printf(_("#\n"
scripts/kconfig/expr.h+1−0
@@ -156,6 +156,7 @@ struct file *lookup_file(const char *name); · 155 unmodified lines
156 156
157extern struct symbol symbol_yes, symbol_no, symbol_mod;157extern struct symbol symbol_yes, symbol_no, symbol_mod;
158extern struct symbol *modules_sym;158extern struct symbol *modules_sym;
159extern struct symbol *sym_defconfig_list;
159extern int cdebug;160extern int cdebug;
160struct expr *expr_alloc_symbol(struct symbol *sym);161struct expr *expr_alloc_symbol(struct symbol *sym);
161struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);162struct 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
104/* symbol.c */104/* symbol.c */
105void sym_init(void);105void sym_init(void);
106void sym_clear_all_valid(void);106void sym_clear_all_valid(void);
107void sym_set_all_changed(void);
107void sym_set_changed(struct symbol *sym);108void sym_set_changed(struct symbol *sym);
108struct symbol *sym_check_deps(struct symbol *sym);109struct symbol *sym_check_deps(struct symbol *sym);
109struct property *prop_alloc(enum prop_type type, struct symbol *sym);110struct 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
154 154
155void menu_add_option(int token, char *arg)155void menu_add_option(int token, char *arg)
156{156{
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 }
157}171}
158 172
159static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)173static 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
31};31};
32 32
33int sym_change_count;33int sym_change_count;
34struct symbol *sym_defconfig_list;
34struct symbol *modules_sym;35struct symbol *modules_sym;
35tristate modules_val;36tristate modules_val;
36 37
@@ -352,10 +353,13 @@ void sym_calc_value(struct symbol *sym) · 315 unmodified lines
352 sym->curr.val = sym_calc_choice(sym);353 sym->curr.val = sym_calc_choice(sym);
353 sym_validate_range(sym);354 sym_validate_range(sym);
354 355
355 if (memcmp(&oldval, &sym->curr, sizeof(oldval)))356 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
356 sym_set_changed(sym);357 sym_set_changed(sym);
357 if (modules_sym == sym)358 if (modules_sym == sym) {
358 modules_val = modules_sym->curr.tri;359 sym_set_all_changed();
360 modules_val = modules_sym->curr.tri;
361 }
362 }
359 363
360 if (sym_is_choice(sym)) {364 if (sym_is_choice(sym)) {
361 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);365 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
449 }453 }
450 454
451 sym->def[S_DEF_USER].tri = val;455 sym->def[S_DEF_USER].tri = val;
452 if (oldval != val) {456 if (oldval != val)
453 sym_clear_all_valid();457 sym_clear_all_valid();
454 if (sym == modules_sym)
455 sym_set_all_changed();
456 }
457 458
458 return true;459 return true;
459}460}
scripts/kconfig/zconf.tab.c_shipped+9−1
@@ -2112,7 +2112,9 @@ void conf_parse(const char *name) · 2111 unmodified lines
2112 2112
2113 sym_init();2113 sym_init();
2114 menu_init();2114 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;
2116 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);2118 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
2117 2119
2118#if YYDEBUG2120#if YYDEBUG
@@ -2122,6 +2124,12 @@ void conf_parse(const char *name) · 3 unmodified lines
2122 zconfparse();2124 zconfparse();
2123 if (zconfnerrs)2125 if (zconfnerrs)
2124 exit(1);2126 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 }
2125 menu_finalize(&rootmenu);2133 menu_finalize(&rootmenu);
2126 for_all_symbols(i, sym) {2134 for_all_symbols(i, sym) {
2127 sym_check_deps(sym);2135 sym_check_deps(sym);
scripts/kconfig/zconf.y+9−1
@@ -481,7 +481,9 @@ void conf_parse(const char *name) · 480 unmodified lines
481 481
482 sym_init();482 sym_init();
483 menu_init();483 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;
485 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);487 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
486 488
487#if YYDEBUG489#if YYDEBUG
@@ -491,6 +493,12 @@ void conf_parse(const char *name) · 3 unmodified lines
491 zconfparse();493 zconfparse();
492 if (zconfnerrs)494 if (zconfnerrs)
493 exit(1);495 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 }
494 menu_finalize(&rootmenu);502 menu_finalize(&rootmenu);
495 for_all_symbols(i, sym) {503 for_all_symbols(i, sym) {
496 sym_check_deps(sym);504 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