X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fconfig%2Fconfdata.c;h=30517020d925aa6cdc7e66a5061fa908719ef978;hb=5d26126b9e8fd6c6f5098dbaa2e5b9e2901749bf;hp=fd3a345e268ab36532c8f725fd21d350ae3162fd;hpb=837f058fb307e0bcf7b9ad4f02a44ea3047f427e;p=oweals%2Fbusybox.git diff --git a/scripts/config/confdata.c b/scripts/config/confdata.c index fd3a345e2..30517020d 100644 --- a/scripts/config/confdata.c +++ b/scripts/config/confdata.c @@ -15,7 +15,7 @@ const char conf_def_filename[] = ".config"; -const char conf_defname[] = "sysdeps/linux/defconfig"; +const char conf_defname[] = "defconfig"; const char *conf_confnames[] = { ".config", @@ -102,8 +102,7 @@ int conf_read(const char *name) case S_INT: case S_HEX: case S_STRING: - if (sym->user.val) - free(sym->user.val); + free(sym->user.val); default: sym->user.val = NULL; sym->user.tri = no; @@ -255,6 +254,21 @@ int conf_read(const char *name) return 0; } +struct menu *next_menu(struct menu *menu) +{ + if (menu->list) return menu->list; + do { + if (menu->next) { + menu = menu->next; + break; + } + } while ((menu = menu->parent)); + + return menu; +} + +#define SYMBOL_FORCEWRITE (1<<31) + int conf_write(const char *name) { FILE *out, *out_h; @@ -265,6 +279,10 @@ int conf_write(const char *name) int type, l; const char *str; + /* busybox`s code */ + const char *opt_name; + int use_flg; + dirname[0] = 0; if (name && name[0]) { struct stat st; @@ -287,7 +305,7 @@ int conf_write(const char *name) } else basename = conf_def_filename; - sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); + sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid()); out = fopen(newname, "w"); if (!out) return 1; @@ -300,11 +318,13 @@ int conf_write(const char *name) fprintf(out, "#\n" "# Automatically generated make config: don't edit\n" "#\n"); + + /* busybox`s code */ if (out_h) { + fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n"); fprintf(out_h, "/*\n" " * Automatically generated header file: don't edit\n" " */\n\n" - "#define AUTOCONF_INCLUDED\n\n" "/* Version Number */\n" "#define BB_VER \"%s\"\n" "#define BB_BT \"%s\"\n", @@ -315,10 +335,17 @@ int conf_write(const char *name) getenv("EXTRA_VERSION")); fprintf(out_h, "\n"); } + /* end busybox`s code */ if (!sym_change_count) sym_clear_all_valid(); + /* Force write of all non-duplicate symbols. */ + + /* Write out everything by default. */ + for(menu = rootmenu.list; menu; menu = next_menu(menu)) + if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE; + menu = rootmenu.list; while (menu) { sym = menu->sym; @@ -337,15 +364,26 @@ int conf_write(const char *name) " */\n", str); } else if (!(sym->flags & SYMBOL_CHOICE)) { sym_calc_value(sym); - if (!(sym->flags & SYMBOL_WRITE)) + if (!(sym->flags & SYMBOL_FORCEWRITE)) goto next; - sym->flags &= ~SYMBOL_WRITE; + + sym->flags &= ~SYMBOL_FORCEWRITE; type = sym->type; if (type == S_TRISTATE) { sym_calc_value(modules_sym); if (modules_sym->curr.tri == no) type = S_BOOLEAN; } + + /* busybox`s code */ + opt_name = strchr(sym->name, '_'); + if(opt_name == NULL) + opt_name = sym->name; + else + opt_name++; + use_flg = 1; + /* end busybox`s code */ + switch (type) { case S_BOOLEAN: case S_TRISTATE: @@ -354,13 +392,14 @@ int conf_write(const char *name) fprintf(out, "# %s is not set\n", sym->name); if (out_h) fprintf(out_h, "#undef %s\n", sym->name); + use_flg = 0; /* busybox`s code */ break; case mod: -#if 0 +#if 0 /* busybox`s code */ fprintf(out, "%s=m\n", sym->name); if (out_h) fprintf(out_h, "#define %s_MODULE 1\n", sym->name); -#endif +#endif /* busybox`s code */ break; case yes: fprintf(out, "%s=y\n", sym->name); @@ -397,38 +436,36 @@ int conf_write(const char *name) case S_HEX: str = sym_get_string_value(sym); if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out, "%s=%s\n", sym->name, str); + fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); if (out_h) fprintf(out_h, "#define %s 0x%s\n", sym->name, str); break; } case S_INT: str = sym_get_string_value(sym); - fprintf(out, "%s=%s\n", sym->name, str); + fprintf(out, "%s=%s\n", sym->name, *str ? str : "0"); if (out_h) fprintf(out_h, "#define %s %s\n", sym->name, str); break; } - } - - next: - if (menu->list) { - menu = menu->list; - continue; - } - if (menu->next) - menu = menu->next; - else while ((menu = menu->parent)) { - if (menu->next) { - menu = menu->next; - break; + /* busybox`s code */ + if (out_h) { + fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg); + fprintf(out_h, "#define USE_%s(...)%s\n", opt_name, + (use_flg ? " __VA_ARGS__" : "")); + fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name, + (use_flg ? "" : " __VA_ARGS__")); } + /* end busybox`s code */ } +next: + menu = next_menu(menu); } fclose(out); if (out_h) { + fprintf(out_h, "#endif /* BB_CONFIG_H */\n"); /* busybox`s code */ fclose(out_h); - rename(".tmpconfig.h", "include/config.h"); + rename(".tmpconfig.h", "include/bb_config.h"); /* busybox`s config name */ file_write_dep(NULL); } if (!name || basename != conf_def_filename) {