summaryrefslogtreecommitdiff
path: root/scripts/kconfig/mconf.c
Unidiff
Diffstat (limited to 'scripts/kconfig/mconf.c') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/mconf.c101
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,6 +1,9 @@
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>
@@ -8,10 +11,12 @@
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
@@ -44,18 +49,18 @@ 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.",
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. "
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.",
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"
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"
@@ -65,7 +70,7 @@ save_config_text[] =
65 "as an alternate. Leave blank to abort.", 70 "as an alternate. Leave blank to abort.",
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"
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"
@@ -78,12 +83,15 @@ save_config_help[] =
78 83
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);
89static void conf_choice(struct menu *menu); 97static void conf_choice(struct menu *menu);
@@ -103,6 +111,7 @@ static int cprint(const char *fmt, ...);
103static void init_wsize(void) 111static 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;
@@ -110,6 +119,20 @@ static void init_wsize(void)
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) {
@@ -274,10 +297,20 @@ static void build_conf(struct menu *menu)
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) {
@@ -392,6 +425,7 @@ static void conf(struct menu *menu)
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();
@@ -442,7 +476,10 @@ static void conf(struct menu *menu)
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)
@@ -484,6 +521,8 @@ static void conf(struct menu *menu)
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 }
@@ -518,11 +557,19 @@ static void show_helptext(const char *title, const char *text)
518static void show_help(struct menu *menu) 557static 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
528static void show_readme(void) 575static void show_readme(void)
@@ -631,7 +678,7 @@ static void conf_load(void)
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:
@@ -660,7 +707,7 @@ static void conf_save(void)
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:
@@ -679,14 +726,35 @@ static void conf_save(void)
679 } 726 }
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);
692 760
@@ -702,10 +770,11 @@ int main(int ac, char **av)
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}