Commit fea1ca8e3418bac4b55f4cc8b66a6ae0d41e91e4

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent 2b3c9d3ddd

Makefile: refactor include path settings

This commit merges commonly-used header include paths
to UBOOTINCLUDE and NOSTDINC_FLAGS variables, which are placed
at the top Makefile.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Showing 4 changed files with 19 additions and 18 deletions Side-by-side Diff

... ... @@ -226,6 +226,15 @@
226 226 CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
227 227 -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
228 228  
  229 +# Use UBOOTINCLUDE when you must reference the include/ directory.
  230 +# Needed to be compatible with the O= option
  231 +UBOOTINCLUDE :=
  232 +ifneq ($(OBJTREE),$(SRCTREE))
  233 +UBOOTINCLUDE += -I$(OBJTREE)/include
  234 +endif
  235 +UBOOTINCLUDE += -I$(srctree)/include \
  236 + -I$(srctree)/arch/$(ARCH)/include
  237 +
229 238 KBUILD_CPPFLAGS := -D__KERNEL__
230 239  
231 240 KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
... ... @@ -238,7 +247,7 @@
238 247 export MAKE AWK
239 248 export DTC CHECK CHECKFLAGS
240 249  
241   -export KBUILD_CPPFLAGS
  250 +export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
242 251 export KBUILD_CFLAGS KBUILD_AFLAGS
243 252  
244 253 KBUILD_CFLAGS += -Os #-fomit-frame-pointer
... ... @@ -253,6 +262,9 @@
253 262 # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
254 263 # option to the assembler.
255 264 KBUILD_AFLAGS += -g
  265 +
  266 +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  267 +CHECKFLAGS += $(NOSTDINC_FLAGS)
256 268  
257 269 # Report stack usage if supported
258 270 KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
... ... @@ -94,8 +94,6 @@
94 94  
95 95 OBJCFLAGS += --gap-fill=0xff
96 96  
97   -gccincdir := $(shell $(CC) -print-file-name=include)
98   -
99 97 CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
100 98  
101 99 # Enable garbage collection of un-used sections for SPL
... ... @@ -123,13 +121,8 @@
123 121 endif
124 122 endif
125 123  
126   -ifneq ($(OBJTREE),$(SRCTREE))
127   -CPPFLAGS += -I$(OBJTREE)/include
128   -endif
129   -
130   -CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
131   -CPPFLAGS += -nostdinc \
132   - -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
  124 +CPPFLAGS += $(UBOOTINCLUDE)
  125 +CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
133 126  
134 127 CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
135 128  
... ... @@ -175,11 +175,9 @@
175 175 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
176 176 #
177 177 HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
178   - -idirafter $(SRCTREE)/include \
179   - -idirafter $(SRCTREE)/arch/$(ARCH)/include \
180   - -idirafter $(OBJTREE)/include \
181   - -I $(SRCTREE)/lib/libfdt \
182   - -I $(SRCTREE)/tools \
  178 + $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
  179 + -I$(SRCTREE)/lib/libfdt \
  180 + -I$(SRCTREE)/tools \
183 181 -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
184 182 -DUSE_HOSTCC \
185 183 -D__KERNEL_STRICT_NAMES \
... ... @@ -6,9 +6,7 @@
6 6 #
7 7  
8 8 # Compile for a hosted environment on the target
9   -HOST_EXTRACFLAGS = -idirafter $(SRCTREE)/include \
10   - -idirafter $(SRCTREE)/arch/$(ARCH)/include \
11   - -idirafter $(OBJTREE)/include \
  9 +HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
12 10 -idirafter $(SRCTREE)/tools/env \
13 11 -DUSE_HOSTCC \
14 12 -DTEXT_BASE=$(TEXT_BASE)