]> git.ipfire.org Git - people/ms/u-boot.git/blame - scripts/Makefile.spl
kconfig: Adjust ordering so that defaults work as expected
[people/ms/u-boot.git] / scripts / Makefile.spl
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
9e414032
MY
17src := $(obj)
18
19# Create output directory if not already present
20_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
21
bf4b3de1
MY
22include $(srctree)/scripts/Kbuild.include
23
51148790 24UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
6a11cf48 25
51148790
MY
26-include $(obj)/include/config/auto.conf
27-include $(obj)/include/autoconf.mk
e0d5d9f8 28
3aa29de0
YZ
29ifeq ($(CONFIG_TPL_BUILD),y)
30export CONFIG_TPL_BUILD
31SPL_BIN := u-boot-tpl
32else
33SPL_BIN := u-boot-spl
34endif
35
4379ac61 36include $(srctree)/config.mk
e19db555 37include $(srctree)/arch/$(ARCH)/Makefile
6a11cf48 38
026f9cf2
MY
39# Enable garbage collection of un-used sections for SPL
40KBUILD_CFLAGS += -ffunction-sections -fdata-sections
41LDFLAGS_FINAL += --gc-sections
42
5fe6301a 43# FIX ME
026f9cf2
MY
44cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
45 $(NOSTDINC_FLAGS)
5fe6301a 46
01286329 47HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
6a11cf48 48
bf69d664 49libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
656de6b8
MY
50libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
51
52libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
53libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
54libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
11516518 55libs-$(CONFIG_SPL_DM) += drivers/core/
656de6b8
MY
56libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
57libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
58libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
59libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
0cf47862 60libs-$(CONFIG_SYS_MVEBU_DDR) += drivers/ddr/mvebu/
656de6b8
MY
61libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
62libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
63libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
64libs-y += fs/
65libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
66libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/
6dd3b566 67libs-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/
167544e8 68libs-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/
656de6b8
MY
69libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
70libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
71libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
72libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
73libs-$(CONFIG_SPL_NET_SUPPORT) += net/
74libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
75libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
76libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
77libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
78libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
79libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
80libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
81libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
82libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
efcc6096 83
656de6b8
MY
84head-y := $(addprefix $(obj)/,$(head-y))
85libs-y := $(addprefix $(obj)/,$(libs-y))
86u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
87
88libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
e2906a59 89
660e98f2 90# Add GCC lib
cd2e46cb 91ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
a86cf89c 92PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
6445262c 93PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
660e98f2
AM
94endif
95
656de6b8
MY
96u-boot-spl-init := $(head-y)
97u-boot-spl-main := $(libs-y)
6a11cf48
DS
98
99# Linker Script
100ifdef CONFIG_SPL_LDSCRIPT
101# need to strip off double quotes
01286329 102LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
6a11cf48
DS
103endif
104
105ifeq ($(wildcard $(LDSCRIPT)),)
4379ac61 106 LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds
6a11cf48
DS
107endif
108ifeq ($(wildcard $(LDSCRIPT)),)
4379ac61 109 LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds
6a11cf48 110endif
ee60197e 111ifeq ($(wildcard $(LDSCRIPT)),)
4379ac61 112 LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds
ee60197e 113endif
6a11cf48
DS
114ifeq ($(wildcard $(LDSCRIPT)),)
115$(error could not find linker script)
116endif
117
118# Special flags for CPP when processing the linker script.
119# Pass the version down so we can handle backwards compatibility
120# on the fly.
121LDPPFLAGS += \
4379ac61 122 -include $(srctree)/include/u-boot/u-boot.lds.h \
5ee828ca 123 -include $(objtree)/include/config.h \
7e6403a6 124 -DCPUDIR=$(CPUDIR) \
6a11cf48
DS
125 $(shell $(LD) --version | \
126 sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
127
b97241b3 128quiet_cmd_mkimage = MKIMAGE $@
9bf215b0
MY
129cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
130 $(if $(KBUILD_VERBOSE:1=), >/dev/null)
79b9ebb7 131
9bf215b0
MY
132MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE)
133
134MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
135
136MLO MLO.byteswap: $(obj)/u-boot-spl.bin
137 $(call if_changed,mkimage)
3decb14a 138
5c390a5b
AB
139MKIMAGEFLAGS_boot.bin = -T atmelimage
140
141ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y)
142MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params)
143
144boot.bin: $(obj)/../tools/atmel_pmecc_params
145endif
146
147boot.bin: $(obj)/u-boot-spl.bin
148 $(call if_changed,mkimage)
149
9e414032 150ALL-y += $(obj)/$(SPL_BIN).bin
6a11cf48 151
98a48c5d 152ifdef CONFIG_SAMSUNG
9e414032 153ALL-y += $(obj)/$(BOARD)-spl.bin
98a48c5d
CK
154endif
155
50827a59 156ifdef CONFIG_SUNXI
50827a59
IC
157ALL-y += $(obj)/sunxi-spl.bin
158endif
50827a59 159
c001486d
HS
160ifeq ($(CONFIG_SYS_SOC),"at91")
161ALL-y += boot.bin
162endif
163
6a11cf48
DS
164all: $(ALL-y)
165
98a48c5d 166ifdef CONFIG_SAMSUNG
0fcac1ab
RS
167ifdef CONFIG_VAR_SIZE_SPL
168VAR_SIZE_PARAM = --vs
169else
170VAR_SIZE_PARAM =
171endif
9e414032 172$(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
5ee828ca
MY
173 $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
174 $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
175 $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
98a48c5d
CK
176endif
177
f9c235fd
MY
178quiet_cmd_objcopy = OBJCOPY $@
179cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
180
181OBJCOPYFLAGS_$(SPL_BIN).bin = $(SPL_OBJCFLAGS) -O binary
182
183$(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN) FORCE
184 $(call if_changed,objcopy)
6a11cf48 185
9e414032 186LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
e0d5d9f8
MY
187ifneq ($(CONFIG_SPL_TEXT_BASE),)
188LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
189endif
190
50827a59
IC
191ifdef CONFIG_SUNXI
192quiet_cmd_mksunxiboot = MKSUNXI $@
193cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
194$(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin
195 $(call if_changed,mksunxiboot)
196endif
197
656de6b8 198quiet_cmd_u-boot-spl = LD $@
9adb6d24 199 cmd_u-boot-spl = (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
656de6b8
MY
200 $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
201 $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
9adb6d24 202 $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
6a11cf48 203
9adb6d24
MY
204$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
205 $(call if_changed,u-boot-spl)
6a11cf48 206
656de6b8 207$(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
6a11cf48 208
656de6b8
MY
209PHONY += $(u-boot-spl-dirs)
210$(u-boot-spl-dirs):
211 $(Q)$(MAKE) $(build)=$@
6a11cf48 212
04a34c96 213quiet_cmd_cpp_lds = LDS $@
395e60cd
MY
214cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
215 -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
04a34c96 216
6825a95b 217$(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
395e60cd 218 $(call if_changed_dep,cpp_lds)
6a11cf48 219
f9c235fd
MY
220# read all saved command lines
221
222targets := $(wildcard $(sort $(targets)))
223cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
224
225ifneq ($(cmd_files),)
226 $(cmd_files): ; # Do not try to update included dependency files
227 include $(cmd_files)
228endif
229
6825a95b
MY
230PHONY += FORCE
231FORCE:
232
233# Declare the contents of the .PHONY variable as phony. We keep that
234# information in a variable so we can use it in if_changed and friends.
235.PHONY: $(PHONY)