From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Schwierzeck Date: Tue, 5 Jul 2011 18:26:21 +0200 Subject: [U-Boot] [RFC PATCH 3/4] Add new folder and build system for SPL In-Reply-To: <1309883182-12854-1-git-send-email-daniel.schwierzeck@googlemail.com> References: <1309352967-5719-1-git-send-email-aneesh@ti.com> <1309883182-12854-1-git-send-email-daniel.schwierzeck@googlemail.com> Message-ID: <1309883182-12854-4-git-send-email-daniel.schwierzeck@googlemail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de [aneesh at ti.com: 1. Changed definition of OBJTREE for SPL 2. Added support for linker script from various places 4. $(OBJTREE)/spl/obj for objects 5. Minor cleanup ] [daniel.schwierzeck at googlemail.com: 1. removed ALL and clean targets 2. fixed out-of-tree build error on u-boot-spl.lds generation 3. determine LDSCRIPT variable like top Makefiles does 4. fixed dependency error in target $(obj)u-boot-spl.lds ] Signed-off-by: Aneesh V Signed-off-by: Daniel Schwierzeck --- spl/Makefile | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-) create mode 100644 spl/Makefile diff --git a/spl/Makefile b/spl/Makefile new file mode 100644 index 0000000..0521008 --- /dev/null +++ b/spl/Makefile @@ -0,0 +1,97 @@ +# +# (C) Copyright 2011 Daniel Schwierzeck, daniel.schwierzeck at googlemail.com. +# +# (C) Copyright 2011 +# Texas Instruments Incorporated - http://www.ti.com/ +# Aneesh V +# +# This file is released under the terms of GPL v2 and any later version. +# See the file COPYING in the root directory of the source tree for details. +# + +CONFIG_UBOOT_SPL_BUILD = y +export CONFIG_UBOOT_SPL_BUILD + +# create 'spl/obj' within OBJTREE for spl +OBJTREE := $(OBJTREE)/spl/obj +LNDIR := $(OBJTREE) + +include $(TOPDIR)/config.mk +# We want the final binaries in this directory +obj := $(obj)../ +START = $(OBJTREE)/$(CPUDIR)/start.o + +LIBS-y += $(shell if [ -f $(SRCTREE)/board/$(VENDOR)/common/Makefile ]; \ + then echo "board/$(VENDOR)/common/lib$(VENDOR).o"; fi) +LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o +LIBS-y += $(CPUDIR)/lib$(CPU).o +ifdef SOC +LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o +endif +LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o +LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o +LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o +LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/libgpio.o +LIBS-$(CONFIG_SPL_NAND_BOOT) += spl/nand/libnand_spl.o +LIBS-$(CONFIG_SPL_ONENAND_BOOT) += spl/nand/libonenand_spl.o + +LIBS = $(addprefix $(OBJTREE)/,$(sort $(LIBS-y))) + +__START = $(subst $(OBJTREE)/,,$(START)) +__LIBS = $(subst $(OBJTREE)/,,$(LIBS)) + +# Linker Script +ifdef CONFIG_SYS_SPL_LDSCRIPT +# need to strip off double quotes +LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SYS_SPL_LDSCRIPT))) +endif + +ifeq ($(wildcard $(LDSCRIPT)),) + LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds +endif +ifeq ($(wildcard $(LDSCRIPT)),) + LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds +endif +ifeq ($(wildcard $(LDSCRIPT)),) +$(error could not find linker script) +endif + +# Special flags for CPP when processing the linker script. +# Pass the version down so we can handle backwards compatibility +# on the fly. +LDPPFLAGS += \ + -include $(TOPDIR)/include/u-boot/u-boot.lds.h \ + -include $(OBJTREE)/../../include/config.h \ + $(shell $(LD) --version | \ + sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') + +all: $(obj)u-boot-spl.bin + +$(obj)u-boot-spl.bin: $(obj)u-boot-spl + $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ + +GEN_UBOOT = \ + UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \ + sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ + cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \ + --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ + -Map u-boot-spl.map -o u-boot-spl + +$(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds + $(GEN_UBOOT) + +$(START): depend + $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@ + +$(LIBS): depend + $(MAKE) -C $(SRCTREE)$(dir $(subst $(OBJTREE),,$@)) + +$(obj)u-boot-spl.lds: $(LDSCRIPT) depend + $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@ + +depend: $(obj).depend +.PHONY: depend + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + -- 1.7.5.4