summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-20 03:46:34 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-25 10:25:32 -0400
commitd79424137a7312d381d131d707a462440c0e8df9 (patch)
tree2261c12316483c8747da49371cedee3de9bbeef1 /Makefile
parent9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0 (diff)
kbuild: do not update config when running install targets
"make syncconfig" is automatically invoked when any of the following happens: - .config is updated - any of Kconfig files is updated - any of environment variables referenced in Kconfig is changed Then, it updates configuration files such as include/config/auto.conf include/generated/autoconf.h, etc. Even install targets (install, modules_install, etc.) are no exception. However, they should never ever modify the source tree. Install targets are often run with root privileges. Once those configuration files are owned by root, "make mrproper" would end up with permission error. Install targets should just copy things blindly. They should not care whether the configuration is up-to-date or not. This makes more sense because we are interested in the configuration that was used in the previous kernel building. This issue has existed since before, but rarely happened. I expect more chance where people are hit by this; with the new Kconfig syntax extension, the .config now contains the compiler information. If you cross-compile the kernel with CROSS_COMPILE, but forget to pass it for "make install", you meet "any of environment variables referenced in Kconfig is changed" because $(CC) is referenced in Kconfig. Another scenario is the compiler upgrade before the installation. Install targets need the configuration. "make modules_install" refer to CONFIG_MODULES etc. "make dtbs_install" also needs CONFIG_ARCH_* to decide which dtb files to install. However, the auto-update of the configuration files should be avoided. We already do this for external modules. Now, Make targets are categorized into 3 groups: [1] Do not need the kernel configuration at all help, coccicheck, headers_install etc. [2] Need the latest kernel configuration If new config options are added, Kconfig will show prompt to ask user's selection. Build targets such as vmlinux, in-kernel modules are the cases. [3] Need the kernel configuration, but do not want to update it Install targets except headers_install, and external modules are the cases. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile27
1 files changed, 20 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 6a222e21ca6d..8ca9e0b114f1 100644
--- a/Makefile
+++ b/Makefile
@@ -225,10 +225,12 @@ no-dot-config-targets := $(clean-targets) \
225 cscope gtags TAGS tags help% %docs check% coccicheck \ 225 cscope gtags TAGS tags help% %docs check% coccicheck \
226 $(version_h) headers_% archheaders archscripts \ 226 $(version_h) headers_% archheaders archscripts \
227 kernelversion %src-pkg 227 kernelversion %src-pkg
228no-sync-config-targets := $(no-dot-config-targets) install %install
228 229
229config-targets := 0 230config-targets := 0
230mixed-targets := 0 231mixed-targets := 0
231dot-config := 1 232dot-config := 1
233may-sync-config := 1
232 234
233ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 235ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
234 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 236 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
@@ -236,6 +238,16 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
236 endif 238 endif
237endif 239endif
238 240
241ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
242 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
243 may-sync-config := 0
244 endif
245endif
246
247ifneq ($(KBUILD_EXTMOD),)
248 may-sync-config := 0
249endif
250
239ifeq ($(KBUILD_EXTMOD),) 251ifeq ($(KBUILD_EXTMOD),)
240 ifneq ($(filter config %config,$(MAKECMDGOALS)),) 252 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
241 config-targets := 1 253 config-targets := 1
@@ -606,7 +618,7 @@ ARCH_CFLAGS :=
606include arch/$(SRCARCH)/Makefile 618include arch/$(SRCARCH)/Makefile
607 619
608ifeq ($(dot-config),1) 620ifeq ($(dot-config),1)
609ifeq ($(KBUILD_EXTMOD),) 621ifeq ($(may-sync-config),1)
610# Read in dependencies to all Kconfig* files, make sure to run syncconfig if 622# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
611# changes are detected. This should be included after arch/$(SRCARCH)/Makefile 623# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
612# because some architectures define CROSS_COMPILE there. 624# because some architectures define CROSS_COMPILE there.
@@ -621,8 +633,9 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
621include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 633include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
622 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 634 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
623else 635else
624# external modules needs include/generated/autoconf.h and include/config/auto.conf 636# External modules and some install targets need include/generated/autoconf.h
625# but do not care if they are up-to-date. Use auto.conf to trigger the test 637# and include/config/auto.conf but do not care if they are up-to-date.
638# Use auto.conf to trigger the test
626PHONY += include/config/auto.conf 639PHONY += include/config/auto.conf
627 640
628include/config/auto.conf: 641include/config/auto.conf:
@@ -634,7 +647,7 @@ include/config/auto.conf:
634 echo >&2 ; \ 647 echo >&2 ; \
635 /bin/false) 648 /bin/false)
636 649
637endif # KBUILD_EXTMOD 650endif # may-sync-config
638 651
639else 652else
640# Dummy target needed, because used as prerequisite 653# Dummy target needed, because used as prerequisite