summaryrefslogtreecommitdiff
path: root/scripts/kconfig/mconf.c
Unidiff
Diffstat (limited to 'scripts/kconfig/mconf.c') (more/less context) (show whitespace changes)
-rw-r--r--scripts/kconfig/mconf.c91
1 files changed, 80 insertions, 11 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
@@ -2,4 +2,7 @@
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
@@ -9,8 +12,10 @@
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
@@ -45,5 +50,5 @@ setmod_text[] =
45 "As a result, this feature will be built as a module.", 50 "As a result, this feature will be built as a module.",
46nohelp_text[] = 51nohelp_text[] =
47 "There is no help available for this option.\n", 52 "There is no help available for this kernel option.\n",
48load_config_text[] = 53load_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. "
@@ -52,9 +57,9 @@ load_config_text[] =
52load_config_help[] = 57load_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"
@@ -66,5 +71,5 @@ save_config_text[] =
66save_config_help[] = 71save_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"
@@ -79,10 +84,13 @@ save_config_help[] =
79static char buf[4096], *bufptr = buf; 84static char buf[4096], *bufptr = buf;
80static char input_buf[4096]; 85static char input_buf[4096];
86static char filename[PATH_MAX+1] = ".config";
81static char *args[1024], **argptr = args; 87static char *args[1024], **argptr = args;
82static int indent = 0; 88static int indent = 0;
89static struct termios ios_org;
83static int rows, cols; 90static int rows, cols;
84static struct menu *current_menu; 91static struct menu *current_menu;
85static int child_count; 92static int child_count;
86static int do_resize; 93static int do_resize;
94static int single_menu_mode;
87 95
88static void conf(struct menu *menu); 96static void conf(struct menu *menu);
@@ -104,4 +112,5 @@ 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) {
@@ -111,4 +120,18 @@ static void init_wsize(void)
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
@@ -275,8 +298,18 @@ static void build_conf(struct menu *menu)
275 child_count++; 298 child_count++;
276 cprint("m%p", menu); 299 cprint("m%p", menu);
300
301 if (single_menu_mode) {
302 cprint1("%s%*c%s",
303 menu->data ? "-->" : "++>",
304 indent + 1, ' ', prompt);
305 } else {
277 if (menu->parent != &rootmenu) 306 if (menu->parent != &rootmenu)
278 cprint1(" %*c", indent + 1, ' '); 307 cprint1(" %*c", indent + 1, ' ');
279 cprint1("%s --->", prompt); 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:
@@ -393,4 +426,5 @@ static void conf(struct menu *menu)
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) {
@@ -443,4 +477,7 @@ static void conf(struct menu *menu)
443 switch (type) { 477 switch (type) {
444 case 'm': 478 case 'm':
479 if (single_menu_mode)
480 submenu->data = (void *) !submenu->data;
481 else
445 conf(submenu); 482 conf(submenu);
446 break; 483 break;
@@ -485,4 +522,6 @@ static void conf(struct menu *menu)
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 }
@@ -519,8 +558,16 @@ 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;
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
525 show_helptext(menu_get_prompt(menu), help); 572 show_helptext(menu_get_prompt(menu), help);
526} 573}
@@ -632,5 +679,5 @@ static void conf_load(void)
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) {
@@ -661,5 +708,5 @@ static void conf_save(void)
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) {
@@ -680,12 +727,33 @@ static void conf_save(void)
680} 727}
681 728
729static void conf_cleanup(void)
730{
731 tcsetattr(1, TCSAFLUSH, &ios_org);
732 unlink(".help.tmp");
733 unlink("lxdialog.scrltmp");
734}
735
682int main(int ac, char **av) 736int 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);
@@ -703,8 +771,9 @@ int main(int ac, char **av)
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;