aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r--scripts/kconfig/conf.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 006ad817cd5..f208f900ed3 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -14,11 +14,11 @@
14#include <sys/stat.h> 14#include <sys/stat.h>
15#include <sys/time.h> 15#include <sys/time.h>
16 16
17#define LKC_DIRECT_LINK
18#include "lkc.h" 17#include "lkc.h"
19 18
20static void conf(struct menu *menu); 19static void conf(struct menu *menu);
21static void check_conf(struct menu *menu); 20static void check_conf(struct menu *menu);
21static void xfgets(char *str, int size, FILE *in);
22 22
23enum input_mode { 23enum input_mode {
24 oldaskconfig, 24 oldaskconfig,
@@ -35,8 +35,6 @@ enum input_mode {
35 oldnoconfig, 35 oldnoconfig,
36} input_mode = oldaskconfig; 36} input_mode = oldaskconfig;
37 37
38char *defconfig_file;
39
40static int indent = 1; 38static int indent = 1;
41static int valid_stdin = 1; 39static int valid_stdin = 1;
42static int sync_kconfig; 40static int sync_kconfig;
@@ -106,6 +104,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
106 return 0; 104 return 0;
107 } 105 }
108 check_stdin(); 106 check_stdin();
107 /* fall through */
109 case oldaskconfig: 108 case oldaskconfig:
110 fflush(stdout); 109 fflush(stdout);
111 xfgets(line, 128, stdin); 110 xfgets(line, 128, stdin);
@@ -150,6 +149,7 @@ static int conf_string(struct menu *menu)
150 def = NULL; 149 def = NULL;
151 break; 150 break;
152 } 151 }
152 /* fall through */
153 default: 153 default:
154 line[strlen(line)-1] = 0; 154 line[strlen(line)-1] = 0;
155 def = line; 155 def = line;
@@ -304,6 +304,7 @@ static int conf_choice(struct menu *menu)
304 break; 304 break;
305 } 305 }
306 check_stdin(); 306 check_stdin();
307 /* fall through */
307 case oldaskconfig: 308 case oldaskconfig:
308 fflush(stdout); 309 fflush(stdout);
309 xfgets(line, 128, stdin); 310 xfgets(line, 128, stdin);
@@ -369,6 +370,7 @@ static void conf(struct menu *menu)
369 check_conf(menu); 370 check_conf(menu);
370 return; 371 return;
371 } 372 }
373 /* fall through */
372 case P_COMMENT: 374 case P_COMMENT:
373 prompt = menu_get_prompt(menu); 375 prompt = menu_get_prompt(menu);
374 if (prompt) 376 if (prompt)
@@ -456,10 +458,30 @@ static struct option long_opts[] = {
456 {NULL, 0, NULL, 0} 458 {NULL, 0, NULL, 0}
457}; 459};
458 460
461static void conf_usage(const char *progname)
462{
463
464 printf("Usage: %s [option] <kconfig-file>\n", progname);
465 printf("[option] is _one_ of the following:\n");
466 printf(" --listnewconfig List new options\n");
467 printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
468 printf(" --oldconfig Update a configuration using a provided .config as base\n");
469 printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
470 printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n");
471 printf(" --defconfig <file> New config with default defined in <file>\n");
472 printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
473 printf(" --allnoconfig New config where all options are answered with no\n");
474 printf(" --allyesconfig New config where all options are answered with yes\n");
475 printf(" --allmodconfig New config where all options are answered with mod\n");
476 printf(" --alldefconfig New config with all symbols set to default\n");
477 printf(" --randconfig New config with random answer to all options\n");
478}
479
459int main(int ac, char **av) 480int main(int ac, char **av)
460{ 481{
482 const char *progname = av[0];
461 int opt; 483 int opt;
462 const char *name; 484 const char *name, *defconfig_file = NULL /* gcc uninit */;
463 struct stat tmpstat; 485 struct stat tmpstat;
464 486
465 setlocale(LC_ALL, ""); 487 setlocale(LC_ALL, "");
@@ -491,14 +513,24 @@ int main(int ac, char **av)
491 srand(seed); 513 srand(seed);
492 break; 514 break;
493 } 515 }
516 case oldaskconfig:
517 case oldconfig:
518 case allnoconfig:
519 case allyesconfig:
520 case allmodconfig:
521 case alldefconfig:
522 case listnewconfig:
523 case oldnoconfig:
524 break;
494 case '?': 525 case '?':
495 fprintf(stderr, _("See README for usage info\n")); 526 conf_usage(progname);
496 exit(1); 527 exit(1);
497 break; 528 break;
498 } 529 }
499 } 530 }
500 if (ac == optind) { 531 if (ac == optind) {
501 printf(_("%s: Kconfig file missing\n"), av[0]); 532 printf(_("%s: Kconfig file missing\n"), av[0]);
533 conf_usage(progname);
502 exit(1); 534 exit(1);
503 } 535 }
504 name = av[optind]; 536 name = av[optind];
@@ -641,13 +673,11 @@ int main(int ac, char **av)
641 } 673 }
642 return 0; 674 return 0;
643} 675}
676
644/* 677/*
645 * Helper function to facilitate fgets() by Jean Sacren. 678 * Helper function to facilitate fgets() by Jean Sacren.
646 */ 679 */
647void xfgets(str, size, in) 680void xfgets(char *str, int size, FILE *in)
648 char *str;
649 int size;
650 FILE *in;
651{ 681{
652 if (fgets(str, size, in) == NULL) 682 if (fgets(str, size, in) == NULL)
653 fprintf(stderr, "\nError in reading or end of file.\n"); 683 fprintf(stderr, "\nError in reading or end of file.\n");