xref: /rk3399_rockchip-uboot/config.mk (revision c4e5f52a58d278eebb87f476e353972c5dacea40)
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# When cross-compiling on NetBSD, we have to define __PPC__ or else we
49e2211743Swdenk# will pick up a va_list declaration that is incompatible with the
50e2211743Swdenk# actual argument lists emitted by the compiler.
51e2211743Swdenk#
52e2211743Swdenk# [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
53e2211743Swdenk
54e2211743Swdenkifeq ($(ARCH),ppc)
55e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-netbsd-)
56e2211743SwdenkPLATFORM_CPPFLAGS+= -D__PPC__
57e2211743Swdenkendif
58e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-openbsd-)
59e2211743SwdenkPLATFORM_CPPFLAGS+= -D__PPC__
60e2211743Swdenkendif
61e2211743Swdenkendif
62e2211743Swdenk
63e2211743Swdenkifeq ($(ARCH),arm)
64e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-netbsd-)
65e2211743SwdenkPLATFORM_CPPFLAGS+= -D__ARM__
66e2211743Swdenkendif
67e2211743Swdenkifeq ($(CROSS_COMPILE),powerpc-openbsd-)
68e2211743SwdenkPLATFORM_CPPFLAGS+= -D__ARM__
69e2211743Swdenkendif
70e2211743Swdenkendif
71e2211743Swdenk
72e2211743Swdenk#########################################################################
73e2211743Swdenk
74e2211743SwdenkCONFIG_SHELL	:= $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
75e2211743Swdenk		    else if [ -x /bin/bash ]; then echo /bin/bash; \
76e2211743Swdenk		    else echo sh; fi ; fi)
77e2211743Swdenk
78e2211743Swdenkifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
79e2211743SwdenkHOSTCC		= cc
80e2211743Swdenkelse
81e2211743SwdenkHOSTCC		= gcc
82e2211743Swdenkendif
83e2211743SwdenkHOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
84e2211743SwdenkHOSTSTRIP	= strip
85e2211743Swdenk
86e2211743Swdenk#########################################################################
871820d4c7SWolfgang Denk#
881820d4c7SWolfgang Denk# Option checker (courtesy linux kernel) to ensure
891820d4c7SWolfgang Denk# only supported compiler options are used
901820d4c7SWolfgang Denk#
911820d4c7SWolfgang Denkcc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
921820d4c7SWolfgang Denk		> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
93e2211743Swdenk
94e2211743Swdenk#
95e2211743Swdenk# Include the make variables (CC, etc...)
96e2211743Swdenk#
97e2211743SwdenkAS	= $(CROSS_COMPILE)as
98e2211743SwdenkLD	= $(CROSS_COMPILE)ld
99e2211743SwdenkCC	= $(CROSS_COMPILE)gcc
100e2211743SwdenkCPP	= $(CC) -E
101e2211743SwdenkAR	= $(CROSS_COMPILE)ar
102e2211743SwdenkNM	= $(CROSS_COMPILE)nm
10394a91e24SMike FrysingerLDR	= $(CROSS_COMPILE)ldr
104e2211743SwdenkSTRIP	= $(CROSS_COMPILE)strip
105e2211743SwdenkOBJCOPY = $(CROSS_COMPILE)objcopy
106e2211743SwdenkOBJDUMP = $(CROSS_COMPILE)objdump
107e2211743SwdenkRANLIB	= $(CROSS_COMPILE)RANLIB
108e2211743Swdenk
109*c4e5f52aSWolfgang Denk#########################################################################
110*c4e5f52aSWolfgang Denk
111*c4e5f52aSWolfgang Denk# Load generated board configuration
112*c4e5f52aSWolfgang Denksinclude $(OBJTREE)/include/autoconf.mk
113*c4e5f52aSWolfgang Denk
114*c4e5f52aSWolfgang Denkifdef	ARCH
115*c4e5f52aSWolfgang Denksinclude $(TOPDIR)/$(ARCH)_config.mk	# include architecture dependend rules
116*c4e5f52aSWolfgang Denkendif
117*c4e5f52aSWolfgang Denkifdef	CPU
118*c4e5f52aSWolfgang Denksinclude $(TOPDIR)/cpu/$(CPU)/config.mk	# include  CPU	specific rules
119*c4e5f52aSWolfgang Denkendif
120*c4e5f52aSWolfgang Denkifdef	SOC
121*c4e5f52aSWolfgang Denksinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk	# include  SoC	specific rules
122*c4e5f52aSWolfgang Denkendif
123*c4e5f52aSWolfgang Denkifdef	VENDOR
124*c4e5f52aSWolfgang DenkBOARDDIR = $(VENDOR)/$(BOARD)
125*c4e5f52aSWolfgang Denkelse
126*c4e5f52aSWolfgang DenkBOARDDIR = $(BOARD)
127*c4e5f52aSWolfgang Denkendif
128*c4e5f52aSWolfgang Denkifdef	BOARD
129*c4e5f52aSWolfgang Denksinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
130*c4e5f52aSWolfgang Denkendif
131*c4e5f52aSWolfgang Denk
132*c4e5f52aSWolfgang Denk#########################################################################
133*c4e5f52aSWolfgang Denk
1341954be6eSWolfgang Denkifneq (,$(findstring s,$(MAKEFLAGS)))
1351954be6eSWolfgang DenkARFLAGS = cr
1361954be6eSWolfgang Denkelse
1372b208f53SWolfgang DenkARFLAGS = crv
1381954be6eSWolfgang Denkendif
139e2211743SwdenkRELFLAGS= $(PLATFORM_RELFLAGS)
140e2211743SwdenkDBGFLAGS= -g # -DDEBUG
141e2211743SwdenkOPTFLAGS= -Os #-fomit-frame-pointer
1426dd652faSwdenkifndef LDSCRIPT
1434aeb251fSwdenk#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
144887e2ec9SStefan Roeseifeq ($(CONFIG_NAND_U_BOOT),y)
145887e2ec9SStefan RoeseLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
146887e2ec9SStefan Roeseelse
147e2211743SwdenkLDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
1486dd652faSwdenkendif
149887e2ec9SStefan Roeseendif
1506dd652faSwdenkOBJCFLAGS += --gap-fill=0xff
151e2211743Swdenk
152b783edaeSwdenkgccincdir := $(shell $(CC) -print-file-name=include)
153b783edaeSwdenk
154e2211743SwdenkCPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
155161b2af4SMike Frysinger	-D__KERNEL__
156161b2af4SMike Frysingerifneq ($(TEXT_BASE),)
157161b2af4SMike FrysingerCPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
158161b2af4SMike Frysingerendif
159f9328639SMarian Balakowicz
160f9328639SMarian Balakowiczifneq ($(OBJTREE),$(SRCTREE))
161f9328639SMarian BalakowiczCPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
162f9328639SMarian Balakowiczendif
163f9328639SMarian Balakowicz
164f9328639SMarian BalakowiczCPPFLAGS += -I$(TOPDIR)/include
165f9328639SMarian BalakowiczCPPFLAGS += -fno-builtin -ffreestanding -nostdinc 	\
166f9328639SMarian Balakowicz	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
167e2211743Swdenk
168e2211743Swdenkifdef BUILD_TAG
169e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
170e2211743Swdenk	-DBUILD_TAG='"$(BUILD_TAG)"'
171e2211743Swdenkelse
172e2211743SwdenkCFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
173e2211743Swdenkendif
174e2211743Swdenk
175c40b2956Swdenk# avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
176c40b2956Swdenk# this option have to be placed behind -Wall -- that's why it is here
177c40b2956Swdenkifeq ($(ARCH),nios)
178c40b2956Swdenkifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
179e4cc71aaSwdenkCFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
180c40b2956Swdenkendif
181c40b2956Swdenkendif
182c40b2956Swdenk
183e11887a7SHaavard Skinnemoen# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
184e11887a7SHaavard Skinnemoen# option to the assembler.
185e11887a7SHaavard SkinnemoenAFLAGS_DEBUG :=
186b62fa913SMarian Balakowicz
187483a0cf8SMarian Balakowicz# turn jbsr into jsr for m68k
188483a0cf8SMarian Balakowiczifeq ($(ARCH),m68k)
189483a0cf8SMarian Balakowiczifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
190483a0cf8SMarian BalakowiczAFLAGS_DEBUG := -Wa,-gstabs,-S
191483a0cf8SMarian Balakowiczendif
192483a0cf8SMarian Balakowiczendif
193b62fa913SMarian Balakowicz
194e2211743SwdenkAFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
195e2211743Swdenk
196161b2af4SMike FrysingerLDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)
197161b2af4SMike Frysingerifneq ($(TEXT_BASE),)
198161b2af4SMike FrysingerLDFLAGS += -Ttext $(TEXT_BASE)
199161b2af4SMike Frysingerendif
200e2211743Swdenk
201e2211743Swdenk# Location of a usable BFD library, where we define "usable" as
202e2211743Swdenk# "built for ${HOST}, supports ${TARGET}".  Sensible values are
203e2211743Swdenk# - When cross-compiling: the root of the cross-environment
204e2211743Swdenk# - Linux/ppc (native): /usr
205e2211743Swdenk# - NetBSD/ppc (native): you lose ... (must extract these from the
206e2211743Swdenk#   binutils build directory, plus the native and U-Boot include
207e2211743Swdenk#   files don't like each other)
208e2211743Swdenk#
209e2211743Swdenk# So far, this is used only by tools/gdb/Makefile.
210e2211743Swdenk
211e2211743Swdenkifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
212e2211743SwdenkBFD_ROOT_DIR =		/usr/local/tools
213e2211743Swdenkelse
214ea909b76Swdenkifeq ($(HOSTARCH),$(ARCH))
215ea909b76Swdenk# native
216ea909b76SwdenkBFD_ROOT_DIR =		/usr
217ea909b76Swdenkelse
218e2211743Swdenk#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
219e2211743Swdenk#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
220e2211743SwdenkBFD_ROOT_DIR =		/opt/powerpc
221e2211743Swdenkendif
222ea909b76Swdenkendif
223e2211743Swdenk
224f046ccd1SEran Libertyifeq ($(PCI_CLOCK),PCI_66M)
225f046ccd1SEran LibertyCFLAGS := $(CFLAGS) -DPCI_66M
226f046ccd1SEran Libertyendif
227f046ccd1SEran Liberty
228e2211743Swdenk#########################################################################
229e2211743Swdenk
230e2211743Swdenkexport	CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
231e2211743Swdenk	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
232e2211743Swdenk	MAKE
233e2211743Swdenkexport	TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
234e2211743Swdenk
235e2211743Swdenk#########################################################################
236e2211743Swdenk
237f9328639SMarian Balakowiczifndef REMOTE_BUILD
238f9328639SMarian Balakowicz
239e2211743Swdenk%.s:	%.S
240f9328639SMarian Balakowicz	$(CPP) $(AFLAGS) -o $@ $<
241e2211743Swdenk%.o:	%.S
242f9328639SMarian Balakowicz	$(CC) $(AFLAGS) -c -o $@ $<
243e2211743Swdenk%.o:	%.c
244e2211743Swdenk	$(CC) $(CFLAGS) -c -o $@ $<
245e2211743Swdenk
246f9328639SMarian Balakowiczelse
247f9328639SMarian Balakowicz
248f9328639SMarian Balakowicz$(obj)%.s:	%.S
249f9328639SMarian Balakowicz	$(CPP) $(AFLAGS) -o $@ $<
250f9328639SMarian Balakowicz$(obj)%.o:	%.S
251f9328639SMarian Balakowicz	$(CC) $(AFLAGS) -c -o $@ $<
252f9328639SMarian Balakowicz$(obj)%.o:	%.c
253f9328639SMarian Balakowicz	$(CC) $(CFLAGS) -c -o $@ $<
254f9328639SMarian Balakowiczendif
255f9328639SMarian Balakowicz
256e2211743Swdenk#########################################################################
257