Set default compiler for ps3
[openwrt.git] / toolchain / gcc / Makefile
1 #
2 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
3 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
4 # Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
5 # Copyright (C) 2006-2009 OpenWrt.org
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 include $(TOPDIR)/rules.mk
22
23 PKG_NAME:=gcc
24 PKG_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
25
26 PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
27 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
28
29 ifeq ($(PKG_VERSION),3.4.6)
30 PKG_MD5SUM:=4a21ac777d4b5617283ce488b808da7b
31 endif
32 ifeq ($(PKG_VERSION),4.1.2)
33 PKG_MD5SUM:=a4a3eb15c96030906d8494959eeda23c
34 endif
35 ifeq ($(PKG_VERSION),4.2.4)
36 PKG_MD5SUM:=d79f553e7916ea21c556329eacfeaa16
37 endif
38 ifeq ($(PKG_VERSION),4.3.1)
39 PKG_MD5SUM:=4afa0290cc3a41ac8822666f1110de98
40 endif
41 ifeq ($(PKG_VERSION),4.3.2)
42 PKG_MD5SUM:=5dfac5da961ecd5f227c3175859a486d
43 endif
44 ifeq ($(PKG_VERSION),4.3.3)
45 PKG_MD5SUM:=cc3c5565fdb9ab87a05ddb106ba0bd1f
46 endif
47
48 PATCH_DIR=./patches/$(PKG_VERSION)
49
50 include $(INCLUDE_DIR)/toolchain-build.mk
51
52 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
53
54 HOST_BUILD_DIR0:=$(HOST_BUILD_DIR)-minimal
55 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
56 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
57
58 SEP:=,
59 TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
60
61 GCC_CONFIGURE:= \
62 SHELL="$(BASH)" \
63 $(HOST_BUILD_DIR)/configure \
64 --prefix=$(TOOLCHAIN_DIR)/usr \
65 --build=$(GNU_HOST_NAME) \
66 --host=$(GNU_HOST_NAME) \
67 --target=$(REAL_GNU_TARGET_NAME) \
68 --with-gnu-ld \
69 --enable-target-optspace \
70 --disable-libgomp \
71 --disable-libmudflap \
72 --disable-multilib \
73 --disable-nls \
74 $(SOFT_FLOAT_CONFIG_OPTION) \
75 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
76
77 ifneq ($(CONFIG_GCC_VERSION_4_3),)
78 GCC_BUILD_TARGET_LIBGCC:=y
79 GCC_CONFIGURE+= \
80 --with-gmp=$(TOPDIR)/staging_dir/host \
81 --with-mpfr=$(TOPDIR)/staging_dir/host \
82 --disable-decimal-float
83 endif
84
85 ifneq ($(CONFIG_SSP_SUPPORT),)
86 GCC_CONFIGURE+= \
87 --enable-libssp
88 else
89 GCC_CONFIGURE+= \
90 --disable-libssp
91 endif
92
93 ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
94 GCC_CONFIGURE+= \
95 --enable-biarch \
96 --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
97 endif
98
99 ifeq ($(LIBC),uClibc)
100 GCC_CONFIGURE+= \
101 --disable-__cxa_atexit
102 else
103 GCC_CONFIGURE+= \
104 --enable-__cxa_atexit
105 endif
106
107 GCC_CONFIGURE_STAGE0:= \
108 $(GCC_CONFIGURE) \
109 --with-newlib \
110 --without-headers \
111 --enable-languages=c \
112 --disable-libssp \
113 --disable-shared \
114 --disable-threads \
115
116 GCC_CONFIGURE_STAGE1:= \
117 $(GCC_CONFIGURE) \
118 --with-newlib \
119 --with-sysroot=$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
120 --enable-languages=c \
121 --disable-shared \
122 --disable-threads \
123
124 GCC_CONFIGURE_STAGE2:= \
125 $(GCC_CONFIGURE) \
126 --enable-languages=$(TARGET_LANGUAGES) \
127 --enable-shared \
128 --enable-threads \
129 --with-slibdir=$(TOOLCHAIN_DIR)/lib \
130
131 GCC_MAKE:= \
132 export SHELL="$(BASH)"; \
133 $(MAKE) \
134
135
136 define Host/SetToolchainInfo
137 $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
138 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
139 endef
140
141
142 define Stage0/Configure
143 mkdir -p $(HOST_BUILD_DIR0)
144 (cd $(HOST_BUILD_DIR0); rm -f config.cache; \
145 $(GCC_CONFIGURE_STAGE0) \
146 );
147 endef
148
149 define Stage0/Compile
150 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) all-gcc
151 endef
152
153 define Stage0/Install
154 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) install-gcc
155 endef
156
157
158 define Stage1/Configure
159 mkdir -p $(HOST_BUILD_DIR1)
160 (cd $(HOST_BUILD_DIR1); rm -f config.cache; \
161 $(GCC_CONFIGURE_STAGE1) \
162 );
163 endef
164
165 define Stage1/Compile
166 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
167 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
168 all-build-libiberty \
169 all-gcc \
170 $(if $(GCC_BUILD_TARGET_LIBGCC),all-target-libgcc)
171 endef
172
173 define Stage1/Install
174 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
175 install-gcc \
176 $(if $(GCC_BUILD_TARGET_LIBGCC),install-target-libgcc)
177
178 # XXX: glibc insists on linking against libgcc_eh
179 ( cd $(TOOLCHAIN_DIR)/usr/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
180 [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
181 )
182 endef
183
184
185 define Stage2/Configure
186 mkdir -p $(HOST_BUILD_DIR2) $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)
187 # Important! Required for limits.h to be fixed.
188 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
189 ln -sf ../include $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
190 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
191 ln -sf ../lib $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
192 (cd $(HOST_BUILD_DIR2); rm -f config.cache; \
193 $(GCC_CONFIGURE_STAGE2) \
194 );
195 endef
196
197 define Stage2/Compile
198 $(GCC_MAKE) -C $(HOST_BUILD_DIR2) all
199 endef
200
201 define SetupExtraArch
202 for app in $(TOOLCHAIN_DIR)/usr/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
203 [ -e $$$$app ] || continue; \
204 old_base=$$$$(basename $$$$app); \
205 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
206 sed -e "s/@CC_BASE@/$$$$old_base/" \
207 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
208 ./files/alternate-arch-cc.in > \
209 $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
210 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
211 done
212 endef
213
214 define Stage2/Install
215 $(GCC_MAKE) -C $(HOST_BUILD_DIR2) install
216 # Set up the symlinks to enable lying about target name.
217 set -e; \
218 (cd $(TOOLCHAIN_DIR)/usr; \
219 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
220 cd bin; \
221 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
222 ln -sf $$$${app} \
223 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
224 done; \
225 );
226 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
227 endef
228
229
230 define Host/Prepare
231 $(call Host/SetToolchainInfo)
232 $(call Host/Prepare/Default)
233 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
234 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
235 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(HOST_BUILD_DIR)/gcc/version.c
236 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(HOST_BUILD_DIR)/gcc/version.c
237 (cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
238 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
239 $(call Stage0/Configure)
240 $(call Stage0/Compile)
241 $(call Stage0/Install)
242 endef
243
244 define Host/Configure
245 endef
246
247 define Host/Compile
248 $(call Stage1/Configure)
249 $(call Stage1/Compile)
250 $(call Stage1/Install)
251 endef
252
253 define Host/Install
254 $(call Stage2/Configure)
255 $(call Stage2/Compile)
256 $(call Stage2/Install)
257 endef
258
259 define Host/Clean
260 rm -rf \
261 $(HOST_BUILD_DIR) \
262 $(HOST_BUILD_DIR0) \
263 $(HOST_BUILD_DIR1) \
264 $(HOST_BUILD_DIR2) \
265 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
266 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME) \
267 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gc* \
268 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c*
269 endef
270
271 $(eval $(call HostBuild))
This page took 0.070767 seconds and 5 git commands to generate.