diff options
Diffstat (limited to 'scripts/kconfig/conf.c')
| -rw-r--r-- | scripts/kconfig/conf.c | 181 |
1 files changed, 105 insertions, 76 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9960d1c303f8..010600ef58c0 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <string.h> | 10 | #include <string.h> |
| 11 | #include <time.h> | 11 | #include <time.h> |
| 12 | #include <unistd.h> | 12 | #include <unistd.h> |
| 13 | #include <getopt.h> | ||
| 13 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
| 14 | #include <sys/time.h> | 15 | #include <sys/time.h> |
| 15 | 16 | ||
| @@ -19,16 +20,21 @@ | |||
| 19 | static void conf(struct menu *menu); | 20 | static void conf(struct menu *menu); |
| 20 | static void check_conf(struct menu *menu); | 21 | static void check_conf(struct menu *menu); |
| 21 | 22 | ||
| 22 | enum { | 23 | enum input_mode { |
| 23 | ask_all, | 24 | oldaskconfig, |
| 24 | ask_new, | 25 | silentoldconfig, |
| 25 | ask_silent, | 26 | oldconfig, |
| 26 | set_default, | 27 | allnoconfig, |
| 27 | set_yes, | 28 | allyesconfig, |
| 28 | set_mod, | 29 | allmodconfig, |
| 29 | set_no, | 30 | alldefconfig, |
| 30 | set_random | 31 | randconfig, |
| 31 | } input_mode = ask_all; | 32 | defconfig, |
| 33 | savedefconfig, | ||
| 34 | listnewconfig, | ||
| 35 | oldnoconfig, | ||
| 36 | } input_mode = oldaskconfig; | ||
| 37 | |||
| 32 | char *defconfig_file; | 38 | char *defconfig_file; |
| 33 | 39 | ||
| 34 | static int indent = 1; | 40 | static int indent = 1; |
| @@ -93,14 +99,14 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
| 93 | } | 99 | } |
| 94 | 100 | ||
| 95 | switch (input_mode) { | 101 | switch (input_mode) { |
| 96 | case ask_new: | 102 | case oldconfig: |
| 97 | case ask_silent: | 103 | case silentoldconfig: |
| 98 | if (sym_has_value(sym)) { | 104 | if (sym_has_value(sym)) { |
| 99 | printf("%s\n", def); | 105 | printf("%s\n", def); |
| 100 | return 0; | 106 | return 0; |
| 101 | } | 107 | } |
| 102 | check_stdin(); | 108 | check_stdin(); |
| 103 | case ask_all: | 109 | case oldaskconfig: |
| 104 | fflush(stdout); | 110 | fflush(stdout); |
| 105 | fgets(line, 128, stdin); | 111 | fgets(line, 128, stdin); |
| 106 | return 1; | 112 | return 1; |
| @@ -156,14 +162,12 @@ static int conf_string(struct menu *menu) | |||
| 156 | static int conf_sym(struct menu *menu) | 162 | static int conf_sym(struct menu *menu) |
| 157 | { | 163 | { |
| 158 | struct symbol *sym = menu->sym; | 164 | struct symbol *sym = menu->sym; |
| 159 | int type; | ||
| 160 | tristate oldval, newval; | 165 | tristate oldval, newval; |
| 161 | 166 | ||
| 162 | while (1) { | 167 | while (1) { |
| 163 | printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); | 168 | printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
| 164 | if (sym->name) | 169 | if (sym->name) |
| 165 | printf("(%s) ", sym->name); | 170 | printf("(%s) ", sym->name); |
| 166 | type = sym_get_type(sym); | ||
| 167 | putchar('['); | 171 | putchar('['); |
| 168 | oldval = sym_get_tristate_value(sym); | 172 | oldval = sym_get_tristate_value(sym); |
| 169 | switch (oldval) { | 173 | switch (oldval) { |
| @@ -228,11 +232,9 @@ static int conf_choice(struct menu *menu) | |||
| 228 | { | 232 | { |
| 229 | struct symbol *sym, *def_sym; | 233 | struct symbol *sym, *def_sym; |
| 230 | struct menu *child; | 234 | struct menu *child; |
| 231 | int type; | ||
| 232 | bool is_new; | 235 | bool is_new; |
| 233 | 236 | ||
| 234 | sym = menu->sym; | 237 | sym = menu->sym; |
| 235 | type = sym_get_type(sym); | ||
| 236 | is_new = !sym_has_value(sym); | 238 | is_new = !sym_has_value(sym); |
| 237 | if (sym_is_changable(sym)) { | 239 | if (sym_is_changable(sym)) { |
| 238 | conf_sym(menu); | 240 | conf_sym(menu); |
| @@ -294,15 +296,15 @@ static int conf_choice(struct menu *menu) | |||
| 294 | printf("?"); | 296 | printf("?"); |
| 295 | printf("]: "); | 297 | printf("]: "); |
| 296 | switch (input_mode) { | 298 | switch (input_mode) { |
| 297 | case ask_new: | 299 | case oldconfig: |
| 298 | case ask_silent: | 300 | case silentoldconfig: |
| 299 | if (!is_new) { | 301 | if (!is_new) { |
| 300 | cnt = def; | 302 | cnt = def; |
| 301 | printf("%d\n", cnt); | 303 | printf("%d\n", cnt); |
| 302 | break; | 304 | break; |
| 303 | } | 305 | } |
| 304 | check_stdin(); | 306 | check_stdin(); |
| 305 | case ask_all: | 307 | case oldaskconfig: |
| 306 | fflush(stdout); | 308 | fflush(stdout); |
| 307 | fgets(line, 128, stdin); | 309 | fgets(line, 128, stdin); |
| 308 | strip(line); | 310 | strip(line); |
| @@ -360,7 +362,10 @@ static void conf(struct menu *menu) | |||
| 360 | 362 | ||
| 361 | switch (prop->type) { | 363 | switch (prop->type) { |
| 362 | case P_MENU: | 364 | case P_MENU: |
| 363 | if (input_mode == ask_silent && rootEntry != menu) { | 365 | if ((input_mode == silentoldconfig || |
| 366 | input_mode == listnewconfig || | ||
| 367 | input_mode == oldnoconfig) && | ||
| 368 | rootEntry != menu) { | ||
| 364 | check_conf(menu); | 369 | check_conf(menu); |
| 365 | return; | 370 | return; |
| 366 | } | 371 | } |
| @@ -418,10 +423,16 @@ static void check_conf(struct menu *menu) | |||
| 418 | if (sym && !sym_has_value(sym)) { | 423 | if (sym && !sym_has_value(sym)) { |
| 419 | if (sym_is_changable(sym) || | 424 | if (sym_is_changable(sym) || |
| 420 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { | 425 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { |
| 421 | if (!conf_cnt++) | 426 | if (input_mode == listnewconfig) { |
| 422 | printf(_("*\n* Restart config...\n*\n")); | 427 | if (sym->name && !sym_is_choice_value(sym)) { |
| 423 | rootEntry = menu_get_parent_menu(menu); | 428 | printf("CONFIG_%s\n", sym->name); |
| 424 | conf(rootEntry); | 429 | } |
| 430 | } else { | ||
| 431 | if (!conf_cnt++) | ||
| 432 | printf(_("*\n* Restart config...\n*\n")); | ||
| 433 | rootEntry = menu_get_parent_menu(menu); | ||
| 434 | conf(rootEntry); | ||
| 435 | } | ||
| 425 | } | 436 | } |
| 426 | } | 437 | } |
| 427 | 438 | ||
| @@ -429,6 +440,22 @@ static void check_conf(struct menu *menu) | |||
| 429 | check_conf(child); | 440 | check_conf(child); |
| 430 | } | 441 | } |
| 431 | 442 | ||
| 443 | static struct option long_opts[] = { | ||
| 444 | {"oldaskconfig", no_argument, NULL, oldaskconfig}, | ||
| 445 | {"oldconfig", no_argument, NULL, oldconfig}, | ||
| 446 | {"silentoldconfig", no_argument, NULL, silentoldconfig}, | ||
| 447 | {"defconfig", optional_argument, NULL, defconfig}, | ||
| 448 | {"savedefconfig", required_argument, NULL, savedefconfig}, | ||
| 449 | {"allnoconfig", no_argument, NULL, allnoconfig}, | ||
| 450 | {"allyesconfig", no_argument, NULL, allyesconfig}, | ||
| 451 | {"allmodconfig", no_argument, NULL, allmodconfig}, | ||
| 452 | {"alldefconfig", no_argument, NULL, alldefconfig}, | ||
| 453 | {"randconfig", no_argument, NULL, randconfig}, | ||
| 454 | {"listnewconfig", no_argument, NULL, listnewconfig}, | ||
| 455 | {"oldnoconfig", no_argument, NULL, oldnoconfig}, | ||
| 456 | {NULL, 0, NULL, 0} | ||
| 457 | }; | ||
| 458 | |||
| 432 | int main(int ac, char **av) | 459 | int main(int ac, char **av) |
| 433 | { | 460 | { |
| 434 | int opt; | 461 | int opt; |
| @@ -439,32 +466,17 @@ int main(int ac, char **av) | |||
| 439 | bindtextdomain(PACKAGE, LOCALEDIR); | 466 | bindtextdomain(PACKAGE, LOCALEDIR); |
| 440 | textdomain(PACKAGE); | 467 | textdomain(PACKAGE); |
| 441 | 468 | ||
| 442 | while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { | 469 | while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) { |
| 470 | input_mode = (enum input_mode)opt; | ||
| 443 | switch (opt) { | 471 | switch (opt) { |
| 444 | case 'o': | 472 | case silentoldconfig: |
| 445 | input_mode = ask_silent; | ||
| 446 | break; | ||
| 447 | case 's': | ||
| 448 | input_mode = ask_silent; | ||
| 449 | sync_kconfig = 1; | 473 | sync_kconfig = 1; |
| 450 | break; | 474 | break; |
| 451 | case 'd': | 475 | case defconfig: |
| 452 | input_mode = set_default; | 476 | case savedefconfig: |
| 453 | break; | ||
| 454 | case 'D': | ||
| 455 | input_mode = set_default; | ||
| 456 | defconfig_file = optarg; | 477 | defconfig_file = optarg; |
| 457 | break; | 478 | break; |
| 458 | case 'n': | 479 | case randconfig: |
| 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': | ||
| 468 | { | 480 | { |
| 469 | struct timeval now; | 481 | struct timeval now; |
| 470 | unsigned int seed; | 482 | unsigned int seed; |
| @@ -477,17 +489,12 @@ int main(int ac, char **av) | |||
| 477 | 489 | ||
| 478 | seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); | 490 | seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); |
| 479 | srand(seed); | 491 | srand(seed); |
| 480 | |||
| 481 | input_mode = set_random; | ||
| 482 | break; | 492 | break; |
| 483 | } | 493 | } |
| 484 | case 'h': | 494 | case '?': |
| 485 | printf(_("See README for usage info\n")); | ||
| 486 | exit(0); | ||
| 487 | break; | ||
| 488 | default: | ||
| 489 | fprintf(stderr, _("See README for usage info\n")); | 495 | fprintf(stderr, _("See README for usage info\n")); |
| 490 | exit(1); | 496 | exit(1); |
| 497 | break; | ||
| 491 | } | 498 | } |
| 492 | } | 499 | } |
| 493 | if (ac == optind) { | 500 | if (ac == optind) { |
| @@ -512,7 +519,7 @@ int main(int ac, char **av) | |||
| 512 | } | 519 | } |
| 513 | 520 | ||
| 514 | switch (input_mode) { | 521 | switch (input_mode) { |
| 515 | case set_default: | 522 | case defconfig: |
| 516 | if (!defconfig_file) | 523 | if (!defconfig_file) |
| 517 | defconfig_file = conf_get_default_confname(); | 524 | defconfig_file = conf_get_default_confname(); |
| 518 | if (conf_read(defconfig_file)) { | 525 | if (conf_read(defconfig_file)) { |
| @@ -522,25 +529,32 @@ int main(int ac, char **av) | |||
| 522 | exit(1); | 529 | exit(1); |
| 523 | } | 530 | } |
| 524 | break; | 531 | break; |
| 525 | case ask_silent: | 532 | case savedefconfig: |
| 526 | case ask_all: | 533 | conf_read(NULL); |
| 527 | case ask_new: | 534 | break; |
| 535 | case silentoldconfig: | ||
| 536 | case oldaskconfig: | ||
| 537 | case oldconfig: | ||
| 538 | case listnewconfig: | ||
| 539 | case oldnoconfig: | ||
| 528 | conf_read(NULL); | 540 | conf_read(NULL); |
| 529 | break; | 541 | break; |
| 530 | case set_no: | 542 | case allnoconfig: |
| 531 | case set_mod: | 543 | case allyesconfig: |
| 532 | case set_yes: | 544 | case allmodconfig: |
| 533 | case set_random: | 545 | case alldefconfig: |
| 546 | case randconfig: | ||
| 534 | name = getenv("KCONFIG_ALLCONFIG"); | 547 | name = getenv("KCONFIG_ALLCONFIG"); |
| 535 | if (name && !stat(name, &tmpstat)) { | 548 | if (name && !stat(name, &tmpstat)) { |
| 536 | conf_read_simple(name, S_DEF_USER); | 549 | conf_read_simple(name, S_DEF_USER); |
| 537 | break; | 550 | break; |
| 538 | } | 551 | } |
| 539 | switch (input_mode) { | 552 | switch (input_mode) { |
| 540 | case set_no: name = "allno.config"; break; | 553 | case allnoconfig: name = "allno.config"; break; |
| 541 | case set_mod: name = "allmod.config"; break; | 554 | case allyesconfig: name = "allyes.config"; break; |
| 542 | case set_yes: name = "allyes.config"; break; | 555 | case allmodconfig: name = "allmod.config"; break; |
| 543 | case set_random: name = "allrandom.config"; break; | 556 | case alldefconfig: name = "alldef.config"; break; |
| 557 | case randconfig: name = "allrandom.config"; break; | ||
| 544 | default: break; | 558 | default: break; |
| 545 | } | 559 | } |
| 546 | if (!stat(name, &tmpstat)) | 560 | if (!stat(name, &tmpstat)) |
| @@ -565,33 +579,42 @@ int main(int ac, char **av) | |||
| 565 | } | 579 | } |
| 566 | 580 | ||
| 567 | switch (input_mode) { | 581 | switch (input_mode) { |
| 568 | case set_no: | 582 | case allnoconfig: |
| 569 | conf_set_all_new_symbols(def_no); | 583 | conf_set_all_new_symbols(def_no); |
| 570 | break; | 584 | break; |
| 571 | case set_yes: | 585 | case allyesconfig: |
| 572 | conf_set_all_new_symbols(def_yes); | 586 | conf_set_all_new_symbols(def_yes); |
| 573 | break; | 587 | break; |
| 574 | case set_mod: | 588 | case allmodconfig: |
| 575 | conf_set_all_new_symbols(def_mod); | 589 | conf_set_all_new_symbols(def_mod); |
| 576 | break; | 590 | break; |
| 577 | case set_random: | 591 | case alldefconfig: |
| 592 | conf_set_all_new_symbols(def_default); | ||
| 593 | break; | ||
| 594 | case randconfig: | ||
| 578 | conf_set_all_new_symbols(def_random); | 595 | conf_set_all_new_symbols(def_random); |
| 579 | break; | 596 | break; |
| 580 | case set_default: | 597 | case defconfig: |
| 581 | conf_set_all_new_symbols(def_default); | 598 | conf_set_all_new_symbols(def_default); |
| 582 | break; | 599 | break; |
| 583 | case ask_new: | 600 | case savedefconfig: |
| 584 | case ask_all: | 601 | break; |
| 602 | case oldconfig: | ||
| 603 | case oldaskconfig: | ||
| 585 | rootEntry = &rootmenu; | 604 | rootEntry = &rootmenu; |
| 586 | conf(&rootmenu); | 605 | conf(&rootmenu); |
| 587 | input_mode = ask_silent; | 606 | input_mode = silentoldconfig; |
| 588 | /* fall through */ | 607 | /* fall through */ |
| 589 | case ask_silent: | 608 | case listnewconfig: |
| 609 | case oldnoconfig: | ||
| 610 | case silentoldconfig: | ||
| 590 | /* Update until a loop caused no more changes */ | 611 | /* Update until a loop caused no more changes */ |
| 591 | do { | 612 | do { |
| 592 | conf_cnt = 0; | 613 | conf_cnt = 0; |
| 593 | check_conf(&rootmenu); | 614 | check_conf(&rootmenu); |
| 594 | } while (conf_cnt); | 615 | } while (conf_cnt && |
| 616 | (input_mode != listnewconfig && | ||
| 617 | input_mode != oldnoconfig)); | ||
| 595 | break; | 618 | break; |
| 596 | } | 619 | } |
| 597 | 620 | ||
| @@ -607,7 +630,13 @@ int main(int ac, char **av) | |||
| 607 | fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); | 630 | fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); |
| 608 | return 1; | 631 | return 1; |
| 609 | } | 632 | } |
| 610 | } else { | 633 | } else if (input_mode == savedefconfig) { |
| 634 | if (conf_write_defconfig(defconfig_file)) { | ||
| 635 | fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), | ||
| 636 | defconfig_file); | ||
| 637 | return 1; | ||
| 638 | } | ||
| 639 | } else if (input_mode != listnewconfig) { | ||
| 611 | if (conf_write(NULL)) { | 640 | if (conf_write(NULL)) { |
| 612 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); | 641 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); |
| 613 | exit(1); | 642 | exit(1); |
