-rw-r--r-- | scripts/kconfig/mconf.c | 101 |
1 files changed, 85 insertions, 16 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index dec8603..eba5ff7 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -1,18 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | * | ||
5 | * Introduced single menu mode (show all sub-menus in one large tree). | ||
6 | * 2002-11-06 Petr Baudis <pasky@ucw.cz> | ||
4 | */ | 7 | */ |
5 | 8 | ||
6 | #include <sys/ioctl.h> | 9 | #include <sys/ioctl.h> |
7 | #include <sys/wait.h> | 10 | #include <sys/wait.h> |
8 | #include <ctype.h> | 11 | #include <ctype.h> |
9 | #include <errno.h> | 12 | #include <errno.h> |
10 | #include <fcntl.h> | 13 | #include <fcntl.h> |
14 | #include <limits.h> | ||
11 | #include <signal.h> | 15 | #include <signal.h> |
12 | #include <stdarg.h> | 16 | #include <stdarg.h> |
13 | #include <stdlib.h> | 17 | #include <stdlib.h> |
14 | #include <string.h> | 18 | #include <string.h> |
19 | #include <termios.h> | ||
15 | #include <unistd.h> | 20 | #include <unistd.h> |
16 | 21 | ||
17 | #define LKC_DIRECT_LINK | 22 | #define LKC_DIRECT_LINK |
18 | #include "lkc.h" | 23 | #include "lkc.h" |
@@ -43,20 +48,20 @@ inputbox_instructions_string[] = | |||
43 | setmod_text[] = | 48 | setmod_text[] = |
44 | "This feature depends on another which has been configured as a module.\n" | 49 | "This feature depends on another which has been configured as a module.\n" |
45 | "As a result, this feature will be built as a module.", | 50 | "As a result, this feature will be built as a module.", |
46 | nohelp_text[] = | 51 | nohelp_text[] = |
47 | "There is no help available for this option.\n", | 52 | "There is no help available for this kernel option.\n", |
48 | load_config_text[] = | 53 | load_config_text[] = |
49 | "Enter the name of the configuration file you wish to load. " | 54 | "Enter the name of the configuration file you wish to load. " |
50 | "Accept the name shown to restore the configuration you " | 55 | "Accept the name shown to restore the configuration you " |
51 | "last retrieved. Leave blank to abort.", | 56 | "last retrieved. Leave blank to abort.", |
52 | load_config_help[] = | 57 | load_config_help[] = |
53 | "\n" | 58 | "\n" |
54 | "For various reasons, one may wish to keep several different\n" | 59 | "For various reasons, one may wish to keep several different kernel\n" |
55 | "configurations available on a single machine.\n" | 60 | "configurations available on a single machine.\n" |
56 | "\n" | 61 | "\n" |
57 | "If you have saved a previous configuration in a file other than the\n" | 62 | "If you have saved a previous configuration in a file other than the\n" |
58 | "default, entering the name of the file here will allow you\n" | 63 | "kernel's default, entering the name of the file here will allow you\n" |
59 | "to modify that configuration.\n" | 64 | "to modify that configuration.\n" |
60 | "\n" | 65 | "\n" |
61 | "If you are uncertain, then you have probably never used alternate\n" | 66 | "If you are uncertain, then you have probably never used alternate\n" |
62 | "configuration files. You should therefor leave this blank to abort.\n", | 67 | "configuration files. You should therefor leave this blank to abort.\n", |
@@ -64,9 +69,9 @@ save_config_text[] = | |||
64 | "Enter a filename to which this configuration should be saved " | 69 | "Enter a filename to which this configuration should be saved " |
65 | "as an alternate. Leave blank to abort.", | 70 | "as an alternate. Leave blank to abort.", |
66 | save_config_help[] = | 71 | save_config_help[] = |
67 | "\n" | 72 | "\n" |
68 | "For various reasons, one may wish to keep different\n" | 73 | "For various reasons, one may wish to keep different kernel\n" |
69 | "configurations available on a single machine.\n" | 74 | "configurations available on a single machine.\n" |
70 | "\n" | 75 | "\n" |
71 | "Entering a file name here will allow you to later retrieve, modify\n" | 76 | "Entering a file name here will allow you to later retrieve, modify\n" |
72 | "and use the current configuration as an alternate to whatever\n" | 77 | "and use the current configuration as an alternate to whatever\n" |
@@ -77,14 +82,17 @@ save_config_help[] = | |||
77 | ; | 82 | ; |
78 | 83 | ||
79 | static char buf[4096], *bufptr = buf; | 84 | static char buf[4096], *bufptr = buf; |
80 | static char input_buf[4096]; | 85 | static char input_buf[4096]; |
86 | static char filename[PATH_MAX+1] = ".config"; | ||
81 | static char *args[1024], **argptr = args; | 87 | static char *args[1024], **argptr = args; |
82 | static int indent = 0; | 88 | static int indent = 0; |
89 | static struct termios ios_org; | ||
83 | static int rows, cols; | 90 | static int rows, cols; |
84 | static struct menu *current_menu; | 91 | static struct menu *current_menu; |
85 | static int child_count; | 92 | static int child_count; |
86 | static int do_resize; | 93 | static int do_resize; |
94 | static int single_menu_mode; | ||
87 | 95 | ||
88 | static void conf(struct menu *menu); | 96 | static void conf(struct menu *menu); |
89 | static void conf_choice(struct menu *menu); | 97 | static void conf_choice(struct menu *menu); |
90 | static void conf_string(struct menu *menu); | 98 | static void conf_string(struct menu *menu); |
@@ -102,15 +110,30 @@ static int cprint(const char *fmt, ...); | |||
102 | 110 | ||
103 | static void init_wsize(void) | 111 | static void init_wsize(void) |
104 | { | 112 | { |
105 | struct winsize ws; | 113 | struct winsize ws; |
114 | char *env; | ||
106 | 115 | ||
107 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | 116 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { |
108 | rows = 24; | 117 | rows = 24; |
109 | cols = 80; | 118 | cols = 80; |
110 | } else { | 119 | } else { |
111 | rows = ws.ws_row; | 120 | rows = ws.ws_row; |
112 | cols = ws.ws_col; | 121 | cols = ws.ws_col; |
122 | if (!rows) { | ||
123 | env = getenv("LINES"); | ||
124 | if (env) | ||
125 | rows = atoi(env); | ||
126 | if (!rows) | ||
127 | rows = 24; | ||
128 | } | ||
129 | if (!cols) { | ||
130 | env = getenv("COLUMNS"); | ||
131 | if (env) | ||
132 | cols = atoi(env); | ||
133 | if (!cols) | ||
134 | cols = 80; | ||
135 | } | ||
113 | } | 136 | } |
114 | 137 | ||
115 | if (rows < 19 || cols < 80) { | 138 | if (rows < 19 || cols < 80) { |
116 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); | 139 | fprintf(stderr, "Your display is too small to run Menuconfig!\n"); |
@@ -273,12 +296,22 @@ static void build_conf(struct menu *menu) | |||
273 | switch (prop->type) { | 296 | switch (prop->type) { |
274 | case P_MENU: | 297 | case P_MENU: |
275 | child_count++; | 298 | child_count++; |
276 | cprint("m%p", menu); | 299 | cprint("m%p", menu); |
277 | if (menu->parent != &rootmenu) | 300 | |
278 | cprint1(" %*c", indent + 1, ' '); | 301 | if (single_menu_mode) { |
279 | cprint1("%s --->", prompt); | 302 | cprint1("%s%*c%s", |
303 | menu->data ? "-->" : "++>", | ||
304 | indent + 1, ' ', prompt); | ||
305 | } else { | ||
306 | if (menu->parent != &rootmenu) | ||
307 | cprint1(" %*c", indent + 1, ' '); | ||
308 | cprint1("%s --->", prompt); | ||
309 | } | ||
310 | |||
280 | cprint_done(); | 311 | cprint_done(); |
312 | if (single_menu_mode && menu->data) | ||
313 | goto conf_childs; | ||
281 | return; | 314 | return; |
282 | default: | 315 | default: |
283 | if (prompt) { | 316 | if (prompt) { |
284 | child_count++; | 317 | child_count++; |
@@ -391,8 +424,9 @@ static void conf(struct menu *menu) | |||
391 | struct symbol *sym; | 424 | struct symbol *sym; |
392 | char active_entry[40]; | 425 | char active_entry[40]; |
393 | int stat, type, i; | 426 | int stat, type, i; |
394 | 427 | ||
428 | unlink("lxdialog.scrltmp"); | ||
395 | active_entry[0] = 0; | 429 | active_entry[0] = 0; |
396 | while (1) { | 430 | while (1) { |
397 | cprint_init(); | 431 | cprint_init(); |
398 | cprint("--title"); | 432 | cprint("--title"); |
@@ -441,9 +475,12 @@ static void conf(struct menu *menu) | |||
441 | switch (stat) { | 475 | switch (stat) { |
442 | case 0: | 476 | case 0: |
443 | switch (type) { | 477 | switch (type) { |
444 | case 'm': | 478 | case 'm': |
445 | conf(submenu); | 479 | if (single_menu_mode) |
480 | submenu->data = (void *) !submenu->data; | ||
481 | else | ||
482 | conf(submenu); | ||
446 | break; | 483 | break; |
447 | case 't': | 484 | case 't': |
448 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) | 485 | if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) |
449 | conf_choice(submenu); | 486 | conf_choice(submenu); |
@@ -483,8 +520,10 @@ static void conf(struct menu *menu) | |||
483 | break; | 520 | break; |
484 | case 6: | 521 | case 6: |
485 | if (type == 't') | 522 | if (type == 't') |
486 | sym_toggle_tristate_value(sym); | 523 | sym_toggle_tristate_value(sym); |
524 | else if (type == 'm') | ||
525 | conf(submenu); | ||
487 | break; | 526 | break; |
488 | } | 527 | } |
489 | } | 528 | } |
490 | } | 529 | } |
@@ -517,13 +556,21 @@ static void show_helptext(const char *title, const char *text) | |||
517 | 556 | ||
518 | static void show_help(struct menu *menu) | 557 | static void show_help(struct menu *menu) |
519 | { | 558 | { |
520 | const char *help; | 559 | const char *help; |
560 | char *helptext; | ||
561 | struct symbol *sym = menu->sym; | ||
521 | 562 | ||
522 | help = menu->sym->help; | 563 | help = sym->help; |
523 | if (!help) | 564 | if (!help) |
524 | help = nohelp_text; | 565 | help = nohelp_text; |
525 | show_helptext(menu_get_prompt(menu), help); | 566 | if (sym->name) { |
567 | helptext = malloc(strlen(sym->name) + strlen(help) + 16); | ||
568 | sprintf(helptext, "CONFIG_%s:\n\n%s", sym->name, help); | ||
569 | show_helptext(menu_get_prompt(menu), helptext); | ||
570 | free(helptext); | ||
571 | } else | ||
572 | show_helptext(menu_get_prompt(menu), help); | ||
526 | } | 573 | } |
527 | 574 | ||
528 | static void show_readme(void) | 575 | static void show_readme(void) |
529 | { | 576 | { |
@@ -630,9 +677,9 @@ static void conf_load(void) | |||
630 | cprint("--inputbox"); | 677 | cprint("--inputbox"); |
631 | cprint(load_config_text); | 678 | cprint(load_config_text); |
632 | cprint("11"); | 679 | cprint("11"); |
633 | cprint("55"); | 680 | cprint("55"); |
634 | cprint("%s", conf_filename); | 681 | cprint("%s", filename); |
635 | stat = exec_conf(); | 682 | stat = exec_conf(); |
636 | switch(stat) { | 683 | switch(stat) { |
637 | case 0: | 684 | case 0: |
638 | if (!input_buf[0]) | 685 | if (!input_buf[0]) |
@@ -659,9 +706,9 @@ static void conf_save(void) | |||
659 | cprint("--inputbox"); | 706 | cprint("--inputbox"); |
660 | cprint(save_config_text); | 707 | cprint(save_config_text); |
661 | cprint("11"); | 708 | cprint("11"); |
662 | cprint("55"); | 709 | cprint("55"); |
663 | cprint("%s", conf_filename); | 710 | cprint("%s", filename); |
664 | stat = exec_conf(); | 711 | stat = exec_conf(); |
665 | switch(stat) { | 712 | switch(stat) { |
666 | case 0: | 713 | case 0: |
667 | if (!input_buf[0]) | 714 | if (!input_buf[0]) |
@@ -678,16 +725,37 @@ static void conf_save(void) | |||
678 | } | 725 | } |
679 | } | 726 | } |
680 | } | 727 | } |
681 | 728 | ||
729 | static void conf_cleanup(void) | ||
730 | { | ||
731 | tcsetattr(1, TCSAFLUSH, &ios_org); | ||
732 | unlink(".help.tmp"); | ||
733 | unlink("lxdialog.scrltmp"); | ||
734 | } | ||
735 | |||
682 | int main(int ac, char **av) | 736 | int main(int ac, char **av) |
683 | { | 737 | { |
738 | struct symbol *sym; | ||
739 | char *mode; | ||
684 | int stat; | 740 | int stat; |
741 | |||
685 | conf_parse(av[1]); | 742 | conf_parse(av[1]); |
686 | conf_read(NULL); | 743 | conf_read(NULL); |
687 | 744 | ||
688 | sprintf(menu_backtitle, "Configuration"); | 745 | sym = sym_lookup("KERNELRELEASE", 0); |
746 | sym_calc_value(sym); | ||
747 | sprintf(menu_backtitle, "Linux Kernel v%s Configuration", | ||
748 | sym_get_string_value(sym)); | ||
749 | |||
750 | mode = getenv("MENUCONFIG_MODE"); | ||
751 | if (mode) { | ||
752 | if (!strcasecmp(mode, "single_menu")) | ||
753 | single_menu_mode = 1; | ||
754 | } | ||
689 | 755 | ||
756 | tcgetattr(1, &ios_org); | ||
757 | atexit(conf_cleanup); | ||
690 | init_wsize(); | 758 | init_wsize(); |
691 | conf(&rootmenu); | 759 | conf(&rootmenu); |
692 | 760 | ||
693 | do { | 761 | do { |
@@ -701,11 +769,12 @@ int main(int ac, char **av) | |||
701 | 769 | ||
702 | if (stat == 0) { | 770 | if (stat == 0) { |
703 | conf_write(NULL); | 771 | conf_write(NULL); |
704 | printf("\n\n" | 772 | printf("\n\n" |
705 | "*** End of configuration.\n" | 773 | "*** End of Linux kernel configuration.\n" |
706 | "*** Check the top-level Makefile for additional configuration.\n"); | 774 | "*** Check the top-level Makefile for additional configuration.\n" |
775 | "*** Next, you may run 'make bzImage', 'make bzdisk', or 'make install'.\n\n"); | ||
707 | } else | 776 | } else |
708 | printf("\n\nYour configuration changes were NOT saved.\n\n"); | 777 | printf("\n\nYour kernel configuration changes were NOT saved.\n\n"); |
709 | 778 | ||
710 | return 0; | 779 | return 0; |
711 | } | 780 | } |