blob: 1e912f0de23afd5b3a347b4eca17979f4b714dc6 [file] [log] [blame]
Daniel Schwierzeck39ca08e2011-07-18 07:48:07 +00001#
2# (C) Copyright 2000-2011
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
5# (C) Copyright 2011
6# Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
7#
8# (C) Copyright 2011
9# Texas Instruments Incorporated - http://www.ti.com/
10# Aneesh V <aneesh@ti.com>
11#
12# This file is released under the terms of GPL v2 and any later version.
13# See the file COPYING in the root directory of the source tree for details.
14#
15# Based on top-level Makefile.
16#
17
18CONFIG_SPL_BUILD := y
19export CONFIG_SPL_BUILD
20
21include $(TOPDIR)/config.mk
22
23# We want the final binaries in this directory
24obj := $(OBJTREE)/spl/
25
26HAVE_VENDOR_COMMON_LIB := $(shell [ -f $(SRCTREE)/board/$(VENDOR)/common/Makefile ] \
27 && echo y || echo n)
28
29START := $(CPUDIR)/start.o
30
31LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
32LIBS-y += $(CPUDIR)/lib$(CPU).o
33ifdef SOC
34LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
35endif
36LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
37LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
38
Daniel Schwierzeck2a7cda82011-07-13 05:11:08 +000039LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/libcommon.o
40LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libdisk.o
41LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/libi2c.o
42LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/libgpio.o
43LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/libmmc.o
44LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/libserial.o
45LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
46LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
47LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
48LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
Simon Schwarz4f62e982011-09-14 15:30:16 -040049LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
Daniel Schwierzeck2a7cda82011-07-13 05:11:08 +000050
Daniel Schwierzeck4504f2f2011-07-13 05:11:09 +000051ifeq ($(SOC),omap3)
52LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
53endif
54ifeq ($(SOC),omap4)
55LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
56endif
57
Daniel Schwierzeck39ca08e2011-07-18 07:48:07 +000058START := $(addprefix $(SPLTREE)/,$(START))
59LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
60
61__START := $(subst $(obj),,$(START))
62__LIBS := $(subst $(obj),,$(LIBS))
63
64# Linker Script
65ifdef CONFIG_SPL_LDSCRIPT
66# need to strip off double quotes
67LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
68endif
69
70ifeq ($(wildcard $(LDSCRIPT)),)
71 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
72endif
73ifeq ($(wildcard $(LDSCRIPT)),)
74 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
75endif
76ifeq ($(wildcard $(LDSCRIPT)),)
77$(error could not find linker script)
78endif
79
80# Special flags for CPP when processing the linker script.
81# Pass the version down so we can handle backwards compatibility
82# on the fly.
83LDPPFLAGS += \
84 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
85 -include $(OBJTREE)/include/config.h \
86 $(shell $(LD) --version | \
87 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
88
John Rigby34d12a12011-07-21 09:10:30 -040089ifdef CONFIG_OMAP
90$(OBJTREE)/MLO: $(obj)u-boot-spl.bin
91 $(OBJTREE)/tools/mkimage -T omapimage \
92 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
93endif
94
Daniel Schwierzeck39ca08e2011-07-18 07:48:07 +000095ALL-y += $(obj)u-boot-spl.bin
96
Chander Kashyap488ef1a2011-08-18 22:37:20 +000097ifdef CONFIG_SAMSUNG
98ALL-y += $(obj)$(BOARD)-spl.bin
99endif
100
Daniel Schwierzeck39ca08e2011-07-18 07:48:07 +0000101all: $(ALL-y)
102
Chander Kashyap488ef1a2011-08-18 22:37:20 +0000103ifdef CONFIG_SAMSUNG
104$(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
105 $(TOPDIR)/board/$(BOARDDIR)/tools/mk$(BOARD)spl.exe \
106 $(obj)u-boot-spl.bin $(obj)$(BOARD)-spl.bin
107endif
108
Daniel Schwierzeck39ca08e2011-07-18 07:48:07 +0000109$(obj)u-boot-spl.bin: $(obj)u-boot-spl
110 $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
111
112GEN_UBOOT = \
113 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \
114 sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
115 cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \
116 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
117 -Map u-boot-spl.map -o u-boot-spl
118
119$(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds
120 $(GEN_UBOOT)
121
122$(START): depend
123 $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@
124
125$(LIBS): depend
126 $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
127
128$(obj)u-boot-spl.lds: $(LDSCRIPT) depend
129 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
130
131depend: $(obj).depend
132.PHONY: depend
133
134# defines $(obj).depend target
135include $(SRCTREE)/rules.mk