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

kbuild: use $(srctree) instead of KBUILD_SRC to check out-of-tree build

KBUILD_SRC was conventionally used for some different purposes:
[1] To remember the source tree path
[2] As a flag to check if sub-make is already done
[3] As a flag to check if Kbuild runs out of tree

For [1], we do not need to remember it because the top Makefile
can compute it by $(realpath $(dir $(lastword $(MAKEFILE_LIST))))

[2] has been replaced with self-commenting 'sub_make_done'.

For [3], we can distinguish in-tree/out-of-tree by comparing
$(srctree) and '.'

This commit converts [3] to prepare for the KBUILD_SRC removal.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

+9 -9
+3 -3
Makefile
··· 448 448 LINUXINCLUDE := \ 449 449 -I$(srctree)/arch/$(SRCARCH)/include \ 450 450 -I$(objtree)/arch/$(SRCARCH)/include/generated \ 451 - $(if $(KBUILD_SRC), -I$(srctree)/include) \ 451 + $(if $(filter .,$(srctree)),,-I$(srctree)/include) \ 452 452 -I$(objtree)/include \ 453 453 $(USERINCLUDE) 454 454 ··· 509 509 # At the same time when output Makefile generated, generate .gitignore to 510 510 # ignore whole output directory 511 511 outputmakefile: 512 - ifneq ($(KBUILD_SRC),) 512 + ifneq ($(srctree),.) 513 513 $(Q)ln -fsn $(srctree) source 514 514 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 515 515 $(Q)test -e .gitignore || \ ··· 1089 1089 # and if so do: 1090 1090 # 1) Check that make has not been executed in the kernel src $(srctree) 1091 1091 prepare3: include/config/kernel.release 1092 - ifneq ($(KBUILD_SRC),) 1092 + ifneq ($(srctree),.) 1093 1093 @$(kecho) ' Using $(srctree) as source for kernel' 1094 1094 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 1095 1095 echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
+1 -1
scripts/Makefile.build
··· 501 501 502 502 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 503 503 504 - ifneq ($(KBUILD_SRC),) 504 + ifneq ($(srctree),.) 505 505 # Create directories for object files if they do not exist 506 506 obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) 507 507 # If targets exist, their directories apparently exist. Skip mkdir.
+1 -1
scripts/Makefile.host
··· 71 71 __hostcxx_flags = $(_hostcxx_flags) 72 72 73 73 ifeq ($(KBUILD_EXTMOD),) 74 - ifneq ($(KBUILD_SRC),) 74 + ifneq ($(srctree),.) 75 75 __hostc_flags = -I$(obj) $(call flags,_hostc_flags) 76 76 __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) 77 77 endif
+1 -1
scripts/Makefile.lib
··· 144 144 # If building the kernel in a separate objtree expand all occurrences 145 145 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 146 146 ifeq ($(KBUILD_EXTMOD),) 147 - ifneq ($(KBUILD_SRC),) 147 + ifneq ($(srctree),.) 148 148 149 149 # -I$(obj) locates generated .h files 150 150 # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
+1 -1
scripts/Makefile.modbuiltin
··· 15 15 16 16 include scripts/Kbuild.include 17 17 18 - ifneq ($(KBUILD_SRC),) 18 + ifneq ($(srctree),.) 19 19 # Create output directory if not already present 20 20 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) 21 21 endif
+1 -1
scripts/gdb/linux/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - ifneq ($(KBUILD_SRC),) 3 + ifneq ($(srctree),.) 4 4 5 5 symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py)) 6 6
+1 -1
scripts/tags.sh
··· 19 19 # Do not use full path if we do not use O=.. builds 20 20 # Use make O=. {tags|cscope} 21 21 # to force full paths for a non-O= build 22 - if [ "${KBUILD_SRC}" = "" ]; then 22 + if [ "${srctree}" = "." ]; then 23 23 tree= 24 24 else 25 25 tree=${srctree}/