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.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 6d82718..b9cf25f 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -28,70 +28,70 @@ static const char menu_instructions[] =
28 "<Enter> selects submenus --->. " 28 "<Enter> selects submenus --->. "
29 "Highlighted letters are hotkeys. " 29 "Highlighted letters are hotkeys. "
30 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 30 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
31 "Press <Esc><Esc> to exit, <?> for Help. " 31 "Press <Esc><Esc> to exit, <?> for Help. "
32 "Legend: [*] built-in [ ] excluded <M> module < > module capable", 32 "Legend: [*] built-in [ ] excluded <M> module < > module capable",
33radiolist_instructions[] = 33radiolist_instructions[] =
34 "Use the arrow keys to navigate this window or " 34 "Use the arrow keys to navigate this window or "
35 "press the hotkey of the item you wish to select " 35 "press the hotkey of the item you wish to select "
36 "followed by the <SPACE BAR>. " 36 "followed by the <SPACE BAR>. "
37 "Press <?> for additional information about this option.", 37 "Press <?> for additional information about this option.",
38inputbox_instructions_int[] = 38inputbox_instructions_int[] =
39 "Please enter a decimal value. " 39 "Please enter a decimal value. "
40 "Fractions will not be accepted. " 40 "Fractions will not be accepted. "
41 "Use the <TAB> key to move from the input field to the buttons below it.", 41 "Use the <TAB> key to move from the input field to the buttons below it.",
42inputbox_instructions_hex[] = 42inputbox_instructions_hex[] =
43 "Please enter a hexadecimal value. " 43 "Please enter a hexadecimal value. "
44 "Use the <TAB> key to move from the input field to the buttons below it.", 44 "Use the <TAB> key to move from the input field to the buttons below it.",
45inputbox_instructions_string[] = 45inputbox_instructions_string[] =
46 "Please enter a string value. " 46 "Please enter a string value. "
47 "Use the <TAB> key to move from the input field to the buttons below it.", 47 "Use the <TAB> key to move from the input field to the buttons below it.",
48setmod_text[] = 48setmod_text[] =
49 "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"
50 "As a result, this feature will be built as a module.", 50 "As a result, this feature will be built as a module.",
51nohelp_text[] = 51nohelp_text[] =
52 "There is no help available for this kernel option.\n", 52 "There is no help available for this option.\n",
53load_config_text[] = 53load_config_text[] =
54 "Enter the name of the configuration file you wish to load. " 54 "Enter the name of the configuration file you wish to load. "
55 "Accept the name shown to restore the configuration you " 55 "Accept the name shown to restore the configuration you "
56 "last retrieved. Leave blank to abort.", 56 "last retrieved. Leave blank to abort.",
57load_config_help[] = 57load_config_help[] =
58 "\n" 58 "\n"
59 "For various reasons, one may wish to keep several different kernel\n" 59 "For various reasons, one may wish to keep several different \n"
60 "configurations available on a single machine.\n" 60 "configurations available on a single machine.\n"
61 "\n" 61 "\n"
62 "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"
63 "kernel's default, entering the name of the file here will allow you\n" 63 "default, entering the name of the file here will allow you\n"
64 "to modify that configuration.\n" 64 "to modify that configuration.\n"
65 "\n" 65 "\n"
66 "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"
67 "configuration files. You should therefor leave this blank to abort.\n", 67 "configuration files. You should therefor leave this blank to abort.\n",
68save_config_text[] = 68save_config_text[] =
69 "Enter a filename to which this configuration should be saved " 69 "Enter a filename to which this configuration should be saved "
70 "as an alternate. Leave blank to abort.", 70 "as an alternate. Leave blank to abort.",
71save_config_help[] = 71save_config_help[] =
72 "\n" 72 "\n"
73 "For various reasons, one may wish to keep different kernel\n" 73 "For various reasons, one may wish to keep different\n"
74 "configurations available on a single machine.\n" 74 "configurations available on a single machine.\n"
75 "\n" 75 "\n"
76 "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"
77 "and use the current configuration as an alternate to whatever\n" 77 "and use the current configuration as an alternate to whatever\n"
78 "configuration options you have selected at that time.\n" 78 "configuration options you have selected at that time.\n"
79 "\n" 79 "\n"
80 "If you are uncertain what all this means then you should probably\n" 80 "If you are uncertain what all this means then you should probably\n"
81 "leave this blank.\n" 81 "leave this blank.\n"
82; 82;
83 83
84static char buf[4096], *bufptr = buf; 84static char buf[4096], *bufptr = buf;
85static char input_buf[4096]; 85static char input_buf[4096];
86static char filename[PATH_MAX+1] = ".config"; 86static char filename[PATH_MAX+1] = ".config";
87static char *args[1024], **argptr = args; 87static char *args[1024], **argptr = args;
88static int indent = 0; 88static int indent = 0;
89static struct termios ios_org; 89static struct termios ios_org;
90static int rows, cols; 90static int rows, cols;
91static struct menu *current_menu; 91static struct menu *current_menu;
92static int child_count; 92static int child_count;
93static int do_resize; 93static int do_resize;
94static int single_menu_mode; 94static int single_menu_mode;
95 95
96static void conf(struct menu *menu); 96static void conf(struct menu *menu);
97static void conf_choice(struct menu *menu); 97static void conf_choice(struct menu *menu);
@@ -126,54 +126,59 @@ static void init_wsize(void)
126 if (!rows) 126 if (!rows)
127 rows = 24; 127 rows = 24;
128 } 128 }
129 if (!cols) { 129 if (!cols) {
130 env = getenv("COLUMNS"); 130 env = getenv("COLUMNS");
131 if (env) 131 if (env)
132 cols = atoi(env); 132 cols = atoi(env);
133 if (!cols) 133 if (!cols)
134 cols = 80; 134 cols = 80;
135 } 135 }
136 } 136 }
137 137
138 if (rows < 19 || cols < 80) { 138 if (rows < 19 || cols < 80) {
139 fprintf(stderr, "Your display is too small to run Menuconfig!\n"); 139 fprintf(stderr, "Your display is too small to run Menuconfig!\n");
140 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n"); 140 fprintf(stderr, "It must be at least 19 lines by 80 columns.\n");
141 exit(1); 141 exit(1);
142 } 142 }
143 143
144 rows -= 4; 144 rows -= 4;
145 cols -= 5; 145 cols -= 5;
146} 146}
147 147
148static void cprint_init(void) 148static void cprint_init(void)
149{ 149{
150 char *env = getenv("LXDIALOG");
150 bufptr = buf; 151 bufptr = buf;
151 argptr = args; 152 argptr = args;
152 memset(args, 0, sizeof(args)); 153 memset(args, 0, sizeof(args));
153 indent = 0; 154 indent = 0;
154 child_count = 0; 155 child_count = 0;
156 if(env != NULL) {
157 cprint(env);
158 } else {
155 cprint("./scripts/lxdialog/lxdialog"); 159 cprint("./scripts/lxdialog/lxdialog");
160 }
156 cprint("--backtitle"); 161 cprint("--backtitle");
157 cprint(menu_backtitle); 162 cprint(menu_backtitle);
158} 163}
159 164
160static int cprint1(const char *fmt, ...) 165static int cprint1(const char *fmt, ...)
161{ 166{
162 va_list ap; 167 va_list ap;
163 int res; 168 int res;
164 169
165 if (!*argptr) 170 if (!*argptr)
166 *argptr = bufptr; 171 *argptr = bufptr;
167 va_start(ap, fmt); 172 va_start(ap, fmt);
168 res = vsprintf(bufptr, fmt, ap); 173 res = vsprintf(bufptr, fmt, ap);
169 va_end(ap); 174 va_end(ap);
170 bufptr += res; 175 bufptr += res;
171 176
172 return res; 177 return res;
173} 178}
174 179
175static void cprint_done(void) 180static void cprint_done(void)
176{ 181{
177 *bufptr++ = 0; 182 *bufptr++ = 0;
178 argptr++; 183 argptr++;
179} 184}
@@ -281,53 +286,50 @@ static void build_conf(struct menu *menu)
281 struct symbol *sym; 286 struct symbol *sym;
282 struct property *prop; 287 struct property *prop;
283 struct menu *child; 288 struct menu *child;
284 int type, tmp, doint = 2; 289 int type, tmp, doint = 2;
285 tristate val; 290 tristate val;
286 char ch; 291 char ch;
287 292
288 if (!menu_is_visible(menu)) 293 if (!menu_is_visible(menu))
289 return; 294 return;
290 295
291 sym = menu->sym; 296 sym = menu->sym;
292 prop = menu->prompt; 297 prop = menu->prompt;
293 if (!sym) { 298 if (!sym) {
294 if (prop && menu != current_menu) { 299 if (prop && menu != current_menu) {
295 const char *prompt = menu_get_prompt(menu); 300 const char *prompt = menu_get_prompt(menu);
296 switch (prop->type) { 301 switch (prop->type) {
297 case P_MENU: 302 case P_MENU:
298 child_count++; 303 child_count++;
299 cprint("m%p", menu); 304 cprint("m%p", menu);
300 305
301 if (single_menu_mode) { 306 if (single_menu_mode) {
302 cprint1("%s%*c%s", 307 cprint1("%s%*c%s",
303 menu->data ? "-->" : "++>", 308 menu->data ? "-->" : "++>",
304 indent + 1, ' ', prompt); 309 indent + 1, ' ', prompt);
305 } else { 310 } else
306 if (menu->parent != &rootmenu) 311 cprint1(" %*c%s --->", indent + 1, ' ', prompt);
307 cprint1(" %*c", indent + 1, ' ');
308 cprint1("%s --->", prompt);
309 }
310 312
311 cprint_done(); 313 cprint_done();
312 if (single_menu_mode && menu->data) 314 if (single_menu_mode && menu->data)
313 goto conf_childs; 315 goto conf_childs;
314 return; 316 return;
315 default: 317 default:
316 if (prompt) { 318 if (prompt) {
317 child_count++; 319 child_count++;
318 cprint(":%p", menu); 320 cprint(":%p", menu);
319 cprint("---%*c%s", indent + 1, ' ', prompt); 321 cprint("---%*c%s", indent + 1, ' ', prompt);
320 } 322 }
321 } 323 }
322 } else 324 } else
323 doint = 0; 325 doint = 0;
324 goto conf_childs; 326 goto conf_childs;
325 } 327 }
326 328
327 type = sym_get_type(sym); 329 type = sym_get_type(sym);
328 if (sym_is_choice(sym)) { 330 if (sym_is_choice(sym)) {
329 struct symbol *def_sym = sym_get_choice_value(sym); 331 struct symbol *def_sym = sym_get_choice_value(sym);
330 struct menu *def_menu = NULL; 332 struct menu *def_menu = NULL;
331 333
332 child_count++; 334 child_count++;
333 for (child = menu->list; child; child = child->next) { 335 for (child = menu->list; child; child = child->next) {
@@ -352,82 +354,100 @@ static void build_conf(struct menu *menu)
352 break; 354 break;
353 } 355 }
354 } else { 356 } else {
355 cprint("%c%p", def_menu ? 't' : ':', menu); 357 cprint("%c%p", def_menu ? 't' : ':', menu);
356 cprint1(" "); 358 cprint1(" ");
357 } 359 }
358 360
359 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); 361 cprint1("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
360 if (val == yes) { 362 if (val == yes) {
361 if (def_menu) { 363 if (def_menu) {
362 cprint1(" (%s)", menu_get_prompt(def_menu)); 364 cprint1(" (%s)", menu_get_prompt(def_menu));
363 cprint1(" --->"); 365 cprint1(" --->");
364 cprint_done(); 366 cprint_done();
365 if (def_menu->list) { 367 if (def_menu->list) {
366 indent += 2; 368 indent += 2;
367 build_conf(def_menu); 369 build_conf(def_menu);
368 indent -= 2; 370 indent -= 2;
369 } 371 }
370 } else 372 } else
371 cprint_done(); 373 cprint_done();
372 return; 374 return;
373 } 375 }
374 cprint_done(); 376 cprint_done();
375 } else { 377 } else {
378 if (menu == current_menu) {
379 cprint(":%p", menu);
380 cprint("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
381 goto conf_childs;
382 }
376 child_count++; 383 child_count++;
377 val = sym_get_tristate_value(sym); 384 val = sym_get_tristate_value(sym);
378 if (sym_is_choice_value(sym) && val == yes) { 385 if (sym_is_choice_value(sym) && val == yes) {
379 cprint(":%p", menu); 386 cprint(":%p", menu);
380 cprint1(" "); 387 cprint1(" ");
381 } else { 388 } else {
382 switch (type) { 389 switch (type) {
383 case S_BOOLEAN: 390 case S_BOOLEAN:
384 cprint("t%p", menu); 391 cprint("t%p", menu);
392 if (sym_is_changable(sym))
385 cprint1("[%c]", val == no ? ' ' : '*'); 393 cprint1("[%c]", val == no ? ' ' : '*');
394 else
395 cprint1("---");
386 break; 396 break;
387 case S_TRISTATE: 397 case S_TRISTATE:
388 cprint("t%p", menu); 398 cprint("t%p", menu);
389 switch (val) { 399 switch (val) {
390 case yes: ch = '*'; break; 400 case yes: ch = '*'; break;
391 case mod: ch = 'M'; break; 401 case mod: ch = 'M'; break;
392 default: ch = ' '; break; 402 default: ch = ' '; break;
393 } 403 }
404 if (sym_is_changable(sym))
394 cprint1("<%c>", ch); 405 cprint1("<%c>", ch);
406 else
407 cprint1("---");
395 break; 408 break;
396 default: 409 default:
397 cprint("s%p", menu); 410 cprint("s%p", menu);
398 tmp = cprint1("(%s)", sym_get_string_value(sym)); 411 tmp = cprint1("(%s)", sym_get_string_value(sym));
399 tmp = indent - tmp + 4; 412 tmp = indent - tmp + 4;
400 if (tmp < 0) 413 if (tmp < 0)
401 tmp = 0; 414 tmp = 0;
402 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu), 415 cprint1("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
403 sym_has_value(sym) ? "" : " (NEW)"); 416 (sym_has_value(sym) || !sym_is_changable(sym)) ?
417 "" : " (NEW)");
404 cprint_done(); 418 cprint_done();
405 goto conf_childs; 419 goto conf_childs;
406 } 420 }
407 } 421 }
408 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), 422 cprint1("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
409 sym_has_value(sym) ? "" : " (NEW)"); 423 (sym_has_value(sym) || !sym_is_changable(sym)) ?
424 "" : " (NEW)");
425 if (menu->prompt->type == P_MENU) {
426 cprint1(" --->");
427 cprint_done();
428 return;
429 }
410 cprint_done(); 430 cprint_done();
411 } 431 }
412 432
413conf_childs: 433conf_childs:
414 indent += doint; 434 indent += doint;
415 for (child = menu->list; child; child = child->next) 435 for (child = menu->list; child; child = child->next)
416 build_conf(child); 436 build_conf(child);
417 indent -= doint; 437 indent -= doint;
418} 438}
419 439
420static void conf(struct menu *menu) 440static void conf(struct menu *menu)
421{ 441{
422 struct menu *submenu; 442 struct menu *submenu;
423 const char *prompt = menu_get_prompt(menu); 443 const char *prompt = menu_get_prompt(menu);
424 struct symbol *sym; 444 struct symbol *sym;
425 char active_entry[40]; 445 char active_entry[40];
426 int stat, type, i; 446 int stat, type, i;
427 447
428 unlink("lxdialog.scrltmp"); 448 unlink("lxdialog.scrltmp");
429 active_entry[0] = 0; 449 active_entry[0] = 0;
430 while (1) { 450 while (1) {
431 cprint_init(); 451 cprint_init();
432 cprint("--title"); 452 cprint("--title");
433 cprint("%s", prompt ? prompt : "Main Menu"); 453 cprint("%s", prompt ? prompt : "Main Menu");
@@ -463,48 +483,50 @@ static void conf(struct menu *menu)
463 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++) 483 for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
464 ; 484 ;
465 if (i >= sizeof(active_entry)) 485 if (i >= sizeof(active_entry))
466 i = sizeof(active_entry) - 1; 486 i = sizeof(active_entry) - 1;
467 input_buf[i] = 0; 487 input_buf[i] = 0;
468 strcpy(active_entry, input_buf); 488 strcpy(active_entry, input_buf);
469 489
470 sym = NULL; 490 sym = NULL;
471 submenu = NULL; 491 submenu = NULL;
472 if (sscanf(input_buf + 1, "%p", &submenu) == 1) 492 if (sscanf(input_buf + 1, "%p", &submenu) == 1)
473 sym = submenu->sym; 493 sym = submenu->sym;
474 494
475 switch (stat) { 495 switch (stat) {
476 case 0: 496 case 0:
477 switch (type) { 497 switch (type) {
478 case 'm': 498 case 'm':
479 if (single_menu_mode) 499 if (single_menu_mode)
480 submenu->data = (void *) !submenu->data; 500 submenu->data = (void *) !submenu->data;
481 else 501 else
482 conf(submenu); 502 conf(submenu);
483 break; 503 break;
484 case 't': 504 case 't':
485 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes) 505 if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
486 conf_choice(submenu); 506 conf_choice(submenu);
507 else if (submenu->prompt->type == P_MENU)
508 conf(submenu);
487 break; 509 break;
488 case 's': 510 case 's':
489 conf_string(submenu); 511 conf_string(submenu);
490 break; 512 break;
491 case 'L': 513 case 'L':
492 conf_load(); 514 conf_load();
493 break; 515 break;
494 case 'S': 516 case 'S':
495 conf_save(); 517 conf_save();
496 break; 518 break;
497 } 519 }
498 break; 520 break;
499 case 2: 521 case 2:
500 if (sym) 522 if (sym)
501 show_help(submenu); 523 show_help(submenu);
502 else 524 else
503 show_readme(); 525 show_readme();
504 break; 526 break;
505 case 3: 527 case 3:
506 if (type == 't') { 528 if (type == 't') {
507 if (sym_set_tristate_value(sym, yes)) 529 if (sym_set_tristate_value(sym, yes))
508 break; 530 break;
509 if (sym_set_tristate_value(sym, mod)) 531 if (sym_set_tristate_value(sym, mod))
510 show_textbox(NULL, setmod_text, 6, 74); 532 show_textbox(NULL, setmod_text, 6, 74);
@@ -723,58 +745,58 @@ static void conf_save(void)
723 case 255: 745 case 255:
724 return; 746 return;
725 } 747 }
726 } 748 }
727} 749}
728 750
729static void conf_cleanup(void) 751static void conf_cleanup(void)
730{ 752{
731 tcsetattr(1, TCSAFLUSH, &ios_org); 753 tcsetattr(1, TCSAFLUSH, &ios_org);
732 unlink(".help.tmp"); 754 unlink(".help.tmp");
733 unlink("lxdialog.scrltmp"); 755 unlink("lxdialog.scrltmp");
734} 756}
735 757
736int main(int ac, char **av) 758int main(int ac, char **av)
737{ 759{
738 struct symbol *sym; 760 struct symbol *sym;
739 char *mode; 761 char *mode;
740 int stat; 762 int stat;
741 763
742 conf_parse(av[1]); 764 conf_parse(av[1]);
743 conf_read(NULL); 765 conf_read(NULL);
744 766
745 sym = sym_lookup("KERNELRELEASE", 0); 767 sym = sym_lookup("KERNELRELEASE", 0);
746 sym_calc_value(sym); 768 sym_calc_value(sym);
747 sprintf(menu_backtitle, "Opie %s Configuration", 769 sprintf(menu_backtitle, "Build Configuration");
748 sym_get_string_value(sym));
749 770
750 mode = getenv("MENUCONFIG_MODE"); 771 mode = getenv("MENUCONFIG_MODE");
751 if (mode) { 772 if (mode) {
752 if (!strcasecmp(mode, "single_menu")) 773 if (!strcasecmp(mode, "single_menu"))
753 single_menu_mode = 1; 774 single_menu_mode = 1;
754 } 775 }
755 776
756 tcgetattr(1, &ios_org); 777 tcgetattr(1, &ios_org);
757 atexit(conf_cleanup); 778 atexit(conf_cleanup);
758 init_wsize(); 779 init_wsize();
759 conf(&rootmenu); 780 conf(&rootmenu);
760 781
761 do { 782 do {
762 cprint_init(); 783 cprint_init();
763 cprint("--yesno"); 784 cprint("--yesno");
764 cprint("Do you wish to save your new configuration?"); 785 cprint("Do you wish to save your new configuration?");
765 cprint("5"); 786 cprint("5");
766 cprint("60"); 787 cprint("60");
767 stat = exec_conf(); 788 stat = exec_conf();
768 } while (stat < 0); 789 } while (stat < 0);
769 790
770 if (stat == 0) { 791 if (stat == 0) {
771 conf_write(NULL); 792 conf_write(NULL);
772 printf("\n\n" 793 printf("\n\n"
773 "*** End of Opie configuration.\n" 794 "*** End of configuration.\n"
774 "*** Check the top-level Makefile for additional configuration.\n" 795 "\n\n");
775 "*** Next, you may run 'make'.\n\n");
776 } else 796 } else
777 printf("\n\nYour Opie configuration changes were NOT saved.\n\n"); 797 printf("\n\n"
798 "Your configuration changes were NOT saved."
799 "\n\n");
778 800
779 return 0; 801 return 0;
780} 802}