2011-07-18 15:48:07 +08:00
|
|
|
#
|
|
|
|
# (C) Copyright 2000-2011
|
|
|
|
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
#
|
|
|
|
# (C) Copyright 2011
|
|
|
|
# Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
|
|
|
|
#
|
|
|
|
# (C) Copyright 2011
|
|
|
|
# Texas Instruments Incorporated - http://www.ti.com/
|
|
|
|
# Aneesh V <aneesh@ti.com>
|
|
|
|
#
|
2013-07-08 15:37:19 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2011-07-18 15:48:07 +08:00
|
|
|
#
|
|
|
|
# Based on top-level Makefile.
|
|
|
|
#
|
|
|
|
|
2014-02-04 16:24:24 +08:00
|
|
|
src := $(obj)
|
|
|
|
|
|
|
|
# Create output directory if not already present
|
|
|
|
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
|
|
|
|
|
2014-02-04 16:24:18 +08:00
|
|
|
include $(srctree)/scripts/Kbuild.include
|
|
|
|
|
2011-07-18 15:48:07 +08:00
|
|
|
CONFIG_SPL_BUILD := y
|
|
|
|
export CONFIG_SPL_BUILD
|
|
|
|
|
2014-02-04 16:24:22 +08:00
|
|
|
KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
|
|
|
|
ifeq ($(CONFIG_TPL_BUILD),y)
|
|
|
|
KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
|
|
|
|
endif
|
|
|
|
|
2013-08-16 15:16:15 +08:00
|
|
|
ifeq ($(CONFIG_TPL_BUILD),y)
|
|
|
|
export CONFIG_TPL_BUILD
|
|
|
|
SPL_BIN := u-boot-tpl
|
|
|
|
else
|
|
|
|
SPL_BIN := u-boot-spl
|
|
|
|
endif
|
|
|
|
|
2014-02-04 16:24:32 +08:00
|
|
|
include include/config.mk
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_TPL_BUILD),y)
|
|
|
|
-include include/tpl-autoconf.mk
|
|
|
|
else
|
|
|
|
-include include/spl-autoconf.mk
|
|
|
|
endif
|
|
|
|
|
2014-03-11 10:05:19 +08:00
|
|
|
include $(srctree)/config.mk
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-03-05 15:59:40 +08:00
|
|
|
# Enable garbage collection of un-used sections for SPL
|
|
|
|
KBUILD_CFLAGS += -ffunction-sections -fdata-sections
|
|
|
|
LDFLAGS_FINAL += --gc-sections
|
|
|
|
|
2014-02-04 16:24:33 +08:00
|
|
|
# FIX ME
|
2014-03-05 15:59:40 +08:00
|
|
|
cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
|
|
|
|
$(NOSTDINC_FLAGS)
|
|
|
|
c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
|
2014-02-04 16:24:33 +08:00
|
|
|
|
|
|
|
# Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
|
|
|
|
quiet_cmd_autoconf = GEN $@
|
|
|
|
cmd_autoconf = \
|
|
|
|
$(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
|
|
|
|
sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
|
|
|
|
rm $@.tmp
|
|
|
|
|
|
|
|
include/tpl-autoconf.mk: include/config.h
|
|
|
|
$(call cmd,autoconf)
|
|
|
|
|
|
|
|
include/spl-autoconf.mk: include/config.h
|
|
|
|
$(call cmd,autoconf)
|
|
|
|
|
2014-03-11 10:05:20 +08:00
|
|
|
HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2011-09-12 01:56:19 +08:00
|
|
|
ifdef CONFIG_SPL_START_S_PATH
|
2013-12-05 14:08:31 +08:00
|
|
|
START_PATH := $(CONFIG_SPL_START_S_PATH:"%"=%)
|
2011-09-12 01:56:19 +08:00
|
|
|
else
|
|
|
|
START_PATH := $(CPUDIR)
|
|
|
|
endif
|
|
|
|
|
2013-11-28 11:09:59 +08:00
|
|
|
head-y := $(START_PATH)/start.o
|
|
|
|
head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
|
|
|
|
head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
|
|
|
|
head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-y += arch/$(ARCH)/lib/
|
2012-09-20 06:56:39 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-y += $(CPUDIR)/
|
2012-09-20 06:56:39 +08:00
|
|
|
|
2011-07-18 15:48:07 +08:00
|
|
|
ifdef SOC
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-y += $(CPUDIR)/$(SOC)/
|
|
|
|
endif
|
2014-04-25 20:54:31 +08:00
|
|
|
libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
|
|
|
|
|
|
|
|
libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
|
|
|
|
libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
|
|
|
|
libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
|
|
|
|
libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
|
|
|
|
libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
|
|
|
|
libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
|
|
|
|
libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
|
|
|
|
libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
|
|
|
|
libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
|
|
|
|
libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
|
|
|
|
libs-y += fs/
|
|
|
|
libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
|
|
|
|
libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/
|
2014-03-29 00:03:36 +08:00
|
|
|
libs-$(CONFIG_SPL_MTD_SUPPORT) += drivers/mtd/
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
|
|
|
|
libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
|
|
|
|
libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
|
|
|
|
libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
|
|
|
|
libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
|
|
|
|
libs-$(CONFIG_SPL_NET_SUPPORT) += net/
|
|
|
|
libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
|
|
|
|
libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
|
|
|
|
libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
|
|
|
|
libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
|
|
|
|
libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
|
|
|
|
libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
|
|
|
|
libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
|
|
|
|
libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
|
|
|
|
libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
|
2011-07-13 13:11:08 +08:00
|
|
|
|
2013-12-11 09:00:08 +08:00
|
|
|
ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-y += arch/$(ARCH)/imx-common/
|
2013-04-21 13:52:25 +08:00
|
|
|
endif
|
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
libs-$(CONFIG_ARM) += arch/arm/cpu/
|
|
|
|
libs-$(CONFIG_PPC) += arch/powerpc/cpu/
|
2012-08-31 16:30:01 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
head-y := $(addprefix $(obj)/,$(head-y))
|
|
|
|
libs-y := $(addprefix $(obj)/,$(libs-y))
|
|
|
|
u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
|
|
|
|
|
|
|
|
libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
|
2013-11-11 13:36:00 +08:00
|
|
|
|
2012-08-31 16:30:14 +08:00
|
|
|
# Add GCC lib
|
2014-03-05 15:59:38 +08:00
|
|
|
ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
|
2014-02-27 21:40:34 +08:00
|
|
|
PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
|
2014-02-24 19:44:14 +08:00
|
|
|
PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
|
2012-08-31 16:30:14 +08:00
|
|
|
endif
|
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
u-boot-spl-init := $(head-y)
|
|
|
|
u-boot-spl-main := $(libs-y)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
|
|
|
# Linker Script
|
|
|
|
ifdef CONFIG_SPL_LDSCRIPT
|
|
|
|
# need to strip off double quotes
|
2014-03-11 10:05:20 +08:00
|
|
|
LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
|
2011-07-18 15:48:07 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(wildcard $(LDSCRIPT)),)
|
2014-03-11 10:05:19 +08:00
|
|
|
LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds
|
2011-07-18 15:48:07 +08:00
|
|
|
endif
|
|
|
|
ifeq ($(wildcard $(LDSCRIPT)),)
|
2014-03-11 10:05:19 +08:00
|
|
|
LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds
|
2011-07-18 15:48:07 +08:00
|
|
|
endif
|
2011-11-21 18:49:37 +08:00
|
|
|
ifeq ($(wildcard $(LDSCRIPT)),)
|
2014-03-11 10:05:19 +08:00
|
|
|
LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds
|
2011-11-21 18:49:37 +08:00
|
|
|
endif
|
2011-07-18 15:48:07 +08:00
|
|
|
ifeq ($(wildcard $(LDSCRIPT)),)
|
|
|
|
$(error could not find linker script)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Special flags for CPP when processing the linker script.
|
|
|
|
# Pass the version down so we can handle backwards compatibility
|
|
|
|
# on the fly.
|
|
|
|
LDPPFLAGS += \
|
2014-03-11 10:05:19 +08:00
|
|
|
-include $(srctree)/include/u-boot/u-boot.lds.h \
|
2014-03-11 10:05:21 +08:00
|
|
|
-include $(objtree)/include/config.h \
|
2011-11-21 18:49:40 +08:00
|
|
|
-DCPUDIR=$(CPUDIR) \
|
2011-07-18 15:48:07 +08:00
|
|
|
$(shell $(LD) --version | \
|
|
|
|
sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
|
|
|
|
|
2014-03-14 12:00:14 +08:00
|
|
|
quiet_cmd_mkimage = MKIMAGE $@
|
2014-02-24 10:12:15 +08:00
|
|
|
cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
|
|
|
|
$(if $(KBUILD_VERBOSE:1=), >/dev/null)
|
2012-10-16 21:06:06 +08:00
|
|
|
|
2014-02-24 10:12:15 +08:00
|
|
|
MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE)
|
|
|
|
|
|
|
|
MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
|
|
|
|
|
|
|
|
MLO MLO.byteswap: $(obj)/u-boot-spl.bin
|
|
|
|
$(call if_changed,mkimage)
|
2011-07-21 21:10:30 +08:00
|
|
|
|
2014-02-04 16:24:24 +08:00
|
|
|
ALL-y += $(obj)/$(SPL_BIN).bin
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2011-08-19 06:37:20 +08:00
|
|
|
ifdef CONFIG_SAMSUNG
|
2014-02-04 16:24:24 +08:00
|
|
|
ALL-y += $(obj)/$(BOARD)-spl.bin
|
2011-08-19 06:37:20 +08:00
|
|
|
endif
|
|
|
|
|
2014-05-05 18:52:30 +08:00
|
|
|
ifdef CONFIG_SUNXI
|
|
|
|
ifndef CONFIG_SPL_FEL
|
|
|
|
ALL-y += $(obj)/sunxi-spl.bin
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2011-07-18 15:48:07 +08:00
|
|
|
all: $(ALL-y)
|
|
|
|
|
2011-08-19 06:37:20 +08:00
|
|
|
ifdef CONFIG_SAMSUNG
|
2013-12-26 12:14:27 +08:00
|
|
|
ifdef CONFIG_VAR_SIZE_SPL
|
|
|
|
VAR_SIZE_PARAM = --vs
|
|
|
|
else
|
|
|
|
VAR_SIZE_PARAM =
|
|
|
|
endif
|
2014-02-04 16:24:24 +08:00
|
|
|
$(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
|
2014-03-11 10:05:21 +08:00
|
|
|
$(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
|
|
|
|
$(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
|
|
|
|
$(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
|
2011-08-19 06:37:20 +08:00
|
|
|
endif
|
|
|
|
|
2014-02-24 10:12:14 +08:00
|
|
|
quiet_cmd_objcopy = OBJCOPY $@
|
|
|
|
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
|
|
|
|
|
|
|
|
OBJCOPYFLAGS_$(SPL_BIN).bin = $(SPL_OBJCFLAGS) -O binary
|
|
|
|
|
|
|
|
$(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN) FORCE
|
|
|
|
$(call if_changed,objcopy)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-04 16:24:24 +08:00
|
|
|
LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
|
2014-02-04 16:24:22 +08:00
|
|
|
ifneq ($(CONFIG_SPL_TEXT_BASE),)
|
|
|
|
LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
|
|
|
|
endif
|
|
|
|
|
2014-05-05 18:52:30 +08:00
|
|
|
ifdef CONFIG_SUNXI
|
|
|
|
quiet_cmd_mksunxiboot = MKSUNXI $@
|
|
|
|
cmd_mksunxiboot = $(objtree)/tools/mksunxiboot $< $@
|
|
|
|
$(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin
|
|
|
|
$(call if_changed,mksunxiboot)
|
|
|
|
endif
|
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
quiet_cmd_u-boot-spl = LD $@
|
|
|
|
cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
|
|
|
|
$(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
|
|
|
|
$(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
|
|
|
|
$(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds
|
|
|
|
$(call cmd,u-boot-spl)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
$(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-04 16:24:37 +08:00
|
|
|
PHONY += $(u-boot-spl-dirs)
|
|
|
|
$(u-boot-spl-dirs):
|
|
|
|
$(Q)$(MAKE) $(build)=$@
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-24 10:12:19 +08:00
|
|
|
quiet_cmd_cpp_lds = LDS $@
|
2014-04-09 19:10:43 +08:00
|
|
|
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
|
|
|
|
-D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<
|
2014-02-24 10:12:19 +08:00
|
|
|
|
kbuild: use Linux Kernel build scripts
Now we are ready to switch over to real Kbuild.
This commit disables temporary scripts:
scripts/{Makefile.build.tmp, Makefile.host.tmp}
and enables real Kbuild scripts:
scripts/{Makefile.build,Makefile.host,Makefile.lib}.
This switch is triggered by the line in scripts/Kbuild.include
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
We need to adjust some build scripts for U-Boot.
But smaller amount of modification is preferable.
Additionally, we need to fix compiler flags which are
locally added or removed.
In Kbuild, it is not allowed to change CFLAGS locally.
Instead, ccflags-y, asflags-y, cppflags-y,
CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o
are prepared for that purpose.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Gerhard Sittig <gsi@denx.de>
2014-02-04 16:24:28 +08:00
|
|
|
$(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
|
2014-04-09 19:10:43 +08:00
|
|
|
$(call if_changed_dep,cpp_lds)
|
2011-07-18 15:48:07 +08:00
|
|
|
|
2014-02-24 10:12:14 +08:00
|
|
|
# read all saved command lines
|
|
|
|
|
|
|
|
targets := $(wildcard $(sort $(targets)))
|
|
|
|
cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
|
|
|
|
|
|
|
|
ifneq ($(cmd_files),)
|
|
|
|
$(cmd_files): ; # Do not try to update included dependency files
|
|
|
|
include $(cmd_files)
|
|
|
|
endif
|
|
|
|
|
kbuild: use Linux Kernel build scripts
Now we are ready to switch over to real Kbuild.
This commit disables temporary scripts:
scripts/{Makefile.build.tmp, Makefile.host.tmp}
and enables real Kbuild scripts:
scripts/{Makefile.build,Makefile.host,Makefile.lib}.
This switch is triggered by the line in scripts/Kbuild.include
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build.tmp obj
+build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
We need to adjust some build scripts for U-Boot.
But smaller amount of modification is preferable.
Additionally, we need to fix compiler flags which are
locally added or removed.
In Kbuild, it is not allowed to change CFLAGS locally.
Instead, ccflags-y, asflags-y, cppflags-y,
CFLAGS_$(basetarget).o, CFLAGS_REMOVE_$(basetarget).o
are prepared for that purpose.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Gerhard Sittig <gsi@denx.de>
2014-02-04 16:24:28 +08:00
|
|
|
PHONY += FORCE
|
|
|
|
FORCE:
|
|
|
|
|
|
|
|
# Declare the contents of the .PHONY variable as phony. We keep that
|
|
|
|
# information in a variable so we can use it in if_changed and friends.
|
|
|
|
.PHONY: $(PHONY)
|