toolchain/gcc: add support for gcc-4.4.4
[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-2010 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 GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
25 PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
26 GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
27
28 ifdef CONFIG_GCC_VERSION_LLVM
29 PKG_SOURCE_VERSION:=c98c494b72ff875884c0c7286be67f16f9f6d7ab
30 PKG_REV:=83504
31 GCC_DIR:=llvm-gcc-4.2-r$(PKG_REV)
32 PKG_VERSION:=4.2.1
33 PKG_SOURCE:=$(GCC_DIR).tar.gz
34 PKG_SOURCE_PROTO:=git
35 PKG_SOURCE_URL:=git://repo.or.cz/llvm-gcc-4.2.git
36 PKG_SOURCE_SUBDIR:=$(GCC_DIR)
37 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(GCC_DIR)
38 else
39 PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
40 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
41
42 ifeq ($(PKG_VERSION),3.4.6)
43 PKG_MD5SUM:=4a21ac777d4b5617283ce488b808da7b
44 endif
45 ifeq ($(PKG_VERSION),4.1.2)
46 PKG_MD5SUM:=a4a3eb15c96030906d8494959eeda23c
47 endif
48 ifeq ($(PKG_VERSION),4.2.4)
49 PKG_MD5SUM:=d79f553e7916ea21c556329eacfeaa16
50 endif
51 ifeq ($(PKG_VERSION),4.3.3)
52 PKG_MD5SUM:=cc3c5565fdb9ab87a05ddb106ba0bd1f
53 endif
54 ifeq ($(PKG_VERSION),4.3.4)
55 PKG_MD5SUM:=60df63222dbffd53ca11492a2545044f
56 endif
57 ifeq ($(PKG_VERSION),4.3.5)
58 PKG_MD5SUM:=e588cfde3bf323f82918589b94f14a15
59 endif
60 ifeq ($(PKG_VERSION),4,4,1)
61 PKG_MD5SUM:=927eaac3d44b22f31f9c83df82f26436
62 endif
63 ifeq ($(PKG_VERSION),4.4.2)
64 PKG_MD5SUM:=70f5ac588a79e3c9901d5b34f58d896d
65 endif
66 ifeq ($(PKG_VERSION),4.4.3)
67 PKG_MD5SUM:=fe1ca818fc6d2caeffc9051fe67ff103
68 endif
69 ifeq ($(PKG_VERSION),4.4.4)
70 PKG_MD5SUM:=7ff5ce9e5f0b088ab48720bbd7203530
71 endif
72 ifeq ($(PKG_VERSION),4.5.0)
73 PKG_MD5SUM:=ff27b7c4a5d5060c8a8543a44abca31f
74 endif
75 endif
76
77 PATCH_DIR=./patches/$(GCC_VERSION)
78
79 include $(INCLUDE_DIR)/toolchain-build.mk
80
81 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
82
83 HOST_BUILD_DIR0:=$(HOST_BUILD_DIR)-minimal
84 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
85 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
86
87 SEP:=,
88 TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
89
90 export libgcc_cv_fixed_point=no
91
92 GCC_CONFIGURE:= \
93 SHELL="$(BASH)" \
94 $(HOST_BUILD_DIR)/configure \
95 --prefix=$(TOOLCHAIN_DIR)/usr \
96 --build=$(GNU_HOST_NAME) \
97 --host=$(GNU_HOST_NAME) \
98 --target=$(REAL_GNU_TARGET_NAME) \
99 --with-gnu-ld \
100 --enable-target-optspace \
101 --disable-libgomp \
102 --disable-libmudflap \
103 --disable-multilib \
104 --disable-nls \
105 $(GRAPHITE_CONFIGURE) \
106 $(if $(CONFIG_GCC_USE_GRAPHITE),--with-host-libstdcxx=-lstdc++) \
107 $(SOFT_FLOAT_CONFIG_OPTION) \
108 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
109 $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 --with-abi=64) \
110 $(if $(CONFIG_GCC_VERSION_LLVM),--enable-llvm=$(BUILD_DIR_BASE)/host/llvm) \
111 $(if $(CONFIG_GCC_VERSION_4_3_3_CS)$(CONFIG_GCC_VERSION_4_4_1_CS)$(CONFIG_GCC_VERSION_4_4_3_CS),--enable-poison-system-directories)
112
113 ifneq ($(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4)$(CONFIG_GCC_VERSION_4_5),)
114 GCC_BUILD_TARGET_LIBGCC:=y
115 GCC_CONFIGURE+= \
116 --with-gmp=$(TOPDIR)/staging_dir/host \
117 --with-mpfr=$(TOPDIR)/staging_dir/host \
118 --disable-decimal-float
119 endif
120
121 ifneq ($(CONFIG_GCC_VERSION_4_5),)
122 GCC_BUILD_TARGET_LIBGCC:=y
123 GCC_CONFIGURE+= \
124 --with-gmp=$(TOPDIR)/staging_dir/host \
125 --with-mpc=$(TOPDIR)/staging_dir/host \
126 --with-mpfr=$(TOPDIR)/staging_dir/host \
127 --disable-decimal-float
128 endif
129
130 ifneq ($(CONFIG_SSP_SUPPORT),)
131 GCC_CONFIGURE+= \
132 --enable-libssp
133 else
134 GCC_CONFIGURE+= \
135 --disable-libssp
136 endif
137
138 ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
139 GCC_CONFIGURE+= \
140 --enable-biarch \
141 --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
142 endif
143
144 ifeq ($(LIBC),uClibc)
145 GCC_CONFIGURE+= \
146 --disable-__cxa_atexit
147 else
148 GCC_CONFIGURE+= \
149 --enable-__cxa_atexit
150 endif
151
152 GCC_CONFIGURE_STAGE0:= \
153 $(GCC_CONFIGURE) \
154 --with-newlib \
155 --without-headers \
156 --enable-languages=c \
157 --disable-libssp \
158 --disable-shared \
159 --disable-threads \
160
161 GCC_CONFIGURE_STAGE1:= \
162 $(GCC_CONFIGURE) \
163 --with-newlib \
164 --with-sysroot=$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
165 --enable-languages=c \
166 --disable-shared \
167 --disable-threads \
168
169 GCC_CONFIGURE_STAGE2:= \
170 $(GCC_CONFIGURE) \
171 --enable-languages=$(TARGET_LANGUAGES) \
172 --enable-shared \
173 --enable-threads \
174 --with-slibdir=$(TOOLCHAIN_DIR)/lib
175
176 ifneq ($(CONFIG_GCC_VERSION_4_5),)
177 GCC_CONFIGURE_STAGE2+= \
178 --enable-lto \
179 --with-libelf=$(TOPDIR)/staging_dir/host
180 endif
181
182 ifneq ($(CONFIG_TLS_SUPPORT),)
183 GCC_CONFIGURE_STAGE2+= \
184 --enable-tls
185 else
186 GCC_CONFIGURE_STAGE2+= \
187 --disable-tls
188 endif
189
190 ifdef CONFIG_powerpc
191 TARGET_CFLAGS := $(patsubst -Os,-O2,$(TARGET_CFLAGS))
192 endif
193
194 GCC_MAKE:= \
195 export SHELL="$(BASH)"; \
196 $(MAKE) \
197 CFLAGS_FOR_TARGET="$(TARGET_CFLAGS)" \
198 CXXFLAGS_FOR_TARGET="$(TARGET_CFLAGS)"
199
200 define Host/SetToolchainInfo
201 $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
202 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk
203 endef
204
205
206 define Stage0/Configure
207 mkdir -p $(HOST_BUILD_DIR0)
208 (cd $(HOST_BUILD_DIR0); rm -f config.cache; \
209 $(GCC_CONFIGURE_STAGE0) \
210 );
211 endef
212
213 define Stage0/Compile
214 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) all-gcc
215 endef
216
217 define Stage0/Install
218 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) install-gcc
219 endef
220
221
222 define Stage1/Configure
223 mkdir -p $(HOST_BUILD_DIR1)
224 (cd $(HOST_BUILD_DIR1); rm -f config.cache; \
225 $(GCC_CONFIGURE_STAGE1) \
226 );
227 endef
228
229 define Stage1/Compile
230 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
231 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
232 all-build-libiberty \
233 all-gcc \
234 $(if $(GCC_BUILD_TARGET_LIBGCC),all-target-libgcc)
235 endef
236
237 define Stage1/Install
238 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
239 install-gcc \
240 $(if $(GCC_BUILD_TARGET_LIBGCC),install-target-libgcc)
241
242 # XXX: glibc insists on linking against libgcc_eh
243 ( cd $(TOOLCHAIN_DIR)/usr/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
244 [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
245 cp libgcc.a libgcc_initial.a; \
246 )
247 endef
248
249
250 define Stage2/Configure
251 mkdir -p $(HOST_BUILD_DIR2) $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)
252 # Important! Required for limits.h to be fixed.
253 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
254 ln -sf ../include $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
255 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
256 ln -sf ../lib $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
257 $(if $(CONFIG_mips64)$(CONFIG_mips64el)$(CONFIG_x86_64),ln -sf ../lib64 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib64)
258 (cd $(HOST_BUILD_DIR2); rm -f config.cache; \
259 $(GCC_CONFIGURE_STAGE2) \
260 );
261 endef
262
263 define Stage2/Compile
264 $(GCC_MAKE) -C $(HOST_BUILD_DIR2) all
265 endef
266
267 define SetupExtraArch
268 for app in $(TOOLCHAIN_DIR)/usr/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
269 [ -e $$$$app ] || continue; \
270 old_base=$$$$(basename $$$$app); \
271 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
272 sed -e "s/@CC_BASE@/$$$$old_base/" \
273 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
274 ./files/alternate-arch-cc.in > \
275 $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
276 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
277 done
278 endef
279
280 define Stage2/Install
281 $(_SINGLE)$(GCC_MAKE) -C $(HOST_BUILD_DIR2) install
282 # Set up the symlinks to enable lying about target name.
283 set -e; \
284 (cd $(TOOLCHAIN_DIR)/usr; \
285 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
286 cd bin; \
287 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
288 ln -sf $$$${app} \
289 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
290 done; \
291 );
292 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
293 endef
294
295
296 BUGURL=https://dev.openwrt.org/
297
298 define Host/Prepare
299 $(call Host/SetToolchainInfo)
300 $(call Host/Prepare/Default)
301 ln -snf $(GCC_DIR) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
302 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
303 $(SED) 's,^MULTILIB_OSDIRNAMES,# MULTILIB_OSDIRNAMES,' $(HOST_BUILD_DIR)/gcc/config/*/t-*
304 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(HOST_BUILD_DIR)/gcc/version.c
305 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:$(BUGURL)>\2,' $(HOST_BUILD_DIR)/gcc/version.c
306 $(SED) 's,http://gcc.gnu.org/bugs.html,$(BUGURL),' $(HOST_BUILD_DIR)/gcc/configure
307 #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
308 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
309 $(call Stage0/Configure)
310 $(call Stage0/Compile)
311 $(call Stage0/Install)
312 endef
313
314 define Host/Configure
315 endef
316
317 define Host/Compile
318 $(call Stage1/Configure)
319 $(call Stage1/Compile)
320 $(call Stage1/Install)
321 endef
322
323 define Host/Install
324 $(call Stage2/Configure)
325 $(call Stage2/Compile)
326 $(call Stage2/Install)
327 endef
328
329 define Host/Clean
330 rm -rf \
331 $(HOST_BUILD_DIR) \
332 $(HOST_BUILD_DIR0) \
333 $(HOST_BUILD_DIR1) \
334 $(HOST_BUILD_DIR2) \
335 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
336 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME) \
337 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gc* \
338 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c*
339 endef
340
341 $(eval $(call HostBuild))
This page took 0.050764 seconds and 5 git commands to generate.