diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-05-13 02:22:17 -0400 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-05-17 22:49:57 -0400 |
| commit | cdd750bfb1f76fe9be8cfb53cbe77b2e811081ab (patch) | |
| tree | aef9cb28da3409096df0239e3e315c4787fd5787 /scripts | |
| parent | 9cc342f6c4a06ea613ddef1bcaa25409260aec63 (diff) | |
kbuild: remove 'addtree' and 'flags' magic for header search paths
The 'addtree' and 'flags' in scripts/Kbuild.include are so compilecated
and ugly.
As I mentioned in [1], Kbuild should stop automatic prefixing of header
search path options.
I fixed up (almost) all Makefiles in the kernel. Now 'addtree' and
'flags' have been removed.
Kbuild still caters to add $(srctree)/$(src) and $(objtree)/$(obj)
to the header search path for O= building, but never touches extra
compiler options from ccflags-y etc.
[1]: https://patchwork.kernel.org/patch/9632347/
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Kbuild.include | 8 | ||||
| -rw-r--r-- | scripts/Makefile.host | 12 | ||||
| -rw-r--r-- | scripts/Makefile.lib | 26 |
3 files changed, 13 insertions, 33 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7484b9d8272f..a675ce11a573 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -192,14 +192,6 @@ clean := -f $(srctree)/scripts/Makefile.clean obj | |||
| 192 | # $(Q)$(MAKE) $(hdr-inst)=dir | 192 | # $(Q)$(MAKE) $(hdr-inst)=dir |
| 193 | hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj | 193 | hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj |
| 194 | 194 | ||
| 195 | # Prefix -I with $(srctree) if it is not an absolute path. | ||
| 196 | # skip if -I has no parameter | ||
| 197 | addtree = $(if $(patsubst -I%,%,$(1)), \ | ||
| 198 | $(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) | ||
| 199 | |||
| 200 | # Find all -I options and call addtree | ||
| 201 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) | ||
| 202 | |||
| 203 | # echo command. | 195 | # echo command. |
| 204 | # Short version is used, if $(quiet) equals `quiet_', otherwise full one. | 196 | # Short version is used, if $(quiet) equals `quiet_', otherwise full one. |
| 205 | echo-cmd = $(if $($(quiet)cmd_$(1)),\ | 197 | echo-cmd = $(if $($(quiet)cmd_$(1)),\ |
diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 73b804197fca..b6a54bdf0965 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host | |||
| @@ -67,18 +67,16 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ | |||
| 67 | _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ | 67 | _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ |
| 68 | $(HOSTCXXFLAGS_$(basetarget).o) | 68 | $(HOSTCXXFLAGS_$(basetarget).o) |
| 69 | 69 | ||
| 70 | __hostc_flags = $(_hostc_flags) | 70 | # $(objtree)/$(obj) for including generated headers from checkin source files |
| 71 | __hostcxx_flags = $(_hostcxx_flags) | ||
| 72 | |||
| 73 | ifeq ($(KBUILD_EXTMOD),) | 71 | ifeq ($(KBUILD_EXTMOD),) |
| 74 | ifneq ($(srctree),.) | 72 | ifneq ($(srctree),.) |
| 75 | __hostc_flags = -I$(obj) $(call flags,_hostc_flags) | 73 | _hostc_flags += -I $(objtree)/$(obj) |
| 76 | __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) | 74 | _hostcxx_flags += -I $(objtree)/$(obj) |
| 77 | endif | 75 | endif |
| 78 | endif | 76 | endif |
| 79 | 77 | ||
| 80 | hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) | 78 | hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) |
| 81 | hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) | 79 | hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) |
| 82 | 80 | ||
| 83 | ##### | 81 | ##### |
| 84 | # Compile programs on the host | 82 | # Compile programs on the host |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 41e98fa66b91..1b412d4394ae 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -137,36 +137,26 @@ _c_flags += $(if $(patsubst n%,, \ | |||
| 137 | $(CFLAGS_KCOV)) | 137 | $(CFLAGS_KCOV)) |
| 138 | endif | 138 | endif |
| 139 | 139 | ||
| 140 | __c_flags = $(_c_flags) | 140 | # $(srctree)/$(src) for including checkin headers from generated source files |
| 141 | __a_flags = $(_a_flags) | 141 | # $(objtree)/$(obj) for including generated headers from checkin source files |
| 142 | __cpp_flags = $(_cpp_flags) | ||
| 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),) | 142 | ifeq ($(KBUILD_EXTMOD),) |
| 147 | ifneq ($(srctree),.) | 143 | ifneq ($(srctree),.) |
| 148 | 144 | _c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) | |
| 149 | # -I$(obj) locates generated .h files | 145 | _a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
| 150 | # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files | 146 | _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) |
| 151 | # and locates generated .h files | ||
| 152 | # FIXME: Replace both with specific CFLAGS* statements in the makefiles | ||
| 153 | __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ | ||
| 154 | $(call flags,_c_flags) | ||
| 155 | __a_flags = $(call flags,_a_flags) | ||
| 156 | __cpp_flags = $(call flags,_cpp_flags) | ||
| 157 | endif | 147 | endif |
| 158 | endif | 148 | endif |
| 159 | 149 | ||
| 160 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 150 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 161 | -include $(srctree)/include/linux/compiler_types.h \ | 151 | -include $(srctree)/include/linux/compiler_types.h \ |
| 162 | $(__c_flags) $(modkern_cflags) \ | 152 | $(_c_flags) $(modkern_cflags) \ |
| 163 | $(basename_flags) $(modname_flags) | 153 | $(basename_flags) $(modname_flags) |
| 164 | 154 | ||
| 165 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 155 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 166 | $(__a_flags) $(modkern_aflags) | 156 | $(_a_flags) $(modkern_aflags) |
| 167 | 157 | ||
| 168 | cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ | 158 | cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 169 | $(__cpp_flags) | 159 | $(_cpp_flags) |
| 170 | 160 | ||
| 171 | ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) | 161 | ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) |
| 172 | 162 | ||
