1.1 --- a/kconfig/util.c Sat Feb 24 11:00:05 2007 +0000
1.2 +++ b/kconfig/util.c Sun Oct 26 11:26:46 2008 +0000
1.3 @@ -29,6 +29,8 @@
1.4 /* write a dependency file as used by kbuild to track dependencies */
1.5 int file_write_dep(const char *name)
1.6 {
1.7 + struct symbol *sym, *env_sym;
1.8 + struct expr *e;
1.9 struct file *file;
1.10 FILE *out;
1.11
1.12 @@ -45,8 +47,25 @@
1.13 fprintf(out, "\t%s\n", file->name);
1.14 }
1.15 fprintf(out, "\ninclude/config/auto.conf: \\\n"
1.16 - "\t$(deps_config)\n\n"
1.17 - "$(deps_config): ;\n");
1.18 + "\t$(deps_config)\n\n");
1.19 +
1.20 + expr_list_for_each_sym(sym_env_list, e, sym) {
1.21 + struct property *prop;
1.22 + const char *value;
1.23 +
1.24 + prop = sym_get_env_prop(sym);
1.25 + env_sym = prop_get_symbol(prop);
1.26 + if (!env_sym)
1.27 + continue;
1.28 + value = getenv(env_sym->name);
1.29 + if (!value)
1.30 + value = "";
1.31 + fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
1.32 + fprintf(out, "include/config/auto.conf: FORCE\n");
1.33 + fprintf(out, "endif\n");
1.34 + }
1.35 +
1.36 + fprintf(out, "\n$(deps_config): ;\n");
1.37 fclose(out);
1.38 rename("..config.tmp", name);
1.39 return 0;
1.40 @@ -58,7 +77,7 @@
1.41 {
1.42 struct gstr gs;
1.43 gs.s = malloc(sizeof(char) * 64);
1.44 - gs.len = 16;
1.45 + gs.len = 64;
1.46 strcpy(gs.s, "\0");
1.47 return gs;
1.48 }
1.49 @@ -84,12 +103,15 @@
1.50 /* Append to growable string */
1.51 void str_append(struct gstr *gs, const char *s)
1.52 {
1.53 - size_t l = strlen(gs->s) + strlen(s) + 1;
1.54 - if (l > gs->len) {
1.55 - gs->s = realloc(gs->s, l);
1.56 - gs->len = l;
1.57 + size_t l;
1.58 + if (s) {
1.59 + l = strlen(gs->s) + strlen(s) + 1;
1.60 + if (l > gs->len) {
1.61 + gs->s = realloc(gs->s, l);
1.62 + gs->len = l;
1.63 + }
1.64 + strcat(gs->s, s);
1.65 }
1.66 - strcat(gs->s, s);
1.67 }
1.68
1.69 /* Append printf formatted string to growable string */