aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r--scripts/kconfig/conf.c178
1 files changed, 73 insertions, 105 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda63136ae68..3e1057f885c6 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -32,6 +32,7 @@ char *defconfig_file;
32 32
33static int indent = 1; 33static int indent = 1;
34static int valid_stdin = 1; 34static int valid_stdin = 1;
35static int sync_kconfig;
35static int conf_cnt; 36static int conf_cnt;
36static char line[128]; 37static char line[128];
37static struct menu *rootEntry; 38static struct menu *rootEntry;
@@ -65,7 +66,7 @@ static void strip(char *str)
65 66
66static void check_stdin(void) 67static void check_stdin(void)
67{ 68{
68 if (!valid_stdin && input_mode == ask_silent) { 69 if (!valid_stdin) {
69 printf(_("aborted!\n\n")); 70 printf(_("aborted!\n\n"));
70 printf(_("Console input/output is redirected. ")); 71 printf(_("Console input/output is redirected. "));
71 printf(_("Run 'make oldconfig' to update configuration.\n\n")); 72 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
@@ -76,7 +77,6 @@ static void check_stdin(void)
76static int conf_askvalue(struct symbol *sym, const char *def) 77static int conf_askvalue(struct symbol *sym, const char *def)
77{ 78{
78 enum symbol_type type = sym_get_type(sym); 79 enum symbol_type type = sym_get_type(sym);
79 tristate val;
80 80
81 if (!sym_has_value(sym)) 81 if (!sym_has_value(sym))
82 printf(_("(NEW) ")); 82 printf(_("(NEW) "));
@@ -92,15 +92,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
92 } 92 }
93 93
94 switch (input_mode) { 94 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: 95 case ask_new:
105 case ask_silent: 96 case ask_silent:
106 if (sym_has_value(sym)) { 97 if (sym_has_value(sym)) {
@@ -112,9 +103,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
112 fflush(stdout); 103 fflush(stdout);
113 fgets(line, 128, stdin); 104 fgets(line, 128, stdin);
114 return 1; 105 return 1;
115 case set_default:
116 printf("%s\n", def);
117 return 1;
118 default: 106 default:
119 break; 107 break;
120 } 108 }
@@ -128,52 +116,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
128 default: 116 default:
129 ; 117 ;
130 } 118 }
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); 119 printf("%s", line);
178 return 1; 120 return 1;
179} 121}
@@ -374,15 +316,7 @@ static int conf_choice(struct menu *menu)
374 else 316 else
375 continue; 317 continue;
376 break; 318 break;
377 case set_random: 319 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; 320 break;
387 } 321 }
388 322
@@ -507,11 +441,11 @@ int main(int ac, char **av)
507 while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { 441 while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
508 switch (opt) { 442 switch (opt) {
509 case 'o': 443 case 'o':
510 input_mode = ask_new; 444 input_mode = ask_silent;
511 break; 445 break;
512 case 's': 446 case 's':
513 input_mode = ask_silent; 447 input_mode = ask_silent;
514 valid_stdin = isatty(0) && isatty(1) && isatty(2); 448 sync_kconfig = 1;
515 break; 449 break;
516 case 'd': 450 case 'd':
517 input_mode = set_default; 451 input_mode = set_default;
@@ -549,6 +483,19 @@ int main(int ac, char **av)
549 name = av[optind]; 483 name = av[optind];
550 conf_parse(name); 484 conf_parse(name);
551 //zconfdump(stdout); 485 //zconfdump(stdout);
486 if (sync_kconfig) {
487 if (stat(".config", &tmpstat)) {
488 fprintf(stderr, _("***\n"
489 "*** You have not yet configured your kernel!\n"
490 "*** (missing kernel .config file)\n"
491 "***\n"
492 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
493 "*** \"make menuconfig\" or \"make xconfig\").\n"
494 "***\n"));
495 exit(1);
496 }
497 }
498
552 switch (input_mode) { 499 switch (input_mode) {
553 case set_default: 500 case set_default:
554 if (!defconfig_file) 501 if (!defconfig_file)
@@ -561,16 +508,6 @@ int main(int ac, char **av)
561 } 508 }
562 break; 509 break;
563 case ask_silent: 510 case ask_silent:
564 if (stat(".config", &tmpstat)) {
565 printf(_("***\n"
566 "*** You have not yet configured your kernel!\n"
567 "*** (missing kernel .config file)\n"
568 "***\n"
569 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
570 "*** \"make menuconfig\" or \"make xconfig\").\n"
571 "***\n"));
572 exit(1);
573 }
574 case ask_all: 511 case ask_all:
575 case ask_new: 512 case ask_new:
576 conf_read(NULL); 513 conf_read(NULL);
@@ -600,35 +537,66 @@ int main(int ac, char **av)
600 break; 537 break;
601 } 538 }
602 539
603 if (input_mode != ask_silent) { 540 if (sync_kconfig) {
541 if (conf_get_changed()) {
542 name = getenv("KCONFIG_NOSILENTUPDATE");
543 if (name && *name) {
544 fprintf(stderr,
545 _("\n*** Kernel configuration requires explicit update.\n\n"));
546 return 1;
547 }
548 }
549 valid_stdin = isatty(0) && isatty(1) && isatty(2);
550 }
551
552 switch (input_mode) {
553 case set_no:
554 conf_set_all_new_symbols(def_no);
555 break;
556 case set_yes:
557 conf_set_all_new_symbols(def_yes);
558 break;
559 case set_mod:
560 conf_set_all_new_symbols(def_mod);
561 break;
562 case set_random:
563 conf_set_all_new_symbols(def_random);
564 break;
565 case set_default:
566 conf_set_all_new_symbols(def_default);
567 break;
568 case ask_new:
569 case ask_all:
604 rootEntry = &rootmenu; 570 rootEntry = &rootmenu;
605 conf(&rootmenu); 571 conf(&rootmenu);
606 if (input_mode == ask_all) { 572 input_mode = ask_silent;
607 input_mode = ask_silent; 573 /* fall through */
608 valid_stdin = 1; 574 case ask_silent:
575 /* Update until a loop caused no more changes */
576 do {
577 conf_cnt = 0;
578 check_conf(&rootmenu);
579 } while (conf_cnt);
580 break;
581 }
582
583 if (sync_kconfig) {
584 /* silentoldconfig is used during the build so we shall update autoconf.
585 * All other commands are only used to generate a config.
586 */
587 if (conf_get_changed() && conf_write(NULL)) {
588 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
589 exit(1);
609 } 590 }
610 } else if (conf_get_changed()) { 591 if (conf_write_autoconf()) {
611 name = getenv("KCONFIG_NOSILENTUPDATE"); 592 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
612 if (name && *name) {
613 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
614 return 1; 593 return 1;
615 } 594 }
616 } else 595 } else {
617 goto skip_check; 596 if (conf_write(NULL)) {
618 597 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
619 do { 598 exit(1);
620 conf_cnt = 0; 599 }
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"));
625 return 1;
626 }
627skip_check:
628 if (input_mode == ask_silent && conf_write_autoconf()) {
629 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
630 return 1;
631 } 600 }
632
633 return 0; 601 return 0;
634} 602}