summaryrefslogtreecommitdiff
path: root/extra/config/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'extra/config/conf.c')
-rw-r--r--extra/config/conf.c178
1 files changed, 73 insertions, 105 deletions
diff --git a/extra/config/conf.c b/extra/config/conf.c
index 6735bfe76..02b2600c2 100644
--- a/extra/config/conf.c
+++ b/extra/config/conf.c
@@ -32,6 +32,7 @@ char *defconfig_file;
static int indent = 1;
static int valid_stdin = 1;
+static int sync_kconfig;
static int conf_cnt;
static char line[128];
static struct menu *rootEntry;
@@ -65,7 +66,7 @@ static void strip(char *str)
static void check_stdin(void)
{
- if (!valid_stdin && input_mode == ask_silent) {
+ if (!valid_stdin) {
printf(_("aborted!\n\n"));
printf(_("Console input/output is redirected. "));
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
@@ -76,7 +77,6 @@ static void check_stdin(void)
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
- tristate val;
if (!sym_has_value(sym))
printf(_("(NEW) "));
@@ -92,15 +92,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
}
switch (input_mode) {
- case set_no:
- case set_mod:
- case set_yes:
- case set_random:
- if (sym_has_value(sym)) {
- printf("%s\n", def);
- return 0;
- }
- break;
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
@@ -112,9 +103,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
fflush(stdout);
fgets(line, 128, stdin);
return 1;
- case set_default:
- printf("%s\n", def);
- return 1;
default:
break;
}
@@ -128,52 +116,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
default:
;
}
- switch (input_mode) {
- case set_yes:
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_mod:
- if (type == S_TRISTATE) {
- if (sym_tristate_within_range(sym, mod)) {
- line[0] = 'm';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- } else {
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- }
- case set_no:
- if (sym_tristate_within_range(sym, no)) {
- line[0] = 'n';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_random:
- do {
- val = (tristate)(rand() % 3);
- } while (!sym_tristate_within_range(sym, val));
- switch (val) {
- case no: line[0] = 'n'; break;
- case mod: line[0] = 'm'; break;
- case yes: line[0] = 'y'; break;
- }
- line[1] = '\n';
- line[2] = 0;
- break;
- default:
- break;
- }
printf("%s", line);
return 1;
}
@@ -374,15 +316,7 @@ static int conf_choice(struct menu *menu)
else
continue;
break;
- case set_random:
- if (is_new)
- def = (rand() % cnt) + 1;
- case set_default:
- case set_yes:
- case set_mod:
- case set_no:
- cnt = def;
- printf("%d\n", cnt);
+ default:
break;
}
@@ -507,11 +441,11 @@ int main(int ac, char **av)
while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
switch (opt) {
case 'o':
- input_mode = ask_new;
+ input_mode = ask_silent;
break;
case 's':
input_mode = ask_silent;
- valid_stdin = isatty(0) && isatty(1) && isatty(2);
+ sync_kconfig = 1;
break;
case 'd':
input_mode = set_default;
@@ -549,6 +483,19 @@ int main(int ac, char **av)
name = av[optind];
conf_parse(name);
//zconfdump(stdout);
+ if (sync_kconfig) {
+ if (stat(".config", &tmpstat)) {
+ fprintf(stderr, _("***\n"
+ "*** You have not yet configured!\n"
+ "*** (missing .config file)\n"
+ "***\n"
+ "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
+ "*** \"make menuconfig\" or \"make xconfig\").\n"
+ "***\n"));
+ exit(1);
+ }
+ }
+
switch (input_mode) {
case set_default:
if (!defconfig_file)
@@ -561,16 +508,6 @@ int main(int ac, char **av)
}
break;
case ask_silent:
- if (stat(".config", &tmpstat)) {
- printf(_("***\n"
- "*** You have not yet configured!\n"
- "*** (missing .config file)\n"
- "***\n"
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
- "*** \"make menuconfig\" or \"make xconfig\").\n"
- "***\n"));
- exit(1);
- }
case ask_all:
case ask_new:
conf_read(NULL);
@@ -600,35 +537,66 @@ int main(int ac, char **av)
break;
}
- if (input_mode != ask_silent) {
+ if (sync_kconfig) {
+ if (conf_get_changed()) {
+ name = getenv("KCONFIG_NOSILENTUPDATE");
+ if (name && *name) {
+ fprintf(stderr,
+ _("\n*** configuration requires explicit update.\n\n"));
+ return 1;
+ }
+ }
+ valid_stdin = isatty(0) && isatty(1) && isatty(2);
+ }
+
+ switch (input_mode) {
+ case set_no:
+ conf_set_all_new_symbols(def_no);
+ break;
+ case set_yes:
+ conf_set_all_new_symbols(def_yes);
+ break;
+ case set_mod:
+ conf_set_all_new_symbols(def_mod);
+ break;
+ case set_random:
+ conf_set_all_new_symbols(def_random);
+ break;
+ case set_default:
+ conf_set_all_new_symbols(def_default);
+ break;
+ case ask_new:
+ case ask_all:
rootEntry = &rootmenu;
conf(&rootmenu);
- if (input_mode == ask_all) {
- input_mode = ask_silent;
- valid_stdin = 1;
+ input_mode = ask_silent;
+ /* fall through */
+ case ask_silent:
+ /* Update until a loop caused no more changes */
+ do {
+ conf_cnt = 0;
+ check_conf(&rootmenu);
+ } while (conf_cnt);
+ break;
+ }
+
+ if (sync_kconfig) {
+ /* silentoldconfig is used during the build so we shall update autoconf.
+ * All other commands are only used to generate a config.
+ */
+ if (conf_get_changed() && conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
}
- } else if (conf_get_changed()) {
- name = getenv("KCONFIG_NOSILENTUPDATE");
- if (name && *name) {
- fprintf(stderr, _("\n*** configuration requires explicit update.\n\n"));
+ if (conf_write_autoconf()) {
+ fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
return 1;
}
- } else
- goto skip_check;
-
- do {
- conf_cnt = 0;
- check_conf(&rootmenu);
- } while (conf_cnt);
- if (conf_write(NULL)) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
- }
-skip_check:
- if (/*input_mode == ask_silent &&*/ conf_write_autoconf()) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
+ } else {
+ if (conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
+ }
}
-
return 0;
}