Skip to content

Commit a9a49c2

Browse files
committed
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>
1 parent 48b5ffd commit a9a49c2

7 files changed

Lines changed: 9 additions & 9 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ USERINCLUDE := \
448448
LINUXINCLUDE := \
449449
-I$(srctree)/arch/$(SRCARCH)/include \
450450
-I$(objtree)/arch/$(SRCARCH)/include/generated \
451-
$(if $(KBUILD_SRC), -I$(srctree)/include) \
451+
$(if $(filter .,$(srctree)),,-I$(srctree)/include) \
452452
-I$(objtree)/include \
453453
$(USERINCLUDE)
454454

@@ -509,7 +509,7 @@ PHONY += outputmakefile
509509
# At the same time when output Makefile generated, generate .gitignore to
510510
# ignore whole output directory
511511
outputmakefile:
512-
ifneq ($(KBUILD_SRC),)
512+
ifneq ($(srctree),.)
513513
$(Q)ln -fsn $(srctree) source
514514
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
515515
$(Q)test -e .gitignore || \
@@ -1089,7 +1089,7 @@ PHONY += prepare archprepare prepare1 prepare3
10891089
# and if so do:
10901090
# 1) Check that make has not been executed in the kernel src $(srctree)
10911091
prepare3: include/config/kernel.release
1092-
ifneq ($(KBUILD_SRC),)
1092+
ifneq ($(srctree),.)
10931093
@$(kecho) ' Using $(srctree) as source for kernel'
10941094
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
10951095
echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \

scripts/Makefile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ existing-targets := $(wildcard $(sort $(targets)))
501501

502502
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
503503

504-
ifneq ($(KBUILD_SRC),)
504+
ifneq ($(srctree),.)
505505
# Create directories for object files if they do not exist
506506
obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
507507
# If targets exist, their directories apparently exist. Skip mkdir.

scripts/Makefile.host

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ __hostc_flags = $(_hostc_flags)
7171
__hostcxx_flags = $(_hostcxx_flags)
7272

7373
ifeq ($(KBUILD_EXTMOD),)
74-
ifneq ($(KBUILD_SRC),)
74+
ifneq ($(srctree),.)
7575
__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
7676
__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
7777
endif

scripts/Makefile.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ __cpp_flags = $(_cpp_flags)
144144
# If building the kernel in a separate objtree expand all occurrences
145145
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
146146
ifeq ($(KBUILD_EXTMOD),)
147-
ifneq ($(KBUILD_SRC),)
147+
ifneq ($(srctree),.)
148148

149149
# -I$(obj) locates generated .h files
150150
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files

scripts/Makefile.modbuiltin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include include/config/tristate.conf
1515

1616
include scripts/Kbuild.include
1717

18-
ifneq ($(KBUILD_SRC),)
18+
ifneq ($(srctree),.)
1919
# Create output directory if not already present
2020
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
2121
endif

scripts/gdb/linux/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3-
ifneq ($(KBUILD_SRC),)
3+
ifneq ($(srctree),.)
44

55
symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))
66

scripts/tags.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ignore="$ignore ( -name *.mod.c ) -prune -o"
1919
# Do not use full path if we do not use O=.. builds
2020
# Use make O=. {tags|cscope}
2121
# to force full paths for a non-O= build
22-
if [ "${KBUILD_SRC}" = "" ]; then
22+
if [ "${srctree}" = "." ]; then
2323
tree=
2424
else
2525
tree=${srctree}/

0 commit comments

Comments
 (0)