]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - config.mk
kbuild: Use Kbuild.include
[karo-tx-uboot.git] / config.mk
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
9 ifeq ($(CURDIR),$(SRCTREE))
10 dir :=
11 else
12 dir := $(subst $(SRCTREE)/,,$(CURDIR))
13 endif
14
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)/)
20 else
21 obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
22 endif
23 else
24 obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
25 endif
26 src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
27
28 $(shell mkdir -p $(obj))
29 else
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)/)
34 else
35 obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
36
37 endif
38 $(shell mkdir -p $(obj))
39 else
40 obj :=
41 endif
42 src :=
43 endif
44
45 # clean the slate ...
46 PLATFORM_RELFLAGS =
47 PLATFORM_CPPFLAGS =
48 PLATFORM_LDFLAGS =
49
50 #########################################################################
51
52 # Load generated board configuration
53 ifeq ($(CONFIG_TPL_BUILD),y)
54 # Include TPL autoconf
55 sinclude $(OBJTREE)/include/tpl-autoconf.mk
56 else
57 ifeq ($(CONFIG_SPL_BUILD),y)
58 # Include SPL autoconf
59 sinclude $(OBJTREE)/include/spl-autoconf.mk
60 else
61 # Include normal autoconf
62 sinclude $(OBJTREE)/include/autoconf.mk
63 endif
64 endif
65 sinclude $(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.
71 CPUDIR=arch/$(ARCH)/cpu/$(CPU)
72 ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
73 CPUDIR=arch/$(ARCH)/cpu
74 endif
75
76 sinclude $(TOPDIR)/arch/$(ARCH)/config.mk       # include architecture dependend rules
77 sinclude $(TOPDIR)/$(CPUDIR)/config.mk          # include  CPU  specific rules
78
79 ifdef   SOC
80 sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk   # include  SoC  specific rules
81 endif
82 ifdef   VENDOR
83 BOARDDIR = $(VENDOR)/$(BOARD)
84 else
85 BOARDDIR = $(BOARD)
86 endif
87 ifdef   BOARD
88 sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk  # include board specific rules
89 endif
90
91 #########################################################################
92
93 # We don't actually use $(ARFLAGS) anywhere anymore, so catch people
94 # who are porting old code to latest mainline but not updating $(AR).
95 ARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR)
96 RELFLAGS= $(PLATFORM_RELFLAGS)
97 DBGFLAGS= -g # -DDEBUG
98 OPTFLAGS= -Os #-fomit-frame-pointer
99
100 OBJCFLAGS += --gap-fill=0xff
101
102 gccincdir := $(shell $(CC) -print-file-name=include)
103
104 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)         \
105         -D__KERNEL__
106
107 # Enable garbage collection of un-used sections for SPL
108 ifeq ($(CONFIG_SPL_BUILD),y)
109 CPPFLAGS += -ffunction-sections -fdata-sections
110 LDFLAGS_FINAL += --gc-sections
111 endif
112
113 ifneq ($(CONFIG_SYS_TEXT_BASE),)
114 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
115 endif
116
117 ifeq ($(CONFIG_SPL_BUILD),y)
118 CPPFLAGS += -DCONFIG_SPL_BUILD
119 ifeq ($(CONFIG_TPL_BUILD),y)
120 CPPFLAGS += -DCONFIG_TPL_BUILD
121 endif
122 endif
123
124 # Does this architecture support generic board init?
125 ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
126 ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
127 CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
128 Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
129 endif
130 endif
131
132 ifneq ($(OBJTREE),$(SRCTREE))
133 CPPFLAGS += -I$(OBJTREE)/include
134 endif
135
136 CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
137 CPPFLAGS += -fno-builtin -ffreestanding -nostdinc       \
138         -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
139
140 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
141
142 ifdef BUILD_TAG
143 CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
144 endif
145
146 CFLAGS_SSP := $(call cc-option,-fno-stack-protector)
147 CFLAGS += $(CFLAGS_SSP)
148 # Some toolchains enable security related warning flags by default,
149 # but they don't make much sense in the u-boot world, so disable them.
150 CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \
151                $(call cc-option,-Wno-format-security)
152 CFLAGS += $(CFLAGS_WARN)
153
154 # Report stack usage if supported
155 CFLAGS_STACK := $(call cc-option,-fstack-usage)
156 CFLAGS += $(CFLAGS_STACK)
157
158 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
159
160 ifeq ($(findstring examples/,$(BCURDIR)),)
161 ifeq ($(CONFIG_SPL_BUILD),)
162 ifdef FTRACE
163 CFLAGS += -finstrument-functions -DFTRACE
164 endif
165 endif
166 endif
167
168 # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
169 # option to the assembler.
170 AFLAGS_DEBUG :=
171
172 # turn jbsr into jsr for m68k
173 ifeq ($(ARCH),m68k)
174 ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
175 AFLAGS_DEBUG := -Wa,-gstabs,-S
176 endif
177 endif
178
179 AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
180
181 LDFLAGS += $(PLATFORM_LDFLAGS)
182 LDFLAGS_FINAL += -Bstatic
183
184 LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
185 ifneq ($(CONFIG_SYS_TEXT_BASE),)
186 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
187 endif
188
189 LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
190 ifneq ($(CONFIG_SPL_TEXT_BASE),)
191 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
192 endif
193
194 #########################################################################
195
196 export  CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS