]> git.ipfire.org Git - people/ms/u-boot.git/blame - config.mk
Makefile: move more flags to the top Makefile
[people/ms/u-boot.git] / config.mk
CommitLineData
e2211743 1#
eca3aeb3 2# (C) Copyright 2000-2013
e2211743
WD
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
eca3aeb3 5# SPDX-License-Identifier: GPL-2.0+
e2211743 6#
e2211743
WD
7#########################################################################
8
f9328639 9ifeq ($(CURDIR),$(SRCTREE))
511d0c72 10dir :=
f9328639
MB
11else
12dir := $(subst $(SRCTREE)/,,$(CURDIR))
13endif
14
c8f9c302
DS
15ifneq ($(OBJTREE),$(SRCTREE))
16# Create object files for SPL in a separate directory
17ifeq ($(CONFIG_SPL_BUILD),y)
3aa29de0
YZ
18ifeq ($(CONFIG_TPL_BUILD),y)
19obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
20else
c8f9c302 21obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
3aa29de0 22endif
c8f9c302 23else
f9328639 24obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
c8f9c302 25endif
f9328639
MB
26src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
27
c8f9c302
DS
28$(shell mkdir -p $(obj))
29else
30# Create object files for SPL in a separate directory
31ifeq ($(CONFIG_SPL_BUILD),y)
3aa29de0
YZ
32ifeq ($(CONFIG_TPL_BUILD),y)
33obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
34else
c8f9c302
DS
35obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
36
3aa29de0 37endif
f9328639
MB
38$(shell mkdir -p $(obj))
39else
40obj :=
c8f9c302 41endif
f9328639
MB
42src :=
43endif
44
592c5cab
WD
45# clean the slate ...
46PLATFORM_RELFLAGS =
47PLATFORM_CPPFLAGS =
48PLATFORM_LDFLAGS =
49
c4e5f52a
WD
50#########################################################################
51
52# Load generated board configuration
3aa29de0
YZ
53ifeq ($(CONFIG_TPL_BUILD),y)
54# Include TPL autoconf
55sinclude $(OBJTREE)/include/tpl-autoconf.mk
56else
39bc12dd
JF
57ifeq ($(CONFIG_SPL_BUILD),y)
58# Include SPL autoconf
59sinclude $(OBJTREE)/include/spl-autoconf.mk
60else
61# Include normal autoconf
c4e5f52a 62sinclude $(OBJTREE)/include/autoconf.mk
39bc12dd 63endif
3aa29de0 64endif
5e987ddf 65sinclude $(OBJTREE)/include/config.mk
c4e5f52a 66
03b7004d
PT
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.
8d1f2682
PT
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
03b7004d 75
ea0364f1 76sinclude $(TOPDIR)/arch/$(ARCH)/config.mk # include architecture dependend rules
03b7004d
PT
77sinclude $(TOPDIR)/$(CPUDIR)/config.mk # include CPU specific rules
78
c4e5f52a 79ifdef SOC
03b7004d 80sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk # include SoC specific rules
c4e5f52a
WD
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
e2211743 93RELFLAGS= $(PLATFORM_RELFLAGS)
83b7e2a7 94
6dd652fa 95OBJCFLAGS += --gap-fill=0xff
e2211743 96
b783edae
WD
97gccincdir := $(shell $(CC) -print-file-name=include)
98
2b3c9d3d 99CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
c8f9c302
DS
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
14d0a02a
WD
107ifneq ($(CONFIG_SYS_TEXT_BASE),)
108CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
161b2af4 109endif
f9328639 110
c8f9c302
DS
111ifeq ($(CONFIG_SPL_BUILD),y)
112CPPFLAGS += -DCONFIG_SPL_BUILD
3aa29de0
YZ
113ifeq ($(CONFIG_TPL_BUILD),y)
114CPPFLAGS += -DCONFIG_TPL_BUILD
115endif
c8f9c302
DS
116endif
117
5c1a7ea6
SG
118# Does this architecture support generic board init?
119ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
120ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
fada9e20
SG
121CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
122Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
5c1a7ea6
SG
123endif
124endif
125
f9328639 126ifneq ($(OBJTREE),$(SRCTREE))
3d83efbc 127CPPFLAGS += -I$(OBJTREE)/include
f9328639
MB
128endif
129
3d83efbc 130CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
2b3c9d3d 131CPPFLAGS += -nostdinc \
f9328639 132 -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
e2211743 133
2b3c9d3d 134CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
4a30f1e8 135
5c2aeac5
SG
136BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
137
138ifeq ($(findstring examples/,$(BCURDIR)),)
139ifeq ($(CONFIG_SPL_BUILD),)
140ifdef FTRACE
141CFLAGS += -finstrument-functions -DFTRACE
142endif
143endif
144endif
145
2b3c9d3d 146AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
e2211743 147
8aba9dce 148LDFLAGS += $(PLATFORM_LDFLAGS)
6dc1eceb 149LDFLAGS_FINAL += -Bstatic
8aba9dce 150
6dc1eceb 151LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
14d0a02a 152ifneq ($(CONFIG_SYS_TEXT_BASE),)
8aba9dce 153LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
161b2af4 154endif
e2211743 155
3aa29de0 156LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
c8f9c302 157ifneq ($(CONFIG_SPL_TEXT_BASE),)
3aa29de0 158LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
c8f9c302
DS
159endif
160
e2211743
WD
161#########################################################################
162
14d0a02a 163export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS