aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile27
-rw-r--r--scripts/Makefile.build2
-rw-r--r--scripts/Makefile.modpost2
-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
7 files changed, 156 insertions, 73 deletions
diff --git a/Makefile b/Makefile
index a3a7baad8555..b1610562a65f 100644
--- a/Makefile
+++ b/Makefile
@@ -404,7 +404,7 @@ include $(srctree)/arch/$(ARCH)/Makefile
404export KBUILD_DEFCONFIG 404export KBUILD_DEFCONFIG
405 405
406config %config: scripts_basic outputmakefile FORCE 406config %config: scripts_basic outputmakefile FORCE
407 $(Q)mkdir -p include/linux 407 $(Q)mkdir -p include/linux include/config
408 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 408 $(Q)$(MAKE) $(build)=scripts/kconfig $@
409 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease 409 $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
410 410
@@ -421,8 +421,6 @@ PHONY += scripts
421scripts: scripts_basic include/config/MARKER 421scripts: scripts_basic include/config/MARKER
422 $(Q)$(MAKE) $(build)=$(@) 422 $(Q)$(MAKE) $(build)=$(@)
423 423
424scripts_basic: include/linux/autoconf.h
425
426# Objects we will link into vmlinux / subdirs we need to visit 424# Objects we will link into vmlinux / subdirs we need to visit
427init-y := init/ 425init-y := init/
428drivers-y := drivers/ sound/ 426drivers-y := drivers/ sound/
@@ -436,25 +434,22 @@ ifeq ($(dot-config),1)
436 434
437# Read in dependencies to all Kconfig* files, make sure to run 435# Read in dependencies to all Kconfig* files, make sure to run
438# oldconfig if changes are detected. 436# oldconfig if changes are detected.
439-include .kconfig.d 437-include include/config/auto.conf.cmd
440 438-include include/config/auto.conf
441include .config
442 439
443# If .config needs to be updated, it will be done via the dependency
444# that autoconf has on .config.
445# To avoid any implicit rule to kick in, define an empty command 440# To avoid any implicit rule to kick in, define an empty command
446.config .kconfig.d: ; 441.config include/config/auto.conf.cmd: ;
447 442
448# If .config is newer than include/linux/autoconf.h, someone tinkered 443# If .config is newer than include/config/auto.conf, someone tinkered
449# with it and forgot to run make oldconfig. 444# with it and forgot to run make oldconfig.
450# If kconfig.d is missing then we are probarly in a cleaned tree so 445# if auto.conf.cmd is missing then we are probarly in a cleaned tree so
451# we execute the config step to be sure to catch updated Kconfig files 446# we execute the config step to be sure to catch updated Kconfig files
452include/linux/autoconf.h: .kconfig.d .config 447include/config/auto.conf: .config include/config/auto.conf.cmd
453 $(Q)mkdir -p include/linux
454 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig 448 $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
449
455else 450else
456# Dummy target needed, because used as prerequisite 451# Dummy target needed, because used as prerequisite
457include/linux/autoconf.h: ; 452include/config/auto.conf: ;
458endif 453endif
459 454
460# The all: target is the default when no target is given on the 455# The all: target is the default when no target is given on the
@@ -779,7 +774,7 @@ PHONY += prepare-all
779prepare3: .kernelrelease 774prepare3: .kernelrelease
780ifneq ($(KBUILD_SRC),) 775ifneq ($(KBUILD_SRC),)
781 @echo ' Using $(srctree) as source for kernel' 776 @echo ' Using $(srctree) as source for kernel'
782 $(Q)if [ -f $(srctree)/.config ]; then \ 777 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
783 echo " $(srctree) is not clean, please run 'make mrproper'";\ 778 echo " $(srctree) is not clean, please run 'make mrproper'";\
784 echo " in the '$(srctree)' directory.";\ 779 echo " in the '$(srctree)' directory.";\
785 /bin/false; \ 780 /bin/false; \
@@ -822,7 +817,7 @@ include/asm:
822 817
823# Split autoconf.h into include/linux/config/* 818# Split autoconf.h into include/linux/config/*
824 819
825include/config/MARKER: scripts/basic/split-include include/linux/autoconf.h 820include/config/MARKER: scripts/basic/split-include include/config/auto.conf
826 @echo ' SPLIT include/linux/autoconf.h -> include/config/*' 821 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
827 @scripts/basic/split-include include/linux/autoconf.h include/config 822 @scripts/basic/split-include include/linux/autoconf.h include/config
828 @touch $@ 823 @touch $@
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index e48e60da3040..53e53a2e80ae 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -8,7 +8,7 @@ PHONY := __build
8__build: 8__build:
9 9
10# Read .config if it exist, otherwise ignore 10# Read .config if it exist, otherwise ignore
11-include .config 11-include include/config/auto.conf
12 12
13include scripts/Kbuild.include 13include scripts/Kbuild.include
14 14
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 0e056cffffdb..576cce5e387f 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -35,7 +35,7 @@
35PHONY := _modpost 35PHONY := _modpost
36_modpost: __modpost 36_modpost: __modpost
37 37
38include .config 38include include/config/auto.conf
39include scripts/Kbuild.include 39include scripts/Kbuild.include
40include scripts/Makefile.lib 40include scripts/Makefile.lib
41 41
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;