config.mk 4.1 KB
Newer Older
wdenk's avatar
wdenk committed
1
#
2
# (C) Copyright 2000-2013
wdenk's avatar
wdenk committed
3 4
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
5
# SPDX-License-Identifier:	GPL-2.0+
wdenk's avatar
wdenk committed
6 7 8
#
#########################################################################

9
ifeq ($(CURDIR),$(SRCTREE))
Wolfgang Denk's avatar
Wolfgang Denk committed
10
dir :=
11 12 13 14
else
dir := $(subst $(SRCTREE)/,,$(CURDIR))
endif

15 16 17
ifneq ($(OBJTREE),$(SRCTREE))
# Create object files for SPL in a separate directory
ifeq ($(CONFIG_SPL_BUILD),y)
18 19 20
ifeq ($(CONFIG_TPL_BUILD),y)
obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
else
21
obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
22
endif
23
else
24
obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
25
endif
26 27
src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)

28 29 30 31
$(shell mkdir -p $(obj))
else
# Create object files for SPL in a separate directory
ifeq ($(CONFIG_SPL_BUILD),y)
32 33 34
ifeq ($(CONFIG_TPL_BUILD),y)
obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
else
35 36
obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)

37
endif
38 39 40
$(shell mkdir -p $(obj))
else
obj :=
41
endif
42 43 44
src :=
endif

wdenk's avatar
wdenk committed
45 46 47 48 49
# clean the slate ...
PLATFORM_RELFLAGS =
PLATFORM_CPPFLAGS =
PLATFORM_LDFLAGS =

50 51 52
#########################################################################

# Load generated board configuration
53 54 55 56
ifeq ($(CONFIG_TPL_BUILD),y)
# Include TPL autoconf
sinclude $(OBJTREE)/include/tpl-autoconf.mk
else
57 58 59 60 61
ifeq ($(CONFIG_SPL_BUILD),y)
# Include SPL autoconf
sinclude $(OBJTREE)/include/spl-autoconf.mk
else
# Include normal autoconf
62
sinclude $(OBJTREE)/include/autoconf.mk
63
endif
64
endif
65
sinclude $(OBJTREE)/include/config.mk
66

Peter Tyser's avatar
Peter Tyser committed
67 68
# Some architecture config.mk files need to know what CPUDIR is set to,
# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
69 70 71 72 73 74
# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
# CPU-specific code.
CPUDIR=arch/$(ARCH)/cpu/$(CPU)
ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
CPUDIR=arch/$(ARCH)/cpu
endif
Peter Tyser's avatar
Peter Tyser committed
75

76
sinclude $(TOPDIR)/arch/$(ARCH)/config.mk	# include architecture dependend rules
Peter Tyser's avatar
Peter Tyser committed
77 78
sinclude $(TOPDIR)/$(CPUDIR)/config.mk		# include  CPU	specific rules

79
ifdef	SOC
Peter Tyser's avatar
Peter Tyser committed
80
sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk	# include  SoC	specific rules
81 82 83 84 85 86 87 88 89 90 91 92
endif
ifdef	VENDOR
BOARDDIR = $(VENDOR)/$(BOARD)
else
BOARDDIR = $(BOARD)
endif
ifdef	BOARD
sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
endif

#########################################################################

wdenk's avatar
wdenk committed
93
RELFLAGS= $(PLATFORM_RELFLAGS)
94

95
OBJCFLAGS += --gap-fill=0xff
wdenk's avatar
wdenk committed
96

wdenk's avatar
wdenk committed
97 98
gccincdir := $(shell $(CC) -print-file-name=include)

99
CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
100 101 102 103 104 105 106

# Enable garbage collection of un-used sections for SPL
ifeq ($(CONFIG_SPL_BUILD),y)
CPPFLAGS += -ffunction-sections -fdata-sections
LDFLAGS_FINAL += --gc-sections
endif

107 108
ifneq ($(CONFIG_SYS_TEXT_BASE),)
CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
109
endif
110

111 112
ifeq ($(CONFIG_SPL_BUILD),y)
CPPFLAGS += -DCONFIG_SPL_BUILD
113 114 115
ifeq ($(CONFIG_TPL_BUILD),y)
CPPFLAGS += -DCONFIG_TPL_BUILD
endif
116 117
endif

118 119 120
# Does this architecture support generic board init?
ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
121 122
CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
123 124 125
endif
endif

126
ifneq ($(OBJTREE),$(SRCTREE))
127
CPPFLAGS += -I$(OBJTREE)/include
128 129
endif

130
CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include
131
CPPFLAGS += -nostdinc	\
132
	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
wdenk's avatar
wdenk committed
133

134
CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
135

136 137 138 139 140 141 142 143 144 145
BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))

ifeq ($(findstring examples/,$(BCURDIR)),)
ifeq ($(CONFIG_SPL_BUILD),)
ifdef FTRACE
CFLAGS += -finstrument-functions -DFTRACE
endif
endif
endif

146
AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
wdenk's avatar
wdenk committed
147

148
LDFLAGS += $(PLATFORM_LDFLAGS)
149
LDFLAGS_FINAL += -Bstatic
150

151
LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
152
ifneq ($(CONFIG_SYS_TEXT_BASE),)
153
LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
154
endif
wdenk's avatar
wdenk committed
155

156
LDFLAGS_$(SPL_BIN) += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL)
157
ifneq ($(CONFIG_SPL_TEXT_BASE),)
158
LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
159 160
endif

wdenk's avatar
wdenk committed
161 162
#########################################################################

163
export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS