summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-04-07 13:43:51 +0300
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-04-09 16:51:56 +0300
commita788b2ed81abeb949325fd50d7527f45203c1b21 (patch)
treef20f94a39e6906f3f26443fc5f3deca417be89ee /Makefile
parent24512795df0901f79a670f8285c450ae912c009d (diff)
downloadlinux-a788b2ed81abeb949325fd50d7527f45203c1b21.tar.xz
kbuild: check arch/$(SRCARCH)/include/generated before out-of-tree build
After cross-compiling the kernel, "make mrproper" should be executed with the proper ARCH= option. Otherwise, stale objects will remain under arch/$(SRCARCH)/. One bad scenario is like this: $ make ARCH=arm defconfig all # cross-compile the kernel for arm $ make mrproper # mrproper for host-arch (i.e. x86) $ make ARCH=arm O=build_dir defconfig all If you miss ARCH= for mrproper and cross-compile the kernel with O= and ARCH= options, Kbuild will happily start to build, but may fail due to stale objects in the srctree. If $(srctree)/arch/$(SRCARCH)/include/generated/ exists, let's stop the out-of-tree build. To detect this, mrproper should clean only arch/$(SRCARCH)/include/generated/. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 7294d4051ff2..04bee1c5b400 100644
--- a/Makefile
+++ b/Makefile
@@ -1091,7 +1091,9 @@ PHONY += prepare archprepare prepare1 prepare3
prepare3: include/config/kernel.release
ifneq ($(srctree),.)
@$(kecho) ' Using $(srctree) as source for kernel'
- $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
+ $(Q)if [ -f $(srctree)/.config -o \
+ -d $(srctree)/include/config -o \
+ -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
echo >&2 " in the '$(srctree)' directory.";\
/bin/false; \
@@ -1350,7 +1352,7 @@ CLEAN_DIRS += $(MODVERDIR) include/ksym
# Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config usr/include include/generated \
- arch/*/include/generated .tmp_objdiff
+ arch/$(SRCARCH)/include/generated .tmp_objdiff
MRPROPER_FILES += .config .config.old .version \
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
signing_key.pem signing_key.priv signing_key.x509 \