aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-06-09 01:12:39 -0400
committerSam Ravnborg <sam@mars.ravnborg.org>2006-06-09 01:31:30 -0400
commitc955ccafc38e77312b4c65e5a70960080fb8a3f2 (patch)
treef630610edef42b8ed60c455cfdb74d897190f1d3 /scripts/kconfig
parentddc97cacb310ad68483952e67764c4153c138ed2 (diff)
kconfig: fix .config dependencies
This fixes one of the worst kbuild warts left - the broken dependencies used to check and regenerate the .config file. This was done via an indirect dependency and the .config itself had an empty command, which can cause make not to reread the changed .config file. Instead of this we generate now a new file include/config/auto.conf from .config, which is used for kbuild and has the proper dependencies. It's also the main make target now for all files generated during this step (and thus replaces include/linux/autoconf.h). This also means we can now relax the syntax requirements for the .config file and we don't have to rewrite it all the time, i.e. silentoldconfig only writes .config now when it's necessary to keep it in sync with the Kconfig files and even this can be suppressed by setting the environment variable KCONFIG_NOSILENTUPDATE, so the update can (and must) be done manually. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/conf.c16
-rw-r--r--scripts/kconfig/confdata.c177
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rw-r--r--scripts/kconfig/util.c4
4 files changed, 143 insertions, 55 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 8012d1076876..9334da65f364 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -599,7 +599,15 @@ int main(int ac, char **av)
599 input_mode = ask_silent; 599 input_mode = ask_silent;
600 valid_stdin = 1; 600 valid_stdin = 1;
601 } 601 }
602 } 602 } else if (sym_change_count) {
603 name = getenv("KCONFIG_NOSILENTUPDATE");
604 if (name && *name) {
605 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
606 return 1;
607 }
608 } else
609 goto skip_check;
610
603 do { 611 do {
604 conf_cnt = 0; 612 conf_cnt = 0;
605 check_conf(&rootmenu); 613 check_conf(&rootmenu);
@@ -608,5 +616,11 @@ int main(int ac, char **av)
608 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 616 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
609 return 1; 617 return 1;
610 } 618 }
619skip_check:
620 if (input_mode == ask_silent && conf_write_autoconf()) {
621 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
622 return 1;
623 }
624
611 return 0; 625 return 0;
612} 626}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index a9e3b6abf661..2da4a8d775a5 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -342,7 +342,7 @@ int conf_read(const char *name)
342 342
343int conf_write(const char *name) 343int conf_write(const char *name)
344{ 344{
345 FILE *out, *out_h; 345 FILE *out;
346 struct symbol *sym; 346 struct symbol *sym;
347 struct menu *menu; 347 struct menu *menu;
348 const char *basename; 348 const char *basename;
@@ -379,13 +379,6 @@ int conf_write(const char *name)
379 out = fopen(newname, "w"); 379 out = fopen(newname, "w");
380 if (!out) 380 if (!out)
381 return 1; 381 return 1;
382 out_h = NULL;
383 if (!name) {
384 out_h = fopen(".tmpconfig.h", "w");
385 if (!out_h)
386 return 1;
387 file_write_dep(NULL);
388 }
389 sym = sym_lookup("KERNELVERSION", 0); 382 sym = sym_lookup("KERNELVERSION", 0);
390 sym_calc_value(sym); 383 sym_calc_value(sym);
391 time(&now); 384 time(&now);
@@ -401,16 +394,6 @@ int conf_write(const char *name)
401 sym_get_string_value(sym), 394 sym_get_string_value(sym),
402 use_timestamp ? "# " : "", 395 use_timestamp ? "# " : "",
403 use_timestamp ? ctime(&now) : ""); 396 use_timestamp ? ctime(&now) : "");
404 if (out_h)
405 fprintf(out_h, "/*\n"
406 " * Automatically generated C config: don't edit\n"
407 " * Linux kernel version: %s\n"
408 "%s%s"
409 " */\n"
410 "#define AUTOCONF_INCLUDED\n",
411 sym_get_string_value(sym),
412 use_timestamp ? " * " : "",
413 use_timestamp ? ctime(&now) : "");
414 397
415 if (!sym_change_count) 398 if (!sym_change_count)
416 sym_clear_all_valid(); 399 sym_clear_all_valid();
@@ -426,11 +409,6 @@ int conf_write(const char *name)
426 "#\n" 409 "#\n"
427 "# %s\n" 410 "# %s\n"
428 "#\n", str); 411 "#\n", str);
429 if (out_h)
430 fprintf(out_h, "\n"
431 "/*\n"
432 " * %s\n"
433 " */\n", str);
434 } else if (!(sym->flags & SYMBOL_CHOICE)) { 412 } else if (!(sym->flags & SYMBOL_CHOICE)) {
435 sym_calc_value(sym); 413 sym_calc_value(sym);
436 if (!(sym->flags & SYMBOL_WRITE)) 414 if (!(sym->flags & SYMBOL_WRITE))
@@ -448,59 +426,39 @@ int conf_write(const char *name)
448 switch (sym_get_tristate_value(sym)) { 426 switch (sym_get_tristate_value(sym)) {
449 case no: 427 case no:
450 fprintf(out, "# CONFIG_%s is not set\n", sym->name); 428 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
451 if (out_h)
452 fprintf(out_h, "#undef CONFIG_%s\n", sym->name);
453 break; 429 break;
454 case mod: 430 case mod:
455 fprintf(out, "CONFIG_%s=m\n", sym->name); 431 fprintf(out, "CONFIG_%s=m\n", sym->name);
456 if (out_h)
457 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
458 break; 432 break;
459 case yes: 433 case yes:
460 fprintf(out, "CONFIG_%s=y\n", sym->name); 434 fprintf(out, "CONFIG_%s=y\n", sym->name);
461 if (out_h)
462 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
463 break; 435 break;
464 } 436 }
465 break; 437 break;
466 case S_STRING: 438 case S_STRING:
467 // fix me
468 str = sym_get_string_value(sym); 439 str = sym_get_string_value(sym);
469 fprintf(out, "CONFIG_%s=\"", sym->name); 440 fprintf(out, "CONFIG_%s=\"", sym->name);
470 if (out_h) 441 while (1) {
471 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
472 do {
473 l = strcspn(str, "\"\\"); 442 l = strcspn(str, "\"\\");
474 if (l) { 443 if (l) {
475 fwrite(str, l, 1, out); 444 fwrite(str, l, 1, out);
476 if (out_h) 445 str += l;
477 fwrite(str, l, 1, out_h);
478 }
479 str += l;
480 while (*str == '\\' || *str == '"') {
481 fprintf(out, "\\%c", *str);
482 if (out_h)
483 fprintf(out_h, "\\%c", *str);
484 str++;
485 } 446 }
486 } while (*str); 447 if (!*str)
448 break;
449 fprintf(out, "\\%c", *str++);
450 }
487 fputs("\"\n", out); 451 fputs("\"\n", out);
488 if (out_h)
489 fputs("\"\n", out_h);
490 break; 452 break;
491 case S_HEX: 453 case S_HEX:
492 str = sym_get_string_value(sym); 454 str = sym_get_string_value(sym);
493 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 455 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
494 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 456 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
495 if (out_h)
496 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
497 break; 457 break;
498 } 458 }
499 case S_INT: 459 case S_INT:
500 str = sym_get_string_value(sym); 460 str = sym_get_string_value(sym);
501 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 461 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
502 if (out_h)
503 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
504 break; 462 break;
505 } 463 }
506 } 464 }
@@ -520,10 +478,6 @@ int conf_write(const char *name)
520 } 478 }
521 } 479 }
522 fclose(out); 480 fclose(out);
523 if (out_h) {
524 fclose(out_h);
525 rename(".tmpconfig.h", "include/linux/autoconf.h");
526 }
527 if (!name || basename != conf_def_filename) { 481 if (!name || basename != conf_def_filename) {
528 if (!name) 482 if (!name)
529 name = conf_def_filename; 483 name = conf_def_filename;
@@ -542,3 +496,120 @@ int conf_write(const char *name)
542 496
543 return 0; 497 return 0;
544} 498}
499
500int conf_write_autoconf(void)
501{
502 struct symbol *sym;
503 const char *str;
504 char *name;
505 FILE *out, *out_h;
506 time_t now;
507 int i, l;
508
509 file_write_dep("include/config/auto.conf.cmd");
510
511 out = fopen(".tmpconfig", "w");
512 if (!out)
513 return 1;
514
515 out_h = fopen(".tmpconfig.h", "w");
516 if (!out_h) {
517 fclose(out);
518 return 1;
519 }
520
521 sym = sym_lookup("KERNELVERSION", 0);
522 sym_calc_value(sym);
523 time(&now);
524 fprintf(out, "#\n"
525 "# Automatically generated make config: don't edit\n"
526 "# Linux kernel version: %s\n"
527 "# %s"
528 "#\n",
529 sym_get_string_value(sym), ctime(&now));
530 fprintf(out_h, "/*\n"
531 " * Automatically generated C config: don't edit\n"
532 " * Linux kernel version: %s\n"
533 " * %s"
534 " */\n"
535 "#define AUTOCONF_INCLUDED\n",
536 sym_get_string_value(sym), ctime(&now));
537
538 sym_clear_all_valid();
539
540 for_all_symbols(i, sym) {
541 sym_calc_value(sym);
542 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
543 continue;
544 switch (sym->type) {
545 case S_BOOLEAN:
546 case S_TRISTATE:
547 switch (sym_get_tristate_value(sym)) {
548 case no:
549 break;
550 case mod:
551 fprintf(out, "CONFIG_%s=m\n", sym->name);
552 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
553 break;
554 case yes:
555 fprintf(out, "CONFIG_%s=y\n", sym->name);
556 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
557 break;
558 }
559 break;
560 case S_STRING:
561 str = sym_get_string_value(sym);
562 fprintf(out, "CONFIG_%s=\"", sym->name);
563 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
564 while (1) {
565 l = strcspn(str, "\"\\");
566 if (l) {
567 fwrite(str, l, 1, out);
568 fwrite(str, l, 1, out_h);
569 str += l;
570 }
571 if (!*str)
572 break;
573 fprintf(out, "\\%c", *str);
574 fprintf(out_h, "\\%c", *str);
575 str++;
576 }
577 fputs("\"\n", out);
578 fputs("\"\n", out_h);
579 break;
580 case S_HEX:
581 str = sym_get_string_value(sym);
582 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
583 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
584 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str);
585 break;
586 }
587 case S_INT:
588 str = sym_get_string_value(sym);
589 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
590 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str);
591 break;
592 default:
593 break;
594 }
595 }
596 fclose(out);
597 fclose(out_h);
598
599 name = getenv("KCONFIG_AUTOHEADER");
600 if (!name)
601 name = "include/linux/autoconf.h";
602 if (rename(".tmpconfig.h", name))
603 return 1;
604 name = getenv("KCONFIG_AUTOCONFIG");
605 if (!name)
606 name = "include/config/auto.conf";
607 /*
608 * This must be the last step, kbuild has a dependency on auto.conf
609 * and this marks the successful completion of the previous steps.
610 */
611 if (rename(".tmpconfig", name))
612 return 1;
613
614 return 0;
615}
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index b6a389c5fcbd..bd0fb1dc1322 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -4,6 +4,7 @@ P(conf_parse,void,(const char *name));
4P(conf_read,int,(const char *name)); 4P(conf_read,int,(const char *name));
5P(conf_read_simple,int,(const char *name)); 5P(conf_read_simple,int,(const char *name));
6P(conf_write,int,(const char *name)); 6P(conf_write,int,(const char *name));
7P(conf_write_autoconf,int,(void));
7 8
8/* menu.c */ 9/* menu.c */
9P(rootmenu,struct menu,); 10P(rootmenu,struct menu,);
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 656d2c87d661..e3f28b9d59f4 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -44,7 +44,9 @@ int file_write_dep(const char *name)
44 else 44 else
45 fprintf(out, "\t%s\n", file->name); 45 fprintf(out, "\t%s\n", file->name);
46 } 46 }
47 fprintf(out, "\n.config include/linux/autoconf.h: $(deps_config)\n\n$(deps_config):\n"); 47 fprintf(out, "\ninclude/config/auto.conf: \\\n"
48 "\t$(deps_config)\n\n"
49 "$(deps_config): ;\n");
48 fclose(out); 50 fclose(out);
49 rename("..config.tmp", name); 51 rename("..config.tmp", name);
50 return 0; 52 return 0;