-rw-r--r-- | scripts/kconfig/confdata.c | 152 |
1 files changed, 98 insertions, 54 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 9bf7af9..f3796ce 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -1,378 +1,422 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <sys/stat.h> | 6 | #include <sys/stat.h> |
7 | #include <ctype.h> | 7 | #include <ctype.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <unistd.h> | 11 | #include <unistd.h> |
12 | 12 | ||
13 | #define LKC_DIRECT_LINK | 13 | #define LKC_DIRECT_LINK |
14 | #include "lkc.h" | 14 | #include "lkc.h" |
15 | 15 | ||
16 | const char conf_def_filename[] = ".config"; | 16 | const char conf_def_filename[] = ".config"; |
17 | 17 | ||
18 | const char conf_defname[] = "arch/$ARCH/defconfig"; | 18 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
19 | 19 | ||
20 | const char *conf_confnames[] = { | 20 | const char *conf_confnames[] = { |
21 | ".config", | 21 | ".config", |
22 | "/lib/modules/$UNAME_RELEASE/.config", | ||
23 | "/etc/kernel-config", | ||
24 | "/boot/config-$UNAME_RELEASE", | ||
25 | conf_defname, | 22 | conf_defname, |
26 | NULL, | 23 | NULL, |
27 | }; | 24 | }; |
28 | 25 | ||
29 | static char *conf_expand_value(const char *in) | 26 | static char *conf_expand_value(const char *in) |
30 | { | 27 | { |
31 | struct symbol *sym; | 28 | struct symbol *sym; |
32 | const char *src; | 29 | const char *src; |
33 | static char res_value[SYMBOL_MAXLENGTH]; | 30 | static char res_value[SYMBOL_MAXLENGTH]; |
34 | char *dst, name[SYMBOL_MAXLENGTH]; | 31 | char *dst, name[SYMBOL_MAXLENGTH]; |
35 | 32 | ||
36 | res_value[0] = 0; | 33 | res_value[0] = 0; |
37 | dst = name; | 34 | dst = name; |
38 | while ((src = strchr(in, '$'))) { | 35 | while ((src = strchr(in, '$'))) { |
39 | strncat(res_value, in, src - in); | 36 | strncat(res_value, in, src - in); |
40 | src++; | 37 | src++; |
41 | dst = name; | 38 | dst = name; |
42 | while (isalnum(*src) || *src == '_') | 39 | while (isalnum(*src) || *src == '_') |
43 | *dst++ = *src++; | 40 | *dst++ = *src++; |
44 | *dst = 0; | 41 | *dst = 0; |
45 | sym = sym_lookup(name, 0); | 42 | sym = sym_lookup(name, 0); |
46 | sym_calc_value(sym); | 43 | sym_calc_value(sym); |
47 | strcat(res_value, sym_get_string_value(sym)); | 44 | strcat(res_value, sym_get_string_value(sym)); |
48 | in = src; | 45 | in = src; |
49 | } | 46 | } |
50 | strcat(res_value, in); | 47 | strcat(res_value, in); |
51 | 48 | ||
52 | return res_value; | 49 | return res_value; |
53 | } | 50 | } |
54 | 51 | ||
55 | char *conf_get_default_confname(void) | 52 | char *conf_get_default_confname(void) |
56 | { | 53 | { |
57 | struct stat buf; | 54 | struct stat buf; |
58 | static char fullname[PATH_MAX+1]; | 55 | static char fullname[PATH_MAX+1]; |
59 | char *env, *name; | 56 | char *env, *name; |
60 | 57 | ||
61 | name = conf_expand_value(conf_defname); | 58 | name = conf_expand_value(conf_defname); |
62 | env = getenv(SRCTREE); | 59 | env = getenv(SRCTREE); |
63 | if (env) { | 60 | if (env) { |
64 | sprintf(fullname, "%s/%s", env, name); | 61 | sprintf(fullname, "%s/%s", env, name); |
65 | if (!stat(fullname, &buf)) | 62 | if (!stat(fullname, &buf)) |
66 | return fullname; | 63 | return fullname; |
67 | } | 64 | } |
68 | return name; | 65 | return name; |
69 | } | 66 | } |
70 | 67 | ||
71 | int conf_read(const char *name) | 68 | int conf_read(const char *name) |
72 | { | 69 | { |
73 | FILE *in = NULL; | 70 | FILE *in = NULL; |
74 | char line[1024]; | 71 | char line[1024]; |
75 | char *p, *p2; | 72 | char *p, *p2; |
76 | int lineno = 0; | 73 | int lineno = 0; |
77 | struct symbol *sym; | 74 | struct symbol *sym; |
78 | struct property *prop; | 75 | struct property *prop; |
79 | struct expr *e; | 76 | struct expr *e; |
80 | int i; | 77 | int i; |
81 | 78 | ||
82 | if (name) { | 79 | if (name) { |
83 | in = zconf_fopen(name); | 80 | in = zconf_fopen(name); |
84 | } else { | 81 | } else { |
85 | const char **names = conf_confnames; | 82 | const char **names = conf_confnames; |
86 | while ((name = *names++)) { | 83 | while ((name = *names++)) { |
87 | name = conf_expand_value(name); | 84 | name = conf_expand_value(name); |
88 | in = zconf_fopen(name); | 85 | in = zconf_fopen(name); |
89 | if (in) { | 86 | if (in) { |
90 | printf("#\n" | 87 | printf("#\n" |
91 | "# using defaults found in %s\n" | 88 | "# using defaults found in %s\n" |
92 | "#\n", name); | 89 | "#\n", name); |
93 | break; | 90 | break; |
94 | } | 91 | } |
95 | } | 92 | } |
96 | } | 93 | } |
97 | 94 | ||
98 | if (!in) | 95 | if (!in) |
99 | return 1; | 96 | return 1; |
100 | 97 | ||
101 | for_all_symbols(i, sym) { | 98 | for_all_symbols(i, sym) { |
102 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; | 99 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; |
103 | sym->flags &= ~SYMBOL_VALID; | 100 | sym->flags &= ~SYMBOL_VALID; |
104 | switch (sym->type) { | 101 | switch (sym->type) { |
105 | case S_INT: | 102 | case S_INT: |
106 | case S_HEX: | 103 | case S_HEX: |
107 | case S_STRING: | 104 | case S_STRING: |
108 | if (S_VAL(sym->def)) | 105 | if (sym->user.val) |
109 | free(S_VAL(sym->def)); | 106 | free(sym->user.val); |
110 | default: | 107 | default: |
111 | S_VAL(sym->def) = NULL; | 108 | sym->user.val = NULL; |
112 | S_TRI(sym->def) = no; | 109 | sym->user.tri = no; |
113 | } | 110 | } |
114 | } | 111 | } |
115 | 112 | ||
116 | while (fgets(line, sizeof(line), in)) { | 113 | while (fgets(line, sizeof(line), in)) { |
117 | lineno++; | 114 | lineno++; |
118 | switch (line[0]) { | 115 | switch (line[0]) { |
119 | case '#': | 116 | case '#': |
120 | if (memcmp(line + 2, "CONFIG_", 7)) | 117 | if (memcmp(line + 2, "CONFIG_", 7)) |
121 | continue; | 118 | continue; |
122 | p = strchr(line + 9, ' '); | 119 | p = strchr(line + 9, ' '); |
123 | if (!p) | 120 | if (!p) |
124 | continue; | 121 | continue; |
125 | *p++ = 0; | 122 | *p++ = 0; |
126 | if (strncmp(p, "is not set", 10)) | 123 | if (strncmp(p, "is not set", 10)) |
127 | continue; | 124 | continue; |
128 | sym = sym_lookup(line + 9, 0); | 125 | sym = sym_lookup(line + 9, 0); |
129 | switch (sym->type) { | 126 | switch (sym->type) { |
130 | case S_BOOLEAN: | 127 | case S_BOOLEAN: |
131 | case S_TRISTATE: | 128 | case S_TRISTATE: |
132 | sym->def = symbol_no.curr; | 129 | sym->user = symbol_no.curr; |
133 | sym->flags &= ~SYMBOL_NEW; | 130 | sym->flags &= ~SYMBOL_NEW; |
134 | break; | 131 | break; |
135 | default: | 132 | default: |
136 | ; | 133 | ; |
137 | } | 134 | } |
138 | break; | 135 | break; |
139 | case 'C': | 136 | case 'C': |
140 | if (memcmp(line, "CONFIG_", 7)) | 137 | if (memcmp(line, "CONFIG_", 7)) |
141 | continue; | 138 | continue; |
142 | p = strchr(line + 7, '='); | 139 | p = strchr(line + 7, '='); |
143 | if (!p) | 140 | if (!p) |
144 | continue; | 141 | continue; |
145 | *p++ = 0; | 142 | *p++ = 0; |
146 | p2 = strchr(p, '\n'); | 143 | p2 = strchr(p, '\n'); |
147 | if (p2) | 144 | if (p2) |
148 | *p2 = 0; | 145 | *p2 = 0; |
149 | sym = sym_find(line + 7); | 146 | sym = sym_find(line + 7); |
150 | if (!sym) { | 147 | if (!sym) { |
151 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); | 148 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); |
152 | break; | 149 | break; |
153 | } | 150 | } |
154 | switch (sym->type) { | 151 | switch (sym->type) { |
155 | case S_TRISTATE: | 152 | case S_TRISTATE: |
156 | if (p[0] == 'm') { | 153 | if (p[0] == 'm') { |
157 | S_TRI(sym->def) = mod; | 154 | sym->user.tri = mod; |
158 | sym->flags &= ~SYMBOL_NEW; | 155 | sym->flags &= ~SYMBOL_NEW; |
159 | break; | 156 | break; |
160 | } | 157 | } |
161 | case S_BOOLEAN: | 158 | case S_BOOLEAN: |
162 | if (p[0] == 'y') { | 159 | if (p[0] == 'y') { |
163 | S_TRI(sym->def) = yes; | 160 | sym->user.tri = yes; |
164 | sym->flags &= ~SYMBOL_NEW; | 161 | sym->flags &= ~SYMBOL_NEW; |
165 | break; | 162 | break; |
166 | } | 163 | } |
167 | if (p[0] == 'n') { | 164 | if (p[0] == 'n') { |
168 | S_TRI(sym->def) = no; | 165 | sym->user.tri = no; |
169 | sym->flags &= ~SYMBOL_NEW; | 166 | sym->flags &= ~SYMBOL_NEW; |
170 | break; | 167 | break; |
171 | } | 168 | } |
172 | break; | 169 | break; |
173 | case S_STRING: | 170 | case S_STRING: |
174 | if (*p++ != '"') | 171 | if (*p++ != '"') |
175 | break; | 172 | break; |
176 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { | 173 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { |
177 | if (*p2 == '"') { | 174 | if (*p2 == '"') { |
178 | *p2 = 0; | 175 | *p2 = 0; |
179 | break; | 176 | break; |
180 | } | 177 | } |
181 | memmove(p2, p2 + 1, strlen(p2)); | 178 | memmove(p2, p2 + 1, strlen(p2)); |
182 | } | 179 | } |
183 | if (!p2) { | 180 | if (!p2) { |
184 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); | 181 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); |
185 | exit(1); | 182 | exit(1); |
186 | } | 183 | } |
187 | case S_INT: | 184 | case S_INT: |
188 | case S_HEX: | 185 | case S_HEX: |
189 | if (sym_string_valid(sym, p)) { | 186 | if (sym_string_valid(sym, p)) { |
190 | S_VAL(sym->def) = strdup(p); | 187 | sym->user.val = strdup(p); |
191 | sym->flags &= ~SYMBOL_NEW; | 188 | sym->flags &= ~SYMBOL_NEW; |
192 | } else { | 189 | } else { |
193 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); | 190 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); |
194 | exit(1); | 191 | exit(1); |
195 | } | 192 | } |
196 | break; | 193 | break; |
197 | default: | 194 | default: |
198 | ; | 195 | ; |
199 | } | 196 | } |
200 | if (sym_is_choice_value(sym)) { | 197 | if (sym_is_choice_value(sym)) { |
201 | prop = sym_get_choice_prop(sym); | 198 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); |
202 | switch (S_TRI(sym->def)) { | 199 | switch (sym->user.tri) { |
203 | case mod: | 200 | case mod: |
204 | if (S_TRI(prop->def->def) == yes) | 201 | if (cs->user.tri == yes) |
205 | /* warn? */; | 202 | /* warn? */; |
206 | break; | 203 | break; |
207 | case yes: | 204 | case yes: |
208 | if (S_TRI(prop->def->def) != no) | 205 | if (cs->user.tri != no) |
209 | /* warn? */; | 206 | /* warn? */; |
210 | S_VAL(prop->def->def) = sym; | 207 | cs->user.val = sym; |
211 | break; | 208 | break; |
212 | case no: | 209 | case no: |
213 | break; | 210 | break; |
214 | } | 211 | } |
215 | S_TRI(prop->def->def) = S_TRI(sym->def); | 212 | cs->user.tri = sym->user.tri; |
216 | } | 213 | } |
217 | break; | 214 | break; |
218 | case '\n': | 215 | case '\n': |
219 | break; | 216 | break; |
220 | default: | 217 | default: |
221 | continue; | 218 | continue; |
222 | } | 219 | } |
223 | } | 220 | } |
224 | fclose(in); | 221 | fclose(in); |
225 | 222 | ||
226 | for_all_symbols(i, sym) { | 223 | for_all_symbols(i, sym) { |
224 | sym_calc_value(sym); | ||
225 | if (sym_has_value(sym)) { | ||
226 | if (sym->visible == no) | ||
227 | sym->flags |= SYMBOL_NEW; | ||
228 | switch (sym->type) { | ||
229 | case S_STRING: | ||
230 | case S_INT: | ||
231 | case S_HEX: | ||
232 | if (!sym_string_within_range(sym, sym->user.val)) | ||
233 | sym->flags |= SYMBOL_NEW; | ||
234 | default: | ||
235 | break; | ||
236 | } | ||
237 | } | ||
227 | if (!sym_is_choice(sym)) | 238 | if (!sym_is_choice(sym)) |
228 | continue; | 239 | continue; |
229 | prop = sym_get_choice_prop(sym); | 240 | prop = sym_get_choice_prop(sym); |
230 | sym->flags &= ~SYMBOL_NEW; | 241 | sym->flags &= ~SYMBOL_NEW; |
231 | for (e = prop->dep; e; e = e->left.expr) | 242 | for (e = prop->expr; e; e = e->left.expr) |
232 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; | 243 | if (e->right.sym->visible != no) |
244 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; | ||
233 | } | 245 | } |
234 | 246 | ||
235 | sym_change_count = 1; | 247 | sym_change_count = 1; |
236 | 248 | ||
237 | return 0; | 249 | return 0; |
238 | } | 250 | } |
239 | 251 | ||
240 | int conf_write(const char *name) | 252 | int conf_write(const char *name) |
241 | { | 253 | { |
242 | FILE *out, *out_h; | 254 | FILE *out, *out_h; |
243 | struct symbol *sym; | 255 | struct symbol *sym; |
244 | struct menu *menu; | 256 | struct menu *menu; |
245 | char oldname[128]; | 257 | const char *basename; |
258 | char dirname[128], tmpname[128], newname[128]; | ||
246 | int type, l; | 259 | int type, l; |
247 | const char *str; | 260 | const char *str; |
248 | 261 | ||
249 | out = fopen(".tmpconfig", "w"); | 262 | dirname[0] = 0; |
263 | if (name && name[0]) { | ||
264 | char *slash = strrchr(name, '/'); | ||
265 | if (slash) { | ||
266 | int size = slash - name + 1; | ||
267 | memcpy(dirname, name, size); | ||
268 | dirname[size] = 0; | ||
269 | if (slash[1]) | ||
270 | basename = slash + 1; | ||
271 | else | ||
272 | basename = conf_def_filename; | ||
273 | } else | ||
274 | basename = name; | ||
275 | } else | ||
276 | basename = conf_def_filename; | ||
277 | |||
278 | sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); | ||
279 | out = fopen(newname, "w"); | ||
250 | if (!out) | 280 | if (!out) |
251 | return 1; | 281 | return 1; |
252 | out_h = fopen(".tmpconfig.h", "w"); | 282 | out_h = NULL; |
253 | if (!out_h) | 283 | if (!name) { |
254 | return 1; | 284 | out_h = fopen(".tmpconfig.h", "w"); |
285 | if (!out_h) | ||
286 | return 1; | ||
287 | } | ||
255 | fprintf(out, "#\n" | 288 | fprintf(out, "#\n" |
256 | "# Automatically generated make config: don't edit\n" | 289 | "# Automatically generated make config: don't edit\n" |
257 | "#\n"); | 290 | "#\n"); |
258 | fprintf(out_h, "/*\n" | 291 | if (out_h) |
259 | " * Automatically generated C config: don't edit\n" | 292 | fprintf(out_h, "/*\n" |
260 | " */\n" | 293 | " * Automatically generated C config: don't edit\n" |
261 | "#define AUTOCONF_INCLUDED\n"); | 294 | " */\n" |
295 | "#define AUTOCONF_INCLUDED\n"); | ||
262 | 296 | ||
263 | if (!sym_change_count) | 297 | if (!sym_change_count) |
264 | sym_clear_all_valid(); | 298 | sym_clear_all_valid(); |
265 | 299 | ||
266 | menu = rootmenu.list; | 300 | menu = rootmenu.list; |
267 | while (menu) { | 301 | while (menu) { |
268 | sym = menu->sym; | 302 | sym = menu->sym; |
269 | if (!sym) { | 303 | if (!sym) { |
270 | if (!menu_is_visible(menu)) | 304 | if (!menu_is_visible(menu)) |
271 | goto next; | 305 | goto next; |
272 | str = menu_get_prompt(menu); | 306 | str = menu_get_prompt(menu); |
273 | fprintf(out, "\n" | 307 | fprintf(out, "\n" |
274 | "#\n" | 308 | "#\n" |
275 | "# %s\n" | 309 | "# %s\n" |
276 | "#\n", str); | 310 | "#\n", str); |
277 | fprintf(out_h, "\n" | 311 | if (out_h) |
278 | "/*\n" | 312 | fprintf(out_h, "\n" |
279 | " * %s\n" | 313 | "/*\n" |
280 | " */\n", str); | 314 | " * %s\n" |
315 | " */\n", str); | ||
281 | } else if (!(sym->flags & SYMBOL_CHOICE)) { | 316 | } else if (!(sym->flags & SYMBOL_CHOICE)) { |
282 | sym_calc_value(sym); | 317 | sym_calc_value(sym); |
283 | if (!(sym->flags & SYMBOL_WRITE)) | 318 | if (!(sym->flags & SYMBOL_WRITE)) |
284 | goto next; | 319 | goto next; |
285 | sym->flags &= ~SYMBOL_WRITE; | 320 | sym->flags &= ~SYMBOL_WRITE; |
286 | type = sym->type; | 321 | type = sym->type; |
287 | if (type == S_TRISTATE) { | 322 | if (type == S_TRISTATE) { |
288 | sym_calc_value(modules_sym); | 323 | sym_calc_value(modules_sym); |
289 | if (S_TRI(modules_sym->curr) == no) | 324 | if (modules_sym->curr.tri == no) |
290 | type = S_BOOLEAN; | 325 | type = S_BOOLEAN; |
291 | } | 326 | } |
292 | switch (type) { | 327 | switch (type) { |
293 | case S_BOOLEAN: | 328 | case S_BOOLEAN: |
294 | case S_TRISTATE: | 329 | case S_TRISTATE: |
295 | switch (sym_get_tristate_value(sym)) { | 330 | switch (sym_get_tristate_value(sym)) { |
296 | case no: | 331 | case no: |
297 | fprintf(out, "# CONFIG_%s is not set\n", sym->name); | 332 | fprintf(out, "# CONFIG_%s is not set\n", sym->name); |
298 | fprintf(out_h, "#undef CONFIG_%s\n", sym->name); | 333 | if (out_h) |
334 | fprintf(out_h, "#undef CONFIG_%s\n", sym->name); | ||
299 | break; | 335 | break; |
300 | case mod: | 336 | case mod: |
301 | fprintf(out, "CONFIG_%s=m\n", sym->name); | 337 | fprintf(out, "CONFIG_%s=m\n", sym->name); |
302 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); | 338 | if (out_h) |
339 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); | ||
303 | break; | 340 | break; |
304 | case yes: | 341 | case yes: |
305 | fprintf(out, "CONFIG_%s=y\n", sym->name); | 342 | fprintf(out, "CONFIG_%s=y\n", sym->name); |
306 | fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); | 343 | if (out_h) |
344 | fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); | ||
307 | break; | 345 | break; |
308 | } | 346 | } |
309 | break; | 347 | break; |
310 | case S_STRING: | 348 | case S_STRING: |
311 | // fix me | 349 | // fix me |
312 | str = sym_get_string_value(sym); | 350 | str = sym_get_string_value(sym); |
313 | fprintf(out, "CONFIG_%s=\"", sym->name); | 351 | fprintf(out, "CONFIG_%s=\"", sym->name); |
314 | fprintf(out_h, "#define CONFIG_%s \"", sym->name); | 352 | if (out_h) |
353 | fprintf(out_h, "#define CONFIG_%s \"", sym->name); | ||
315 | do { | 354 | do { |
316 | l = strcspn(str, "\"\\"); | 355 | l = strcspn(str, "\"\\"); |
317 | if (l) { | 356 | if (l) { |
318 | fwrite(str, l, 1, out); | 357 | fwrite(str, l, 1, out); |
319 | fwrite(str, l, 1, out_h); | 358 | if (out_h) |
359 | fwrite(str, l, 1, out_h); | ||
320 | } | 360 | } |
321 | str += l; | 361 | str += l; |
322 | while (*str == '\\' || *str == '"') { | 362 | while (*str == '\\' || *str == '"') { |
323 | fprintf(out, "\\%c", *str); | 363 | fprintf(out, "\\%c", *str); |
324 | fprintf(out_h, "\\%c", *str); | 364 | if (out_h) |
365 | fprintf(out_h, "\\%c", *str); | ||
325 | str++; | 366 | str++; |
326 | } | 367 | } |
327 | } while (*str); | 368 | } while (*str); |
328 | fputs("\"\n", out); | 369 | fputs("\"\n", out); |
329 | fputs("\"\n", out_h); | 370 | if (out_h) |
371 | fputs("\"\n", out_h); | ||
330 | break; | 372 | break; |
331 | case S_HEX: | 373 | case S_HEX: |
332 | str = sym_get_string_value(sym); | 374 | str = sym_get_string_value(sym); |
333 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | 375 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { |
334 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | 376 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); |
335 | fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); | 377 | if (out_h) |
378 | fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); | ||
336 | break; | 379 | break; |
337 | } | 380 | } |
338 | case S_INT: | 381 | case S_INT: |
339 | str = sym_get_string_value(sym); | 382 | str = sym_get_string_value(sym); |
340 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | 383 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); |
341 | fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); | 384 | if (out_h) |
385 | fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); | ||
342 | break; | 386 | break; |
343 | } | 387 | } |
344 | } | 388 | } |
345 | 389 | ||
346 | next: | 390 | next: |
347 | if (menu->list) { | 391 | if (menu->list) { |
348 | menu = menu->list; | 392 | menu = menu->list; |
349 | continue; | 393 | continue; |
350 | } | 394 | } |
351 | if (menu->next) | 395 | if (menu->next) |
352 | menu = menu->next; | 396 | menu = menu->next; |
353 | else while ((menu = menu->parent)) { | 397 | else while ((menu = menu->parent)) { |
354 | if (menu->next) { | 398 | if (menu->next) { |
355 | menu = menu->next; | 399 | menu = menu->next; |
356 | break; | 400 | break; |
357 | } | 401 | } |
358 | } | 402 | } |
359 | } | 403 | } |
360 | fclose(out); | 404 | fclose(out); |
361 | fclose(out_h); | 405 | if (out_h) { |
362 | 406 | fclose(out_h); | |
363 | if (!name) { | ||
364 | rename(".tmpconfig.h", "include/linux/autoconf.h"); | 407 | rename(".tmpconfig.h", "include/linux/autoconf.h"); |
365 | name = conf_def_filename; | 408 | } |
366 | file_write_dep(NULL); | 409 | if (!name || basename != conf_def_filename) { |
367 | } else | 410 | if (!name) |
368 | unlink(".tmpconfig.h"); | 411 | name = conf_def_filename; |
369 | 412 | sprintf(tmpname, "%s.old", name); | |
370 | sprintf(oldname, "%s.old", name); | 413 | rename(name, tmpname); |
371 | rename(name, oldname); | 414 | } |
372 | if (rename(".tmpconfig", name)) | 415 | sprintf(tmpname, "%s%s", dirname, basename); |
416 | if (rename(newname, tmpname)) | ||
373 | return 1; | 417 | return 1; |
374 | 418 | ||
375 | sym_change_count = 0; | 419 | sym_change_count = 0; |
376 | 420 | ||
377 | return 0; | 421 | return 0; |
378 | } | 422 | } |