]>
Commit | Line | Data |
---|---|---|
6a11cf48 DS |
1 | # |
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 | ||
18 | CONFIG_SPL_BUILD := y | |
19 | export CONFIG_SPL_BUILD | |
20 | ||
21 | include $(TOPDIR)/config.mk | |
22 | ||
23 | # We want the final binaries in this directory | |
24 | obj := $(OBJTREE)/spl/ | |
25 | ||
26 | HAVE_VENDOR_COMMON_LIB := $(shell [ -f $(SRCTREE)/board/$(VENDOR)/common/Makefile ] \ | |
27 | && echo y || echo n) | |
28 | ||
29 | START := $(CPUDIR)/start.o | |
30 | ||
31 | LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o | |
32 | LIBS-y += $(CPUDIR)/lib$(CPU).o | |
33 | ifdef SOC | |
34 | LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o | |
35 | endif | |
36 | LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o | |
37 | LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o | |
38 | ||
39 | START := $(addprefix $(SPLTREE)/,$(START)) | |
40 | LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y))) | |
41 | ||
42 | __START := $(subst $(obj),,$(START)) | |
43 | __LIBS := $(subst $(obj),,$(LIBS)) | |
44 | ||
45 | # Linker Script | |
46 | ifdef CONFIG_SPL_LDSCRIPT | |
47 | # need to strip off double quotes | |
48 | LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT))) | |
49 | endif | |
50 | ||
51 | ifeq ($(wildcard $(LDSCRIPT)),) | |
52 | LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds | |
53 | endif | |
54 | ifeq ($(wildcard $(LDSCRIPT)),) | |
55 | LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds | |
56 | endif | |
57 | ifeq ($(wildcard $(LDSCRIPT)),) | |
58 | $(error could not find linker script) | |
59 | endif | |
60 | ||
61 | # Special flags for CPP when processing the linker script. | |
62 | # Pass the version down so we can handle backwards compatibility | |
63 | # on the fly. | |
64 | LDPPFLAGS += \ | |
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') | |
69 | ||
70 | ALL-y += $(obj)u-boot-spl.bin | |
71 | ||
72 | all: $(ALL-y) | |
73 | ||
74 | $(obj)u-boot-spl.bin: $(obj)u-boot-spl | |
75 | $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@ | |
76 | ||
77 | GEN_UBOOT = \ | |
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 | |
83 | ||
84 | $(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds | |
85 | $(GEN_UBOOT) | |
86 | ||
87 | $(START): depend | |
88 | $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@ | |
89 | ||
90 | $(LIBS): depend | |
91 | $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@)) | |
92 | ||
93 | $(obj)u-boot-spl.lds: $(LDSCRIPT) depend | |
94 | $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@ | |
95 | ||
96 | depend: $(obj).depend | |
97 | .PHONY: depend | |
98 | ||
99 | # defines $(obj).depend target | |
100 | include $(SRCTREE)/rules.mk |