1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 */ 5 6 #include <ctype.h> 7 #include <limits.h> 8 #include <stdio.h> 9 #include <stdlib.h> 10 #include <string.h> 11 #include <time.h> 12 #include <unistd.h> 13 #include <getopt.h> 14 #include <sys/time.h> 15 #include <errno.h> 16 17 #include "internal.h" 18 #include "lkc.h" 19 20 static void conf(struct menu *menu); 21 static void check_conf(struct menu *menu); 22 23 enum input_mode { 24 oldaskconfig, 25 syncconfig, 26 oldconfig, 27 allnoconfig, 28 allyesconfig, 29 allmodconfig, 30 alldefconfig, 31 randconfig, 32 defconfig, 33 savedefconfig, 34 listnewconfig, 35 helpnewconfig, 36 olddefconfig, 37 yes2modconfig, 38 mod2yesconfig, 39 mod2noconfig, 40 }; 41 static enum input_mode input_mode = oldaskconfig; 42 static int input_mode_opt; 43 static int indent = 1; 44 static int tty_stdio; 45 static int sync_kconfig; 46 static int conf_cnt; 47 static char line[PATH_MAX]; 48 static struct menu *rootEntry; 49 50 static void print_help(struct menu *menu) 51 { 52 struct gstr help = str_new(); 53 54 menu_get_ext_help(menu, &help); 55 56 printf("\n%s\n", str_get(&help)); 57 str_free(&help); 58 } 59 60 static void strip(char *str) 61 { 62 char *p = str; 63 int l; 64 65 while ((isspace(*p))) 66 p++; 67 l = strlen(p); 68 if (p != str) 69 memmove(str, p, l + 1); 70 if (!l) 71 return; 72 p = str + l - 1; 73 while ((isspace(*p))) 74 *p-- = 0; 75 } 76 77 /* Helper function to facilitate fgets() by Jean Sacren. */ 78 static void xfgets(char *str, int size, FILE *in) 79 { 80 if (!fgets(str, size, in)) 81 fprintf(stderr, "\nError in reading or end of file.\n"); 82 83 if (!tty_stdio) 84 printf("%s", str); 85 } 86 87 static void set_randconfig_seed(void) 88 { 89 unsigned int seed; 90 char *env; 91 bool seed_set = false; 92 93 env = getenv("KCONFIG_SEED"); 94 if (env && *env) { 95 char *endp; 96 97 seed = strtol(env, &endp, 0); 98 if (*endp == '\0') 99 seed_set = true; 100 } 101 102 if (!seed_set) { 103 struct timeval now; 104 105 /* 106 * Use microseconds derived seed, compensate for systems where it may 107 * be zero. 108 */ 109 gettimeofday(&now, NULL); 110 seed = (now.tv_sec + 1) * (now.tv_usec + 1); 111 } 112 113 printf("KCONFIG_SEED=0x%X\n", seed); 114 srand(seed); 115 } 116 117 /** 118 * randomize_choice_values - randomize choice block 119 * 120 * @choice: menu entry for the choice 121 */ 122 static void randomize_choice_values(struct menu *choice) 123 { 124 struct menu *menu; 125 int x; 126 int cnt = 0; 127 128 /* 129 * First, count the number of symbols to randomize. If sym_has_value() 130 * is true, it was specified by KCONFIG_ALLCONFIG. It needs to be 131 * respected. 132 */ 133 menu_for_each_sub_entry(menu, choice) { 134 struct symbol *sym = menu->sym; 135 136 if (sym && !sym_has_value(sym)) 137 cnt++; 138 } 139 140 while (cnt > 0) { 141 x = rand() % cnt; 142 143 menu_for_each_sub_entry(menu, choice) { 144 struct symbol *sym = menu->sym; 145 146 if (sym && !sym_has_value(sym)) 147 x--; 148 149 if (x < 0) { 150 sym->def[S_DEF_USER].tri = yes; 151 sym->flags |= SYMBOL_DEF_USER; 152 /* 153 * Move the selected item to the _tail_ because 154 * this needs to have a lower priority than the 155 * user input from KCONFIG_ALLCONFIG. 156 */ 157 list_move_tail(&sym->choice_link, 158 &choice->choice_members); 159 160 break; 161 } 162 } 163 cnt--; 164 } 165 } 166 167 enum conf_def_mode { 168 def_default, 169 def_yes, 170 def_mod, 171 def_no, 172 def_random 173 }; 174 175 static void conf_set_all_new_symbols(enum conf_def_mode mode) 176 { 177 struct menu *menu; 178 int cnt; 179 /* 180 * can't go as the default in switch-case below, otherwise gcc whines 181 * about -Wmaybe-uninitialized 182 */ 183 int pby = 50; /* probability of bool = y */ 184 int pty = 33; /* probability of tristate = y */ 185 int ptm = 33; /* probability of tristate = m */ 186 187 if (mode == def_random) { 188 int n, p[3]; 189 bool warned = false; 190 char *env = getenv("KCONFIG_PROBABILITY"); 191 192 n = 0; 193 while (env && *env) { 194 char *endp; 195 long tmp = strtol(env, &endp, 10); 196 197 if (!isdigit((unsigned char)*env) || 198 (*endp && *endp != ':') || 199 (*endp == ':' && (!endp[1] || n == 2))) { 200 if (!warned) { 201 fprintf(stderr, 202 "warning: KCONFIG_PROBABILITY has malformed format\n"); 203 warned = true; 204 } 205 } 206 207 if (tmp >= 0 && tmp <= 100) { 208 p[n++] = tmp; 209 } else { 210 errno = ERANGE; 211 perror("KCONFIG_PROBABILITY"); 212 exit(1); 213 } 214 env = (*endp == ':') ? endp + 1 : endp; 215 if (n >= 3) 216 break; 217 } 218 switch (n) { 219 case 1: 220 pby = p[0]; 221 ptm = pby / 2; 222 pty = pby - ptm; 223 break; 224 case 2: 225 pty = p[0]; 226 ptm = p[1]; 227 pby = pty + ptm; 228 break; 229 case 3: 230 pby = p[0]; 231 pty = p[1]; 232 ptm = p[2]; 233 break; 234 } 235 236 if (pty + ptm > 100) { 237 errno = ERANGE; 238 perror("KCONFIG_PROBABILITY"); 239 exit(1); 240 } 241 242 if (warned && getenv("KCONFIG_WERROR")) 243 exit(1); 244 } 245 246 menu_for_each_entry(menu) { 247 struct symbol *sym = menu->sym; 248 tristate val; 249 250 if (!sym || !menu->prompt || sym_has_value(sym) || 251 (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) || 252 sym_is_choice_value(sym)) 253 continue; 254 255 if (sym_is_choice(sym)) { 256 if (mode == def_random) 257 randomize_choice_values(menu); 258 continue; 259 } 260 261 switch (mode) { 262 case def_yes: 263 val = yes; 264 break; 265 case def_mod: 266 val = mod; 267 break; 268 case def_no: 269 val = no; 270 break; 271 case def_random: 272 val = no; 273 cnt = rand() % 100; 274 if (sym->type == S_TRISTATE) { 275 if (cnt < pty) 276 val = yes; 277 else if (cnt < pty + ptm) 278 val = mod; 279 } else if (cnt < pby) { 280 val = yes; 281 } 282 break; 283 default: 284 continue; 285 } 286 sym->def[S_DEF_USER].tri = val; 287 sym->flags |= SYMBOL_DEF_USER; 288 } 289 290 sym_clear_all_valid(); 291 } 292 293 static void conf_rewrite_tristates(tristate old_val, tristate new_val) 294 { 295 struct symbol *sym; 296 297 for_all_symbols(sym) { 298 if (sym_get_type(sym) == S_TRISTATE && 299 sym->def[S_DEF_USER].tri == old_val) 300 sym->def[S_DEF_USER].tri = new_val; 301 } 302 sym_clear_all_valid(); 303 } 304 305 static int conf_askvalue(struct symbol *sym, const char *def) 306 { 307 if (!sym_has_value(sym)) 308 printf("(NEW) "); 309 310 line[0] = '\n'; 311 line[1] = 0; 312 313 if (!sym_is_changeable(sym)) { 314 printf("%s\n", def ?: ""); 315 return 0; 316 } 317 318 switch (input_mode) { 319 case oldconfig: 320 case syncconfig: 321 if (sym_has_value(sym)) { 322 printf("%s\n", def ?: ""); 323 return 0; 324 } 325 /* fall through */ 326 default: 327 fflush(stdout); 328 xfgets(line, sizeof(line), stdin); 329 break; 330 } 331 332 return 1; 333 } 334 335 static int conf_string(struct menu *menu) 336 { 337 struct symbol *sym = menu->sym; 338 const char *def; 339 340 while (1) { 341 printf("%*s%s ", indent - 1, "", menu->prompt->text); 342 printf("(%s) ", sym->name); 343 def = sym_get_string_value(sym); 344 if (def) 345 printf("[%s] ", def); 346 if (!conf_askvalue(sym, def)) 347 return 0; 348 switch (line[0]) { 349 case '\n': 350 break; 351 case '?': 352 /* print help */ 353 if (line[1] == '\n') { 354 print_help(menu); 355 def = NULL; 356 break; 357 } 358 /* fall through */ 359 default: 360 line[strlen(line)-1] = 0; 361 def = line; 362 } 363 if (def && sym_set_string_value(sym, def)) 364 return 0; 365 366 /* 367 * A new int or hex symbol whose default fails validation 368 * cannot be set from an empty answer. When standard input is 369 * exhausted, as it is for a non-interactive oldconfig or 370 * syncconfig, re-asking would loop forever and grow the output 371 * until it exhausts memory. Stop with an error that names the 372 * symbol instead. String symbols accept any text, and bool and 373 * tristate symbols (conf_sym()) and choices (conf_choice()) 374 * accept the default on an empty line, so they are unaffected. 375 */ 376 if (feof(stdin)) { 377 fprintf(stderr, 378 "\nerror: no value for new symbol '%s' at end of input\n", 379 sym->name); 380 exit(1); 381 } 382 } 383 } 384 385 static int conf_sym(struct menu *menu) 386 { 387 struct symbol *sym = menu->sym; 388 tristate oldval, newval; 389 390 while (1) { 391 printf("%*s%s ", indent - 1, "", menu->prompt->text); 392 if (sym->name) 393 printf("(%s) ", sym->name); 394 putchar('['); 395 oldval = sym_get_tristate_value(sym); 396 switch (oldval) { 397 case no: 398 putchar('N'); 399 break; 400 case mod: 401 putchar('M'); 402 break; 403 case yes: 404 putchar('Y'); 405 break; 406 } 407 if (oldval != no && sym_tristate_within_range(sym, no)) 408 printf("/n"); 409 if (oldval != mod && sym_tristate_within_range(sym, mod)) 410 printf("/m"); 411 if (oldval != yes && sym_tristate_within_range(sym, yes)) 412 printf("/y"); 413 printf("/?] "); 414 if (!conf_askvalue(sym, sym_get_string_value(sym))) 415 return 0; 416 strip(line); 417 418 switch (line[0]) { 419 case 'n': 420 case 'N': 421 newval = no; 422 if (!line[1] || !strcmp(&line[1], "o")) 423 break; 424 continue; 425 case 'm': 426 case 'M': 427 newval = mod; 428 if (!line[1]) 429 break; 430 continue; 431 case 'y': 432 case 'Y': 433 newval = yes; 434 if (!line[1] || !strcmp(&line[1], "es")) 435 break; 436 continue; 437 case 0: 438 newval = oldval; 439 break; 440 case '?': 441 goto help; 442 default: 443 continue; 444 } 445 if (sym_set_tristate_value(sym, newval)) 446 return 0; 447 help: 448 print_help(menu); 449 } 450 } 451 452 static void conf_choice(struct menu *menu) 453 { 454 struct symbol *def_sym; 455 struct menu *child; 456 bool is_new = false; 457 458 while (1) { 459 int cnt, def; 460 461 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 462 def_sym = sym_calc_choice(menu); 463 cnt = def = 0; 464 line[0] = 0; 465 for (child = menu->list; child; child = child->next) { 466 if (!menu_is_visible(child)) 467 continue; 468 if (!child->sym) { 469 printf("%*c %s\n", indent, '*', menu_get_prompt(child)); 470 continue; 471 } 472 cnt++; 473 if (child->sym == def_sym) { 474 def = cnt; 475 printf("%*c", indent, '>'); 476 } else 477 printf("%*c", indent, ' '); 478 printf(" %d. %s (%s)", cnt, menu_get_prompt(child), 479 child->sym->name); 480 if (!sym_has_value(child->sym)) { 481 is_new = true; 482 printf(" (NEW)"); 483 } 484 printf("\n"); 485 } 486 /* Nothing to ask if none of the choice values is visible. */ 487 if (!cnt) 488 return; 489 printf("%*schoice", indent - 1, ""); 490 if (cnt == 1) { 491 printf("[1]: 1\n"); 492 goto conf_childs; 493 } 494 printf("[1-%d?]: ", cnt); 495 switch (input_mode) { 496 case oldconfig: 497 case syncconfig: 498 if (!is_new) { 499 cnt = def; 500 printf("%d\n", cnt); 501 break; 502 } 503 /* fall through */ 504 case oldaskconfig: 505 fflush(stdout); 506 xfgets(line, sizeof(line), stdin); 507 strip(line); 508 if (line[0] == '?') { 509 print_help(menu); 510 continue; 511 } 512 if (!line[0]) 513 cnt = def; 514 else if (isdigit(line[0])) 515 cnt = atoi(line); 516 else 517 continue; 518 break; 519 default: 520 break; 521 } 522 523 conf_childs: 524 for (child = menu->list; child; child = child->next) { 525 if (!child->sym || !menu_is_visible(child)) 526 continue; 527 if (!--cnt) 528 break; 529 } 530 if (!child) 531 continue; 532 if (line[0] && line[strlen(line) - 1] == '?') { 533 print_help(child); 534 continue; 535 } 536 choice_set_value(menu, child->sym); 537 return; 538 } 539 } 540 541 static void conf(struct menu *menu) 542 { 543 struct symbol *sym; 544 struct property *prop; 545 struct menu *child; 546 547 if (!menu_is_visible(menu)) 548 return; 549 550 sym = menu->sym; 551 prop = menu->prompt; 552 if (prop) { 553 const char *prompt; 554 555 switch (prop->type) { 556 case P_MENU: 557 /* 558 * Except in oldaskconfig mode, we show only menus that 559 * contain new symbols. 560 */ 561 if (input_mode != oldaskconfig && rootEntry != menu) { 562 check_conf(menu); 563 return; 564 } 565 /* fall through */ 566 case P_COMMENT: 567 prompt = menu_get_prompt(menu); 568 if (prompt) 569 printf("%*c\n%*c %s\n%*c\n", 570 indent, '*', 571 indent, '*', prompt, 572 indent, '*'); 573 default: 574 ; 575 } 576 } 577 578 if (!sym) 579 goto conf_childs; 580 581 if (sym_is_choice(sym)) { 582 conf_choice(menu); 583 return; 584 } 585 586 switch (sym->type) { 587 case S_INT: 588 case S_HEX: 589 case S_STRING: 590 conf_string(menu); 591 break; 592 default: 593 conf_sym(menu); 594 break; 595 } 596 597 conf_childs: 598 if (sym) 599 indent += 2; 600 for (child = menu->list; child; child = child->next) 601 conf(child); 602 if (sym) 603 indent -= 2; 604 } 605 606 static void check_conf(struct menu *menu) 607 { 608 struct symbol *sym; 609 struct menu *child; 610 611 if (!menu_is_visible(menu)) 612 return; 613 614 sym = menu->sym; 615 if (sym && !sym_has_value(sym) && sym_is_changeable(sym)) { 616 switch (input_mode) { 617 case listnewconfig: 618 if (sym->name) 619 print_symbol_for_listconfig(sym); 620 break; 621 case helpnewconfig: 622 printf("-----\n"); 623 print_help(menu); 624 printf("-----\n"); 625 break; 626 default: 627 if (!conf_cnt++) 628 printf("*\n* Restart config...\n*\n"); 629 rootEntry = menu_get_menu_or_parent_menu(menu); 630 conf(rootEntry); 631 break; 632 } 633 } 634 635 for (child = menu->list; child; child = child->next) 636 check_conf(child); 637 } 638 639 static const struct option long_opts[] = { 640 {"help", no_argument, NULL, 'h'}, 641 {"silent", no_argument, NULL, 's'}, 642 {"oldaskconfig", no_argument, &input_mode_opt, oldaskconfig}, 643 {"oldconfig", no_argument, &input_mode_opt, oldconfig}, 644 {"syncconfig", no_argument, &input_mode_opt, syncconfig}, 645 {"defconfig", required_argument, &input_mode_opt, defconfig}, 646 {"savedefconfig", required_argument, &input_mode_opt, savedefconfig}, 647 {"allnoconfig", no_argument, &input_mode_opt, allnoconfig}, 648 {"allyesconfig", no_argument, &input_mode_opt, allyesconfig}, 649 {"allmodconfig", no_argument, &input_mode_opt, allmodconfig}, 650 {"alldefconfig", no_argument, &input_mode_opt, alldefconfig}, 651 {"randconfig", no_argument, &input_mode_opt, randconfig}, 652 {"listnewconfig", no_argument, &input_mode_opt, listnewconfig}, 653 {"helpnewconfig", no_argument, &input_mode_opt, helpnewconfig}, 654 {"olddefconfig", no_argument, &input_mode_opt, olddefconfig}, 655 {"yes2modconfig", no_argument, &input_mode_opt, yes2modconfig}, 656 {"mod2yesconfig", no_argument, &input_mode_opt, mod2yesconfig}, 657 {"mod2noconfig", no_argument, &input_mode_opt, mod2noconfig}, 658 {NULL, 0, NULL, 0} 659 }; 660 661 static void conf_usage(const char *progname) 662 { 663 printf("Usage: %s [options] kconfig_file\n", progname); 664 printf("\n"); 665 printf("Generic options:\n"); 666 printf(" -h, --help Print this message and exit.\n"); 667 printf(" -s, --silent Do not print log.\n"); 668 printf("\n"); 669 printf("Mode options:\n"); 670 printf(" --listnewconfig List new options\n"); 671 printf(" --helpnewconfig List new options and help text\n"); 672 printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); 673 printf(" --oldconfig Update a configuration using a provided .config as base\n"); 674 printf(" --syncconfig Similar to oldconfig but generates configuration in\n" 675 " include/{generated/,config/}\n"); 676 printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n"); 677 printf(" --defconfig <file> New config with default defined in <file>\n"); 678 printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); 679 printf(" --allnoconfig New config where all options are answered with no\n"); 680 printf(" --allyesconfig New config where all options are answered with yes\n"); 681 printf(" --allmodconfig New config where all options are answered with mod\n"); 682 printf(" --alldefconfig New config with all symbols set to default\n"); 683 printf(" --randconfig New config with random answer to all options\n"); 684 printf(" --yes2modconfig Change answers from yes to mod if possible\n"); 685 printf(" --mod2yesconfig Change answers from mod to yes if possible\n"); 686 printf(" --mod2noconfig Change answers from mod to no if possible\n"); 687 printf(" (If none of the above is given, --oldaskconfig is the default)\n"); 688 printf("\n"); 689 printf("Arguments:\n"); 690 printf(" kconfig_file Top-level Kconfig file.\n"); 691 } 692 693 int main(int ac, char **av) 694 { 695 const char *progname = av[0]; 696 int opt; 697 const char *name, *defconfig_file = NULL /* gcc uninit */; 698 int no_conf_write = 0; 699 700 tty_stdio = isatty(0) && isatty(1); 701 702 while ((opt = getopt_long(ac, av, "hs", long_opts, NULL)) != -1) { 703 switch (opt) { 704 case 'h': 705 conf_usage(progname); 706 exit(1); 707 break; 708 case 's': 709 conf_set_message_callback(NULL); 710 break; 711 case 0: 712 input_mode = input_mode_opt; 713 switch (input_mode) { 714 case syncconfig: 715 /* 716 * syncconfig is invoked during the build stage. 717 * Suppress distracting 718 * "configuration written to ..." 719 */ 720 conf_set_message_callback(NULL); 721 sync_kconfig = 1; 722 break; 723 case defconfig: 724 case savedefconfig: 725 defconfig_file = optarg; 726 break; 727 case randconfig: 728 set_randconfig_seed(); 729 break; 730 default: 731 break; 732 } 733 default: 734 break; 735 } 736 } 737 if (ac == optind) { 738 fprintf(stderr, "%s: Kconfig file missing\n", av[0]); 739 conf_usage(progname); 740 exit(1); 741 } 742 conf_parse(av[optind]); 743 //zconfdump(stdout); 744 745 switch (input_mode) { 746 case defconfig: 747 if (conf_read(defconfig_file)) { 748 fprintf(stderr, 749 "***\n" 750 "*** Can't find default configuration \"%s\"!\n" 751 "***\n", 752 defconfig_file); 753 exit(1); 754 } 755 break; 756 case savedefconfig: 757 case syncconfig: 758 case oldaskconfig: 759 case oldconfig: 760 case listnewconfig: 761 case helpnewconfig: 762 case olddefconfig: 763 case yes2modconfig: 764 case mod2yesconfig: 765 case mod2noconfig: 766 conf_read(NULL); 767 break; 768 case allnoconfig: 769 case allyesconfig: 770 case allmodconfig: 771 case alldefconfig: 772 case randconfig: 773 name = getenv("KCONFIG_ALLCONFIG"); 774 if (!name) 775 break; 776 if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { 777 if (conf_read_simple(name, S_DEF_USER)) { 778 fprintf(stderr, 779 "*** Can't read seed configuration \"%s\"!\n", 780 name); 781 exit(1); 782 } 783 break; 784 } 785 switch (input_mode) { 786 case allnoconfig: name = "allno.config"; break; 787 case allyesconfig: name = "allyes.config"; break; 788 case allmodconfig: name = "allmod.config"; break; 789 case alldefconfig: name = "alldef.config"; break; 790 case randconfig: name = "allrandom.config"; break; 791 default: break; 792 } 793 if (conf_read_simple(name, S_DEF_USER) && 794 conf_read_simple("all.config", S_DEF_USER)) { 795 fprintf(stderr, 796 "*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n", 797 name); 798 exit(1); 799 } 800 break; 801 default: 802 break; 803 } 804 805 if (conf_errors()) 806 exit(1); 807 808 if (sync_kconfig) { 809 name = getenv("KCONFIG_NOSILENTUPDATE"); 810 if (name && *name) { 811 if (conf_get_changed()) { 812 fprintf(stderr, 813 "\n*** The configuration requires explicit update.\n\n"); 814 return 1; 815 } 816 no_conf_write = 1; 817 } 818 } 819 820 switch (input_mode) { 821 case allnoconfig: 822 conf_set_all_new_symbols(def_no); 823 break; 824 case allyesconfig: 825 conf_set_all_new_symbols(def_yes); 826 break; 827 case allmodconfig: 828 conf_set_all_new_symbols(def_mod); 829 break; 830 case alldefconfig: 831 conf_set_all_new_symbols(def_default); 832 break; 833 case randconfig: 834 conf_set_all_new_symbols(def_random); 835 break; 836 case defconfig: 837 conf_set_all_new_symbols(def_default); 838 break; 839 case savedefconfig: 840 break; 841 case yes2modconfig: 842 conf_rewrite_tristates(yes, mod); 843 break; 844 case mod2yesconfig: 845 conf_rewrite_tristates(mod, yes); 846 break; 847 case mod2noconfig: 848 conf_rewrite_tristates(mod, no); 849 break; 850 case oldaskconfig: 851 rootEntry = &rootmenu; 852 conf(&rootmenu); 853 input_mode = oldconfig; 854 /* fall through */ 855 case oldconfig: 856 case listnewconfig: 857 case helpnewconfig: 858 case syncconfig: 859 /* Update until a loop caused no more changes */ 860 do { 861 conf_cnt = 0; 862 check_conf(&rootmenu); 863 } while (conf_cnt); 864 break; 865 case olddefconfig: 866 default: 867 break; 868 } 869 870 if (sym_dep_errors()) 871 exit(1); 872 873 if (input_mode == savedefconfig) { 874 if (conf_write_defconfig(defconfig_file)) { 875 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", 876 defconfig_file); 877 return 1; 878 } 879 } else if (input_mode != listnewconfig && input_mode != helpnewconfig) { 880 if (!no_conf_write && conf_write(NULL)) { 881 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); 882 exit(1); 883 } 884 885 /* 886 * Create auto.conf if it does not exist. 887 * This prevents GNU Make 4.1 or older from emitting 888 * "include/config/auto.conf: No such file or directory" 889 * in the top-level Makefile 890 * 891 * syncconfig always creates or updates auto.conf because it is 892 * used during the build. 893 */ 894 if (conf_write_autoconf(sync_kconfig) && sync_kconfig) { 895 fprintf(stderr, 896 "\n*** Error during sync of the configuration.\n\n"); 897 return 1; 898 } 899 } 900 return 0; 901 } 902