2 # (C) Copyright 2000-2013
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 # SPDX-License-Identifier: GPL-2.0+
7 #########################################################################
9 ifeq ($(CURDIR
),$(SRCTREE
))
12 dir := $(subst $(SRCTREE
)/,,$(CURDIR
))
15 ifneq ($(OBJTREE
),$(SRCTREE
))
16 # Create object files for SPL in a separate directory
17 ifeq ($(CONFIG_SPL_BUILD
),y
)
18 ifeq ($(CONFIG_TPL_BUILD
),y
)
19 obj
:= $(if
$(dir),$(TPLTREE
)/$(dir)/,$(TPLTREE
)/)
21 obj
:= $(if
$(dir),$(SPLTREE
)/$(dir)/,$(SPLTREE
)/)
24 obj
:= $(if
$(dir),$(OBJTREE
)/$(dir)/,$(OBJTREE
)/)
26 src
:= $(if
$(dir),$(SRCTREE
)/$(dir)/,$(SRCTREE
)/)
28 $(shell mkdir
-p
$(obj
))
30 # Create object files for SPL in a separate directory
31 ifeq ($(CONFIG_SPL_BUILD
),y
)
32 ifeq ($(CONFIG_TPL_BUILD
),y
)
33 obj
:= $(if
$(dir),$(TPLTREE
)/$(dir)/,$(TPLTREE
)/)
35 obj
:= $(if
$(dir),$(SPLTREE
)/$(dir)/,$(SPLTREE
)/)
38 $(shell mkdir
-p
$(obj
))
50 #########################################################################
52 # Load generated board configuration
53 ifeq ($(CONFIG_TPL_BUILD
),y
)
54 # Include TPL autoconf
55 sinclude
$(OBJTREE
)/include/tpl-autoconf.mk
57 ifeq ($(CONFIG_SPL_BUILD
),y
)
58 # Include SPL autoconf
59 sinclude
$(OBJTREE
)/include/spl-autoconf.mk
61 # Include normal autoconf
62 sinclude
$(OBJTREE
)/include/autoconf.mk
65 sinclude
$(OBJTREE
)/include/config.mk
67 # Some architecture config.mk files need to know what CPUDIR is set to,
68 # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
69 # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
71 CPUDIR
=arch
/$(ARCH
)/cpu
/$(CPU
)
72 ifneq ($(SRCTREE
)/$(CPUDIR
),$(wildcard $(SRCTREE
)/$(CPUDIR
)))
73 CPUDIR
=arch
/$(ARCH
)/cpu
76 sinclude
$(TOPDIR
)/arch
/$(ARCH
)/config.mk
# include architecture dependend rules
77 sinclude
$(TOPDIR
)/$(CPUDIR
)/config.mk
# include CPU specific rules
80 sinclude
$(TOPDIR
)/$(CPUDIR
)/$(SOC
)/config.mk
# include SoC specific rules
83 BOARDDIR
= $(VENDOR
)/$(BOARD
)
88 sinclude
$(TOPDIR
)/board
/$(BOARDDIR
)/config.mk
# include board specific rules
91 #########################################################################
93 RELFLAGS
= $(PLATFORM_RELFLAGS
)
95 OBJCFLAGS
+= --gap-fill
=0xff
97 CPPFLAGS
= $(KBUILD_CPPFLAGS
) $(RELFLAGS
)
99 # Enable garbage collection of un-used sections for SPL
100 ifeq ($(CONFIG_SPL_BUILD
),y
)
101 CPPFLAGS
+= -ffunction-sections
-fdata-sections
102 LDFLAGS_FINAL
+= --gc-sections
105 ifneq ($(CONFIG_SYS_TEXT_BASE
),)
106 CPPFLAGS
+= -DCONFIG_SYS_TEXT_BASE
=$(CONFIG_SYS_TEXT_BASE
)
109 ifeq ($(CONFIG_SPL_BUILD
),y
)
110 CPPFLAGS
+= -DCONFIG_SPL_BUILD
111 ifeq ($(CONFIG_TPL_BUILD
),y
)
112 CPPFLAGS
+= -DCONFIG_TPL_BUILD
116 # Does this architecture support generic board init?
117 ifeq ($(__HAVE_ARCH_GENERIC_BOARD
),)
118 ifneq ($(CONFIG_SYS_GENERIC_BOARD
),)
119 CHECK_GENERIC_BOARD
= $(error Your architecture does not support generic board. \
120 Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file
)
124 CPPFLAGS
+= $(UBOOTINCLUDE
)
125 CPPFLAGS
+= $(NOSTDINC_FLAGS
) -pipe
$(PLATFORM_CPPFLAGS
)
127 CFLAGS
:= $(KBUILD_CFLAGS
) $(CPPFLAGS
)
129 BCURDIR
= $(subst $(SRCTREE
)/,,$(CURDIR
:$(obj
)%=%))
131 ifeq ($(findstring examples
/,$(BCURDIR
)),)
132 ifeq ($(CONFIG_SPL_BUILD
),)
134 CFLAGS
+= -finstrument-functions
-DFTRACE
139 AFLAGS
:= $(KBUILD_AFLAGS
) $(CPPFLAGS
)
141 LDFLAGS
+= $(PLATFORM_LDFLAGS
)
142 LDFLAGS_FINAL
+= -Bstatic
144 LDFLAGS_u-boot
+= -T
$(obj
)u-boot.lds
$(LDFLAGS_FINAL
)
145 ifneq ($(CONFIG_SYS_TEXT_BASE
),)
146 LDFLAGS_u-boot
+= -Ttext
$(CONFIG_SYS_TEXT_BASE
)
149 LDFLAGS_
$(SPL_BIN
) += -T
$(obj
)u-boot-spl.lds
$(LDFLAGS_FINAL
)
150 ifneq ($(CONFIG_SPL_TEXT_BASE
),)
151 LDFLAGS_
$(SPL_BIN
) += -Ttext
$(CONFIG_SPL_TEXT_BASE
)
154 #########################################################################
156 export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS