CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
+# Use UBOOTINCLUDE when you must reference the include/ directory.
+# Needed to be compatible with the O= option
+UBOOTINCLUDE :=
+ifneq ($(OBJTREE),$(SRCTREE))
+UBOOTINCLUDE += -I$(OBJTREE)/include
+endif
+UBOOTINCLUDE += -I$(srctree)/include \
+ -I$(srctree)/arch/$(ARCH)/include
+
KBUILD_CPPFLAGS := -D__KERNEL__
KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
export MAKE AWK
export DTC CHECK CHECKFLAGS
-export KBUILD_CPPFLAGS
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
export KBUILD_CFLAGS KBUILD_AFLAGS
KBUILD_CFLAGS += -Os #-fomit-frame-pointer
# option to the assembler.
KBUILD_AFLAGS += -g
+NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
+CHECKFLAGS += $(NOSTDINC_FLAGS)
+
# Report stack usage if supported
KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
OBJCFLAGS += --gap-fill=0xff
-gccincdir := $(shell $(CC) -print-file-name=include)
-
CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
# Enable garbage collection of un-used sections for SPL
endif
endif
-ifneq ($(OBJTREE),$(SRCTREE))
-CPPFLAGS += -I$(OBJTREE)/include
-endif
-
-CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
-CPPFLAGS += -nostdinc \
- -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+CPPFLAGS += $(UBOOTINCLUDE)
+CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
# Define _GNU_SOURCE to obtain the getline prototype from stdio.h
#
HOST_EXTRACFLAGS += -include $(SRCTREE)/include/libfdt_env.h \
- -idirafter $(SRCTREE)/include \
- -idirafter $(SRCTREE)/arch/$(ARCH)/include \
- -idirafter $(OBJTREE)/include \
- -I $(SRCTREE)/lib/libfdt \
- -I $(SRCTREE)/tools \
+ $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
+ -I$(SRCTREE)/lib/libfdt \
+ -I$(SRCTREE)/tools \
-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
-DUSE_HOSTCC \
-D__KERNEL_STRICT_NAMES \
#
# Compile for a hosted environment on the target
-HOST_EXTRACFLAGS = -idirafter $(SRCTREE)/include \
- -idirafter $(SRCTREE)/arch/$(ARCH)/include \
- -idirafter $(OBJTREE)/include \
+HOST_EXTRACFLAGS = $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
-idirafter $(SRCTREE)/tools/env \
-DUSE_HOSTCC \
-DTEXT_BASE=$(TEXT_BASE)