Makefile: move more flags to the top Makefile
[oweals/u-boot.git] / Makefile
index e4045bcba08d8d46fc2055370787b067f959f9c8..3a97483d453d1fa454e074ba02062d7507e1eb91 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -226,11 +226,46 @@ CHECK             = sparse
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
 
+KBUILD_CPPFLAGS := -D__KERNEL__
+
+KBUILD_CFLAGS   := -Wall -Wstrict-prototypes \
+                  -Wno-format-security \
+                  -fno-builtin -ffreestanding
+KBUILD_AFLAGS   := -D__ASSEMBLY__
+
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
 export DTC CHECK CHECKFLAGS
 
+export KBUILD_CPPFLAGS
+export KBUILD_CFLAGS KBUILD_AFLAGS
+
+KBUILD_CFLAGS += -Os #-fomit-frame-pointer
+
+ifdef BUILD_TAG
+KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
+endif
+
+KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+
+KBUILD_CFLAGS  += -g
+# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+KBUILD_AFLAGS  += -g
+
+# Report stack usage if supported
+KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
+
+KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+KBUILD_AFLAGS += -Wa,-gstabs,-S
+endif
+endif
+
 # load other configuration
 include $(TOPDIR)/config.mk