aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2010-07-31 17:35:26 -0400
committerMichal Marek <mmarek@suse.cz>2010-08-03 07:49:31 -0400
commit4062f1a4c030157216dc8932e27131975cf7253c (patch)
tree4af07e49f6c48b20a38b5eff393c5d28dbdba833 /scripts
parentac1ffde1ba053db0266f886a15ed845a6628fcb0 (diff)
kconfig: use long options in conf
The list of options supported by conf is growing and their abbreviation did not resemble anything usefull. So drop the single letter options in favour of long options. The long options are named equal to what we know from the make target. The internal implmentation was changed to match this, resulting in much more readable code. Support for short options is dropped - no one is supposed to call this program direct anyway. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/Makefile70
-rw-r--r--scripts/kconfig/conf.c161
2 files changed, 105 insertions, 126 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index f8d1ee3a372e..549e50e49cbf 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -21,53 +21,47 @@ menuconfig: $(obj)/mconf
21 $< $(Kconfig) 21 $< $(Kconfig)
22 22
23config: $(obj)/conf 23config: $(obj)/conf
24 $< $(Kconfig) 24 $< --oldaskconfig $(Kconfig)
25 25
26nconfig: $(obj)/nconf 26nconfig: $(obj)/nconf
27 $< $(Kconfig) 27 $< $(Kconfig)
28 28
29oldconfig: $(obj)/conf 29oldconfig: $(obj)/conf
30 $< -o $(Kconfig) 30 $< --$@ $(Kconfig)
31 31
32silentoldconfig: $(obj)/conf 32silentoldconfig: $(obj)/conf
33 $(Q)mkdir -p include/generated 33 $(Q)mkdir -p include/generated
34 $< -s $(Kconfig) 34 $< --$@ $(Kconfig)
35 35
36localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 36localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
37 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 37 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
38 $(Q)if [ -f .config ]; then \ 38 $(Q)if [ -f .config ]; then \
39 cmp -s .tmp.config .config || \ 39 cmp -s .tmp.config .config || \
40 (mv -f .config .config.old.1; \ 40 (mv -f .config .config.old.1; \
41 mv -f .tmp.config .config; \ 41 mv -f .tmp.config .config; \
42 $(obj)/conf -s $(Kconfig); \ 42 $(obj)/conf --silentoldconfig $(Kconfig); \
43 mv -f .config.old.1 .config.old) \ 43 mv -f .config.old.1 .config.old) \
44 else \ 44 else \
45 mv -f .tmp.config .config; \ 45 mv -f .tmp.config .config; \
46 $(obj)/conf -s $(Kconfig); \ 46 $(obj)/conf --silentoldconfig $(Kconfig); \
47 fi 47 fi
48 $(Q)rm -f .tmp.config 48 $(Q)rm -f .tmp.config
49 49
50localyesconfig: $(obj)/streamline_config.pl $(obj)/conf 50localyesconfig: $(obj)/streamline_config.pl $(obj)/conf
51 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config 51 $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config
52 $(Q)sed -i s/=m/=y/ .tmp.config 52 $(Q)sed -i s/=m/=y/ .tmp.config
53 $(Q)if [ -f .config ]; then \ 53 $(Q)if [ -f .config ]; then \
54 cmp -s .tmp.config .config || \ 54 cmp -s .tmp.config .config || \
55 (mv -f .config .config.old.1; \ 55 (mv -f .config .config.old.1; \
56 mv -f .tmp.config .config; \ 56 mv -f .tmp.config .config; \
57 $(obj)/conf -s $(Kconfig); \ 57 $(obj)/conf --silentoldconfig $(Kconfig); \
58 mv -f .config.old.1 .config.old) \ 58 mv -f .config.old.1 .config.old) \
59 else \ 59 else \
60 mv -f .tmp.config .config; \ 60 mv -f .tmp.config .config; \
61 $(obj)/conf -s $(Kconfig); \ 61 $(obj)/conf --silentoldconfig $(Kconfig); \
62 fi 62 fi
63 $(Q)rm -f .tmp.config 63 $(Q)rm -f .tmp.config
64 64
65nonint_oldconfig: $(obj)/conf
66 $< -b $(Kconfig)
67
68loose_nonint_oldconfig: $(obj)/conf
69 $< -B $(Kconfig)
70
71# Create new linux.pot file 65# Create new linux.pot file
72# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 66# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
73# The symlink is used to repair a deficiency in arch/um 67# The symlink is used to repair a deficiency in arch/um
@@ -91,30 +85,26 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
91 $(Q)rm -f arch/um/Kconfig.arch 85 $(Q)rm -f arch/um/Kconfig.arch
92 $(Q)rm -f $(obj)/config.pot 86 $(Q)rm -f $(obj)/config.pot
93 87
94PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig 88PHONY += allnoconfig allyesconfig allmodconfig randconfig
95
96randconfig: $(obj)/conf
97 $< -r $(Kconfig)
98 89
99allyesconfig: $(obj)/conf 90allnoconfig allyesconfig allmodconfig randconfig: $(obj)/conf
100 $< -y $(Kconfig) 91 $< --$@ $(Kconfig)
101 92
102allnoconfig: $(obj)/conf 93PHONY += nonint_oldconfig loose_nonint_oldconfig defconfig
103 $< -n $(Kconfig)
104 94
105allmodconfig: $(obj)/conf 95nonint_oldconfig loose_nonint_oldconfig: $(obj)/conf
106 $< -m $(Kconfig) 96 $< --$@ $(Kconfig)
107 97
108defconfig: $(obj)/conf 98defconfig: $(obj)/conf
109ifeq ($(KBUILD_DEFCONFIG),) 99ifeq ($(KBUILD_DEFCONFIG),)
110 $< -d $(Kconfig) 100 $< --defconfig $(Kconfig)
111else 101else
112 @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" 102 @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
113 $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) 103 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
114endif 104endif
115 105
116%_defconfig: $(obj)/conf 106%_defconfig: $(obj)/conf
117 $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) 107 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
118 108
119# Help text used by make help 109# Help text used by make help
120help: 110help:
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index bde01b4200ee..2dec584f1268 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
@@ -23,18 +24,19 @@
23static void conf(struct menu *menu); 24static void conf(struct menu *menu);
24static void check_conf(struct menu *menu); 25static void check_conf(struct menu *menu);
25 26
26enum { 27enum input_mode {
27 ask_all, 28 oldaskconfig,
28 ask_new, 29 silentoldconfig,
29 ask_silent, 30 oldconfig,
30 dont_ask, 31 allnoconfig,
31 dont_ask_dont_tell, 32 allyesconfig,
32 set_default, 33 allmodconfig,
33 set_yes, 34 randconfig,
34 set_mod, 35 defconfig,
35 set_no, 36 nonint_oldconfig,
36 set_random 37 loose_nonint_oldconfig,
37} input_mode = ask_all; 38} input_mode = oldaskconfig;
39
38char *defconfig_file; 40char *defconfig_file;
39 41
40static int indent = 1; 42static int indent = 1;
@@ -100,14 +102,14 @@ static int conf_askvalue(struct symbol *sym, const char *def)
100 } 102 }
101 103
102 switch (input_mode) { 104 switch (input_mode) {
103 case ask_new: 105 case oldconfig:
104 case ask_silent: 106 case silentoldconfig:
105 if (sym_has_value(sym)) { 107 if (sym_has_value(sym)) {
106 printf("%s\n", def); 108 printf("%s\n", def);
107 return 0; 109 return 0;
108 } 110 }
109 check_stdin(); 111 check_stdin();
110 case ask_all: 112 case oldaskconfig:
111 fflush(stdout); 113 fflush(stdout);
112 fgets(line, 128, stdin); 114 fgets(line, 128, stdin);
113 return 1; 115 return 1;
@@ -297,15 +299,15 @@ static int conf_choice(struct menu *menu)
297 printf("?"); 299 printf("?");
298 printf("]: "); 300 printf("]: ");
299 switch (input_mode) { 301 switch (input_mode) {
300 case ask_new: 302 case oldconfig:
301 case ask_silent: 303 case silentoldconfig:
302 if (!is_new) { 304 if (!is_new) {
303 cnt = def; 305 cnt = def;
304 printf("%d\n", cnt); 306 printf("%d\n", cnt);
305 break; 307 break;
306 } 308 }
307 check_stdin(); 309 check_stdin();
308 case ask_all: 310 case oldaskconfig:
309 fflush(stdout); 311 fflush(stdout);
310 fgets(line, 128, stdin); 312 fgets(line, 128, stdin);
311 strip(line); 313 strip(line);
@@ -363,9 +365,9 @@ static void conf(struct menu *menu)
363 365
364 switch (prop->type) { 366 switch (prop->type) {
365 case P_MENU: 367 case P_MENU:
366 if ((input_mode == ask_silent || 368 if ((input_mode == silentoldconfig ||
367 input_mode == dont_ask || 369 input_mode == nonint_oldconfig ||
368 input_mode == dont_ask_dont_tell) && 370 input_mode == loose_nonint_oldconfig) &&
369 rootEntry != menu) { 371 rootEntry != menu) {
370 check_conf(menu); 372 check_conf(menu);
371 return; 373 return;
@@ -424,9 +426,9 @@ static void check_conf(struct menu *menu)
424 if (sym && !sym_has_value(sym)) { 426 if (sym && !sym_has_value(sym)) {
425 if (sym_is_changable(sym) || 427 if (sym_is_changable(sym) ||
426 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { 428 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
427 if (input_mode == dont_ask || 429 if (input_mode == nonint_oldconfig ||
428 input_mode == dont_ask_dont_tell) { 430 input_mode == loose_nonint_oldconfig) {
429 if (input_mode == dont_ask && 431 if (input_mode == nonint_oldconfig &&
430 sym->name && !sym_is_choice_value(sym)) { 432 sym->name && !sym_is_choice_value(sym)) {
431 if (!unset_variables) 433 if (!unset_variables)
432 fprintf(stderr, "The following" 434 fprintf(stderr, "The following"
@@ -448,6 +450,20 @@ static void check_conf(struct menu *menu)
448 check_conf(child); 450 check_conf(child);
449} 451}
450 452
453static struct option long_opts[] = {
454 {"oldaskconfig", no_argument, NULL, oldaskconfig},
455 {"oldconfig", no_argument, NULL, oldconfig},
456 {"silentoldconfig", no_argument, NULL, silentoldconfig},
457 {"defconfig", optional_argument, NULL, defconfig},
458 {"allnoconfig", no_argument, NULL, allnoconfig},
459 {"allyesconfig", no_argument, NULL, allyesconfig},
460 {"allmodconfig", no_argument, NULL, allmodconfig},
461 {"randconfig", no_argument, NULL, randconfig},
462 {"nonint_oldconfig", no_argument, NULL, nonint_oldconfig},
463 {"loose_nonint_oldconfig", no_argument, NULL, loose_nonint_oldconfig},
464 {NULL, 0, NULL, 0}
465};
466
451int main(int ac, char **av) 467int main(int ac, char **av)
452{ 468{
453 int opt; 469 int opt;
@@ -458,38 +474,16 @@ int main(int ac, char **av)
458 bindtextdomain(PACKAGE, LOCALEDIR); 474 bindtextdomain(PACKAGE, LOCALEDIR);
459 textdomain(PACKAGE); 475 textdomain(PACKAGE);
460 476
461 while ((opt = getopt(ac, av, "osbBdD:nmyrh")) != -1) { 477 while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) {
478 input_mode = (enum input_mode)opt;
462 switch (opt) { 479 switch (opt) {
463 case 'o': 480 case silentoldconfig:
464 input_mode = ask_silent;
465 break;
466 case 's':
467 input_mode = ask_silent;
468 sync_kconfig = 1; 481 sync_kconfig = 1;
469 break; 482 break;
470 case 'b': 483 case defconfig:
471 input_mode = dont_ask;
472 break;
473 case 'B':
474 input_mode = dont_ask_dont_tell;
475 break;
476 case 'd':
477 input_mode = set_default;
478 break;
479 case 'D':
480 input_mode = set_default;
481 defconfig_file = optarg; 484 defconfig_file = optarg;
482 break; 485 break;
483 case 'n': 486 case randconfig:
484 input_mode = set_no;
485 break;
486 case 'm':
487 input_mode = set_mod;
488 break;
489 case 'y':
490 input_mode = set_yes;
491 break;
492 case 'r':
493 { 487 {
494 struct timeval now; 488 struct timeval now;
495 unsigned int seed; 489 unsigned int seed;
@@ -502,17 +496,12 @@ int main(int ac, char **av)
502 496
503 seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); 497 seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
504 srand(seed); 498 srand(seed);
505
506 input_mode = set_random;
507 break; 499 break;
508 } 500 }
509 case 'h': 501 case '?':
510 printf(_("See README for usage info\n"));
511 exit(0);
512 break;
513 default:
514 fprintf(stderr, _("See README for usage info\n")); 502 fprintf(stderr, _("See README for usage info\n"));
515 exit(1); 503 exit(1);
504 break;
516 } 505 }
517 } 506 }
518 if (ac == optind) { 507 if (ac == optind) {
@@ -537,7 +526,7 @@ int main(int ac, char **av)
537 } 526 }
538 527
539 switch (input_mode) { 528 switch (input_mode) {
540 case set_default: 529 case defconfig:
541 if (!defconfig_file) 530 if (!defconfig_file)
542 defconfig_file = conf_get_default_confname(); 531 defconfig_file = conf_get_default_confname();
543 if (conf_read(defconfig_file)) { 532 if (conf_read(defconfig_file)) {
@@ -547,27 +536,27 @@ int main(int ac, char **av)
547 exit(1); 536 exit(1);
548 } 537 }
549 break; 538 break;
550 case ask_silent: 539 case silentoldconfig:
551 case ask_all: 540 case oldaskconfig:
552 case ask_new: 541 case oldconfig:
553 case dont_ask: 542 case nonint_oldconfig:
554 case dont_ask_dont_tell: 543 case loose_nonint_oldconfig:
555 conf_read(NULL); 544 conf_read(NULL);
556 break; 545 break;
557 case set_no: 546 case allnoconfig:
558 case set_mod: 547 case allyesconfig:
559 case set_yes: 548 case allmodconfig:
560 case set_random: 549 case randconfig:
561 name = getenv("KCONFIG_ALLCONFIG"); 550 name = getenv("KCONFIG_ALLCONFIG");
562 if (name && !stat(name, &tmpstat)) { 551 if (name && !stat(name, &tmpstat)) {
563 conf_read_simple(name, S_DEF_USER); 552 conf_read_simple(name, S_DEF_USER);
564 break; 553 break;
565 } 554 }
566 switch (input_mode) { 555 switch (input_mode) {
567 case set_no: name = "allno.config"; break; 556 case allnoconfig: name = "allno.config"; break;
568 case set_mod: name = "allmod.config"; break; 557 case allyesconfig: name = "allyes.config"; break;
569 case set_yes: name = "allyes.config"; break; 558 case allmodconfig: name = "allmod.config"; break;
570 case set_random: name = "allrandom.config"; break; 559 case randconfig: name = "allrandom.config"; break;
571 default: break; 560 default: break;
572 } 561 }
573 if (!stat(name, &tmpstat)) 562 if (!stat(name, &tmpstat))
@@ -592,37 +581,37 @@ int main(int ac, char **av)
592 } 581 }
593 582
594 switch (input_mode) { 583 switch (input_mode) {
595 case set_no: 584 case allnoconfig:
596 conf_set_all_new_symbols(def_no); 585 conf_set_all_new_symbols(def_no);
597 break; 586 break;
598 case set_yes: 587 case allyesconfig:
599 conf_set_all_new_symbols(def_yes); 588 conf_set_all_new_symbols(def_yes);
600 break; 589 break;
601 case set_mod: 590 case allmodconfig:
602 conf_set_all_new_symbols(def_mod); 591 conf_set_all_new_symbols(def_mod);
603 break; 592 break;
604 case set_random: 593 case randconfig:
605 conf_set_all_new_symbols(def_random); 594 conf_set_all_new_symbols(def_random);
606 break; 595 break;
607 case set_default: 596 case defconfig:
608 conf_set_all_new_symbols(def_default); 597 conf_set_all_new_symbols(def_default);
609 break; 598 break;
610 case ask_new: 599 case oldconfig:
611 case ask_all: 600 case oldaskconfig:
612 rootEntry = &rootmenu; 601 rootEntry = &rootmenu;
613 conf(&rootmenu); 602 conf(&rootmenu);
614 input_mode = ask_silent; 603 input_mode = silentoldconfig;
615 /* fall through */ 604 /* fall through */
616 case dont_ask: 605 case nonint_oldconfig:
617 case dont_ask_dont_tell: 606 case loose_nonint_oldconfig:
618 case ask_silent: 607 case silentoldconfig:
619 /* Update until a loop caused no more changes */ 608 /* Update until a loop caused no more changes */
620 do { 609 do {
621 conf_cnt = 0; 610 conf_cnt = 0;
622 check_conf(&rootmenu); 611 check_conf(&rootmenu);
623 } while (conf_cnt && 612 } while (conf_cnt &&
624 (input_mode != dont_ask && 613 (input_mode != nonint_oldconfig &&
625 input_mode != dont_ask_dont_tell)); 614 input_mode != loose_nonint_oldconfig));
626 break; 615 break;
627 } 616 }
628 617
@@ -638,7 +627,7 @@ int main(int ac, char **av)
638 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); 627 fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n"));
639 return 1; 628 return 1;
640 } 629 }
641 } else if (!unset_variables || input_mode != dont_ask) { 630 } else if (!unset_variables || input_mode != nonint_oldconfig) {
642 if (conf_write(NULL)) { 631 if (conf_write(NULL)) {
643 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 632 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
644 exit(1); 633 exit(1);