Makefile: move some flags to spl/Makefile
[oweals/u-boot.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 RELFLAGS= $(PLATFORM_RELFLAGS)
94
95 OBJCFLAGS += --gap-fill=0xff
96
97 CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
98 CPPFLAGS += $(UBOOTINCLUDE)
99 CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
100
101 CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
102
103 BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
104
105 ifeq ($(findstring examples/,$(BCURDIR)),)
106 ifeq ($(CONFIG_SPL_BUILD),)
107 ifdef FTRACE
108 CFLAGS += -finstrument-functions -DFTRACE
109 endif
110 endif
111 endif
112
113 AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
114
115 LDFLAGS += $(PLATFORM_LDFLAGS)
116 LDFLAGS_FINAL += -Bstatic
117
118 #########################################################################
119
120 export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS