xref: /openbmc/u-boot/config.mk (revision 6dd652fa)
1#
2# (C) Copyright 2000
3# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
5# See file CREDITS for list of people who contributed to this
6# project.
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 2 of
11# the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21# MA 02111-1307 USA
22#
23
24#########################################################################
25
26#
27# When cross-compiling on NetBSD, we have to define __PPC__ or else we
28# will pick up a va_list declaration that is incompatible with the
29# actual argument lists emitted by the compiler.
30#
31# [Tested on NetBSD/i386 1.5 + cross-powerpc-netbsd-1.3]
32
33ifeq ($(ARCH),ppc)
34ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
35PLATFORM_CPPFLAGS+= -D__PPC__
36endif
37ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
38PLATFORM_CPPFLAGS+= -D__PPC__
39endif
40endif
41
42ifeq ($(ARCH),arm)
43ifeq ($(CROSS_COMPILE),powerpc-netbsd-)
44PLATFORM_CPPFLAGS+= -D__ARM__
45endif
46ifeq ($(CROSS_COMPILE),powerpc-openbsd-)
47PLATFORM_CPPFLAGS+= -D__ARM__
48endif
49endif
50
51ifdef	ARCH
52sinclude $(TOPDIR)/$(ARCH)_config.mk	# include architecture dependend rules
53endif
54ifdef	CPU
55sinclude $(TOPDIR)/cpu/$(CPU)/config.mk	# include  CPU	specific rules
56endif
57ifdef	VENDOR
58BOARDDIR = $(VENDOR)/$(BOARD)
59else
60BOARDDIR = $(BOARD)
61endif
62ifdef	BOARD
63sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
64endif
65
66#########################################################################
67
68CONFIG_SHELL	:= $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
69		    else if [ -x /bin/bash ]; then echo /bin/bash; \
70		    else echo sh; fi ; fi)
71
72ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
73HOSTCC		= cc
74else
75HOSTCC		= gcc
76endif
77HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
78HOSTSTRIP	= strip
79
80#########################################################################
81
82#
83# Include the make variables (CC, etc...)
84#
85AS	= $(CROSS_COMPILE)as
86LD	= $(CROSS_COMPILE)ld
87CC	= $(CROSS_COMPILE)gcc
88CPP	= $(CC) -E
89AR	= $(CROSS_COMPILE)ar
90NM	= $(CROSS_COMPILE)nm
91STRIP	= $(CROSS_COMPILE)strip
92OBJCOPY = $(CROSS_COMPILE)objcopy
93OBJDUMP = $(CROSS_COMPILE)objdump
94RANLIB	= $(CROSS_COMPILE)RANLIB
95
96RELFLAGS= $(PLATFORM_RELFLAGS)
97DBGFLAGS= -g #-DDEBUG
98OPTFLAGS= -Os #-fomit-frame-pointer
99ifndef LDSCRIPT
100#LDSCRIPT := board/$(BOARDDIR)/u-boot.lds.debug
101LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
102endif
103OBJCFLAGS += --gap-fill=0xff
104
105CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
106	-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE)		\
107	-I$(TOPDIR)/include				\
108	-fno-builtin					\
109	-pipe $(PLATFORM_CPPFLAGS)
110
111ifdef BUILD_TAG
112CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
113	-DBUILD_TAG='"$(BUILD_TAG)"'
114else
115CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
116endif
117
118AFLAGS_DEBUG := -Wa,-gstabs
119AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
120
121LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
122
123# Location of a usable BFD library, where we define "usable" as
124# "built for ${HOST}, supports ${TARGET}".  Sensible values are
125# - When cross-compiling: the root of the cross-environment
126# - Linux/ppc (native): /usr
127# - NetBSD/ppc (native): you lose ... (must extract these from the
128#   binutils build directory, plus the native and U-Boot include
129#   files don't like each other)
130#
131# So far, this is used only by tools/gdb/Makefile.
132
133ifeq ($(HOSTOS)-$(HOSTARCH),darwin-ppc)
134BFD_ROOT_DIR =		/usr/local/tools
135else
136ifeq ($(HOSTARCH),$(ARCH))
137# native
138BFD_ROOT_DIR =		/usr
139else
140#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
141#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
142BFD_ROOT_DIR =		/opt/powerpc
143endif
144endif
145
146#########################################################################
147
148export	CONFIG_SHELL HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
149	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP \
150	MAKE
151export	TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
152
153#########################################################################
154
155%.s:	%.S
156	$(CPP) $(AFLAGS) -o $@ $(CURDIR)/$<
157%.o:	%.S
158	$(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$<
159%.o:	%.c
160	$(CC) $(CFLAGS) -c -o $@ $<
161
162#########################################################################
163