3 confdata.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++---------------
4 util.c | 16 +++++++++++++--
5 3 files changed, 61 insertions(+), 18 deletions(-)
8 ===================================================================
15 - //zconfdump(stdout);
17 name = conf_get_configname();
18 if (stat(name, &tmpstat)) {
20 ===================================================================
33 const char *conf_get_autoconfig_name(void)
35 - char *name = getenv("KCONFIG_AUTOCONFIG");
37 - return name ? name : "include/config/auto.conf";
38 + return getenv("KCONFIG_AUTOCONFIG");
41 static char *conf_expand_value(const char *in)
43 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
47 + name = conf_get_configname();
50 if (name && name[0]) {
55 char path[PATH_MAX+1];
56 + char *opwd, *dir, *_name;
61 name = conf_get_autoconfig_name();
62 conf_read_simple(name, S_DEF_AUTO);
64 - if (chdir("include/config"))
67 + _name = strdup(name);
68 + if (opwd == NULL || _name == NULL)
70 + opwd = getcwd(opwd, 256);
71 + dir = dirname(_name);
82 for_all_symbols(i, sym) {
100 FILE *out, *tristate, *out_h;
102 + char dir[PATH_MAX+1], buf[PATH_MAX+1];
105 + strcpy(dir, conf_get_configname());
106 + s = strrchr(dir, '/');
112 sym_clear_all_valid();
114 - file_write_dep("include/config/auto.conf.cmd");
115 + sprintf(buf, "%s.config.cmd", dir);
116 + file_write_dep(buf);
118 if (conf_split_config())
121 - out = fopen(".tmpconfig", "w");
122 + sprintf(buf, "%s.tmpconfig", dir);
123 + out = fopen(buf, "w");
127 - tristate = fopen(".tmpconfig_tristate", "w");
128 + sprintf(buf, "%s.tmpconfig_tristate", dir);
129 + tristate = fopen(buf, "w");
135 - out_h = fopen(".tmpconfig.h", "w");
136 + sprintf(buf, "%s.tmpconfig.h", dir);
137 + out_h = fopen(buf, "w");
141 @@ -1000,19 +1030,22 @@
142 name = getenv("KCONFIG_AUTOHEADER");
144 name = "include/generated/autoconf.h";
145 - if (rename(".tmpconfig.h", name))
146 + sprintf(buf, "%s.tmpconfig.h", dir);
147 + if (rename(buf, name))
149 name = getenv("KCONFIG_TRISTATE");
151 name = "include/config/tristate.conf";
152 - if (rename(".tmpconfig_tristate", name))
153 + sprintf(buf, "%s.tmpconfig_tristate", dir);
154 + if (rename(buf, name))
156 name = conf_get_autoconfig_name();
158 * This must be the last step, kbuild has a dependency on auto.conf
159 * and this marks the successful completion of the previous steps.
161 - if (rename(".tmpconfig", name))
162 + sprintf(buf, "%s.tmpconfig", dir);
163 + if (rename(buf, name))
168 ===================================================================
172 /* write a dependency file as used by kbuild to track dependencies */
173 int file_write_dep(const char *name)
176 + char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1];
177 struct symbol *sym, *env_sym;
184 - out = fopen("..config.tmp", "w");
186 + strcpy(dir, conf_get_configname());
187 + str = strrchr(dir, '/');
193 + sprintf(buf, "%s..config.tmp", dir);
194 + out = fopen(buf, "w");
197 fprintf(out, "deps_config := \\\n");
200 fprintf(out, "\n$(deps_config): ;\n");
202 - rename("..config.tmp", name);
203 + sprintf(buf2, "%s%s", dir, name);