Blame view
scripts/kconfig/conf.c
15.7 KB
1da177e4c
|
1 2 3 4 |
/* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. */ |
534a450c3
|
5 |
#include <locale.h> |
1da177e4c
|
6 |
#include <ctype.h> |
74dba8091
|
7 |
#include <limits.h> |
9dfb563b0
|
8 |
#include <stdio.h> |
75ff4309c
|
9 |
#include <stdlib.h> |
1da177e4c
|
10 |
#include <string.h> |
1da177e4c
|
11 |
#include <time.h> |
75ff4309c
|
12 |
#include <unistd.h> |
4062f1a4c
|
13 |
#include <getopt.h> |
1da177e4c
|
14 |
#include <sys/stat.h> |
b0fe55100
|
15 |
#include <sys/time.h> |
0d8024c6e
|
16 |
#include <errno.h> |
1da177e4c
|
17 |
|
1da177e4c
|
18 19 20 21 |
#include "lkc.h" static void conf(struct menu *menu); static void check_conf(struct menu *menu); |
ab63f58f2
|
22 |
static void xfgets(char *str, int size, FILE *in); |
1da177e4c
|
23 |
|
4062f1a4c
|
24 25 26 27 28 29 30 |
enum input_mode { oldaskconfig, silentoldconfig, oldconfig, allnoconfig, allyesconfig, allmodconfig, |
0748cb3e1
|
31 |
alldefconfig, |
4062f1a4c
|
32 33 |
randconfig, defconfig, |
7cf3d73b4
|
34 |
savedefconfig, |
861b4ea4c
|
35 |
listnewconfig, |
fb16d8912
|
36 |
olddefconfig, |
4062f1a4c
|
37 |
} input_mode = oldaskconfig; |
1da177e4c
|
38 |
static int indent = 1; |
62dc98992
|
39 |
static int tty_stdio; |
1da177e4c
|
40 |
static int valid_stdin = 1; |
204c96f60
|
41 |
static int sync_kconfig; |
1da177e4c
|
42 |
static int conf_cnt; |
74dba8091
|
43 |
static char line[PATH_MAX]; |
1da177e4c
|
44 |
static struct menu *rootEntry; |
66c4bd808
|
45 |
static void print_help(struct menu *menu) |
03d291227
|
46 |
{ |
66c4bd808
|
47 48 49 50 51 52 53 54 |
struct gstr help = str_new(); menu_get_ext_help(menu, &help); printf(" %s ", str_get(&help)); str_free(&help); |
03d291227
|
55 |
} |
48b9d03c5
|
56 |
static void strip(char *str) |
1da177e4c
|
57 |
{ |
48b9d03c5
|
58 |
char *p = str; |
1da177e4c
|
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
int l; while ((isspace(*p))) p++; l = strlen(p); if (p != str) memmove(str, p, l + 1); if (!l) return; p = str + l - 1; while ((isspace(*p))) *p-- = 0; } static void check_stdin(void) { |
204c96f60
|
75 |
if (!valid_stdin) { |
3b9fa0931
|
76 77 78 79 80 81 82 |
printf(_("aborted! ")); printf(_("Console input/output is redirected. ")); printf(_("Run 'make oldconfig' to update configuration. ")); |
1da177e4c
|
83 84 85 |
exit(1); } } |
f82f3f942
|
86 |
static int conf_askvalue(struct symbol *sym, const char *def) |
1da177e4c
|
87 88 |
{ enum symbol_type type = sym_get_type(sym); |
1da177e4c
|
89 90 |
if (!sym_has_value(sym)) |
534a450c3
|
91 |
printf(_("(NEW) ")); |
1da177e4c
|
92 93 94 95 96 97 98 99 100 101 102 |
line[0] = ' '; line[1] = 0; if (!sym_is_changable(sym)) { printf("%s ", def); line[0] = ' '; line[1] = 0; |
f82f3f942
|
103 |
return 0; |
1da177e4c
|
104 105 106 |
} switch (input_mode) { |
4062f1a4c
|
107 108 |
case oldconfig: case silentoldconfig: |
1da177e4c
|
109 110 111 |
if (sym_has_value(sym)) { printf("%s ", def); |
f82f3f942
|
112 |
return 0; |
1da177e4c
|
113 114 |
} check_stdin(); |
d8fc32007
|
115 |
/* fall through */ |
4062f1a4c
|
116 |
case oldaskconfig: |
1da177e4c
|
117 |
fflush(stdout); |
74dba8091
|
118 |
xfgets(line, sizeof(line), stdin); |
62dc98992
|
119 120 121 |
if (!tty_stdio) printf(" "); |
f82f3f942
|
122 |
return 1; |
1da177e4c
|
123 124 125 126 127 128 129 130 131 132 |
default: break; } switch (type) { case S_INT: case S_HEX: case S_STRING: printf("%s ", def); |
f82f3f942
|
133 |
return 1; |
1da177e4c
|
134 135 136 |
default: ; } |
1da177e4c
|
137 |
printf("%s", line); |
f82f3f942
|
138 |
return 1; |
1da177e4c
|
139 |
} |
4356f4890
|
140 |
static int conf_string(struct menu *menu) |
1da177e4c
|
141 142 |
{ struct symbol *sym = menu->sym; |
03d291227
|
143 |
const char *def; |
1da177e4c
|
144 145 |
while (1) { |
534a450c3
|
146 |
printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
1da177e4c
|
147 148 149 150 |
printf("(%s) ", sym->name); def = sym_get_string_value(sym); if (sym_get_string_value(sym)) printf("[%s] ", def); |
f82f3f942
|
151 152 |
if (!conf_askvalue(sym, def)) return 0; |
1da177e4c
|
153 154 155 156 157 158 159 160 |
switch (line[0]) { case ' ': break; case '?': /* print help */ if (line[1] == ' ') { |
66c4bd808
|
161 |
print_help(menu); |
1da177e4c
|
162 163 164 |
def = NULL; break; } |
d8fc32007
|
165 |
/* fall through */ |
1da177e4c
|
166 167 168 169 170 171 172 173 174 175 176 177 |
default: line[strlen(line)-1] = 0; def = line; } if (def && sym_set_string_value(sym, def)) return 0; } } static int conf_sym(struct menu *menu) { struct symbol *sym = menu->sym; |
1da177e4c
|
178 |
tristate oldval, newval; |
1da177e4c
|
179 180 |
while (1) { |
534a450c3
|
181 |
printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
1da177e4c
|
182 183 |
if (sym->name) printf("(%s) ", sym->name); |
1da177e4c
|
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
putchar('['); oldval = sym_get_tristate_value(sym); switch (oldval) { case no: putchar('N'); break; case mod: putchar('M'); break; case yes: putchar('Y'); break; } if (oldval != no && sym_tristate_within_range(sym, no)) printf("/n"); if (oldval != mod && sym_tristate_within_range(sym, mod)) printf("/m"); if (oldval != yes && sym_tristate_within_range(sym, yes)) printf("/y"); |
03d291227
|
203 |
if (menu_has_help(menu)) |
1da177e4c
|
204 205 |
printf("/?"); printf("] "); |
f82f3f942
|
206 207 |
if (!conf_askvalue(sym, sym_get_string_value(sym))) return 0; |
1da177e4c
|
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
strip(line); switch (line[0]) { case 'n': case 'N': newval = no; if (!line[1] || !strcmp(&line[1], "o")) break; continue; case 'm': case 'M': newval = mod; if (!line[1]) break; continue; case 'y': case 'Y': newval = yes; if (!line[1] || !strcmp(&line[1], "es")) break; continue; case 0: newval = oldval; break; case '?': goto help; default: continue; } if (sym_set_tristate_value(sym, newval)) return 0; help: |
66c4bd808
|
240 |
print_help(menu); |
1da177e4c
|
241 242 243 244 245 246 247 |
} } static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; struct menu *child; |
1da177e4c
|
248 249 250 |
bool is_new; sym = menu->sym; |
1da177e4c
|
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: return 0; case yes: break; } } else { switch (sym_get_tristate_value(sym)) { case no: return 1; case mod: |
534a450c3
|
268 269 |
printf("%*s%s ", indent - 1, "", _(menu_get_prompt(menu))); |
1da177e4c
|
270 271 272 273 274 275 276 277 |
return 0; case yes: break; } } while (1) { int cnt, def; |
534a450c3
|
278 279 |
printf("%*s%s ", indent - 1, "", _(menu_get_prompt(menu))); |
1da177e4c
|
280 281 |
def_sym = sym_get_choice_value(sym); cnt = def = 0; |
40aee729b
|
282 |
line[0] = 0; |
1da177e4c
|
283 284 285 286 |
for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; if (!child->sym) { |
534a450c3
|
287 288 |
printf("%*c %s ", indent, '*', _(menu_get_prompt(child))); |
1da177e4c
|
289 290 291 292 293 294 295 296 |
continue; } cnt++; if (child->sym == def_sym) { def = cnt; printf("%*c", indent, '>'); } else printf("%*c", indent, ' '); |
534a450c3
|
297 |
printf(" %d. %s", cnt, _(menu_get_prompt(child))); |
1da177e4c
|
298 299 300 |
if (child->sym->name) printf(" (%s)", child->sym->name); if (!sym_has_value(child->sym)) |
534a450c3
|
301 |
printf(_(" (NEW)")); |
1da177e4c
|
302 303 304 |
printf(" "); } |
534a450c3
|
305 |
printf(_("%*schoice"), indent - 1, ""); |
1da177e4c
|
306 307 308 309 310 311 |
if (cnt == 1) { printf("[1]: 1 "); goto conf_childs; } printf("[1-%d", cnt); |
03d291227
|
312 |
if (menu_has_help(menu)) |
1da177e4c
|
313 314 315 |
printf("?"); printf("]: "); switch (input_mode) { |
4062f1a4c
|
316 317 |
case oldconfig: case silentoldconfig: |
1da177e4c
|
318 319 320 321 322 323 324 |
if (!is_new) { cnt = def; printf("%d ", cnt); break; } check_stdin(); |
d8fc32007
|
325 |
/* fall through */ |
4062f1a4c
|
326 |
case oldaskconfig: |
1da177e4c
|
327 |
fflush(stdout); |
74dba8091
|
328 |
xfgets(line, sizeof(line), stdin); |
1da177e4c
|
329 330 |
strip(line); if (line[0] == '?') { |
66c4bd808
|
331 |
print_help(menu); |
1da177e4c
|
332 333 334 335 336 337 338 339 340 |
continue; } if (!line[0]) cnt = def; else if (isdigit(line[0])) cnt = atoi(line); else continue; break; |
f443d2ecc
|
341 342 |
default: break; |
1da177e4c
|
343 344 345 346 347 348 349 350 351 352 353 |
} conf_childs: for (child = menu->list; child; child = child->next) { if (!child->sym || !menu_is_visible(child)) continue; if (!--cnt) break; } if (!child) continue; |
3ba416211
|
354 |
if (line[0] && line[strlen(line) - 1] == '?') { |
66c4bd808
|
355 |
print_help(child); |
1da177e4c
|
356 357 358 |
continue; } sym_set_choice_value(sym, child->sym); |
f5eaa323e
|
359 |
for (child = child->list; child; child = child->next) { |
1da177e4c
|
360 |
indent += 2; |
f5eaa323e
|
361 |
conf(child); |
1da177e4c
|
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
indent -= 2; } return 1; } } static void conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; prop = menu->prompt; if (prop) { const char *prompt; switch (prop->type) { case P_MENU: |
4062f1a4c
|
384 |
if ((input_mode == silentoldconfig || |
861b4ea4c
|
385 |
input_mode == listnewconfig || |
fb16d8912
|
386 |
input_mode == olddefconfig) && |
f0778c8c4
|
387 |
rootEntry != menu) { |
1da177e4c
|
388 389 390 |
check_conf(menu); return; } |
d8fc32007
|
391 |
/* fall through */ |
1da177e4c
|
392 393 394 395 396 397 398 399 |
case P_COMMENT: prompt = menu_get_prompt(menu); if (prompt) printf("%*c %*c %s %*c ", indent, '*', |
534a450c3
|
400 |
indent, '*', _(prompt), |
1da177e4c
|
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
indent, '*'); default: ; } } if (!sym) goto conf_childs; if (sym_is_choice(sym)) { conf_choice(menu); if (sym->curr.tri != mod) return; goto conf_childs; } switch (sym->type) { case S_INT: case S_HEX: case S_STRING: conf_string(menu); break; default: conf_sym(menu); break; } conf_childs: if (sym) indent += 2; for (child = menu->list; child; child = child->next) conf(child); if (sym) indent -= 2; } static void check_conf(struct menu *menu) { struct symbol *sym; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; |
3f23ca2b3
|
446 447 448 |
if (sym && !sym_has_value(sym)) { if (sym_is_changable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { |
861b4ea4c
|
449 450 |
if (input_mode == listnewconfig) { if (sym->name && !sym_is_choice_value(sym)) { |
ffb5957bc
|
451 452 |
printf("%s%s ", CONFIG_, sym->name); |
f0778c8c4
|
453 |
} |
fb16d8912
|
454 |
} else if (input_mode != olddefconfig) { |
f0778c8c4
|
455 456 457 458 459 460 461 462 |
if (!conf_cnt++) printf(_("* * Restart config... * ")); rootEntry = menu_get_parent_menu(menu); conf(rootEntry); } |
1da177e4c
|
463 |
} |
1da177e4c
|
464 465 466 467 468 |
} for (child = menu->list; child; child = child->next) check_conf(child); } |
4062f1a4c
|
469 470 471 472 473 |
static struct option long_opts[] = { {"oldaskconfig", no_argument, NULL, oldaskconfig}, {"oldconfig", no_argument, NULL, oldconfig}, {"silentoldconfig", no_argument, NULL, silentoldconfig}, {"defconfig", optional_argument, NULL, defconfig}, |
7cf3d73b4
|
474 |
{"savedefconfig", required_argument, NULL, savedefconfig}, |
4062f1a4c
|
475 476 477 |
{"allnoconfig", no_argument, NULL, allnoconfig}, {"allyesconfig", no_argument, NULL, allyesconfig}, {"allmodconfig", no_argument, NULL, allmodconfig}, |
0748cb3e1
|
478 |
{"alldefconfig", no_argument, NULL, alldefconfig}, |
4062f1a4c
|
479 |
{"randconfig", no_argument, NULL, randconfig}, |
861b4ea4c
|
480 |
{"listnewconfig", no_argument, NULL, listnewconfig}, |
fb16d8912
|
481 482 483 484 485 486 487 |
{"olddefconfig", no_argument, NULL, olddefconfig}, /* * oldnoconfig is an alias of olddefconfig, because people already * are dependent on its behavior(sets new symbols to their default * value but not 'n') with the counter-intuitive name. */ {"oldnoconfig", no_argument, NULL, olddefconfig}, |
4062f1a4c
|
488 489 |
{NULL, 0, NULL, 0} }; |
32543999f
|
490 491 |
static void conf_usage(const char *progname) { |
0a1f00a1c
|
492 493 |
printf("Usage: %s [-s] [option] <kconfig-file> ", progname); |
32543999f
|
494 495 496 497 498 499 500 501 502 503 |
printf("[option] is _one_ of the following: "); printf(" --listnewconfig List new options "); printf(" --oldaskconfig Start a new configuration using a line-oriented program "); printf(" --oldconfig Update a configuration using a provided .config as base "); printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps "); |
fb16d8912
|
504 505 506 507 |
printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value "); printf(" --oldnoconfig An alias of olddefconfig "); |
32543999f
|
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
printf(" --defconfig <file> New config with default defined in <file> "); printf(" --savedefconfig <file> Save the minimal current configuration to <file> "); printf(" --allnoconfig New config where all options are answered with no "); printf(" --allyesconfig New config where all options are answered with yes "); printf(" --allmodconfig New config where all options are answered with mod "); printf(" --alldefconfig New config with all symbols set to default "); printf(" --randconfig New config with random answer to all options "); } |
1da177e4c
|
523 524 |
int main(int ac, char **av) { |
32543999f
|
525 |
const char *progname = av[0]; |
2f4b489b7
|
526 |
int opt; |
275744cc8
|
527 |
const char *name, *defconfig_file = NULL /* gcc uninit */; |
1da177e4c
|
528 |
struct stat tmpstat; |
534a450c3
|
529 530 531 |
setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); |
62dc98992
|
532 |
tty_stdio = isatty(0) && isatty(1) && isatty(2); |
0a1f00a1c
|
533 534 535 536 537 |
while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { if (opt == 's') { conf_set_message_callback(NULL); continue; } |
4062f1a4c
|
538 |
input_mode = (enum input_mode)opt; |
2f4b489b7
|
539 |
switch (opt) { |
4062f1a4c
|
540 |
case silentoldconfig: |
204c96f60
|
541 |
sync_kconfig = 1; |
1da177e4c
|
542 |
break; |
4062f1a4c
|
543 |
case defconfig: |
7cf3d73b4
|
544 |
case savedefconfig: |
2f4b489b7
|
545 |
defconfig_file = optarg; |
1da177e4c
|
546 |
break; |
4062f1a4c
|
547 |
case randconfig: |
b0fe55100
|
548 549 550 |
{ struct timeval now; unsigned int seed; |
0d8024c6e
|
551 |
char *seed_env; |
b0fe55100
|
552 553 554 555 556 557 |
/* * Use microseconds derived seed, * compensate for systems where it may be zero */ gettimeofday(&now, NULL); |
b0fe55100
|
558 |
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); |
0d8024c6e
|
559 560 561 562 |
seed_env = getenv("KCONFIG_SEED"); if( seed_env && *seed_env ) { char *endp; |
e85ac1244
|
563 |
int tmp = (int)strtol(seed_env, &endp, 0); |
0d8024c6e
|
564 565 566 567 |
if (*endp == '\0') { seed = tmp; } } |
a5f6d795f
|
568 569 |
fprintf( stderr, "KCONFIG_SEED=0x%X ", seed ); |
b0fe55100
|
570 |
srand(seed); |
1da177e4c
|
571 |
break; |
b0fe55100
|
572 |
} |
32543999f
|
573 574 575 576 577 578 579 |
case oldaskconfig: case oldconfig: case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case listnewconfig: |
fb16d8912
|
580 |
case olddefconfig: |
32543999f
|
581 |
break; |
4062f1a4c
|
582 |
case '?': |
32543999f
|
583 |
conf_usage(progname); |
2f4b489b7
|
584 |
exit(1); |
4062f1a4c
|
585 |
break; |
1da177e4c
|
586 587 |
} } |
2f4b489b7
|
588 |
if (ac == optind) { |
3b9fa0931
|
589 590 |
printf(_("%s: Kconfig file missing "), av[0]); |
32543999f
|
591 |
conf_usage(progname); |
250725aa1
|
592 |
exit(1); |
1da177e4c
|
593 |
} |
2f4b489b7
|
594 |
name = av[optind]; |
1da177e4c
|
595 596 |
conf_parse(name); //zconfdump(stdout); |
204c96f60
|
597 |
if (sync_kconfig) { |
284026cdf
|
598 599 |
name = conf_get_configname(); if (stat(name, &tmpstat)) { |
204c96f60
|
600 601 |
fprintf(stderr, _("*** " |
652cf9821
|
602 603 |
"*** Configuration file \"%s\" not found! " |
204c96f60
|
604 605 606 607 608 609 |
"*** " "*** Please run some configurator (e.g. \"make oldconfig\" or " "*** \"make menuconfig\" or \"make xconfig\"). " |
284026cdf
|
610 611 |
"*** "), name); |
204c96f60
|
612 613 614 |
exit(1); } } |
1da177e4c
|
615 |
switch (input_mode) { |
4062f1a4c
|
616 |
case defconfig: |
1da177e4c
|
617 618 619 |
if (!defconfig_file) defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { |
534a450c3
|
620 621 |
printf(_("*** " |
1da177e4c
|
622 623 |
"*** Can't find default configuration \"%s\"! " |
534a450c3
|
624 625 |
"*** "), defconfig_file); |
1da177e4c
|
626 627 628 |
exit(1); } break; |
7cf3d73b4
|
629 |
case savedefconfig: |
4062f1a4c
|
630 631 632 |
case silentoldconfig: case oldaskconfig: case oldconfig: |
861b4ea4c
|
633 |
case listnewconfig: |
fb16d8912
|
634 |
case olddefconfig: |
1da177e4c
|
635 636 |
conf_read(NULL); break; |
4062f1a4c
|
637 638 639 |
case allnoconfig: case allyesconfig: case allmodconfig: |
0748cb3e1
|
640 |
case alldefconfig: |
4062f1a4c
|
641 |
case randconfig: |
90389160e
|
642 |
name = getenv("KCONFIG_ALLCONFIG"); |
9f420bf0f
|
643 644 645 |
if (!name) break; if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { |
5efe241ea
|
646 647 648 649 650 651 652 |
if (conf_read_simple(name, S_DEF_USER)) { fprintf(stderr, _("*** Can't read seed configuration \"%s\"! "), name); exit(1); } |
90389160e
|
653 654 655 |
break; } switch (input_mode) { |
4062f1a4c
|
656 657 658 |
case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; |
0748cb3e1
|
659 |
case alldefconfig: name = "alldef.config"; break; |
4062f1a4c
|
660 |
case randconfig: name = "allrandom.config"; break; |
90389160e
|
661 662 |
default: break; } |
5efe241ea
|
663 664 665 666 667 668 669 670 |
if (conf_read_simple(name, S_DEF_USER) && conf_read_simple("all.config", S_DEF_USER)) { fprintf(stderr, _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found "), name); exit(1); } |
90389160e
|
671 |
break; |
1da177e4c
|
672 673 674 |
default: break; } |
204c96f60
|
675 676 677 678 679 680 |
if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { fprintf(stderr, |
652cf9821
|
681 682 683 684 |
_(" *** The configuration requires explicit update. ")); |
204c96f60
|
685 686 687 |
return 1; } } |
62dc98992
|
688 |
valid_stdin = tty_stdio; |
204c96f60
|
689 |
} |
f443d2ecc
|
690 |
switch (input_mode) { |
4062f1a4c
|
691 |
case allnoconfig: |
f443d2ecc
|
692 693 |
conf_set_all_new_symbols(def_no); break; |
4062f1a4c
|
694 |
case allyesconfig: |
f443d2ecc
|
695 696 |
conf_set_all_new_symbols(def_yes); break; |
4062f1a4c
|
697 |
case allmodconfig: |
f443d2ecc
|
698 699 |
conf_set_all_new_symbols(def_mod); break; |
0748cb3e1
|
700 701 702 |
case alldefconfig: conf_set_all_new_symbols(def_default); break; |
4062f1a4c
|
703 |
case randconfig: |
3b9a19e08
|
704 705 |
/* Really nothing to do in this loop */ while (conf_set_all_new_symbols(def_random)) ; |
f443d2ecc
|
706 |
break; |
4062f1a4c
|
707 |
case defconfig: |
09748e178
|
708 709 |
conf_set_all_new_symbols(def_default); break; |
7cf3d73b4
|
710 711 |
case savedefconfig: break; |
4062f1a4c
|
712 |
case oldaskconfig: |
204c96f60
|
713 714 |
rootEntry = &rootmenu; conf(&rootmenu); |
4062f1a4c
|
715 |
input_mode = silentoldconfig; |
204c96f60
|
716 |
/* fall through */ |
148283497
|
717 |
case oldconfig: |
861b4ea4c
|
718 |
case listnewconfig: |
fb16d8912
|
719 |
case olddefconfig: |
4062f1a4c
|
720 |
case silentoldconfig: |
204c96f60
|
721 722 723 724 |
/* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); |
f0778c8c4
|
725 |
} while (conf_cnt && |
861b4ea4c
|
726 |
(input_mode != listnewconfig && |
fb16d8912
|
727 |
input_mode != olddefconfig)); |
f443d2ecc
|
728 729 |
break; } |
1da177e4c
|
730 |
|
204c96f60
|
731 732 733 734 735 |
if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. */ if (conf_get_changed() && conf_write(NULL)) { |
652cf9821
|
736 737 738 739 |
fprintf(stderr, _(" *** Error during writing of the configuration. ")); |
204c96f60
|
740 741 742 |
exit(1); } if (conf_write_autoconf()) { |
652cf9821
|
743 744 745 746 |
fprintf(stderr, _(" *** Error during update of the configuration. ")); |
204c96f60
|
747 748 |
return 1; } |
7cf3d73b4
|
749 750 751 752 753 |
} else if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, _("n*** Error while saving defconfig to: %s "), |
bb66fc671
|
754 |
defconfig_file); |
7cf3d73b4
|
755 756 |
return 1; } |
861b4ea4c
|
757 |
} else if (input_mode != listnewconfig) { |
204c96f60
|
758 |
if (conf_write(NULL)) { |
652cf9821
|
759 760 761 762 |
fprintf(stderr, _(" *** Error during writing of the configuration. ")); |
204c96f60
|
763 764 |
exit(1); } |
c955ccafc
|
765 |
} |
861b4ea4c
|
766 |
return 0; |
1da177e4c
|
767 |
} |
ab63f58f2
|
768 |
|
4418a2b90
|
769 770 771 |
/* * Helper function to facilitate fgets() by Jean Sacren. */ |
ab63f58f2
|
772 |
void xfgets(char *str, int size, FILE *in) |
4418a2b90
|
773 774 775 776 777 778 |
{ if (fgets(str, size, in) == NULL) fprintf(stderr, " Error in reading or end of file. "); } |