blob: 9960d1c303f8c2f985a1a92de8e990850c33ccf6 [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>
Ingo Molnarb0fe5512009-03-12 15:15:31 +010014#include <sys/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#define LKC_DIRECT_LINK
17#include "lkc.h"
18
19static void conf(struct menu *menu);
20static void check_conf(struct menu *menu);
21
22enum {
23 ask_all,
24 ask_new,
25 ask_silent,
26 set_default,
27 set_yes,
28 set_mod,
29 set_no,
30 set_random
31} input_mode = ask_all;
32char *defconfig_file;
33
34static int indent = 1;
35static int valid_stdin = 1;
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +020036static int sync_kconfig;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037static int conf_cnt;
J.A. Magallon48b9d032005-06-25 14:59:22 -070038static char line[128];
Linus Torvalds1da177e2005-04-16 15:20:36 -070039static struct menu *rootEntry;
40
Cheng Renquan66c4bd82009-07-12 16:11:48 +080041static void print_help(struct menu *menu)
Sam Ravnborg03d29122007-07-21 00:00:36 +020042{
Cheng Renquan66c4bd82009-07-12 16:11:48 +080043 struct gstr help = str_new();
44
45 menu_get_ext_help(menu, &help);
46
47 printf("\n%s\n", str_get(&help));
48 str_free(&help);
Sam Ravnborg03d29122007-07-21 00:00:36 +020049}
50
J.A. Magallon48b9d032005-06-25 14:59:22 -070051static void strip(char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
J.A. Magallon48b9d032005-06-25 14:59:22 -070053 char *p = str;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 int l;
55
56 while ((isspace(*p)))
57 p++;
58 l = strlen(p);
59 if (p != str)
60 memmove(str, p, l + 1);
61 if (!l)
62 return;
63 p = str + l - 1;
64 while ((isspace(*p)))
65 *p-- = 0;
66}
67
68static void check_stdin(void)
69{
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +020070 if (!valid_stdin) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -070071 printf(_("aborted!\n\n"));
72 printf(_("Console input/output is redirected. "));
73 printf(_("Run 'make oldconfig' to update configuration.\n\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 exit(1);
75 }
76}
77
Roman Zippelf82f3f92007-08-30 05:06:17 +020078static int conf_askvalue(struct symbol *sym, const char *def)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
80 enum symbol_type type = sym_get_type(sym);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82 if (!sym_has_value(sym))
EGRY Gabor534a4502008-01-11 23:44:39 +010083 printf(_("(NEW) "));
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85 line[0] = '\n';
86 line[1] = 0;
87
88 if (!sym_is_changable(sym)) {
89 printf("%s\n", def);
90 line[0] = '\n';
91 line[1] = 0;
Roman Zippelf82f3f92007-08-30 05:06:17 +020092 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 }
94
95 switch (input_mode) {
96 case ask_new:
97 case ask_silent:
98 if (sym_has_value(sym)) {
99 printf("%s\n", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200100 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 }
102 check_stdin();
103 case ask_all:
104 fflush(stdout);
Roman Zippel59c6a3f2006-04-09 17:26:50 +0200105 fgets(line, 128, stdin);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200106 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 default:
108 break;
109 }
110
111 switch (type) {
112 case S_INT:
113 case S_HEX:
114 case S_STRING:
115 printf("%s\n", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200116 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 default:
118 ;
119 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 printf("%s", line);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200121 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122}
123
Trevor Keith4356f482009-09-18 12:49:23 -0700124static int conf_string(struct menu *menu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
126 struct symbol *sym = menu->sym;
Sam Ravnborg03d29122007-07-21 00:00:36 +0200127 const char *def;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129 while (1) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100130 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 printf("(%s) ", sym->name);
132 def = sym_get_string_value(sym);
133 if (sym_get_string_value(sym))
134 printf("[%s] ", def);
Roman Zippelf82f3f92007-08-30 05:06:17 +0200135 if (!conf_askvalue(sym, def))
136 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 switch (line[0]) {
138 case '\n':
139 break;
140 case '?':
141 /* print help */
142 if (line[1] == '\n') {
Cheng Renquan66c4bd82009-07-12 16:11:48 +0800143 print_help(menu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 def = NULL;
145 break;
146 }
147 default:
148 line[strlen(line)-1] = 0;
149 def = line;
150 }
151 if (def && sym_set_string_value(sym, def))
152 return 0;
153 }
154}
155
156static int conf_sym(struct menu *menu)
157{
158 struct symbol *sym = menu->sym;
159 int type;
160 tristate oldval, newval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162 while (1) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100163 printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 if (sym->name)
165 printf("(%s) ", sym->name);
166 type = sym_get_type(sym);
167 putchar('[');
168 oldval = sym_get_tristate_value(sym);
169 switch (oldval) {
170 case no:
171 putchar('N');
172 break;
173 case mod:
174 putchar('M');
175 break;
176 case yes:
177 putchar('Y');
178 break;
179 }
180 if (oldval != no && sym_tristate_within_range(sym, no))
181 printf("/n");
182 if (oldval != mod && sym_tristate_within_range(sym, mod))
183 printf("/m");
184 if (oldval != yes && sym_tristate_within_range(sym, yes))
185 printf("/y");
Sam Ravnborg03d29122007-07-21 00:00:36 +0200186 if (menu_has_help(menu))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 printf("/?");
188 printf("] ");
Roman Zippelf82f3f92007-08-30 05:06:17 +0200189 if (!conf_askvalue(sym, sym_get_string_value(sym)))
190 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 strip(line);
192
193 switch (line[0]) {
194 case 'n':
195 case 'N':
196 newval = no;
197 if (!line[1] || !strcmp(&line[1], "o"))
198 break;
199 continue;
200 case 'm':
201 case 'M':
202 newval = mod;
203 if (!line[1])
204 break;
205 continue;
206 case 'y':
207 case 'Y':
208 newval = yes;
209 if (!line[1] || !strcmp(&line[1], "es"))
210 break;
211 continue;
212 case 0:
213 newval = oldval;
214 break;
215 case '?':
216 goto help;
217 default:
218 continue;
219 }
220 if (sym_set_tristate_value(sym, newval))
221 return 0;
222help:
Cheng Renquan66c4bd82009-07-12 16:11:48 +0800223 print_help(menu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 }
225}
226
227static int conf_choice(struct menu *menu)
228{
229 struct symbol *sym, *def_sym;
230 struct menu *child;
231 int type;
232 bool is_new;
233
234 sym = menu->sym;
235 type = sym_get_type(sym);
236 is_new = !sym_has_value(sym);
237 if (sym_is_changable(sym)) {
238 conf_sym(menu);
239 sym_calc_value(sym);
240 switch (sym_get_tristate_value(sym)) {
241 case no:
242 return 1;
243 case mod:
244 return 0;
245 case yes:
246 break;
247 }
248 } else {
249 switch (sym_get_tristate_value(sym)) {
250 case no:
251 return 1;
252 case mod:
EGRY Gabor534a4502008-01-11 23:44:39 +0100253 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 return 0;
255 case yes:
256 break;
257 }
258 }
259
260 while (1) {
261 int cnt, def;
262
EGRY Gabor534a4502008-01-11 23:44:39 +0100263 printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 def_sym = sym_get_choice_value(sym);
265 cnt = def = 0;
Roman Zippel40aee722006-04-09 17:26:39 +0200266 line[0] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 for (child = menu->list; child; child = child->next) {
268 if (!menu_is_visible(child))
269 continue;
270 if (!child->sym) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100271 printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 continue;
273 }
274 cnt++;
275 if (child->sym == def_sym) {
276 def = cnt;
277 printf("%*c", indent, '>');
278 } else
279 printf("%*c", indent, ' ');
EGRY Gabor534a4502008-01-11 23:44:39 +0100280 printf(" %d. %s", cnt, _(menu_get_prompt(child)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 if (child->sym->name)
282 printf(" (%s)", child->sym->name);
283 if (!sym_has_value(child->sym))
EGRY Gabor534a4502008-01-11 23:44:39 +0100284 printf(_(" (NEW)"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 printf("\n");
286 }
EGRY Gabor534a4502008-01-11 23:44:39 +0100287 printf(_("%*schoice"), indent - 1, "");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 if (cnt == 1) {
289 printf("[1]: 1\n");
290 goto conf_childs;
291 }
292 printf("[1-%d", cnt);
Sam Ravnborg03d29122007-07-21 00:00:36 +0200293 if (menu_has_help(menu))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 printf("?");
295 printf("]: ");
296 switch (input_mode) {
297 case ask_new:
298 case ask_silent:
299 if (!is_new) {
300 cnt = def;
301 printf("%d\n", cnt);
302 break;
303 }
304 check_stdin();
305 case ask_all:
306 fflush(stdout);
Roman Zippel59c6a3f2006-04-09 17:26:50 +0200307 fgets(line, 128, stdin);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 strip(line);
309 if (line[0] == '?') {
Cheng Renquan66c4bd82009-07-12 16:11:48 +0800310 print_help(menu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 continue;
312 }
313 if (!line[0])
314 cnt = def;
315 else if (isdigit(line[0]))
316 cnt = atoi(line);
317 else
318 continue;
319 break;
Sam Ravnborgf443d2e2008-06-30 22:45:38 +0200320 default:
321 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 }
323
324 conf_childs:
325 for (child = menu->list; child; child = child->next) {
326 if (!child->sym || !menu_is_visible(child))
327 continue;
328 if (!--cnt)
329 break;
330 }
331 if (!child)
332 continue;
333 if (line[strlen(line) - 1] == '?') {
Cheng Renquan66c4bd82009-07-12 16:11:48 +0800334 print_help(child);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 continue;
336 }
337 sym_set_choice_value(sym, child->sym);
Jan Beulichf5eaa322008-01-24 11:54:23 +0000338 for (child = child->list; child; child = child->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 indent += 2;
Jan Beulichf5eaa322008-01-24 11:54:23 +0000340 conf(child);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 indent -= 2;
342 }
343 return 1;
344 }
345}
346
347static void conf(struct menu *menu)
348{
349 struct symbol *sym;
350 struct property *prop;
351 struct menu *child;
352
353 if (!menu_is_visible(menu))
354 return;
355
356 sym = menu->sym;
357 prop = menu->prompt;
358 if (prop) {
359 const char *prompt;
360
361 switch (prop->type) {
362 case P_MENU:
363 if (input_mode == ask_silent && rootEntry != menu) {
364 check_conf(menu);
365 return;
366 }
367 case P_COMMENT:
368 prompt = menu_get_prompt(menu);
369 if (prompt)
370 printf("%*c\n%*c %s\n%*c\n",
371 indent, '*',
EGRY Gabor534a4502008-01-11 23:44:39 +0100372 indent, '*', _(prompt),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 indent, '*');
374 default:
375 ;
376 }
377 }
378
379 if (!sym)
380 goto conf_childs;
381
382 if (sym_is_choice(sym)) {
383 conf_choice(menu);
384 if (sym->curr.tri != mod)
385 return;
386 goto conf_childs;
387 }
388
389 switch (sym->type) {
390 case S_INT:
391 case S_HEX:
392 case S_STRING:
393 conf_string(menu);
394 break;
395 default:
396 conf_sym(menu);
397 break;
398 }
399
400conf_childs:
401 if (sym)
402 indent += 2;
403 for (child = menu->list; child; child = child->next)
404 conf(child);
405 if (sym)
406 indent -= 2;
407}
408
409static void check_conf(struct menu *menu)
410{
411 struct symbol *sym;
412 struct menu *child;
413
414 if (!menu_is_visible(menu))
415 return;
416
417 sym = menu->sym;
Roman Zippel3f23ca22005-11-08 21:34:48 -0800418 if (sym && !sym_has_value(sym)) {
419 if (sym_is_changable(sym) ||
420 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 if (!conf_cnt++)
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700422 printf(_("*\n* Restart config...\n*\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 rootEntry = menu_get_parent_menu(menu);
424 conf(rootEntry);
425 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 }
427
428 for (child = menu->list; child; child = child->next)
429 check_conf(child);
430}
431
432int main(int ac, char **av)
433{
Andres Salomon2f4b4892007-12-17 01:34:58 -0500434 int opt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 const char *name;
436 struct stat tmpstat;
437
EGRY Gabor534a4502008-01-11 23:44:39 +0100438 setlocale(LC_ALL, "");
439 bindtextdomain(PACKAGE, LOCALEDIR);
440 textdomain(PACKAGE);
441
Andres Salomon2f4b4892007-12-17 01:34:58 -0500442 while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
443 switch (opt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 case 'o':
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200445 input_mode = ask_silent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 break;
447 case 's':
448 input_mode = ask_silent;
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200449 sync_kconfig = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 break;
451 case 'd':
452 input_mode = set_default;
453 break;
454 case 'D':
455 input_mode = set_default;
Andres Salomon2f4b4892007-12-17 01:34:58 -0500456 defconfig_file = optarg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 break;
458 case 'n':
459 input_mode = set_no;
460 break;
461 case 'm':
462 input_mode = set_mod;
463 break;
464 case 'y':
465 input_mode = set_yes;
466 break;
467 case 'r':
Ingo Molnarb0fe5512009-03-12 15:15:31 +0100468 {
469 struct timeval now;
470 unsigned int seed;
471
472 /*
473 * Use microseconds derived seed,
474 * compensate for systems where it may be zero
475 */
476 gettimeofday(&now, NULL);
477
478 seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
479 srand(seed);
480
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 input_mode = set_random;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 break;
Ingo Molnarb0fe5512009-03-12 15:15:31 +0100483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 case 'h':
EGRY Gabor534a4502008-01-11 23:44:39 +0100485 printf(_("See README for usage info\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 exit(0);
Andres Salomon2f4b4892007-12-17 01:34:58 -0500487 break;
488 default:
EGRY Gabor534a4502008-01-11 23:44:39 +0100489 fprintf(stderr, _("See README for usage info\n"));
Andres Salomon2f4b4892007-12-17 01:34:58 -0500490 exit(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 }
492 }
Andres Salomon2f4b4892007-12-17 01:34:58 -0500493 if (ac == optind) {
Arnaldo Carvalho de Melo3b9fa092005-05-05 15:09:46 -0700494 printf(_("%s: Kconfig file missing\n"), av[0]);
Randy Dunlap250725a2006-06-08 22:12:50 -0700495 exit(1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 }
Andres Salomon2f4b4892007-12-17 01:34:58 -0500497 name = av[optind];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 conf_parse(name);
499 //zconfdump(stdout);
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200500 if (sync_kconfig) {
Markus Heidelberg284026c2009-05-18 01:36:53 +0200501 name = conf_get_configname();
502 if (stat(name, &tmpstat)) {
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200503 fprintf(stderr, _("***\n"
504 "*** You have not yet configured your kernel!\n"
Markus Heidelberg284026c2009-05-18 01:36:53 +0200505 "*** (missing kernel config file \"%s\")\n"
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200506 "***\n"
507 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
508 "*** \"make menuconfig\" or \"make xconfig\").\n"
Markus Heidelberg284026c2009-05-18 01:36:53 +0200509 "***\n"), name);
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200510 exit(1);
511 }
512 }
513
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 switch (input_mode) {
515 case set_default:
516 if (!defconfig_file)
517 defconfig_file = conf_get_default_confname();
518 if (conf_read(defconfig_file)) {
EGRY Gabor534a4502008-01-11 23:44:39 +0100519 printf(_("***\n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 "*** Can't find default configuration \"%s\"!\n"
EGRY Gabor534a4502008-01-11 23:44:39 +0100521 "***\n"), defconfig_file);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 exit(1);
523 }
524 break;
525 case ask_silent:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 case ask_all:
527 case ask_new:
528 conf_read(NULL);
529 break;
Roman Zippel90389162005-11-08 21:34:49 -0800530 case set_no:
531 case set_mod:
532 case set_yes:
533 case set_random:
534 name = getenv("KCONFIG_ALLCONFIG");
535 if (name && !stat(name, &tmpstat)) {
Roman Zippel669bfad2006-06-08 22:12:42 -0700536 conf_read_simple(name, S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800537 break;
538 }
539 switch (input_mode) {
540 case set_no: name = "allno.config"; break;
541 case set_mod: name = "allmod.config"; break;
542 case set_yes: name = "allyes.config"; break;
543 case set_random: name = "allrandom.config"; break;
544 default: break;
545 }
546 if (!stat(name, &tmpstat))
Roman Zippel669bfad2006-06-08 22:12:42 -0700547 conf_read_simple(name, S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800548 else if (!stat("all.config", &tmpstat))
Roman Zippel669bfad2006-06-08 22:12:42 -0700549 conf_read_simple("all.config", S_DEF_USER);
Roman Zippel90389162005-11-08 21:34:49 -0800550 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 default:
552 break;
553 }
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200554
555 if (sync_kconfig) {
556 if (conf_get_changed()) {
557 name = getenv("KCONFIG_NOSILENTUPDATE");
558 if (name && *name) {
559 fprintf(stderr,
560 _("\n*** Kernel configuration requires explicit update.\n\n"));
561 return 1;
562 }
563 }
564 valid_stdin = isatty(0) && isatty(1) && isatty(2);
565 }
566
Sam Ravnborgf443d2e2008-06-30 22:45:38 +0200567 switch (input_mode) {
568 case set_no:
569 conf_set_all_new_symbols(def_no);
570 break;
571 case set_yes:
572 conf_set_all_new_symbols(def_yes);
573 break;
574 case set_mod:
575 conf_set_all_new_symbols(def_mod);
576 break;
577 case set_random:
578 conf_set_all_new_symbols(def_random);
579 break;
Sam Ravnborg09748e12008-06-30 23:02:59 +0200580 case set_default:
581 conf_set_all_new_symbols(def_default);
582 break;
Sam Ravnborgcd9140e1e2008-06-30 22:53:04 +0200583 case ask_new:
Sam Ravnborgf443d2e2008-06-30 22:45:38 +0200584 case ask_all:
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200585 rootEntry = &rootmenu;
586 conf(&rootmenu);
587 input_mode = ask_silent;
588 /* fall through */
589 case ask_silent:
590 /* Update until a loop caused no more changes */
591 do {
592 conf_cnt = 0;
593 check_conf(&rootmenu);
594 } while (conf_cnt);
Sam Ravnborgf443d2e2008-06-30 22:45:38 +0200595 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 }
Sam Ravnborgf443d2e2008-06-30 22:45:38 +0200597
zippel@linux-m68k.org204c96f2008-09-29 05:27:10 +0200598 if (sync_kconfig) {
599 /* silentoldconfig is used during the build so we shall update autoconf.
600 * All other commands are only used to generate a config.
601 */
602 if (conf_get_changed() && conf_write(NULL)) {
603 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
604 exit(1);
605 }
606 if (conf_write_autoconf()) {
607 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
608 return 1;
609 }
610 } else {
611 if (conf_write(NULL)) {
612 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
613 exit(1);
614 }
Roman Zippelc955cca2006-06-08 22:12:39 -0700615 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 return 0;
617}