20 static void check_conf(
struct menu *
menu);
21 static void xfgets(
char *
str,
int size, FILE *
in);
38 static int indent = 1;
39 static int valid_stdin = 1;
40 static int sync_kconfig;
42 static char line[128];
43 static struct menu *rootEntry;
72 static void check_stdin(
void)
76 printf(
_(
"Console input/output is redirected. "));
77 printf(
_(
"Run 'make oldconfig' to update configuration.\n\n"));
82 static int conf_askvalue(
struct symbol *sym,
const char *def)
86 if (!sym_has_value(sym))
102 if (sym_has_value(sym)) {
110 xfgets(
line, 128, stdin);
129 static int conf_string(
struct menu *
menu)
140 if (!conf_askvalue(sym, def))
147 if (
line[1] ==
'\n') {
162 static int conf_sym(
struct menu *menu)
172 oldval = sym_get_tristate_value(sym);
231 static int conf_choice(
struct menu *menu)
233 struct symbol *sym, *def_sym;
238 is_new = !sym_has_value(sym);
242 switch (sym_get_tristate_value(sym)) {
251 switch (sym_get_tristate_value(sym)) {
266 def_sym = sym_get_choice_value(sym);
269 for (child = menu->
list; child; child = child->
next) {
277 if (child->
sym == def_sym) {
279 printf(
"%*c", indent,
'>');
281 printf(
"%*c", indent,
' ');
283 if (child->
sym->name)
285 if (!sym_has_value(child->
sym))
289 printf(
_(
"%*schoice"), indent - 1,
"");
310 xfgets(
line, 128, stdin);
312 if (
line[0] ==
'?') {
328 for (child = menu->
list; child; child = child->
next) {
340 sym_set_choice_value(sym, child->
sym);
341 for (child = child->
list; child; child = child->
next) {
350 static void conf(
struct menu *menu)
364 switch (prop->
type) {
377 printf(
"%*c\n%*c %s\n%*c\n",
379 indent,
'*',
_(prompt),
389 if (sym_is_choice(sym)) {
410 for (child = menu->
list; child; child = child->
next)
416 static void check_conf(
struct menu *menu)
425 if (sym && !sym_has_value(sym)) {
427 (sym_is_choice(sym) && sym_get_tristate_value(sym) ==
yes)) {
429 if (sym->
name && !sym_is_choice_value(sym)) {
434 printf(
_(
"*\n* Restart config...\n*\n"));
441 for (child = menu->
list; child; child = child->
next)
445 static struct option long_opts[] = {
467 static void conf_usage(
const char *progname)
470 printf(
"Usage: %s [option] <kconfig-file>\n", progname);
471 printf(
"[option] is _one_ of the following:\n");
472 printf(
" --listnewconfig List new options\n");
473 printf(
" --oldaskconfig Start a new configuration using a line-oriented program\n");
474 printf(
" --oldconfig Update a configuration using a provided .config as base\n");
475 printf(
" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
476 printf(
" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
477 printf(
" --oldnoconfig An alias of olddefconfig\n");
478 printf(
" --defconfig <file> New config with default defined in <file>\n");
479 printf(
" --savedefconfig <file> Save the minimal current configuration to <file>\n");
480 printf(
" --allnoconfig New config where all options are answered with no\n");
481 printf(
" --allyesconfig New config where all options are answered with yes\n");
482 printf(
" --allmodconfig New config where all options are answered with mod\n");
483 printf(
" --alldefconfig New config with all symbols set to default\n");
484 printf(
" --randconfig New config with random answer to all options\n");
491 const char *
name, *defconfig_file =
NULL ;
494 setlocale(LC_ALL,
"");
498 while ((opt = getopt_long(ac, av,
"", long_opts,
NULL)) != -1) {
506 defconfig_file = optarg;
533 conf_usage(progname);
539 printf(
_(
"%s: Kconfig file missing\n"), av[0]);
540 conf_usage(progname);
548 if (
stat(name, &tmpstat)) {
550 "*** Configuration file \"%s\" not found!\n"
552 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
553 "*** \"make menuconfig\" or \"make xconfig\").\n"
565 "*** Can't find default configuration \"%s\"!\n"
566 "***\n"), defconfig_file);
583 name = getenv(
"KCONFIG_ALLCONFIG");
586 if ((
strcmp(name,
"") != 0) && (
strcmp(name,
"1") != 0)) {
589 _(
"*** Can't read seed configuration \"%s\"!\n"),
600 case randconfig: name =
"allrandom.config";
break;
606 _(
"*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
617 name = getenv(
"KCONFIG_NOSILENTUPDATE");
620 _(
"\n*** The configuration requires explicit update.\n\n"));
624 valid_stdin = isatty(0) && isatty(1) && isatty(2);
672 fprintf(stderr,
_(
"\n*** Error during writing of the configuration.\n\n"));
676 fprintf(stderr,
_(
"\n*** Error during update of the configuration.\n\n"));
681 fprintf(stderr,
_(
"n*** Error while saving defconfig to: %s\n\n"),
687 fprintf(stderr,
_(
"\n*** Error during writing of the configuration.\n\n"));
697 void xfgets(
char *str,
int size, FILE *
in)
699 if (fgets(str, size, in) ==
NULL)
700 fprintf(stderr,
"\nError in reading or end of file.\n");