mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-16 18:26:42 +00:00
kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
Commit 25b146c5b8ce ("kbuild: allow Kbuild to start from any directory") deprecated KBUILD_SRCTREE. It is only used in tools/testing/selftest/ to distinguish out-of-tree build. Replace it with a new boolean flag, building_out_of_srctree. I also replaced the conditional ($(srctree),.) because the next commit will allow an absolute path to be used for $(srctree) even when building in the source tree. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
75dd47472b
commit
051f278e9d
19
Makefile
19
Makefile
@ -228,9 +228,12 @@ ifeq ("$(origin M)", "command line")
|
|||||||
KBUILD_EXTMOD := $(M)
|
KBUILD_EXTMOD := $(M)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
export KBUILD_CHECKSRC KBUILD_EXTMOD
|
||||||
|
|
||||||
ifeq ($(abs_srctree),$(abs_objtree))
|
ifeq ($(abs_srctree),$(abs_objtree))
|
||||||
# building in the source tree
|
# building in the source tree
|
||||||
srctree := .
|
srctree := .
|
||||||
|
building_out_of_srctree :=
|
||||||
else
|
else
|
||||||
ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
|
ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
|
||||||
# building in a subdirectory of the source tree
|
# building in a subdirectory of the source tree
|
||||||
@ -238,19 +241,13 @@ else
|
|||||||
else
|
else
|
||||||
srctree := $(abs_srctree)
|
srctree := $(abs_srctree)
|
||||||
endif
|
endif
|
||||||
|
building_out_of_srctree := 1
|
||||||
# TODO:
|
|
||||||
# KBUILD_SRC is only used to distinguish in-tree/out-of-tree build.
|
|
||||||
# Replace it with $(srctree) or something.
|
|
||||||
KBUILD_SRC := $(abs_srctree)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
export KBUILD_CHECKSRC KBUILD_EXTMOD KBUILD_SRC
|
|
||||||
|
|
||||||
objtree := .
|
objtree := .
|
||||||
VPATH := $(srctree)
|
VPATH := $(srctree)
|
||||||
|
|
||||||
export srctree objtree VPATH
|
export building_out_of_srctree srctree objtree VPATH
|
||||||
|
|
||||||
# To make sure we do not include .config for any of the *config targets
|
# To make sure we do not include .config for any of the *config targets
|
||||||
# catch them early, and hand them over to scripts/kconfig/Makefile
|
# catch them early, and hand them over to scripts/kconfig/Makefile
|
||||||
@ -453,7 +450,7 @@ USERINCLUDE := \
|
|||||||
LINUXINCLUDE := \
|
LINUXINCLUDE := \
|
||||||
-I$(srctree)/arch/$(SRCARCH)/include \
|
-I$(srctree)/arch/$(SRCARCH)/include \
|
||||||
-I$(objtree)/arch/$(SRCARCH)/include/generated \
|
-I$(objtree)/arch/$(SRCARCH)/include/generated \
|
||||||
$(if $(filter .,$(srctree)),,-I$(srctree)/include) \
|
$(if $(building_out_of_srctree),-I$(srctree)/include) \
|
||||||
-I$(objtree)/include \
|
-I$(objtree)/include \
|
||||||
$(USERINCLUDE)
|
$(USERINCLUDE)
|
||||||
|
|
||||||
@ -514,7 +511,7 @@ PHONY += outputmakefile
|
|||||||
# At the same time when output Makefile generated, generate .gitignore to
|
# At the same time when output Makefile generated, generate .gitignore to
|
||||||
# ignore whole output directory
|
# ignore whole output directory
|
||||||
outputmakefile:
|
outputmakefile:
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
$(Q)ln -fsn $(srctree) source
|
$(Q)ln -fsn $(srctree) source
|
||||||
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
|
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
|
||||||
$(Q)test -e .gitignore || \
|
$(Q)test -e .gitignore || \
|
||||||
@ -1101,7 +1098,7 @@ PHONY += prepare archprepare prepare1 prepare3
|
|||||||
# and if so do:
|
# and if so do:
|
||||||
# 1) Check that make has not been executed in the kernel src $(srctree)
|
# 1) Check that make has not been executed in the kernel src $(srctree)
|
||||||
prepare3: include/config/kernel.release
|
prepare3: include/config/kernel.release
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
@$(kecho) ' Using $(srctree) as source for kernel'
|
@$(kecho) ' Using $(srctree) as source for kernel'
|
||||||
$(Q)if [ -f $(srctree)/.config -o \
|
$(Q)if [ -f $(srctree)/.config -o \
|
||||||
-d $(srctree)/include/config -o \
|
-d $(srctree)/include/config -o \
|
||||||
|
@ -513,7 +513,7 @@ existing-targets := $(wildcard $(sort $(targets)))
|
|||||||
|
|
||||||
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
||||||
|
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
# Create directories for object files if they do not exist
|
# Create directories for object files if they do not exist
|
||||||
obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
|
obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
|
||||||
# If targets exist, their directories apparently exist. Skip mkdir.
|
# If targets exist, their directories apparently exist. Skip mkdir.
|
||||||
|
@ -69,7 +69,7 @@ _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
|
|||||||
|
|
||||||
# $(objtree)/$(obj) for including generated headers from checkin source files
|
# $(objtree)/$(obj) for including generated headers from checkin source files
|
||||||
ifeq ($(KBUILD_EXTMOD),)
|
ifeq ($(KBUILD_EXTMOD),)
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
_hostc_flags += -I $(objtree)/$(obj)
|
_hostc_flags += -I $(objtree)/$(obj)
|
||||||
_hostcxx_flags += -I $(objtree)/$(obj)
|
_hostcxx_flags += -I $(objtree)/$(obj)
|
||||||
endif
|
endif
|
||||||
|
@ -154,7 +154,7 @@ endif
|
|||||||
# $(srctree)/$(src) for including checkin headers from generated source files
|
# $(srctree)/$(src) for including checkin headers from generated source files
|
||||||
# $(objtree)/$(obj) for including generated headers from checkin source files
|
# $(objtree)/$(obj) for including generated headers from checkin source files
|
||||||
ifeq ($(KBUILD_EXTMOD),)
|
ifeq ($(KBUILD_EXTMOD),)
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||||
_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||||
_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
|
||||||
|
@ -15,7 +15,7 @@ include include/config/tristate.conf
|
|||||||
|
|
||||||
include scripts/Kbuild.include
|
include scripts/Kbuild.include
|
||||||
|
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
# Create output directory if not already present
|
# Create output directory if not already present
|
||||||
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
||||||
endif
|
endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
ifneq ($(srctree),.)
|
ifdef building_out_of_srctree
|
||||||
|
|
||||||
symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))
|
symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ endif
|
|||||||
# Append kselftest to KBUILD_OUTPUT to avoid cluttering
|
# Append kselftest to KBUILD_OUTPUT to avoid cluttering
|
||||||
# KBUILD_OUTPUT with selftest objects and headers installed
|
# KBUILD_OUTPUT with selftest objects and headers installed
|
||||||
# by selftests Makefile or lib.mk.
|
# by selftests Makefile or lib.mk.
|
||||||
ifneq ($(KBUILD_SRC),)
|
ifdef building_out_of_srctree
|
||||||
override LDFLAGS =
|
override LDFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ define RUN_TESTS
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
run_tests: all
|
run_tests: all
|
||||||
ifneq ($(KBUILD_SRC),)
|
ifdef building_out_of_srctree
|
||||||
@if [ "X$(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)" != "X" ]; then
|
@if [ "X$(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)" != "X" ]; then
|
||||||
@rsync -aq $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT)
|
@rsync -aq $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT)
|
||||||
fi
|
fi
|
||||||
@ -125,7 +125,7 @@ clean:
|
|||||||
# When make O= with kselftest target from main level
|
# When make O= with kselftest target from main level
|
||||||
# the following aren't defined.
|
# the following aren't defined.
|
||||||
#
|
#
|
||||||
ifneq ($(KBUILD_SRC),)
|
ifdef building_out_of_srctree
|
||||||
LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
|
LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
|
||||||
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
|
COMPILE.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
|
||||||
LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
|
LINK.S = $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user