aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-20 03:46:31 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-25 10:25:30 -0400
commit00c864f8903dd357471e8ee48f4d57aaa9a1a0de (patch)
tree33fc5d65590715b39de4d8fca569bd15eadd41ee
parent16952b77d8b542fe5f3d73065a50842885b2ba0b (diff)
kconfig: allow all config targets to write auto.conf if missing
Currently, only syncconfig creates or updates include/config/auto.conf and some other files. Other config targets create or update only the .config file. When you configure and build the kernel from a pristine source tree, any config target is followed by syncconfig in the build stage since include/config/auto.conf is missing. We are moving compiler tests from Makefile to Kconfig. It means that parsing Kconfig files will be more costly since Kconfig invokes the compiler commands internally. Thus, we want to avoid invoking Kconfig twice (one for *config to create the .config, and one for syncconfig to synchronize the auto.conf). If auto.conf does not exist, we can generate all configuration files in the first configuration stage, which will save the syncconfig in the build stage. Please note this should be done only when auto.conf is missing. If *config blindly did this, time stamp files under include/config/ would be unnecessarily touched, triggering unneeded rebuild of objects. I assume a scenario like this: 1. You have a source tree that has already been built with CONFIG_FOO disabled 2. Run "make menuconfig" to enable CONFIG_FOO 3. CONFIG_FOO turns out to be unnecessary. Run "make menuconfig" again to disable CONFIG_FOO 4. Run "make" In this case, include/config/foo.h should not be touched since there is no change in CONFIG_FOO. The sync process should be delayed until the user really attempts to build the kernel. This commit has another motivation; I want to suppress the 'No such file or directory' warning from the 'include' directive. The top-level Makefile includes auto.conf with '-include' directive, like this: ifeq ($(dot-config),1) -include include/config/auto.conf endif This looks strange because auto.conf is mandatory when dot-config is 1. I guess only the reason of using '-include' is to suppress the warning 'include/config/auto.conf: No such file or directory' when building from a clean tree. However, this has a side-effect; Make considers the files included by '-include' are optional. Hence, Make continues to build even if it fails to generate include/config/auto.conf. I will change this in the next commit, but the warning message is annoying. (At least, kbuild test robot reports it as a regression.) With this commit, Kconfig will generate all configuration files together with the .config and I guess it is a solution good enough to suppress the warning. Note: GNU Make 4.2 or later does not display the warning from the 'include' directive if include files are successfully generated. See GNU Make commit 87a5f98d248f ("[SV 102] Don't show unnecessary include file errors.") However, older GNU Make versions are still widely used. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/kconfig/conf.c31
-rw-r--r--scripts/kconfig/confdata.c11
-rw-r--r--scripts/kconfig/gconf.c1
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/mconf.c1
-rw-r--r--scripts/kconfig/nconf.c1
-rw-r--r--scripts/kconfig/qconf.cc2
7 files changed, 30 insertions, 19 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 5af899112cae..b35cc9303979 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -686,29 +686,32 @@ int main(int ac, char **av)
686 break; 686 break;
687 } 687 }
688 688
689 if (sync_kconfig) { 689 if (input_mode == savedefconfig) {
690 /* syncconfig is used during the build so we shall update autoconf.
691 * All other commands are only used to generate a config.
692 */
693 if (!no_conf_write && conf_write(NULL)) {
694 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
695 exit(1);
696 }
697 if (conf_write_autoconf()) {
698 fprintf(stderr, "\n*** Error during update of the configuration.\n\n");
699 return 1;
700 }
701 } else if (input_mode == savedefconfig) {
702 if (conf_write_defconfig(defconfig_file)) { 690 if (conf_write_defconfig(defconfig_file)) {
703 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", 691 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
704 defconfig_file); 692 defconfig_file);
705 return 1; 693 return 1;
706 } 694 }
707 } else if (input_mode != listnewconfig) { 695 } else if (input_mode != listnewconfig) {
708 if (conf_write(NULL)) { 696 if (!no_conf_write && conf_write(NULL)) {
709 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); 697 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
710 exit(1); 698 exit(1);
711 } 699 }
700
701 /*
702 * Create auto.conf if it does not exist.
703 * This prevents GNU Make 4.1 or older from emitting
704 * "include/config/auto.conf: No such file or directory"
705 * in the top-level Makefile
706 *
707 * syncconfig always creates or updates auto.conf because it is
708 * used during the build.
709 */
710 if (conf_write_autoconf(sync_kconfig) && sync_kconfig) {
711 fprintf(stderr,
712 "\n*** Error during sync of the configuration.\n\n");
713 return 1;
714 }
712 } 715 }
713 return 0; 716 return 0;
714} 717}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index fad403dfa508..91d0a5c014ac 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1013,13 +1013,17 @@ out:
1013 return res; 1013 return res;
1014} 1014}
1015 1015
1016int conf_write_autoconf(void) 1016int conf_write_autoconf(int overwrite)
1017{ 1017{
1018 struct symbol *sym; 1018 struct symbol *sym;
1019 const char *name; 1019 const char *name;
1020 const char *autoconf_name = conf_get_autoconfig_name();
1020 FILE *out, *tristate, *out_h; 1021 FILE *out, *tristate, *out_h;
1021 int i; 1022 int i;
1022 1023
1024 if (!overwrite && is_present(autoconf_name))
1025 return 0;
1026
1023 sym_clear_all_valid(); 1027 sym_clear_all_valid();
1024 1028
1025 conf_write_dep("include/config/auto.conf.cmd"); 1029 conf_write_dep("include/config/auto.conf.cmd");
@@ -1082,14 +1086,13 @@ int conf_write_autoconf(void)
1082 if (rename(".tmpconfig_tristate", name)) 1086 if (rename(".tmpconfig_tristate", name))
1083 return 1; 1087 return 1;
1084 1088
1085 name = conf_get_autoconfig_name(); 1089 if (make_parent_dir(autoconf_name))
1086 if (make_parent_dir(name))
1087 return 1; 1090 return 1;
1088 /* 1091 /*
1089 * This must be the last step, kbuild has a dependency on auto.conf 1092 * This must be the last step, kbuild has a dependency on auto.conf
1090 * and this marks the successful completion of the previous steps. 1093 * and this marks the successful completion of the previous steps.
1091 */ 1094 */
1092 if (rename(".tmpconfig", name)) 1095 if (rename(".tmpconfig", autoconf_name))
1093 return 1; 1096 return 1;
1094 1097
1095 return 0; 1098 return 0;
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index a9e48cc7b50a..36f578415c4a 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -525,6 +525,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data)
525{ 525{
526 if (conf_write(NULL)) 526 if (conf_write(NULL))
527 text_insert_msg("Error", "Unable to save configuration !"); 527 text_insert_msg("Error", "Unable to save configuration !");
528 conf_write_autoconf(0);
528} 529}
529 530
530 531
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index cf4510a2bdc7..86c267540ccc 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -7,7 +7,7 @@ int conf_read(const char *name);
7int conf_read_simple(const char *name, int); 7int conf_read_simple(const char *name, int);
8int conf_write_defconfig(const char *name); 8int conf_write_defconfig(const char *name);
9int conf_write(const char *name); 9int conf_write(const char *name);
10int conf_write_autoconf(void); 10int conf_write_autoconf(int overwrite);
11bool conf_get_changed(void); 11bool conf_get_changed(void);
12void conf_set_changed_callback(void (*fn)(void)); 12void conf_set_changed_callback(void (*fn)(void));
13void conf_set_message_callback(void (*fn)(const char *s)); 13void conf_set_message_callback(void (*fn)(const char *s));
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index b8f3b607962a..83b5836615fb 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -974,6 +974,7 @@ static int handle_exit(void)
974 "\n\n"); 974 "\n\n");
975 return 1; 975 return 1;
976 } 976 }
977 conf_write_autoconf(0);
977 /* fall through */ 978 /* fall through */
978 case -1: 979 case -1:
979 if (!silent) 980 if (!silent)
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 5cbdb92e11b3..1ef232ae5ab9 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -674,6 +674,7 @@ static int do_exit(void)
674 "Your configuration changes were NOT saved.", 674 "Your configuration changes were NOT saved.",
675 1, 675 1,
676 "<OK>"); 676 "<OK>");
677 conf_write_autoconf(0);
677 break; 678 break;
678 default: 679 default:
679 btn_dialog( 680 btn_dialog(
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index ad9c22dd04f5..62261b3a13c7 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1535,6 +1535,8 @@ bool ConfigMainWindow::saveConfig(void)
1535 QMessageBox::information(this, "qconf", "Unable to save configuration!"); 1535 QMessageBox::information(this, "qconf", "Unable to save configuration!");
1536 return false; 1536 return false;
1537 } 1537 }
1538 conf_write_autoconf(0);
1539
1538 return true; 1540 return true;
1539} 1541}
1540 1542