]> git.ipfire.org Git - people/ms/u-boot.git/blame - spl/Makefile
Makefile: move more stuff to top Makefile
[people/ms/u-boot.git] / spl / Makefile
CommitLineData
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#
1a459660 12# SPDX-License-Identifier: GPL-2.0+
6a11cf48
DS
13#
14# Based on top-level Makefile.
15#
16
bf4b3de1
MY
17include $(srctree)/scripts/Kbuild.include
18
6a11cf48
DS
19CONFIG_SPL_BUILD := y
20export CONFIG_SPL_BUILD
21
3aa29de0
YZ
22ifeq ($(CONFIG_TPL_BUILD),y)
23export CONFIG_TPL_BUILD
24SPL_BIN := u-boot-tpl
25else
26SPL_BIN := u-boot-spl
27endif
28
6a11cf48
DS
29include $(TOPDIR)/config.mk
30
31# We want the final binaries in this directory
3aa29de0
YZ
32ifeq ($(CONFIG_TPL_BUILD),y)
33obj := $(OBJTREE)/tpl/
34SPLTREE := $(TPLTREE)
35else
6a11cf48 36obj := $(OBJTREE)/spl/
3aa29de0 37endif
6a11cf48 38
e66443fd 39HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
6a11cf48 40
08e4f700 41ifdef CONFIG_SPL_START_S_PATH
a8c07541 42START_PATH := $(CONFIG_SPL_START_S_PATH:"%"=%)
08e4f700
MV
43else
44START_PATH := $(CPUDIR)
45endif
46
e8a8b824
MY
47head-y := $(START_PATH)/start.o
48head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
49head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
50head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
6a11cf48 51
e2906a59 52LIBS-y += arch/$(ARCH)/lib/
510ed3b8 53
e2906a59 54LIBS-y += $(CPUDIR)/
510ed3b8 55
6a11cf48 56ifdef SOC
e2906a59
MY
57LIBS-y += $(CPUDIR)/$(SOC)/
58endif
59LIBS-y += board/$(BOARDDIR)/
60LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
61
62LIBS-$(CONFIG_SPL_FRAMEWORK) += common/spl/
63LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
64LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
65LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
66LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
67LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
5614e71b 68LIBS-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
e2906a59
MY
69LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
70LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
71LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
57c3e5fc 72LIBS-y += fs/
e2906a59
MY
73LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
74LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \
75 drivers/power/pmic/
392ba525 76LIBS-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
6609916e 77LIBS-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
e2906a59
MY
78LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
79LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
80LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
81LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/
82LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
83LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
84LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
85LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
86LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
87LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
8cffe5bd
DM
88LIBS-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
89LIBS-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
fff40a7e 90LIBS-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
efcc6096 91
ba931259 92ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
e2906a59 93LIBS-y += arch/$(ARCH)/imx-common/
cfb8e87a
MV
94endif
95
e2906a59
MY
96LIBS-$(CONFIG_ARM) += arch/arm/cpu/
97LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
d9e73a87 98
e2906a59
MY
99LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
100
660e98f2
AM
101# Add GCC lib
102ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
103PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
104PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
105endif
106
e8a8b824 107START := $(addprefix $(SPLTREE)/,$(head-y))
6a11cf48
DS
108LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
109
110__START := $(subst $(obj),,$(START))
111__LIBS := $(subst $(obj),,$(LIBS))
112
113# Linker Script
114ifdef CONFIG_SPL_LDSCRIPT
115# need to strip off double quotes
a8c07541 116LDSCRIPT := $(addprefix $(SRCTREE)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
6a11cf48
DS
117endif
118
119ifeq ($(wildcard $(LDSCRIPT)),)
120 LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
121endif
122ifeq ($(wildcard $(LDSCRIPT)),)
123 LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
124endif
ee60197e 125ifeq ($(wildcard $(LDSCRIPT)),)
65cdd643 126 LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot-spl.lds
ee60197e 127endif
6a11cf48
DS
128ifeq ($(wildcard $(LDSCRIPT)),)
129$(error could not find linker script)
130endif
131
132# Special flags for CPP when processing the linker script.
133# Pass the version down so we can handle backwards compatibility
134# on the fly.
135LDPPFLAGS += \
136 -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
137 -include $(OBJTREE)/include/config.h \
7e6403a6 138 -DCPUDIR=$(CPUDIR) \
6a11cf48
DS
139 $(shell $(LD) --version | \
140 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
141
3decb14a
JR
142$(OBJTREE)/MLO: $(obj)u-boot-spl.bin
143 $(OBJTREE)/tools/mkimage -T omapimage \
144 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
79b9ebb7
TR
145
146$(OBJTREE)/MLO.byteswap: $(obj)u-boot-spl.bin
147 $(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
8a8f084e 148 -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
3decb14a 149
71a988aa 150$(OBJTREE)/SPL : $(obj)u-boot-spl.bin depend
71f84ef0 151 $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $@
a80834c0 152
3aa29de0 153ALL-y += $(obj)$(SPL_BIN).bin
6a11cf48 154
98a48c5d
CK
155ifdef CONFIG_SAMSUNG
156ALL-y += $(obj)$(BOARD)-spl.bin
157endif
158
6a11cf48
DS
159all: $(ALL-y)
160
98a48c5d 161ifdef CONFIG_SAMSUNG
0fcac1ab
RS
162ifdef CONFIG_VAR_SIZE_SPL
163VAR_SIZE_PARAM = --vs
164else
165VAR_SIZE_PARAM =
166endif
98a48c5d 167$(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
e183a174
MY
168 $(if $(wildcard $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
169 $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
940db16d 170 $(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
98a48c5d
CK
171endif
172
3aa29de0 173$(obj)$(SPL_BIN).bin: $(obj)$(SPL_BIN)
b02bfc4d 174 $(OBJCOPY) $(OBJCFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
6a11cf48
DS
175
176GEN_UBOOT = \
be7e41ef 177 cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $(__START) \
6a11cf48 178 --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
3aa29de0 179 -Map $(SPL_BIN).map -o $(SPL_BIN)
6a11cf48 180
3aa29de0 181$(obj)$(SPL_BIN): depend $(START) $(LIBS) $(obj)u-boot-spl.lds
6a11cf48
DS
182 $(GEN_UBOOT)
183
3bddafaa
MY
184$(START):
185 @:
6a11cf48
DS
186
187$(LIBS): depend
3bddafaa 188 $(MAKE) $(build) $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
6a11cf48 189
65cdd643 190$(obj)u-boot-spl.lds: $(LDSCRIPT) depend
97b24d3d 191 $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
6a11cf48
DS
192
193depend: $(obj).depend
194.PHONY: depend
195
196# defines $(obj).depend target
197include $(SRCTREE)/rules.mk