blob: fda63136ae6809512c6d84ab5c11d1497eee3bc5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
EGRY Gabor534a4502008-01-11 23:44:39 +01006#include <locale.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <ctype.h>
Randy Dunlap9dfb5632006-04-18 22:21:53 -07008#include <stdio.h>
Ladislav Michl75ff4302008-01-09 16:36:19 +01009#include <stdlib.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <time.h>
Ladislav Michl75ff4302008-01-09 16:36:19 +010012#include <unistd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <sys/stat.h>
14
15#define LKC_DIRECT_LINK
16#include "lkc.h"
17
18static void conf(struct menu *menu);
19static void check_conf(struct menu *menu);
20
21enum {
22 ask_all,
23 ask_new,
24 ask_silent,
25 set_default,
26 set_yes,
27 set_mod,
28 set_no,
29 set_random
30} input_mode = ask_all;
31char *defconfig_file;
32
33static int indent = 1;
34static int valid_stdin = 1;
35static int conf_cnt;
J.A. Magallon48b9d032005-06-25 14:59:22 -070036static char line[128];
Linus Torvalds1da177e2005-04-16 15:20:36 -070037static struct menu *rootEntry;
38
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -070039static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Sam Ravnborg03d29122007-07-21 00:00:36 +020041static const char *get_help(struct menu *menu)
42{
43 if (menu_has_help(menu))
EGRY Gabor534a4502008-01-11 23:44:39 +010044 return _(menu_get_help(menu));
Sam Ravnborg03d29122007-07-21 00:00:36 +020045 else
46 return nohelp_text;
47}
48
J.A. Magallon48b9d032005-06-25 14:59:22 -070049static void strip(char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
J.A. Magallon48b9d032005-06-25 14:59:22 -070051 char *p = str;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 int l;
53
54 while ((isspace(*p)))
55 p++;
56 l = strlen(p);
57 if (p != str)
58 memmove(str, p, l + 1);
59 if (!l)
60 return;
61 p = str + l - 1;
62 while ((isspace(*p)))
63 *p-- = 0;
64}
65
66static void check_stdin(void)
67{
68 if (!valid_stdin && input_mode == ask_silent) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -070069 printf(_("aborted!\n\n"));
70 printf(_("Console input/output is redirected. "));
71 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 exit(1);
73 }
74}
75
Roman Zippelf82f3f92007-08-30 05:06:17 +020076static int conf_askvalue(struct symbol *sym, const char *def)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
78 enum symbol_type type = sym_get_type(sym);
79 tristate val;
80
81 if (!sym_has_value(sym))
EGRY Gabor534a4502008-01-11 23:44:39 +010082 printf(_("(NEW) "));
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84 line[0] = '\n';
85 line[1] = 0;
86
87 if (!sym_is_changable(sym)) {
88 printf("%s\n", def);
89 line[0] = '\n';
90 line[1] = 0;
Roman Zippelf82f3f92007-08-30 05:06:17 +020091 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
93
94 switch (input_mode) {
Roman Zippel90389162005-11-08 21:34:49 -080095 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);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200101 return 0;
Roman Zippel90389162005-11-08 21:34:49 -0800102 }
103 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 case ask_new:
105 case ask_silent:
106 if (sym_has_value(sym)) {
107 printf("%s\n", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200108 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 }
110 check_stdin();
111 case ask_all:
112 fflush(stdout);
Roman Zippel59c6a3f2006-04-09 17:26:50 +0200113 fgets(line, 128, stdin);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200114 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 case set_default:
116 printf("%s\n", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200117 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 default:
119 break;
120 }
121
122 switch (type) {
123 case S_INT:
124 case S_HEX:
125 case S_STRING:
126 printf("%s\n", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200127 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 default:
129 ;
130 }
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 {
Ladislav Michl75ff4302008-01-09 16:36:19 +0100164 val = (tristate)(rand() % 3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 } 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);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200178 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179}
180
181int conf_string(struct menu *menu)
182{
183 struct symbol *sym = menu->sym;
Sam Ravnborg03d29122007-07-21 00:00:36 +0200184 const char *def;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186 while (1) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100187 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 printf("(%s) ", sym->name);
189 def = sym_get_string_value(sym);
190 if (sym_get_string_value(sym))
191 printf("[%s] ", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200192 if (!conf_askvalue(sym, def))
193 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 switch (line[0]) {
195 case '\n':
196 break;
197 case '?':
198 /* print help */
199 if (line[1] == '\n') {
Sam Ravnborg03d29122007-07-21 00:00:36 +0200200 printf("\n%s\n", get_help(menu));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 def = NULL;
202 break;
203 }
204 default:
205 line[strlen(line)-1] = 0;
206 def = line;
207 }
208 if (def && sym_set_string_value(sym, def))
209 return 0;
210 }
211}
212
213static int conf_sym(struct menu *menu)
214{
215 struct symbol *sym = menu->sym;
216 int type;
217 tristate oldval, newval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 while (1) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100220 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 if (sym->name)
222 printf("(%s) ", sym->name);
223 type = sym_get_type(sym);
224 putchar('[');
225 oldval = sym_get_tristate_value(sym);
226 switch (oldval) {
227 case no:
228 putchar('N');
229 break;
230 case mod:
231 putchar('M');
232 break;
233 case yes:
234 putchar('Y');
235 break;
236 }
237 if (oldval != no && sym_tristate_within_range(sym, no))
238 printf("/n");
239 if (oldval != mod && sym_tristate_within_range(sym, mod))
240 printf("/m");
241 if (oldval != yes && sym_tristate_within_range(sym, yes))
242 printf("/y");
Sam Ravnborg03d29122007-07-21 00:00:36 +0200243 if (menu_has_help(menu))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 printf("/?");
245 printf("] ");
Roman Zippelf82f3f92007-08-30 05:06:17 +0200246 if (!conf_askvalue(sym, sym_get_string_value(sym)))
247 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 strip(line);
249
250 switch (line[0]) {
251 case 'n':
252 case 'N':
253 newval = no;
254 if (!line[1] || !strcmp(&line[1], "o"))
255 break;
256 continue;
257 case 'm':
258 case 'M':
259 newval = mod;
260 if (!line[1])
261 break;
262 continue;
263 case 'y':
264 case 'Y':
265 newval = yes;
266 if (!line[1] || !strcmp(&line[1], "es"))
267 break;
268 continue;
269 case 0:
270 newval = oldval;
271 break;
272 case '?':
273 goto help;
274 default:
275 continue;
276 }
277 if (sym_set_tristate_value(sym, newval))
278 return 0;
279help:
Sam Ravnborg03d29122007-07-21 00:00:36 +0200280 printf("\n%s\n", get_help(menu));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 }
282}
283
284static int conf_choice(struct menu *menu)
285{
286 struct symbol *sym, *def_sym;
287 struct menu *child;
288 int type;
289 bool is_new;
290
291 sym = menu->sym;
292 type = sym_get_type(sym);
293 is_new = !sym_has_value(sym);
294 if (sym_is_changable(sym)) {
295 conf_sym(menu);
296 sym_calc_value(sym);
297 switch (sym_get_tristate_value(sym)) {
298 case no:
299 return 1;
300 case mod:
301 return 0;
302 case yes:
303 break;
304 }
305 } else {
306 switch (sym_get_tristate_value(sym)) {
307 case no:
308 return 1;
309 case mod:
EGRY Gabor534a4502008-01-11 23:44:39 +0100310 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 return 0;
312 case yes:
313 break;
314 }
315 }
316
317 while (1) {
318 int cnt, def;
319
EGRY Gabor534a4502008-01-11 23:44:39 +0100320 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 def_sym = sym_get_choice_value(sym);
322 cnt = def = 0;
Roman Zippel40aee722006-04-09 17:26:39 +0200323 line[0] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 for (child = menu->list; child; child = child->next) {
325 if (!menu_is_visible(child))
326 continue;
327 if (!child->sym) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100328 printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 continue;
330 }
331 cnt++;
332 if (child->sym == def_sym) {
333 def = cnt;
334 printf("%*c", indent, '>');
335 } else
336 printf("%*c", indent, ' ');
EGRY Gabor534a4502008-01-11 23:44:39 +0100337 printf(" %d. %s", cnt, _(menu_get_prompt(child)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 if (child->sym->name)
339 printf(" (%s)", child->sym->name);
340 if (!sym_has_value(child->sym))
EGRY Gabor534a4502008-01-11 23:44:39 +0100341 printf(_(" (NEW)"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 printf("\n");
343 }
EGRY Gabor534a4502008-01-11 23:44:39 +0100344 printf(_("%*schoice"), indent - 1, "");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 if (cnt == 1) {
346 printf("[1]: 1\n");
347 goto conf_childs;
348 }
349 printf("[1-%d", cnt);
Sam Ravnborg03d29122007-07-21 00:00:36 +0200350 if (menu_has_help(menu))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 printf("?");
352 printf("]: ");
353 switch (input_mode) {
354 case ask_new:
355 case ask_silent:
356 if (!is_new) {
357 cnt = def;
358 printf("%d\n", cnt);
359 break;
360 }
361 check_stdin();
362 case ask_all:
363 fflush(stdout);
Roman Zippel59c6a3f2006-04-09 17:26:50 +0200364 fgets(line, 128, stdin);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 strip(line);
366 if (line[0] == '?') {
Sam Ravnborg03d29122007-07-21 00:00:36 +0200367 printf("\n%s\n", get_help(menu));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 continue;
369 }
370 if (!line[0])
371 cnt = def;
372 else if (isdigit(line[0]))
373 cnt = atoi(line);
374 else
375 continue;
376 break;
377 case set_random:
Paul Mundt870e6f72007-12-22 14:03:30 -0800378 if (is_new)
Ladislav Michl07f76682008-01-09 16:36:19 +0100379 def = (rand() % cnt) + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 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;
387 }
388
389 conf_childs:
390 for (child = menu->list; child; child = child->next) {
391 if (!child->sym || !menu_is_visible(child))
392 continue;
393 if (!--cnt)
394 break;
395 }
396 if (!child)
397 continue;
398 if (line[strlen(line) - 1] == '?') {
Sam Ravnborg03d29122007-07-21 00:00:36 +0200399 printf("\n%s\n", get_help(child));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 continue;
401 }
402 sym_set_choice_value(sym, child->sym);
Jan Beulichf5eaa322008-01-24 11:54:23 +0000403 for (child = child->list; child; child = child->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 indent += 2;
Jan Beulichf5eaa322008-01-24 11:54:23 +0000405 conf(child);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 indent -= 2;
407 }
408 return 1;
409 }
410}
411
412static void conf(struct menu *menu)
413{
414 struct symbol *sym;
415 struct property *prop;
416 struct menu *child;
417
418 if (!menu_is_visible(menu))
419 return;
420
421 sym = menu->sym;
422 prop = menu->prompt;
423 if (prop) {
424 const char *prompt;
425
426 switch (prop->type) {
427 case P_MENU:
428 if (input_mode == ask_silent && rootEntry != menu) {
429 check_conf(menu);
430 return;
431 }
432 case P_COMMENT:
433 prompt = menu_get_prompt(menu);
434 if (prompt)
435 printf("%*c\n%*c %s\n%*c\n",
436 indent, '*',
EGRY Gabor534a4502008-01-11 23:44:39 +0100437 indent, '*', _(prompt),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 indent, '*');
439 default:
440 ;
441 }
442 }
443
444 if (!sym)
445 goto conf_childs;
446
447 if (sym_is_choice(sym)) {
448 conf_choice(menu);
449 if (sym->curr.tri != mod)
450 return;
451 goto conf_childs;
452 }
453
454 switch (sym->type) {
455 case S_INT:
456 case S_HEX:
457 case S_STRING:
458 conf_string(menu);
459 break;
460 default:
461 conf_sym(menu);
462 break;
463 }
464
465conf_childs:
466 if (sym)
467 indent += 2;
468 for (child = menu->list; child; child = child->next)
469 conf(child);
470 if (sym)
471 indent -= 2;
472}
473
474static void check_conf(struct menu *menu)
475{
476 struct symbol *sym;
477 struct menu *child;
478
479 if (!menu_is_visible(menu))
480 return;
481
482 sym = menu->sym;
Roman Zippel3f23ca22005-11-08 21:34:48 -0800483 if (sym && !sym_has_value(sym)) {
484 if (sym_is_changable(sym) ||
485 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 if (!conf_cnt++)
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700487 printf(_("*\n* Restart config...\n*\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 rootEntry = menu_get_parent_menu(menu);
489 conf(rootEntry);
490 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 }
492
493 for (child = menu->list; child; child = child->next)
494 check_conf(child);
495}
496
497int main(int ac, char **av)
498{
Andres Salomon2f4b4892007-12-17 01:34:58 -0500499 int opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 const char *name;
501 struct stat tmpstat;
502
EGRY Gabor534a4502008-01-11 23:44:39 +0100503 setlocale(LC_ALL, "");
504 bindtextdomain(PACKAGE, LOCALEDIR);
505 textdomain(PACKAGE);
506
Andres Salomon2f4b4892007-12-17 01:34:58 -0500507 while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
508 switch (opt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 case 'o':
510 input_mode = ask_new;
511 break;
512 case 's':
513 input_mode = ask_silent;
514 valid_stdin = isatty(0) && isatty(1) && isatty(2);
515 break;
516 case 'd':
517 input_mode = set_default;
518 break;
519 case 'D':
520 input_mode = set_default;
Andres Salomon2f4b4892007-12-17 01:34:58 -0500521 defconfig_file = optarg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 break;
523 case 'n':
524 input_mode = set_no;
525 break;
526 case 'm':
527 input_mode = set_mod;
528 break;
529 case 'y':
530 input_mode = set_yes;
531 break;
532 case 'r':
533 input_mode = set_random;
Ladislav Michl07f76682008-01-09 16:36:19 +0100534 srand(time(NULL));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 break;
536 case 'h':
EGRY Gabor534a4502008-01-11 23:44:39 +0100537 printf(_("See README for usage info\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 exit(0);
Andres Salomon2f4b4892007-12-17 01:34:58 -0500539 break;
540 default:
EGRY Gabor534a4502008-01-11 23:44:39 +0100541 fprintf(stderr, _("See README for usage info\n"));
Andres Salomon2f4b4892007-12-17 01:34:58 -0500542 exit(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 }
544 }
Andres Salomon2f4b4892007-12-17 01:34:58 -0500545 if (ac == optind) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700546 printf(_("%s: Kconfig file missing\n"), av[0]);
Randy Dunlap250725a2006-06-08 22:12:50 -0700547 exit(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 }
Andres Salomon2f4b4892007-12-17 01:34:58 -0500549 name = av[optind];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 conf_parse(name);
551 //zconfdump(stdout);
552 switch (input_mode) {
553 case set_default:
554 if (!defconfig_file)
555 defconfig_file = conf_get_default_confname();
556 if (conf_read(defconfig_file)) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100557 printf(_("***\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 "*** Can't find default configuration \"%s\"!\n"
EGRY Gabor534a4502008-01-11 23:44:39 +0100559 "***\n"), defconfig_file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 exit(1);
561 }
562 break;
563 case ask_silent:
564 if (stat(".config", &tmpstat)) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700565 printf(_("***\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 "*** You have not yet configured your kernel!\n"
Randy Dunlap7ac1c142007-04-04 21:58:41 -0700567 "*** (missing kernel .config file)\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 "***\n"
569 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
570 "*** \"make menuconfig\" or \"make xconfig\").\n"
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700571 "***\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 exit(1);
573 }
574 case ask_all:
575 case ask_new:
576 conf_read(NULL);
577 break;
Roman Zippel90389162005-11-08 21:34:49 -0800578 case set_no:
579 case set_mod:
580 case set_yes:
581 case set_random:
582 name = getenv("KCONFIG_ALLCONFIG");
583 if (name && !stat(name, &tmpstat)) {
Roman Zippel669bfad2006-06-08 22:12:42 -0700584 conf_read_simple(name, S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800585 break;
586 }
587 switch (input_mode) {
588 case set_no: name = "allno.config"; break;
589 case set_mod: name = "allmod.config"; break;
590 case set_yes: name = "allyes.config"; break;
591 case set_random: name = "allrandom.config"; break;
592 default: break;
593 }
594 if (!stat(name, &tmpstat))
Roman Zippel669bfad2006-06-08 22:12:42 -0700595 conf_read_simple(name, S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800596 else if (!stat("all.config", &tmpstat))
Roman Zippel669bfad2006-06-08 22:12:42 -0700597 conf_read_simple("all.config", S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800598 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 default:
600 break;
601 }
602
603 if (input_mode != ask_silent) {
604 rootEntry = &rootmenu;
605 conf(&rootmenu);
606 if (input_mode == ask_all) {
607 input_mode = ask_silent;
608 valid_stdin = 1;
609 }
Karsten Wieseb3214292006-12-13 00:34:06 -0800610 } else if (conf_get_changed()) {
Roman Zippelc955cca2006-06-08 22:12:39 -0700611 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 do {
620 conf_cnt = 0;
621 check_conf(&rootmenu);
622 } while (conf_cnt);
623 if (conf_write(NULL)) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700624 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 return 1;
626 }
Roman Zippelc955cca2006-06-08 22:12:39 -0700627skip_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 }
632
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 return 0;
634}