]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - config.mk
powerpc: cpm2 boards: update fcc register logic
[people/ms/u-boot.git] / config.mk
index 7ce554ecfec32beb8479c353c40b2b31dfdcf7f3..e2b440d8b2d71ec869cf95dc15038bc88bbbed7b 100644 (file)
--- a/config.mk
+++ b/config.mk
 
 #########################################################################
 
-ifneq ($(OBJTREE),$(SRCTREE))
 ifeq ($(CURDIR),$(SRCTREE))
 dir :=
 else
 dir := $(subst $(SRCTREE)/,,$(CURDIR))
 endif
 
+ifneq ($(OBJTREE),$(SRCTREE))
+# Create object files for SPL in a separate directory
+ifeq ($(CONFIG_SPL_BUILD),y)
+obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
+else
 obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
+endif
 src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
 
+$(shell mkdir -p $(obj))
+else
+# Create object files for SPL in a separate directory
+ifeq ($(CONFIG_SPL_BUILD),y)
+obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
+
 $(shell mkdir -p $(obj))
 else
 obj :=
+endif
 src :=
 endif
 
@@ -154,46 +166,31 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g # -DDEBUG
 OPTFLAGS= -Os #-fomit-frame-pointer
 
-# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
-# that (or fail if absent).  Otherwise, search for a linker script in a
-# standard location.
-
-ifndef LDSCRIPT
-       #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
-       ifdef CONFIG_SYS_LDSCRIPT
-               # need to strip off double quotes
-               LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
-       endif
-endif
-
-ifndef LDSCRIPT
-       ifeq ($(CONFIG_NAND_U_BOOT),y)
-               LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
-               ifeq ($(wildcard $(LDSCRIPT)),)
-                       LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
-               endif
-       endif
-       ifeq ($(wildcard $(LDSCRIPT)),)
-               LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
-       endif
-       ifeq ($(wildcard $(LDSCRIPT)),)
-               LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
-       endif
-       ifeq ($(wildcard $(LDSCRIPT)),)
-$(error could not find linker script)
-       endif
-endif
-
 OBJCFLAGS += --gap-fill=0xff
 
 gccincdir := $(shell $(CC) -print-file-name=include)
 
 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
        -D__KERNEL__
+
+# Enable garbage collection of un-used sections for SPL
+ifeq ($(CONFIG_SPL_BUILD),y)
+CPPFLAGS += -ffunction-sections -fdata-sections
+LDFLAGS_FINAL += --gc-sections
+endif
+
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
 endif
 
+ifneq ($(CONFIG_SPL_TEXT_BASE),)
+CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE)
+endif
+
+ifeq ($(CONFIG_SPL_BUILD),y)
+CPPFLAGS += -DCONFIG_SPL_BUILD
+endif
+
 ifneq ($(RESET_VECTOR_ADDRESS),)
 CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
 endif
@@ -214,6 +211,10 @@ CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
 endif
 
 CFLAGS += $(call cc-option,-fno-stack-protector)
+# Some toolchains enable security related warning flags by default,
+# but they don't make much sense in the u-boot world, so disable them.
+CFLAGS += $(call cc-option,-Wno-format-nonliteral)
+CFLAGS += $(call cc-option,-Wno-format-security)
 
 # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
 # option to the assembler.
@@ -236,6 +237,11 @@ ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
+LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SPL_TEXT_BASE),)
+LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
+endif
+
 # Location of a usable BFD library, where we define "usable" as
 # "built for ${HOST}, supports ${TARGET}".  Sensible values are
 # - When cross-compiling: the root of the cross-environment