diff options
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r-- | scripts/kconfig/conf.c | 161 |
1 files changed, 69 insertions, 92 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index fda63136ae68..9fba838c7069 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -76,7 +76,6 @@ static void check_stdin(void) | |||
76 | static int conf_askvalue(struct symbol *sym, const char *def) | 76 | static int conf_askvalue(struct symbol *sym, const char *def) |
77 | { | 77 | { |
78 | enum symbol_type type = sym_get_type(sym); | 78 | enum symbol_type type = sym_get_type(sym); |
79 | tristate val; | ||
80 | 79 | ||
81 | if (!sym_has_value(sym)) | 80 | if (!sym_has_value(sym)) |
82 | printf(_("(NEW) ")); | 81 | printf(_("(NEW) ")); |
@@ -92,15 +91,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
92 | } | 91 | } |
93 | 92 | ||
94 | switch (input_mode) { | 93 | switch (input_mode) { |
95 | case set_no: | ||
96 | case set_mod: | ||
97 | case set_yes: | ||
98 | case set_random: | ||
99 | if (sym_has_value(sym)) { | ||
100 | printf("%s\n", def); | ||
101 | return 0; | ||
102 | } | ||
103 | break; | ||
104 | case ask_new: | 94 | case ask_new: |
105 | case ask_silent: | 95 | case ask_silent: |
106 | if (sym_has_value(sym)) { | 96 | if (sym_has_value(sym)) { |
@@ -112,9 +102,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
112 | fflush(stdout); | 102 | fflush(stdout); |
113 | fgets(line, 128, stdin); | 103 | fgets(line, 128, stdin); |
114 | return 1; | 104 | return 1; |
115 | case set_default: | ||
116 | printf("%s\n", def); | ||
117 | return 1; | ||
118 | default: | 105 | default: |
119 | break; | 106 | break; |
120 | } | 107 | } |
@@ -128,52 +115,6 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
128 | default: | 115 | default: |
129 | ; | 116 | ; |
130 | } | 117 | } |
131 | switch (input_mode) { | ||
132 | case set_yes: | ||
133 | if (sym_tristate_within_range(sym, yes)) { | ||
134 | line[0] = 'y'; | ||
135 | line[1] = '\n'; | ||
136 | line[2] = 0; | ||
137 | break; | ||
138 | } | ||
139 | case set_mod: | ||
140 | if (type == S_TRISTATE) { | ||
141 | if (sym_tristate_within_range(sym, mod)) { | ||
142 | line[0] = 'm'; | ||
143 | line[1] = '\n'; | ||
144 | line[2] = 0; | ||
145 | break; | ||
146 | } | ||
147 | } else { | ||
148 | if (sym_tristate_within_range(sym, yes)) { | ||
149 | line[0] = 'y'; | ||
150 | line[1] = '\n'; | ||
151 | line[2] = 0; | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | case set_no: | ||
156 | if (sym_tristate_within_range(sym, no)) { | ||
157 | line[0] = 'n'; | ||
158 | line[1] = '\n'; | ||
159 | line[2] = 0; | ||
160 | break; | ||
161 | } | ||
162 | case set_random: | ||
163 | do { | ||
164 | val = (tristate)(rand() % 3); | ||
165 | } while (!sym_tristate_within_range(sym, val)); | ||
166 | switch (val) { | ||
167 | case no: line[0] = 'n'; break; | ||
168 | case mod: line[0] = 'm'; break; | ||
169 | case yes: line[0] = 'y'; break; | ||
170 | } | ||
171 | line[1] = '\n'; | ||
172 | line[2] = 0; | ||
173 | break; | ||
174 | default: | ||
175 | break; | ||
176 | } | ||
177 | printf("%s", line); | 118 | printf("%s", line); |
178 | return 1; | 119 | return 1; |
179 | } | 120 | } |
@@ -374,15 +315,7 @@ static int conf_choice(struct menu *menu) | |||
374 | else | 315 | else |
375 | continue; | 316 | continue; |
376 | break; | 317 | break; |
377 | case set_random: | 318 | default: |
378 | if (is_new) | ||
379 | def = (rand() % cnt) + 1; | ||
380 | case set_default: | ||
381 | case set_yes: | ||
382 | case set_mod: | ||
383 | case set_no: | ||
384 | cnt = def; | ||
385 | printf("%d\n", cnt); | ||
386 | break; | 319 | break; |
387 | } | 320 | } |
388 | 321 | ||
@@ -494,6 +427,43 @@ static void check_conf(struct menu *menu) | |||
494 | check_conf(child); | 427 | check_conf(child); |
495 | } | 428 | } |
496 | 429 | ||
430 | static void conf_do_update(void) | ||
431 | { | ||
432 | /* Update until a loop caused no more changes */ | ||
433 | do { | ||
434 | conf_cnt = 0; | ||
435 | check_conf(&rootmenu); | ||
436 | } while (conf_cnt); | ||
437 | } | ||
438 | |||
439 | static int conf_silent_update(void) | ||
440 | { | ||
441 | const char *name; | ||
442 | |||
443 | if (conf_get_changed()) { | ||
444 | name = getenv("KCONFIG_NOSILENTUPDATE"); | ||
445 | if (name && *name) { | ||
446 | fprintf(stderr, | ||
447 | _("\n*** Kernel configuration requires explicit update.\n\n")); | ||
448 | return 1; | ||
449 | } | ||
450 | conf_do_update(); | ||
451 | } | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int conf_update(void) | ||
456 | { | ||
457 | rootEntry = &rootmenu; | ||
458 | conf(&rootmenu); | ||
459 | if (input_mode == ask_all) { | ||
460 | input_mode = ask_silent; | ||
461 | valid_stdin = 1; | ||
462 | } | ||
463 | conf_do_update(); | ||
464 | return 0; | ||
465 | } | ||
466 | |||
497 | int main(int ac, char **av) | 467 | int main(int ac, char **av) |
498 | { | 468 | { |
499 | int opt; | 469 | int opt; |
@@ -599,36 +569,43 @@ int main(int ac, char **av) | |||
599 | default: | 569 | default: |
600 | break; | 570 | break; |
601 | } | 571 | } |
572 | switch (input_mode) { | ||
573 | case set_no: | ||
574 | conf_set_all_new_symbols(def_no); | ||
575 | break; | ||
576 | case set_yes: | ||
577 | conf_set_all_new_symbols(def_yes); | ||
578 | break; | ||
579 | case set_mod: | ||
580 | conf_set_all_new_symbols(def_mod); | ||
581 | break; | ||
582 | case set_random: | ||
583 | conf_set_all_new_symbols(def_random); | ||
584 | break; | ||
585 | case set_default: | ||
586 | conf_set_all_new_symbols(def_default); | ||
587 | break; | ||
588 | case ask_silent: | ||
589 | case ask_new: | ||
590 | if (conf_silent_update()) | ||
591 | exit(1); | ||
592 | break; | ||
593 | case ask_all: | ||
594 | if (conf_update()) | ||
595 | exit(1); | ||
596 | break; | ||
597 | } | ||
602 | 598 | ||
603 | if (input_mode != ask_silent) { | 599 | if (conf_get_changed() && conf_write(NULL)) { |
604 | rootEntry = &rootmenu; | ||
605 | conf(&rootmenu); | ||
606 | if (input_mode == ask_all) { | ||
607 | input_mode = ask_silent; | ||
608 | valid_stdin = 1; | ||
609 | } | ||
610 | } else if (conf_get_changed()) { | ||
611 | name = getenv("KCONFIG_NOSILENTUPDATE"); | ||
612 | if (name && *name) { | ||
613 | fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n")); | ||
614 | return 1; | ||
615 | } | ||
616 | } else | ||
617 | goto skip_check; | ||
618 | |||
619 | do { | ||
620 | conf_cnt = 0; | ||
621 | check_conf(&rootmenu); | ||
622 | } while (conf_cnt); | ||
623 | if (conf_write(NULL)) { | ||
624 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); | 600 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); |
625 | return 1; | 601 | exit(1); |
626 | } | 602 | } |
627 | skip_check: | 603 | /* ask_silent is used during the build so we shall update autoconf. |
604 | * All other commands are only used to generate a config. | ||
605 | */ | ||
628 | if (input_mode == ask_silent && conf_write_autoconf()) { | 606 | if (input_mode == ask_silent && conf_write_autoconf()) { |
629 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); | 607 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); |
630 | return 1; | 608 | return 1; |
631 | } | 609 | } |
632 | |||
633 | return 0; | 610 | return 0; |
634 | } | 611 | } |