Skip to content

Commit 58156ba

Browse files
committed
kbuild: skip 'addtree' and 'flags' magic for external module build
When building an external module, $(obj) is the absolute path to it. The header search paths from ccflags-y etc. should not be tweaked. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent f17b5f0 commit 58156ba

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎scripts/Makefile.host‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
6767
_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
6868
$(HOSTCXXFLAGS_$(basetarget).o)
6969

70-
ifeq ($(KBUILD_SRC),)
7170
__hostc_flags = $(_hostc_flags)
7271
__hostcxx_flags = $(_hostcxx_flags)
73-
else
72+
73+
ifeq ($(KBUILD_EXTMOD),)
74+
ifneq ($(KBUILD_SRC),)
7475
__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
7576
__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
7677
endif
78+
endif
7779

7880
hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
7981
hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)

‎scripts/Makefile.lib‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \
137137
$(CFLAGS_KCOV))
138138
endif
139139

140-
# If building the kernel in a separate objtree expand all occurrences
141-
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
142-
143-
ifeq ($(KBUILD_SRC),)
144140
__c_flags = $(_c_flags)
145141
__a_flags = $(_a_flags)
146142
__cpp_flags = $(_cpp_flags)
147-
else
143+
144+
# If building the kernel in a separate objtree expand all occurrences
145+
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
146+
ifeq ($(KBUILD_EXTMOD),)
147+
ifneq ($(KBUILD_SRC),)
148148

149149
# -I$(obj) locates generated .h files
150150
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
@@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
155155
__a_flags = $(call flags,_a_flags)
156156
__cpp_flags = $(call flags,_cpp_flags)
157157
endif
158+
endif
158159

159160
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
160161
-include $(srctree)/include/linux/compiler_types.h \

0 commit comments

Comments
 (0)