[adm5120] cleanup memory detection code, fix #2244
[openwrt.git] / scripts / config / confdata.c
index b0cbbe2..4524d51 100644 (file)
@@ -22,13 +22,10 @@ static int conf_lineno, conf_warnings, conf_unsaved;
 
 const char conf_def_filename[] = ".config";
 
 
 const char conf_def_filename[] = ".config";
 
-const char conf_defname[] = "arch/$ARCH/defconfig";
+const char conf_defname[] = "scripts/config/defconfig";
 
 const char *conf_confnames[] = {
        ".config",
 
 const char *conf_confnames[] = {
        ".config",
-       "/lib/modules/$UNAME_RELEASE/.config",
-       "/etc/kernel-config",
-       "/boot/config-$UNAME_RELEASE",
        conf_defname,
        NULL,
 };
        conf_defname,
        NULL,
 };
@@ -86,6 +83,29 @@ char *conf_get_default_confname(void)
        return name;
 }
 
        return name;
 }
 
+void conf_reset(void)
+{
+       struct symbol *sym;
+       int i;
+       
+       for_all_symbols(i, sym) {
+               sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
+               if (sym_is_choice(sym))
+                       sym->flags &= ~SYMBOL_NEW;
+               sym->flags &= ~SYMBOL_VALID;
+               switch (sym->type) {
+               case S_INT:
+               case S_HEX:
+               case S_STRING:
+                       if (sym->user.val)
+                               free(sym->user.val);
+               default:
+                       sym->user.val = NULL;
+                       sym->user.tri = no;
+               }
+       }
+}
+
 int conf_read_simple(const char *name)
 {
        FILE *in = NULL;
 int conf_read_simple(const char *name)
 {
        FILE *in = NULL;
@@ -332,7 +352,7 @@ int conf_read(const char *name)
 
 int conf_write(const char *name)
 {
 
 int conf_write(const char *name)
 {
-       FILE *out, *out_h;
+       FILE *out;
        struct symbol *sym;
        struct menu *menu;
        const char *basename;
        struct symbol *sym;
        struct menu *menu;
        const char *basename;
@@ -369,13 +389,7 @@ int conf_write(const char *name)
        out = fopen(newname, "w");
        if (!out)
                return 1;
        out = fopen(newname, "w");
        if (!out)
                return 1;
-       out_h = NULL;
-       if (!name) {
-               out_h = fopen(".tmpconfig.h", "w");
-               if (!out_h)
-                       return 1;
-       }
-       sym = sym_lookup("KERNELVERSION", 0);
+       sym = sym_lookup("OPENWRTVERSION", 0);
        sym_calc_value(sym);
        time(&now);
        env = getenv("KCONFIG_NOTIMESTAMP");
        sym_calc_value(sym);
        time(&now);
        env = getenv("KCONFIG_NOTIMESTAMP");
@@ -384,22 +398,12 @@ int conf_write(const char *name)
 
        fprintf(out, _("#\n"
                       "# Automatically generated make config: don't edit\n"
 
        fprintf(out, _("#\n"
                       "# Automatically generated make config: don't edit\n"
-                      "# Linux kernel version: %s\n"
+                      "# OpenWrt version: %s\n"
                       "%s%s"
                       "#\n"),
                     sym_get_string_value(sym),
                     use_timestamp ? "# " : "",
                     use_timestamp ? ctime(&now) : "");
                       "%s%s"
                       "#\n"),
                     sym_get_string_value(sym),
                     use_timestamp ? "# " : "",
                     use_timestamp ? ctime(&now) : "");
-       if (out_h)
-               fprintf(out_h, "/*\n"
-                              " * Automatically generated C config: don't edit\n"
-                              " * Linux kernel version: %s\n"
-                              "%s%s"
-                              " */\n"
-                              "#define AUTOCONF_INCLUDED\n",
-                              sym_get_string_value(sym),
-                              use_timestamp ? " * " : "",
-                              use_timestamp ? ctime(&now) : "");
 
        if (!sym_change_count)
                sym_clear_all_valid();
 
        if (!sym_change_count)
                sym_clear_all_valid();
@@ -415,11 +419,6 @@ int conf_write(const char *name)
                                     "#\n"
                                     "# %s\n"
                                     "#\n", str);
                                     "#\n"
                                     "# %s\n"
                                     "#\n", str);
-                       if (out_h)
-                               fprintf(out_h, "\n"
-                                              "/*\n"
-                                              " * %s\n"
-                                              " */\n", str);
                } else if (!(sym->flags & SYMBOL_CHOICE)) {
                        sym_calc_value(sym);
                        if (!(sym->flags & SYMBOL_WRITE))
                } else if (!(sym->flags & SYMBOL_CHOICE)) {
                        sym_calc_value(sym);
                        if (!(sym->flags & SYMBOL_WRITE))
@@ -428,8 +427,11 @@ int conf_write(const char *name)
                        type = sym->type;
                        if (type == S_TRISTATE) {
                                sym_calc_value(modules_sym);
                        type = sym->type;
                        if (type == S_TRISTATE) {
                                sym_calc_value(modules_sym);
+/* tristate always enabled */
+#if 0
                                if (modules_sym->curr.tri == no)
                                        type = S_BOOLEAN;
                                if (modules_sym->curr.tri == no)
                                        type = S_BOOLEAN;
+#endif
                        }
                        switch (type) {
                        case S_BOOLEAN:
                        }
                        switch (type) {
                        case S_BOOLEAN:
@@ -437,18 +439,12 @@ int conf_write(const char *name)
                                switch (sym_get_tristate_value(sym)) {
                                case no:
                                        fprintf(out, "# CONFIG_%s is not set\n", sym->name);
                                switch (sym_get_tristate_value(sym)) {
                                case no:
                                        fprintf(out, "# CONFIG_%s is not set\n", sym->name);
-                                       if (out_h)
-                                               fprintf(out_h, "#undef CONFIG_%s\n", sym->name);
                                        break;
                                case mod:
                                        fprintf(out, "CONFIG_%s=m\n", sym->name);
                                        break;
                                case mod:
                                        fprintf(out, "CONFIG_%s=m\n", sym->name);
-                                       if (out_h)
-                                               fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
                                        break;
                                case yes:
                                        fprintf(out, "CONFIG_%s=y\n", sym->name);
                                        break;
                                case yes:
                                        fprintf(out, "CONFIG_%s=y\n", sym->name);
-                                       if (out_h)
-                                               fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
                                        break;
                                }
                                break;
                                        break;
                                }
                                break;
@@ -456,40 +452,28 @@ int conf_write(const char *name)
                                // fix me
                                str = sym_get_string_value(sym);
                                fprintf(out, "CONFIG_%s=\"", sym->name);
                                // fix me
                                str = sym_get_string_value(sym);
                                fprintf(out, "CONFIG_%s=\"", sym->name);
-                               if (out_h)
-                                       fprintf(out_h, "#define CONFIG_%s \"", sym->name);
                                do {
                                        l = strcspn(str, "\"\\");
                                        if (l) {
                                                fwrite(str, l, 1, out);
                                do {
                                        l = strcspn(str, "\"\\");
                                        if (l) {
                                                fwrite(str, l, 1, out);
-                                               if (out_h)
-                                                       fwrite(str, l, 1, out_h);
                                        }
                                        str += l;
                                        while (*str == '\\' || *str == '"') {
                                                fprintf(out, "\\%c", *str);
                                        }
                                        str += l;
                                        while (*str == '\\' || *str == '"') {
                                                fprintf(out, "\\%c", *str);
-                                               if (out_h)
-                                                       fprintf(out_h, "\\%c", *str);
                                                str++;
                                        }
                                } while (*str);
                                fputs("\"\n", out);
                                                str++;
                                        }
                                } while (*str);
                                fputs("\"\n", out);
-                               if (out_h)
-                                       fputs("\"\n", out_h);
                                break;
                        case S_HEX:
                                str = sym_get_string_value(sym);
                                if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
                                        fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
                                break;
                        case S_HEX:
                                str = sym_get_string_value(sym);
                                if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
                                        fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
-                                       if (out_h)
-                                               fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
                                        break;
                                }
                        case S_INT:
                                str = sym_get_string_value(sym);
                                fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
                                        break;
                                }
                        case S_INT:
                                str = sym_get_string_value(sym);
                                fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
-                               if (out_h)
-                                       fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
                                break;
                        }
                }
                                break;
                        }
                }
@@ -509,11 +493,6 @@ int conf_write(const char *name)
                }
        }
        fclose(out);
                }
        }
        fclose(out);
-       if (out_h) {
-               fclose(out_h);
-               rename(".tmpconfig.h", "include/linux/autoconf.h");
-               file_write_dep(NULL);
-       }
        if (!name || basename != conf_def_filename) {
                if (!name)
                        name = conf_def_filename;
        if (!name || basename != conf_def_filename) {
                if (!name)
                        name = conf_def_filename;
This page took 0.031128 seconds and 4 git commands to generate.