xref: /rk3399_rockchip-uboot/config.mk (revision 2b3c9d3ddd4e0b5a55d17e164e817b42cb555639)
1#
2# (C) Copyright 2000-2013
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
5# SPDX-License-Identifier:	GPL-2.0+
6#
7#########################################################################
8
9ifeq ($(CURDIR),$(SRCTREE))
10dir :=
11else
12dir := $(subst $(SRCTREE)/,,$(CURDIR))
13endif
14
15ifneq ($(OBJTREE),$(SRCTREE))
16# Create object files for SPL in a separate directory
17ifeq ($(CONFIG_SPL_BUILD),y)
18ifeq ($(CONFIG_TPL_BUILD),y)
19obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
20else
21obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
22endif
23else
24obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
25endif
26src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
27
28$(shell mkdir -p $(obj))
29else
30# Create object files for SPL in a separate directory
31ifeq ($(CONFIG_SPL_BUILD),y)
32ifeq ($(CONFIG_TPL_BUILD),y)
33obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
34else
35obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
36
37endif
38$(shell mkdir -p $(obj))
39else
40obj :=
41endif
42src :=
43endif
44
45# clean the slate ...
46PLATFORM_RELFLAGS =
47PLATFORM_CPPFLAGS =
48PLATFORM_LDFLAGS =
49
50#########################################################################
51
52# Load generated board configuration
53ifeq ($(CONFIG_TPL_BUILD),y)
54# Include TPL autoconf
55sinclude $(OBJTREE)/include/tpl-autoconf.mk
56else
57ifeq ($(CONFIG_SPL_BUILD),y)
58# Include SPL autoconf
59sinclude $(OBJTREE)/include/spl-autoconf.mk
60else
61# Include normal autoconf
62sinclude $(OBJTREE)/include/autoconf.mk
63endif
64endif
65sinclude $(OBJTREE)/include/config.mk
66
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
70# CPU-specific code.
71CPUDIR=arch/$(ARCH)/cpu/$(CPU)
72ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
73CPUDIR=arch/$(ARCH)/cpu
74endif
75
76sinclude $(TOPDIR)/arch/$(ARCH)/config.mk	# include architecture dependend rules
77sinclude $(TOPDIR)/$(CPUDIR)/config.mk		# include  CPU	specific rules
78
79ifdef	SOC
80sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk	# include  SoC	specific rules
81endif
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
93RELFLAGS= $(PLATFORM_RELFLAGS)
94
95OBJCFLAGS += --gap-fill=0xff
96
97gccincdir := $(shell $(CC) -print-file-name=include)
98
99CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
100
101# Enable garbage collection of un-used sections for SPL
102ifeq ($(CONFIG_SPL_BUILD),y)
103CPPFLAGS += -ffunction-sections -fdata-sections
104LDFLAGS_FINAL += --gc-sections
105endif
106
107ifneq ($(CONFIG_SYS_TEXT_BASE),)
108CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
109endif
110
111ifeq ($(CONFIG_SPL_BUILD),y)
112CPPFLAGS += -DCONFIG_SPL_BUILD
113ifeq ($(CONFIG_TPL_BUILD),y)
114CPPFLAGS += -DCONFIG_TPL_BUILD
115endif
116endif
117
118# Does this architecture support generic board init?
119ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
120ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
121CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
122Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
123endif
124endif
125
126ifneq ($(OBJTREE),$(SRCTREE))
127CPPFLAGS += -I$(OBJTREE)/include
128endif
129
130CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
131CPPFLAGS += -nostdinc	\
132	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
133
134CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
135
136BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
137
138ifeq ($(findstring examples/,$(BCURDIR)),)
139ifeq ($(CONFIG_SPL_BUILD),)
140ifdef FTRACE
141CFLAGS += -finstrument-functions -DFTRACE
142endif
143endif
144endif
145
146AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
147
148LDFLAGS += $(PLATFORM_LDFLAGS)
149LDFLAGS_FINAL += -Bstatic
150
151LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
152ifneq ($(CONFIG_SYS_TEXT_BASE),)
153LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
154endif
155
156LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
157ifneq ($(CONFIG_SPL_TEXT_BASE),)
158LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
159endif
160
161#########################################################################
162
163export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
164