fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / scripts / kconfig / conf.c
index 10eeae5..0433cc7 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <time.h>
@@ -20,6 +21,7 @@ enum {
        ask_all,
        ask_new,
        ask_silent,
+       dont_ask,
        set_default,
        set_yes,
        set_mod,
@@ -36,6 +38,8 @@ static struct menu *rootEntry;
 
 static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
 
+static int return_value = 0;
+
 static void strip(char *str)
 {
        char *p = str;
@@ -63,20 +67,6 @@ static void check_stdin(void)
        }
 }
 
-static char *fgets_check_stream(char *s, int size, FILE *stream)
-{
-       char *ret = fgets(s, size, stream);
-
-       if (ret == NULL && feof(stream)) {
-               printf(_("aborted!\n\n"));
-               printf(_("Console input is closed. "));
-               printf(_("Run 'make oldconfig' to update configuration.\n\n"));
-               exit(1);
-       }
-
-       return ret;
-}
-
 static void conf_askvalue(struct symbol *sym, const char *def)
 {
        enum symbol_type type = sym_get_type(sym);
@@ -114,7 +104,13 @@ static void conf_askvalue(struct symbol *sym, const char *def)
                check_stdin();
        case ask_all:
                fflush(stdout);
-               fgets_check_stream(line, 128, stdin);
+               fgets(line, 128, stdin);
+               return;
+       case dont_ask:
+               if (!sym_has_value(sym)) {
+                       fprintf(stderr,"CONFIG_%s\n",sym->name);
+                       return_value++;
+               }
                return;
        case set_default:
                printf("%s\n", def);
@@ -328,8 +324,7 @@ static int conf_choice(struct menu *menu)
                printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
                def_sym = sym_get_choice_value(sym);
                cnt = def = 0;
-               line[0] = '0';
-               line[1] = 0;
+               line[0] = 0;
                for (child = menu->list; child; child = child->next) {
                        if (!menu_is_visible(child))
                                continue;
@@ -360,6 +355,10 @@ static int conf_choice(struct menu *menu)
                        printf("?");
                printf("]: ");
                switch (input_mode) {
+               case dont_ask:
+                       cnt = def;
+                       printf("%d\n", cnt);
+                       break;
                case ask_new:
                case ask_silent:
                        if (!is_new) {
@@ -370,7 +369,7 @@ static int conf_choice(struct menu *menu)
                        check_stdin();
                case ask_all:
                        fflush(stdout);
-                       fgets_check_stream(line, 128, stdin);
+                       fgets(line, 128, stdin);
                        strip(line);
                        if (line[0] == '?') {
                                printf("\n%s\n", menu->sym->help ?
@@ -496,7 +495,10 @@ static void check_conf(struct menu *menu)
                        if (!conf_cnt++)
                                printf(_("*\n* Restart config...\n*\n"));
                        rootEntry = menu_get_parent_menu(menu);
-                       conf(rootEntry);
+                       if (input_mode == dont_ask)
+                               fprintf(stderr,"CONFIG_%s\n",sym->name);
+                       else
+                               conf(rootEntry);
                }
        }
 
@@ -515,6 +517,9 @@ int main(int ac, char **av)
                case 'o':
                        input_mode = ask_new;
                        break;
+               case 'b':
+                       input_mode = dont_ask;
+                       break;
                case 's':
                        input_mode = ask_silent;
                        valid_stdin = isatty(0) && isatty(1) && isatty(2);
@@ -546,13 +551,14 @@ int main(int ac, char **av)
                        break;
                case 'h':
                case '?':
-                       printf("%s [-o|-s] config\n", av[0]);
+                       fprintf(stderr, "See README for usage info\n");
                        exit(0);
                }
        }
        name = av[i];
        if (!name) {
                printf(_("%s: Kconfig file missing\n"), av[0]);
+               exit(1);
        }
        conf_parse(name);
        //zconfdump(stdout);
@@ -579,6 +585,7 @@ int main(int ac, char **av)
                }
        case ask_all:
        case ask_new:
+       case dont_ask:
                conf_read(NULL);
                break;
        case set_no:
@@ -587,7 +594,7 @@ int main(int ac, char **av)
        case set_random:
                name = getenv("KCONFIG_ALLCONFIG");
                if (name && !stat(name, &tmpstat)) {
-                       conf_read_simple(name);
+                       conf_read_simple(name, S_DEF_USER);
                        break;
                }
                switch (input_mode) {
@@ -598,9 +605,9 @@ int main(int ac, char **av)
                default: break;
                }
                if (!stat(name, &tmpstat))
-                       conf_read_simple(name);
+                       conf_read_simple(name, S_DEF_USER);
                else if (!stat("all.config", &tmpstat))
-                       conf_read_simple("all.config");
+                       conf_read_simple("all.config", S_DEF_USER);
                break;
        default:
                break;
@@ -613,14 +620,28 @@ int main(int ac, char **av)
                        input_mode = ask_silent;
                        valid_stdin = 1;
                }
-       }
+       } else if (conf_get_changed()) {
+               name = getenv("KCONFIG_NOSILENTUPDATE");
+               if (name && *name) {
+                       fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
+                       return 1;
+               }
+       } else
+               goto skip_check;
+
        do {
                conf_cnt = 0;
                check_conf(&rootmenu);
-       } while (conf_cnt);
+       } while ((conf_cnt) && (input_mode != dont_ask));
        if (conf_write(NULL)) {
                fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
                return 1;
        }
-       return 0;
+skip_check:
+       if (input_mode == ask_silent && conf_write_autoconf()) {
+               fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
+               return 1;
+       }
+
+       return return_value;
 }