xref: /openbmc/u-boot/config.mk (revision 6c97a20d)
1e2211743Swdenk#
2f9328639SMarian Balakowicz# (C) Copyright 2000-2006
3e2211743Swdenk# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4e2211743Swdenk#
5e2211743Swdenk# See file CREDITS for list of people who contributed to this
6e2211743Swdenk# project.
7e2211743Swdenk#
8e2211743Swdenk# This program is free software; you can redistribute it and/or
9e2211743Swdenk# modify it under the terms of the GNU General Public License as
10e2211743Swdenk# published by the Free Software Foundation; either version 2 of
11e2211743Swdenk# the License, or (at your option) any later version.
12e2211743Swdenk#
13e2211743Swdenk# This program is distributed in the hope that it will be useful,
14e2211743Swdenk# but WITHOUT ANY WARRANTY; without even the implied warranty of
15e2211743Swdenk# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16e2211743Swdenk# GNU General Public License for more details.
17e2211743Swdenk#
18e2211743Swdenk# You should have received a copy of the GNU General Public License
19e2211743Swdenk# along with this program; if not, write to the Free Software
20e2211743Swdenk# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21e2211743Swdenk# MA 02111-1307 USA
22e2211743Swdenk#
23e2211743Swdenk
24e2211743Swdenk#########################################################################
25e2211743Swdenk
26f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
27f9328639SMarian Balakowiczifeq ($(CURDIR),$(SRCTREE))
28f9328639SMarian Balakowiczdir :=
29f9328639SMarian Balakowiczelse
30f9328639SMarian Balakowiczdir := $(subst $(SRCTREE)/,,$(CURDIR))
31f9328639SMarian Balakowiczendif
32f9328639SMarian Balakowicz
33f9328639SMarian Balakowiczobj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
34f9328639SMarian Balakowiczsrc := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
35f9328639SMarian Balakowicz
36f9328639SMarian Balakowicz$(shell mkdir -p $(obj))
37f9328639SMarian Balakowiczelse
38f9328639SMarian Balakowiczobj :=
39f9328639SMarian Balakowiczsrc :=
40f9328639SMarian Balakowiczendif
41f9328639SMarian Balakowicz
42592c5cabSwdenk# clean the slate ...
43592c5cabSwdenkPLATFORM_RELFLAGS =
44592c5cabSwdenkPLATFORM_CPPFLAGS =
45592c5cabSwdenkPLATFORM_LDFLAGS =
46592c5cabSwdenk
47e2211743Swdenk#########################################################################
48e2211743Swdenk
494cda4378SMike Frysingerifeq ($(HOSTOS),darwin)
50e2211743SwdenkHOSTCC		= cc
51e2211743Swdenkelse
52e2211743SwdenkHOSTCC		= gcc
53e2211743Swdenkendif
54e2211743SwdenkHOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
55e2211743SwdenkHOSTSTRIP	= strip
56e2211743Swdenk
57e2211743Swdenk#########################################################################
581820d4c7SWolfgang Denk#
591820d4c7SWolfgang Denk# Option checker (courtesy linux kernel) to ensure
601820d4c7SWolfgang Denk# only supported compiler options are used
611820d4c7SWolfgang Denk#
621820d4c7SWolfgang Denkcc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
631820d4c7SWolfgang Denk		> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
64e2211743Swdenk
65e2211743Swdenk#
66e2211743Swdenk# Include the make variables (CC, etc...)
67e2211743Swdenk#
68e2211743SwdenkAS	= $(CROSS_COMPILE)as
69e2211743SwdenkLD	= $(CROSS_COMPILE)ld
70e2211743SwdenkCC	= $(CROSS_COMPILE)gcc
71e2211743SwdenkCPP	= $(CC) -E
72e2211743SwdenkAR	= $(CROSS_COMPILE)ar
73e2211743SwdenkNM	= $(CROSS_COMPILE)nm
7494a91e24SMike FrysingerLDR	= $(CROSS_COMPILE)ldr
75e2211743SwdenkSTRIP	= $(CROSS_COMPILE)strip
76e2211743SwdenkOBJCOPY = $(CROSS_COMPILE)objcopy
77e2211743SwdenkOBJDUMP = $(CROSS_COMPILE)objdump
78e2211743SwdenkRANLIB	= $(CROSS_COMPILE)RANLIB
79e2211743Swdenk
80c4e5f52aSWolfgang Denk#########################################################################
81c4e5f52aSWolfgang Denk
82c4e5f52aSWolfgang Denk# Load generated board configuration
83c4e5f52aSWolfgang Denksinclude $(OBJTREE)/include/autoconf.mk
84c4e5f52aSWolfgang Denk
85c4e5f52aSWolfgang Denkifdef	ARCH
86b220c64dSPeter Tysersinclude $(TOPDIR)/lib_$(ARCH)/config.mk	# include architecture dependend rules
87c4e5f52aSWolfgang Denkendif
88c4e5f52aSWolfgang Denkifdef	CPU
89c4e5f52aSWolfgang Denksinclude $(TOPDIR)/cpu/$(CPU)/config.mk		# include  CPU	specific rules
90c4e5f52aSWolfgang Denkendif
91c4e5f52aSWolfgang Denkifdef	SOC
92c4e5f52aSWolfgang Denksinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk	# include  SoC	specific rules
93c4e5f52aSWolfgang Denkendif
94c4e5f52aSWolfgang Denkifdef	VENDOR
95c4e5f52aSWolfgang DenkBOARDDIR = $(VENDOR)/$(BOARD)
96c4e5f52aSWolfgang Denkelse
97c4e5f52aSWolfgang DenkBOARDDIR = $(BOARD)
98c4e5f52aSWolfgang Denkendif
99c4e5f52aSWolfgang Denkifdef	BOARD
100c4e5f52aSWolfgang Denksinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
101c4e5f52aSWolfgang Denkendif
102c4e5f52aSWolfgang Denk
103c4e5f52aSWolfgang Denk#########################################################################
104c4e5f52aSWolfgang Denk
1051954be6eSWolfgang Denkifneq (,$(findstring s,$(MAKEFLAGS)))
1061954be6eSWolfgang DenkARFLAGS = cr
1071954be6eSWolfgang Denkelse
1082b208f53SWolfgang DenkARFLAGS = crv
1091954be6eSWolfgang Denkendif
110e2211743SwdenkRELFLAGS= $(PLATFORM_RELFLAGS)
111e2211743SwdenkDBGFLAGS= -g # -DDEBUG
112e2211743SwdenkOPTFLAGS= -Os #-fomit-frame-pointer
1136dd652faSwdenkifndef LDSCRIPT
1144aeb251fSwdenk#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
115887e2ec9SStefan Roeseifeq ($(CONFIG_NAND_U_BOOT),y)
116887e2ec9SStefan RoeseLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
117887e2ec9SStefan Roeseelse
118e2211743SwdenkLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
1196dd652faSwdenkendif
120887e2ec9SStefan Roeseendif
1216dd652faSwdenkOBJCFLAGS += --gap-fill=0xff
122e2211743Swdenk
123b783edaeSwdenkgccincdir := $(shell $(CC) -print-file-name=include)
124b783edaeSwdenk
125e2211743SwdenkCPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
126161b2af4SMike Frysinger	-D__KERNEL__
127161b2af4SMike Frysingerifneq ($(TEXT_BASE),)
128161b2af4SMike FrysingerCPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
129161b2af4SMike Frysingerendif
130f9328639SMarian Balakowicz
131*6c97a20dSKumar Galaifneq ($(RESET_VECTOR_ADDRESS),)
132*6c97a20dSKumar GalaCPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
133*6c97a20dSKumar Galaendif
134*6c97a20dSKumar Gala
135f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
136f9328639SMarian BalakowiczCPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
137f9328639SMarian Balakowiczendif
138f9328639SMarian Balakowicz
139f9328639SMarian BalakowiczCPPFLAGS += -I$(TOPDIR)/include
140f9328639SMarian BalakowiczCPPFLAGS += -fno-builtin -ffreestanding -nostdinc	\
141f9328639SMarian Balakowicz	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
142e2211743Swdenk
143e2211743Swdenkifdef BUILD_TAG
144e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
145e2211743Swdenk	-DBUILD_TAG='"$(BUILD_TAG)"'
146e2211743Swdenkelse
147e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
148e2211743Swdenkendif
149e2211743Swdenk
15028eab0d7SHaavard SkinnemoenCFLAGS += $(call cc-option,-fno-stack-protector)
15128eab0d7SHaavard Skinnemoen
152c40b2956Swdenk# avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
153c40b2956Swdenk# this option have to be placed behind -Wall -- that's why it is here
154c40b2956Swdenkifeq ($(ARCH),nios)
155c40b2956Swdenkifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
156e4cc71aaSwdenkCFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
157c40b2956Swdenkendif
158c40b2956Swdenkendif
159c40b2956Swdenk
160e11887a7SHaavard Skinnemoen# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
161e11887a7SHaavard Skinnemoen# option to the assembler.
162e11887a7SHaavard SkinnemoenAFLAGS_DEBUG :=
163b62fa913SMarian Balakowicz
164483a0cf8SMarian Balakowicz# turn jbsr into jsr for m68k
165483a0cf8SMarian Balakowiczifeq ($(ARCH),m68k)
166483a0cf8SMarian Balakowiczifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
167483a0cf8SMarian BalakowiczAFLAGS_DEBUG := -Wa,-gstabs,-S
168483a0cf8SMarian Balakowiczendif
169483a0cf8SMarian Balakowiczendif
170b62fa913SMarian Balakowicz
171e2211743SwdenkAFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
172e2211743Swdenk
1731aada9cdSWolfgang DenkLDFLAGS += -Bstatic -T $(obj)u-boot.lds $(PLATFORM_LDFLAGS)
174161b2af4SMike Frysingerifneq ($(TEXT_BASE),)
175161b2af4SMike FrysingerLDFLAGS += -Ttext $(TEXT_BASE)
176161b2af4SMike Frysingerendif
177e2211743Swdenk
178e2211743Swdenk# Location of a usable BFD library, where we define "usable" as
179e2211743Swdenk# "built for ${HOST}, supports ${TARGET}".  Sensible values are
180e2211743Swdenk# - When cross-compiling: the root of the cross-environment
181e2211743Swdenk# - Linux/ppc (native): /usr
182e2211743Swdenk# - NetBSD/ppc (native): you lose ... (must extract these from the
183e2211743Swdenk#   binutils build directory, plus the native and U-Boot include
184e2211743Swdenk#   files don't like each other)
185e2211743Swdenk#
186e2211743Swdenk# So far, this is used only by tools/gdb/Makefile.
187e2211743Swdenk
1884cda4378SMike Frysingerifeq ($(HOSTOS),darwin)
189e2211743SwdenkBFD_ROOT_DIR =		/usr/local/tools
190e2211743Swdenkelse
191ea909b76Swdenkifeq ($(HOSTARCH),$(ARCH))
192ea909b76Swdenk# native
193ea909b76SwdenkBFD_ROOT_DIR =		/usr
194ea909b76Swdenkelse
195e2211743Swdenk#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
196e2211743Swdenk#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
197e2211743SwdenkBFD_ROOT_DIR =		/opt/powerpc
198e2211743Swdenkendif
199ea909b76Swdenkendif
200e2211743Swdenk
201e2211743Swdenk#########################################################################
202e2211743Swdenk
203cff80f2cSShinya Kuribayashiexport	HOSTCC HOSTCFLAGS CROSS_COMPILE \
204434c51a5SPeter Tyser	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
205e2211743Swdenkexport	TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
206e2211743Swdenk
207e2211743Swdenk#########################################################################
208e2211743Swdenk
2095ec5529bSMike Frysinger# Allow boards to use custom optimize flags on a per dir/file basis
2105ec5529bSMike FrysingerBCURDIR := $(notdir $(CURDIR))
211f9328639SMarian Balakowicz$(obj)%.s:	%.S
2125ec5529bSMike Frysinger	$(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
213f9328639SMarian Balakowicz$(obj)%.o:	%.S
2145ec5529bSMike Frysinger	$(CC)  $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< -c
215f9328639SMarian Balakowicz$(obj)%.o:	%.c
2165ec5529bSMike Frysinger	$(CC)  $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c
21731f30c9eSMike Frysinger$(obj)%.i:	%.c
21831f30c9eSMike Frysinger	$(CPP) $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c
21931f30c9eSMike Frysinger$(obj)%.s:	%.c
22031f30c9eSMike Frysinger	$(CC)  $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c -S
221f9328639SMarian Balakowicz
222e2211743Swdenk#########################################################################
223