powerpc: move mpc8xxx entry under arch/powerpc/cpu/
[kernel/u-boot.git] / spl / Makefile
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 # SPDX-License-Identifier:      GPL-2.0+
13 #
14 # Based on top-level Makefile.
15 #
16
17 CONFIG_SPL_BUILD := y
18 export CONFIG_SPL_BUILD
19
20 ifeq ($(CONFIG_TPL_BUILD),y)
21 export CONFIG_TPL_BUILD
22 SPL_BIN := u-boot-tpl
23 else
24 SPL_BIN := u-boot-spl
25 endif
26
27 include $(TOPDIR)/config.mk
28
29 # We want the final binaries in this directory
30 ifeq ($(CONFIG_TPL_BUILD),y)
31 obj := $(OBJTREE)/tpl/
32 SPLTREE := $(TPLTREE)
33 else
34 obj := $(OBJTREE)/spl/
35 endif
36
37 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
38
39 ifdef   CONFIG_SPL_START_S_PATH
40 START_PATH := $(subst ",,$(CONFIG_SPL_START_S_PATH))
41 else
42 START_PATH := $(CPUDIR)
43 endif
44
45 START := $(START_PATH)/start.o
46 ifeq ($(CPU),x86)
47 START += $(START_PATH)/start16.o
48 START += $(START_PATH)/resetvec.o
49 endif
50 ifeq ($(CPU),ppc4xx)
51 START += $(START_PATH)/resetvec.o
52 endif
53 ifeq ($(CPU),mpc85xx)
54 START += $(START_PATH)/resetvec.o
55 endif
56
57 LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
58
59 LIBS-y += $(CPUDIR)/lib$(CPU).o
60
61 ifdef SOC
62 LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
63 endif
64 LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
65 LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
66
67 LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/libspl.o
68 LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/libcommon.o
69 LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libdisk.o
70 LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/libi2c.o
71 LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/libgpio.o
72 LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/libmmc.o
73 LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/libserial.o
74 LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
75 LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
76 LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
77 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
78 LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o \
79         drivers/power/pmic/libpmic.o
80 LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
81 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
82 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o
83 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/memory.o
84 LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
85 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
86 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
87 LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/libphy.o
88 LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o
89 LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o
90 LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/libwatchdog.o
91
92 ifneq (,$(CONFIG_MX23)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
93 LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
94 endif
95
96 LIBS-$(CONFIG_ARM) += arch/arm/cpu/libcpu.o
97 LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/libcpu.o
98
99 ifneq ($(CONFIG_MX23)$(CONFIG_MX35),)
100 LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o
101 endif
102
103 # Add GCC lib
104 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
105 PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
106 PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
107 endif
108
109 START := $(addprefix $(SPLTREE)/,$(START))
110 LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
111
112 __START := $(subst $(obj),,$(START))
113 __LIBS := $(subst $(obj),,$(LIBS))
114
115 # Linker Script
116 ifdef CONFIG_SPL_LDSCRIPT
117 # need to strip off double quotes
118 LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
119 endif
120
121 ifeq ($(wildcard $(LDSCRIPT)),)
122         LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
123 endif
124 ifeq ($(wildcard $(LDSCRIPT)),)
125         LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
126 endif
127 ifeq ($(wildcard $(LDSCRIPT)),)
128         LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot-spl.lds
129 endif
130 ifeq ($(wildcard $(LDSCRIPT)),)
131 $(error could not find linker script)
132 endif
133
134 build := -f $(TOPDIR)/scripts/Makefile.build -C
135
136 # Special flags for CPP when processing the linker script.
137 # Pass the version down so we can handle backwards compatibility
138 # on the fly.
139 LDPPFLAGS += \
140         -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
141         -include $(OBJTREE)/include/config.h \
142         -DCPUDIR=$(CPUDIR) \
143         $(shell $(LD) --version | \
144           sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
145
146 $(OBJTREE)/MLO: $(obj)u-boot-spl.bin
147         $(OBJTREE)/tools/mkimage -T omapimage \
148                 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
149
150 $(OBJTREE)/MLO.byteswap: $(obj)u-boot-spl.bin
151         $(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
152                 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
153
154 $(OBJTREE)/SPL : $(obj)u-boot-spl.bin depend
155                 $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $@
156
157 ALL-y   += $(obj)$(SPL_BIN).bin
158
159 ifdef CONFIG_SAMSUNG
160 ALL-y   += $(obj)$(BOARD)-spl.bin
161 endif
162
163 all:    $(ALL-y)
164
165 ifdef CONFIG_SAMSUNG
166 $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
167         $(OBJTREE)/tools/mk$(BOARD)spl \
168                 $(obj)u-boot-spl.bin $(obj)$(BOARD)-spl.bin
169 endif
170
171 $(obj)$(SPL_BIN).bin:   $(obj)$(SPL_BIN)
172         $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
173
174 GEN_UBOOT = \
175         cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
176                 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
177                 -Map $(SPL_BIN).map -o $(SPL_BIN)
178
179 $(obj)$(SPL_BIN):       depend $(START) $(LIBS) $(obj)u-boot-spl.lds
180         $(GEN_UBOOT)
181
182 $(START):
183         @:
184
185 $(LIBS):        depend
186         $(MAKE) $(build) $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
187         mv $(dir $@)built-in.o $@
188
189 $(obj)u-boot-spl.lds: $(LDSCRIPT) depend
190         $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
191
192 depend: $(obj).depend
193 .PHONY: depend
194
195 # defines $(obj).depend target
196 include $(SRCTREE)/rules.mk