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 # SPDX-License-Identifier: GPL-2.0+
14 # Based on top-level Makefile.
18 export CONFIG_SPL_BUILD
20 ifeq ($(CONFIG_TPL_BUILD),y)
21 export CONFIG_TPL_BUILD
27 include $(TOPDIR)/config.mk
29 # We want the final binaries in this directory
30 ifeq ($(CONFIG_TPL_BUILD),y)
31 obj := $(OBJTREE)/tpl/
34 obj := $(OBJTREE)/spl/
37 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
39 ifdef CONFIG_SPL_START_S_PATH
40 START_PATH := $(subst ",,$(CONFIG_SPL_START_S_PATH))
42 START_PATH := $(CPUDIR)
45 START := $(START_PATH)/start.o
47 START += $(START_PATH)/start16.o
48 START += $(START_PATH)/resetvec.o
51 START += $(START_PATH)/resetvec.o
54 START += $(START_PATH)/resetvec.o
57 LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
59 LIBS-y += $(CPUDIR)/lib$(CPU).o
61 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
64 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
65 ifdef CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
66 LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
70 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
74 LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
76 LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
77 LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
79 LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/libspl.o
80 LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/libcommon.o
81 LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libdisk.o
82 LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/libi2c.o
83 LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/libgpio.o
84 LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/libmmc.o
85 LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/libserial.o
86 LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
87 LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
88 LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
89 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
90 LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
91 LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
92 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
93 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
94 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
95 LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
96 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
97 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
98 LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/libphy.o
99 LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o
100 LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o
101 LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/libwatchdog.o
103 ifneq ($(CONFIG_OMAP_COMMON),)
104 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
107 ifneq (,$(CONFIG_MX23)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
108 LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
111 ifneq ($(CONFIG_TEGRA),)
112 LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o
113 LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o
114 LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o
117 ifneq ($(CONFIG_MX23)$(CONFIG_MX35),)
118 LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
122 LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
126 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
127 PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
128 PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
131 START := $(addprefix $(SPLTREE)/,$(START))
132 LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
134 __START := $(subst $(obj),,$(START))
135 __LIBS := $(subst $(obj),,$(LIBS))
138 ifdef CONFIG_SPL_LDSCRIPT
139 # need to strip off double quotes
140 LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
143 ifeq ($(wildcard $(LDSCRIPT)),)
144 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
146 ifeq ($(wildcard $(LDSCRIPT)),)
147 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
149 ifeq ($(wildcard $(LDSCRIPT)),)
150 LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot-spl.lds
152 ifeq ($(wildcard $(LDSCRIPT)),)
153 $(error could not find linker script)
156 # Special flags for CPP when processing the linker script.
157 # Pass the version down so we can handle backwards compatibility
160 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
161 -include $(OBJTREE)/include/config.h \
163 $(shell $(LD) --version | \
164 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
166 $(OBJTREE)/MLO: $(obj)u-boot-spl.bin
167 $(OBJTREE)/tools/mkimage -T omapimage \
168 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
170 $(OBJTREE)/MLO.byteswap: $(obj)u-boot-spl.bin
171 $(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
172 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
174 $(OBJTREE)/SPL : $(obj)u-boot-spl.bin depend
175 $(MAKE) -C $(SRCTREE)/arch/arm/imx-common $@
177 ALL-y += $(obj)$(SPL_BIN).bin
180 ALL-y += $(obj)$(BOARD)-spl.bin
186 $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
187 $(OBJTREE)/tools/mk$(BOARD)spl \
188 $(obj)u-boot-spl.bin $(obj)$(BOARD)-spl.bin
191 $(obj)$(SPL_BIN).bin: $(obj)$(SPL_BIN)
192 $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
195 cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
196 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
197 -Map $(SPL_BIN).map -o $(SPL_BIN)
199 $(obj)$(SPL_BIN): depend $(START) $(LIBS) $(obj)u-boot-spl.lds
203 $(MAKE) -C $(SRCTREE)/$(START_PATH) $@
206 $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
208 $(obj)u-boot-spl.lds: $(LDSCRIPT) depend
209 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
211 depend: $(obj).depend
214 # defines $(obj).depend target
215 include $(SRCTREE)/rules.mk