Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: remove --include-dir MAKEFLAG from top Makefile

I added $(srctree)/ to some included Makefiles in the following commits:

- 3204a7fb98a3 ("kbuild: prefix $(srctree)/ to some included Makefiles")
- d82856395505 ("kbuild: do not require sub-make for separate output tree builds")

They were a preparation for removing --include-dir flag.

I have never thought --include-dir useful. Rather, it _is_ harmful.

For example, run the following commands:

$ make -s ARCH=x86 mrproper defconfig
$ make ARCH=arm O=foo dtbs
make[1]: Entering directory '/tmp/linux/foo'
HOSTCC scripts/basic/fixdep
Error: kernelrelease not valid - run 'make prepare' to update it
UPD include/config/kernel.release
make[1]: Leaving directory '/tmp/linux/foo'

The first command configures the source tree for x86. The next command
tries to build ARM device trees in the separate foo/ directory - this
must stop because the directory foo/ has not been configured yet.

However, due to --include-dir=$(abs_srctree), the top Makefile includes
the wrong include/config/auto.conf from the source tree and continues
building. Kbuild traverses the directory tree, but of course it does
not work correctly. The Error message is also pointless - 'make prepare'
does not help at all for fixing the issue.

This commit fixes more arch Makefile, and finally removes --include-dir
from the top Makefile.

There are more breakages under drivers/, but I do not volunteer to fix
them all. I just moved --include-dir to drivers/Makefile.

With this commit, the second command will stop with a sensible message.

$ make -s ARCH=x86 mrproper defconfig
$ make ARCH=arm O=foo dtbs
make[1]: Entering directory '/tmp/linux/foo'
SYNC include/config/auto.conf.cmd
***
*** The source tree is not clean, please run 'make ARCH=arm mrproper'
*** in /tmp/linux
***
make[2]: *** [../Makefile:646: outputmakefile] Error 1
/tmp/linux/Makefile:770: include/config/auto.conf.cmd: No such file or directory
make[1]: *** [/tmp/linux/Makefile:793: include/config/auto.conf.cmd] Error 2
make[1]: Leaving directory '/tmp/linux/foo'
make: *** [Makefile:226: __sub-make] Error 2

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+21 -24
-8
Makefile
··· 203 203 $(error source directory cannot contain spaces or colons) 204 204 endif 205 205 206 - ifneq ($(abs_srctree),$(abs_objtree)) 207 - # Look for make include files relative to root of kernel src 208 - # 209 - # --included-dir is added for backward compatibility, but you should not rely on 210 - # it. Please add $(srctree)/ prefix to include Makefiles in the source tree. 211 - MAKEFLAGS += --include-dir=$(abs_srctree) 212 - endif 213 - 214 206 ifneq ($(filter 3.%,$(MAKE_VERSION)),) 215 207 # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x 216 208 # We need to invoke sub-make to avoid implicit rules in the top Makefile.
+2 -2
arch/arm/mach-s3c/Makefile
··· 3 3 # Copyright 2009 Simtec Electronics 4 4 5 5 ifdef CONFIG_ARCH_S3C24XX 6 - include $(src)/Makefile.s3c24xx 6 + include $(srctree)/$(src)/Makefile.s3c24xx 7 7 endif 8 8 9 9 ifdef CONFIG_ARCH_S3C64XX 10 - include $(src)/Makefile.s3c64xx 10 + include $(srctree)/$(src)/Makefile.s3c64xx 11 11 endif 12 12 13 13 # Objects we always build independent of SoC choice
+1 -1
arch/ia64/kernel/Makefile
··· 43 43 CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 44 44 45 45 # The gate DSO image is built using a special linker script. 46 - include $(src)/Makefile.gate 46 + include $(srctree)/$(src)/Makefile.gate
+1 -1
arch/mips/Kbuild
··· 7 7 endif 8 8 9 9 # platform specific definitions 10 - include arch/mips/Kbuild.platforms 10 + include $(srctree)/arch/mips/Kbuild.platforms 11 11 obj-y := $(platform-y) 12 12 13 13 # make clean traverses $(obj-) without having included .config, so
+1 -1
arch/um/drivers/Makefile
··· 72 72 73 73 CFLAGS_xterm.o += '-DCONFIG_XTERM_CHAN_DEFAULT_EMULATOR="$(CONFIG_XTERM_CHAN_DEFAULT_EMULATOR)"' 74 74 75 - include arch/um/scripts/Makefile.rules 75 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/um/kernel/Makefile
··· 29 29 30 30 USER_OBJS := config.o 31 31 32 - include arch/um/scripts/Makefile.rules 32 + include $(srctree)/arch/um/scripts/Makefile.rules 33 33 34 34 targets := config.c config.tmp capflags.c 35 35
+1 -1
arch/um/kernel/skas/Makefile
··· 14 14 15 15 KCOV_INSTRUMENT := n 16 16 17 - include arch/um/scripts/Makefile.rules 17 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/um/os-Linux/Makefile
··· 18 18 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ 19 19 tty.o umid.o util.o 20 20 21 - include arch/um/scripts/Makefile.rules 21 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/um/os-Linux/drivers/Makefile
··· 10 10 obj-$(CONFIG_UML_NET_ETHERTAP) += ethertap.o 11 11 obj-$(CONFIG_UML_NET_TUNTAP) += tuntap.o 12 12 13 - include arch/um/scripts/Makefile.rules 13 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/um/os-Linux/skas/Makefile
··· 7 7 8 8 USER_OBJS := $(obj-y) 9 9 10 - include arch/um/scripts/Makefile.rules 10 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/x86/Makefile.um
··· 17 17 export LDS_EXTRA 18 18 19 19 # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. 20 - include arch/x86/Makefile_32.cpu 20 + include $(srctree)/arch/x86/Makefile_32.cpu 21 21 22 22 # prevent gcc from keeping the stack 16 byte aligned. Taken from i386. 23 23 cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
+1 -1
arch/x86/um/Makefile
··· 48 48 UNPROFILE_OBJS := stub_segv.o 49 49 CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING) 50 50 51 - include arch/um/scripts/Makefile.rules 51 + include $(srctree)/arch/um/scripts/Makefile.rules
+1 -1
arch/x86/um/os-Linux/Makefile
··· 10 10 11 11 USER_OBJS := $(obj-y) 12 12 13 - include arch/um/scripts/Makefile.rules 13 + include $(srctree)/arch/um/scripts/Makefile.rules
+5
drivers/Makefile
··· 6 6 # Rewritten to use lists instead of if-statements. 7 7 # 8 8 9 + # Some driver Makefiles miss $(srctree)/ for include directive. 10 + ifdef building_out_of_srctree 11 + MAKEFLAGS += --include-dir=$(srctree) 12 + endif 13 + 9 14 obj-y += irqchip/ 10 15 obj-y += bus/ 11 16
+1 -1
fs/hostfs/Makefile
··· 8 8 obj-y := 9 9 obj-$(CONFIG_HOSTFS) += hostfs.o 10 10 11 - include arch/um/scripts/Makefile.rules 11 + include $(srctree)/arch/um/scripts/Makefile.rules