summaryrefslogtreecommitdiff
path: root/scripts/kconfig/confdata.c
authorkergoth <kergoth>2003-06-17 17:03:49 (UTC)
committer kergoth <kergoth>2003-06-17 17:03:49 (UTC)
commit16e53b2a2e94742f3b55ee73700bb264e36638d4 (patch) (unidiff)
tree4f2b65a635d25c1ce0cfeea7953623c2bf7d9534 /scripts/kconfig/confdata.c
parent384b7f1a42f9f2f101dc8fe11c3625055d96f672 (diff)
downloadopie-16e53b2a2e94742f3b55ee73700bb264e36638d4.zip
opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.gz
opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.bz2
Update LinuxKernelConf version to 1.4.
Diffstat (limited to 'scripts/kconfig/confdata.c') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/kconfig/confdata.c152
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
@@ -19,9 +19,6 @@ const char conf_defname[] = "arch/$ARCH/defconfig";
19 19
20const char *conf_confnames[] = { 20const 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};
@@ -105,11 +102,11 @@ int conf_read(const char *name)
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
@@ -129,7 +126,7 @@ int conf_read(const char *name)
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:
@@ -154,18 +151,18 @@ int conf_read(const char *name)
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 }
@@ -187,7 +184,7 @@ int conf_read(const char *name)
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);
@@ -198,21 +195,21 @@ int conf_read(const char *name)
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':
@@ -224,12 +221,27 @@ int conf_read(const char *name)
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;
@@ -242,23 +254,45 @@ int conf_write(const char *name)
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();
@@ -274,10 +308,11 @@ int conf_write(const char *name)
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))
@@ -286,7 +321,7 @@ int conf_write(const char *name)
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) {
@@ -295,15 +330,18 @@ int conf_write(const char *name)
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;
@@ -311,34 +349,40 @@ int conf_write(const char *name)
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 }
@@ -358,18 +402,18 @@ int conf_write(const char *name)
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;