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.
Showing the changes to scripts (7 of 8 files). Show all
Unified · Split
| @@ -25,15 +25,6 @@ const char conf_def_filename[] = ".config"; · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
| 27 | 27 | |
| 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 | − | |
| 37 | 28 | static void conf_warning(const char *fmt, ...) |
| 38 | 29 | { |
| 39 | 30 | va_list ap; |
| @@ -98,16 +89,21 @@ int conf_read_simple(const char *name, int def) · 58 unmodified lines | ||
| 98 | 89 | if (name) { |
| 99 | 90 | in = zconf_fopen(name); |
| 100 | 91 | } 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; | |
| 105 | 95 | in = zconf_fopen(name); |
| 106 | 96 | if (in) |
| 107 | 97 | goto load; |
| 108 | 98 | 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); | |
| 111 | 107 | in = zconf_fopen(name); |
| 112 | 108 | if (in) { |
| 113 | 109 | printf(_("#\n" |
| @@ -156,6 +156,7 @@ struct file *lookup_file(const char *name); · 155 unmodified lines | ||
| 156 | 156 | |
| 157 | 157 | extern struct symbol symbol_yes, symbol_no, symbol_mod; |
| 158 | 158 | extern struct symbol *modules_sym; |
| 159 | +extern struct symbol *sym_defconfig_list; | |
| 159 | 160 | extern int cdebug; |
| 160 | 161 | struct expr *expr_alloc_symbol(struct symbol *sym); |
| 161 | 162 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce); |
| @@ -104,6 +104,7 @@ const char *str_get(struct gstr *gs); · 103 unmodified lines | ||
| 104 | 104 | /* symbol.c */ |
| 105 | 105 | void sym_init(void); |
| 106 | 106 | void sym_clear_all_valid(void); |
| 107 | +void sym_set_all_changed(void); | |
| 107 | 108 | void sym_set_changed(struct symbol *sym); |
| 108 | 109 | struct symbol *sym_check_deps(struct symbol *sym); |
| 109 | 110 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); |
| @@ -154,6 +154,20 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) · 153 unmodified lines | ||
| 154 | 154 | |
| 155 | 155 | void 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 | |
| 159 | 173 | static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) |
| @@ -31,6 +31,7 @@ struct symbol symbol_yes = { · 30 unmodified lines | ||
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | int sym_change_count; |
| 34 | +struct symbol *sym_defconfig_list; | |
| 34 | 35 | struct symbol *modules_sym; |
| 35 | 36 | tristate modules_val; |
| 36 | 37 | |
| @@ -352,10 +353,13 @@ void sym_calc_value(struct symbol *sym) · 315 unmodified lines | ||
| 352 | 353 | sym->curr.val = sym_calc_choice(sym); |
| 353 | 354 | sym_validate_range(sym); |
| 354 | 355 | |
| 355 | − if (memcmp(&oldval, &sym->curr, sizeof(oldval))) | |
| 356 | + if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { | |
| 356 | 357 | 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 | + } | |
| 359 | 363 | |
| 360 | 364 | if (sym_is_choice(sym)) { |
| 361 | 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 | 455 | sym->def[S_DEF_USER].tri = val; |
| 452 | − if (oldval != val) { | |
| 456 | + if (oldval != val) | |
| 453 | 457 | sym_clear_all_valid(); |
| 454 | − if (sym == modules_sym) | |
| 455 | − sym_set_all_changed(); | |
| 456 | − } | |
| 457 | 458 | |
| 458 | 459 | return true; |
| 459 | 460 | } |
| @@ -2112,7 +2112,9 @@ void conf_parse(const char *name) · 2111 unmodified lines | ||
| 2112 | 2112 | |
| 2113 | 2113 | sym_init(); |
| 2114 | 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 | 2118 | rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); |
| 2117 | 2119 | |
| 2118 | 2120 | #if YYDEBUG |
| @@ -2122,6 +2124,12 @@ void conf_parse(const char *name) · 3 unmodified lines | ||
| 2122 | 2124 | zconfparse(); |
| 2123 | 2125 | if (zconfnerrs) |
| 2124 | 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 | 2133 | menu_finalize(&rootmenu); |
| 2126 | 2134 | for_all_symbols(i, sym) { |
| 2127 | 2135 | sym_check_deps(sym); |
| @@ -481,7 +481,9 @@ void conf_parse(const char *name) · 480 unmodified lines | ||
| 481 | 481 | |
| 482 | 482 | sym_init(); |
| 483 | 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 | 487 | rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); |
| 486 | 488 | |
| 487 | 489 | #if YYDEBUG |
| @@ -491,6 +493,12 @@ void conf_parse(const char *name) · 3 unmodified lines | ||
| 491 | 493 | zconfparse(); |
| 492 | 494 | if (zconfnerrs) |
| 493 | 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 | 502 | menu_finalize(&rootmenu); |
| 495 | 503 | for_all_symbols(i, sym) { |
| 496 | 504 | sym_check_deps(sym); |