blob: f700ee13175843e1dcbbba3ae0cebe111d56ada5 [file] [log] [blame]
wdenke2211742002-11-02 23:30:20 +00001#
Wolfgang Denk1234ce72013-06-21 10:22:36 +02002# (C) Copyright 2000-2013
wdenke2211742002-11-02 23:30:20 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denk1234ce72013-06-21 10:22:36 +02005# SPDX-License-Identifier: GPL-2.0+
wdenke2211742002-11-02 23:30:20 +00006#
wdenke2211742002-11-02 23:30:20 +00007#########################################################################
8
Marian Balakowiczd62379d2006-09-01 19:49:50 +02009ifeq ($(CURDIR),$(SRCTREE))
Wolfgang Denk4df0da52006-10-09 00:42:01 +020010dir :=
Marian Balakowiczd62379d2006-09-01 19:49:50 +020011else
12dir := $(subst $(SRCTREE)/,,$(CURDIR))
13endif
14
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000015ifneq ($(OBJTREE),$(SRCTREE))
16# Create object files for SPL in a separate directory
17ifeq ($(CONFIG_SPL_BUILD),y)
Ying Zhang2d2e3b62013-08-16 15:16:15 +080018ifeq ($(CONFIG_TPL_BUILD),y)
19obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
20else
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000021obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
Ying Zhang2d2e3b62013-08-16 15:16:15 +080022endif
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000023else
Marian Balakowiczd62379d2006-09-01 19:49:50 +020024obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000025endif
Marian Balakowiczd62379d2006-09-01 19:49:50 +020026src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
27
28$(shell mkdir -p $(obj))
29else
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000030# Create object files for SPL in a separate directory
31ifeq ($(CONFIG_SPL_BUILD),y)
Ying Zhang2d2e3b62013-08-16 15:16:15 +080032ifeq ($(CONFIG_TPL_BUILD),y)
33obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
34else
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000035obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
36
Ying Zhang2d2e3b62013-08-16 15:16:15 +080037endif
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000038$(shell mkdir -p $(obj))
39else
Marian Balakowiczd62379d2006-09-01 19:49:50 +020040obj :=
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000041endif
Marian Balakowiczd62379d2006-09-01 19:49:50 +020042src :=
43endif
44
wdenkdbae5042003-06-21 00:17:24 +000045# clean the slate ...
46PLATFORM_RELFLAGS =
47PLATFORM_CPPFLAGS =
48PLATFORM_LDFLAGS =
49
wdenke2211742002-11-02 23:30:20 +000050#########################################################################
Wolfgang Denk979b4bd2008-05-03 22:25:00 +020051
52# Load generated board configuration
Ying Zhang2d2e3b62013-08-16 15:16:15 +080053ifeq ($(CONFIG_TPL_BUILD),y)
54# Include TPL autoconf
55sinclude $(OBJTREE)/include/tpl-autoconf.mk
56else
Joel Fernandes2c8c3c22013-08-19 16:14:14 +080057ifeq ($(CONFIG_SPL_BUILD),y)
58# Include SPL autoconf
59sinclude $(OBJTREE)/include/spl-autoconf.mk
60else
61# Include normal autoconf
Wolfgang Denk979b4bd2008-05-03 22:25:00 +020062sinclude $(OBJTREE)/include/autoconf.mk
Joel Fernandes2c8c3c22013-08-19 16:14:14 +080063endif
Ying Zhang2d2e3b62013-08-16 15:16:15 +080064endif
Joakim Tjernlund31162e12011-01-17 23:39:26 +010065sinclude $(OBJTREE)/include/config.mk
Wolfgang Denk979b4bd2008-05-03 22:25:00 +020066
Peter Tyserd53e8fd2010-04-12 22:28:02 -050067# 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.
Peter Tyser29514c72010-04-12 22:28:09 -050069# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
70# CPU-specific code.
71CPUDIR=arch/$(ARCH)/cpu/$(CPU)
72ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
73CPUDIR=arch/$(ARCH)/cpu
74endif
Peter Tyserd53e8fd2010-04-12 22:28:02 -050075
Peter Tysercede5d82010-04-12 22:28:04 -050076sinclude $(TOPDIR)/arch/$(ARCH)/config.mk # include architecture dependend rules
Peter Tyserd53e8fd2010-04-12 22:28:02 -050077sinclude $(TOPDIR)/$(CPUDIR)/config.mk # include CPU specific rules
78
Wolfgang Denk979b4bd2008-05-03 22:25:00 +020079ifdef SOC
Peter Tyserd53e8fd2010-04-12 22:28:02 -050080sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk # include SoC specific rules
Wolfgang Denk979b4bd2008-05-03 22:25:00 +020081endif
82ifdef VENDOR
83BOARDDIR = $(VENDOR)/$(BOARD)
84else
85BOARDDIR = $(BOARD)
86endif
87ifdef BOARD
88sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
89endif
90
91#########################################################################
92
wdenke2211742002-11-02 23:30:20 +000093RELFLAGS= $(PLATFORM_RELFLAGS)
Scott Wood34c6dd22011-04-06 13:31:37 +000094
wdenkb00ec162003-06-19 23:40:20 +000095OBJCFLAGS += --gap-fill=0xff
wdenke2211742002-11-02 23:30:20 +000096
Masahiro Yamada700dd892014-02-04 17:24:19 +090097CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
Daniel Schwierzecka180922a2011-07-18 06:09:15 +000098
99# Enable garbage collection of un-used sections for SPL
100ifeq ($(CONFIG_SPL_BUILD),y)
101CPPFLAGS += -ffunction-sections -fdata-sections
102LDFLAGS_FINAL += --gc-sections
103endif
104
Wolfgang Denk0708bc62010-10-07 21:51:12 +0200105ifneq ($(CONFIG_SYS_TEXT_BASE),)
106CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
Mike Frysinger12805552008-01-28 05:28:50 -0500107endif
Marian Balakowiczd62379d2006-09-01 19:49:50 +0200108
Daniel Schwierzecka180922a2011-07-18 06:09:15 +0000109ifeq ($(CONFIG_SPL_BUILD),y)
110CPPFLAGS += -DCONFIG_SPL_BUILD
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800111ifeq ($(CONFIG_TPL_BUILD),y)
112CPPFLAGS += -DCONFIG_TPL_BUILD
113endif
Daniel Schwierzecka180922a2011-07-18 06:09:15 +0000114endif
115
Simon Glass66828322013-03-08 13:45:27 +0000116# Does this architecture support generic board init?
117ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
118ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
Simon Glass07253bb2013-04-20 08:42:36 +0000119CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
120Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
Simon Glass66828322013-03-08 13:45:27 +0000121endif
122endif
123
Masahiro Yamada03024452014-02-04 17:24:20 +0900124CPPFLAGS += $(UBOOTINCLUDE)
125CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
wdenke2211742002-11-02 23:30:20 +0000126
Masahiro Yamada700dd892014-02-04 17:24:19 +0900127CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
Tom Rinib7f34132012-02-20 13:50:10 +0000128
Simon Glass831aa542013-06-11 11:14:41 -0700129BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
130
131ifeq ($(findstring examples/,$(BCURDIR)),)
132ifeq ($(CONFIG_SPL_BUILD),)
133ifdef FTRACE
134CFLAGS += -finstrument-functions -DFTRACE
135endif
136endif
137endif
138
Masahiro Yamada700dd892014-02-04 17:24:19 +0900139AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
wdenke2211742002-11-02 23:30:20 +0000140
Nobuhiro Iwamatsub859b8c2011-01-06 10:23:54 +0900141LDFLAGS += $(PLATFORM_LDFLAGS)
Haiying Wang39358732011-02-22 16:38:05 -0500142LDFLAGS_FINAL += -Bstatic
Nobuhiro Iwamatsub859b8c2011-01-06 10:23:54 +0900143
Haiying Wang39358732011-02-22 16:38:05 -0500144LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
Wolfgang Denk0708bc62010-10-07 21:51:12 +0200145ifneq ($(CONFIG_SYS_TEXT_BASE),)
Nobuhiro Iwamatsub859b8c2011-01-06 10:23:54 +0900146LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
Mike Frysinger12805552008-01-28 05:28:50 -0500147endif
wdenke2211742002-11-02 23:30:20 +0000148
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800149LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
Daniel Schwierzecka180922a2011-07-18 06:09:15 +0000150ifneq ($(CONFIG_SPL_TEXT_BASE),)
Ying Zhang2d2e3b62013-08-16 15:16:15 +0800151LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
Daniel Schwierzecka180922a2011-07-18 06:09:15 +0000152endif
153
wdenke2211742002-11-02 23:30:20 +0000154#########################################################################
155
Wolfgang Denk0708bc62010-10-07 21:51:12 +0200156export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS