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

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>

+10 -7
+4 -2
scripts/Makefile.host
··· 67 67 _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ 68 68 $(HOSTCXXFLAGS_$(basetarget).o) 69 69 70 - ifeq ($(KBUILD_SRC),) 71 70 __hostc_flags = $(_hostc_flags) 72 71 __hostcxx_flags = $(_hostcxx_flags) 73 - else 72 + 73 + ifeq ($(KBUILD_EXTMOD),) 74 + ifneq ($(KBUILD_SRC),) 74 75 __hostc_flags = -I$(obj) $(call flags,_hostc_flags) 75 76 __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) 77 + endif 76 78 endif 77 79 78 80 hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
+6 -5
scripts/Makefile.lib
··· 137 137 $(CFLAGS_KCOV)) 138 138 endif 139 139 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),) 144 140 __c_flags = $(_c_flags) 145 141 __a_flags = $(_a_flags) 146 142 __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),) 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 ··· 154 154 $(call flags,_c_flags) 155 155 __a_flags = $(call flags,_a_flags) 156 156 __cpp_flags = $(call flags,_cpp_flags) 157 + endif 157 158 endif 158 159 159 160 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \