2 # (C) Copyright 2000-2011
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
9 # Texas Instruments Incorporated - http://www.ti.com/
10 # Aneesh V <aneesh@ti.com>
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.
15 # Based on top-level Makefile.
19 export CONFIG_SPL_BUILD
21 include $(TOPDIR)/config.mk
23 # We want the final binaries in this directory
24 obj := $(OBJTREE)/spl/
26 HAVE_VENDOR_COMMON_LIB := $(shell [ -f $(SRCTREE)/board/$(VENDOR)/common/Makefile ] \
29 START := $(CPUDIR)/start.o
31 LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
32 LIBS-y += $(CPUDIR)/lib$(CPU).o
34 LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
36 LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
37 LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
39 START := $(addprefix $(SPLTREE)/,$(START))
40 LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
42 __START := $(subst $(obj),,$(START))
43 __LIBS := $(subst $(obj),,$(LIBS))
46 ifdef CONFIG_SPL_LDSCRIPT
47 # need to strip off double quotes
48 LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
51 ifeq ($(wildcard $(LDSCRIPT)),)
52 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
54 ifeq ($(wildcard $(LDSCRIPT)),)
55 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
57 ifeq ($(wildcard $(LDSCRIPT)),)
58 $(error could not find linker script)
61 # Special flags for CPP when processing the linker script.
62 # Pass the version down so we can handle backwards compatibility
65 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
66 -include $(OBJTREE)/include/config.h \
67 $(shell $(LD) --version | \
68 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
70 ALL-y += $(obj)u-boot-spl.bin
74 $(obj)u-boot-spl.bin: $(obj)u-boot-spl
75 $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
78 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \
79 sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
80 cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \
81 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
82 -Map u-boot-spl.map -o u-boot-spl
84 $(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds
88 $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@
91 $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
93 $(obj)u-boot-spl.lds: $(LDSCRIPT) depend
94 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
99 # defines $(obj).depend target
100 include $(SRCTREE)/rules.mk