[kernel] use 2.6.30.5
[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.3)
39 PKG_MD5SUM:=cc3c5565fdb9ab87a05ddb106ba0bd1f
40 endif
41 ifeq ($(PKG_VERSION),4.4.0)
42 PKG_MD5SUM:=cf5d787bee57f38168b74d65a7c0e6fd
43 endif
44
45 PATCH_DIR=./patches/$(PKG_VERSION)
46
47 include $(INCLUDE_DIR)/toolchain-build.mk
48
49 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
50
51 HOST_BUILD_DIR0:=$(HOST_BUILD_DIR)-minimal
52 HOST_BUILD_DIR1:=$(HOST_BUILD_DIR)-initial
53 HOST_BUILD_DIR2:=$(HOST_BUILD_DIR)-final
54
55 SEP:=,
56 TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
57
58 GCC_CONFIGURE:= \
59 SHELL="$(BASH)" \
60 $(HOST_BUILD_DIR)/configure \
61 --prefix=$(TOOLCHAIN_DIR)/usr \
62 --build=$(GNU_HOST_NAME) \
63 --host=$(GNU_HOST_NAME) \
64 --target=$(REAL_GNU_TARGET_NAME) \
65 --with-gnu-ld \
66 --enable-target-optspace \
67 --disable-libgomp \
68 --disable-libmudflap \
69 --disable-multilib \
70 --disable-nls \
71 $(SOFT_FLOAT_CONFIG_OPTION) \
72 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
73 $(if $(CONFIG_mips64)$(CONFIG_mips64el),--with-arch=mips64 --with-abi=64) \
74
75 ifneq ($(CONFIG_GCC_VERSION_4_3)$(CONFIG_GCC_VERSION_4_4),)
76 GCC_BUILD_TARGET_LIBGCC:=y
77 GCC_CONFIGURE+= \
78 --with-gmp=$(TOPDIR)/staging_dir/host \
79 --with-mpfr=$(TOPDIR)/staging_dir/host \
80 --disable-decimal-float
81 endif
82
83 ifneq ($(CONFIG_SSP_SUPPORT),)
84 GCC_CONFIGURE+= \
85 --enable-libssp
86 else
87 GCC_CONFIGURE+= \
88 --disable-libssp
89 endif
90
91 ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
92 GCC_CONFIGURE+= \
93 --enable-biarch \
94 --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
95 endif
96
97 ifeq ($(LIBC),uClibc)
98 GCC_CONFIGURE+= \
99 --disable-__cxa_atexit
100 else
101 GCC_CONFIGURE+= \
102 --enable-__cxa_atexit
103 endif
104
105 GCC_CONFIGURE_STAGE0:= \
106 $(GCC_CONFIGURE) \
107 --with-newlib \
108 --without-headers \
109 --enable-languages=c \
110 --disable-libssp \
111 --disable-shared \
112 --disable-threads \
113
114 GCC_CONFIGURE_STAGE1:= \
115 $(GCC_CONFIGURE) \
116 --with-newlib \
117 --with-sysroot=$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
118 --enable-languages=c \
119 --disable-shared \
120 --disable-threads \
121
122 GCC_CONFIGURE_STAGE2:= \
123 $(GCC_CONFIGURE) \
124 --enable-languages=$(TARGET_LANGUAGES) \
125 --enable-shared \
126 --enable-threads \
127 --disable-tls \
128 --with-slibdir=$(TOOLCHAIN_DIR)/lib \
129
130 GCC_MAKE:= \
131 export SHELL="$(BASH)"; \
132 $(MAKE) \
133
134
135 define Host/SetToolchainInfo
136 $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
137 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
138 endef
139
140
141 define Stage0/Configure
142 mkdir -p $(HOST_BUILD_DIR0)
143 (cd $(HOST_BUILD_DIR0); rm -f config.cache; \
144 $(GCC_CONFIGURE_STAGE0) \
145 );
146 endef
147
148 define Stage0/Compile
149 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) all-gcc
150 endef
151
152 define Stage0/Install
153 $(GCC_MAKE) -C $(HOST_BUILD_DIR0) install-gcc
154 endef
155
156
157 define Stage1/Configure
158 mkdir -p $(HOST_BUILD_DIR1)
159 (cd $(HOST_BUILD_DIR1); rm -f config.cache; \
160 $(GCC_CONFIGURE_STAGE1) \
161 );
162 endef
163
164 define Stage1/Compile
165 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
166 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
167 all-build-libiberty \
168 all-gcc \
169 $(if $(GCC_BUILD_TARGET_LIBGCC),all-target-libgcc)
170 endef
171
172 define Stage1/Install
173 $(GCC_MAKE) -C $(HOST_BUILD_DIR1) \
174 install-gcc \
175 $(if $(GCC_BUILD_TARGET_LIBGCC),install-target-libgcc)
176
177 # XXX: glibc insists on linking against libgcc_eh
178 ( cd $(TOOLCHAIN_DIR)/usr/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
179 [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
180 cp libgcc.a libgcc_initial.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 $(if $(CONFIG_mips64)$(CONFIG_mips64el)$(CONFIG_x86_64),ln -sf ../lib64 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib64)
193 (cd $(HOST_BUILD_DIR2); rm -f config.cache; \
194 $(GCC_CONFIGURE_STAGE2) \
195 );
196 endef
197
198 define Stage2/Compile
199 $(GCC_MAKE) -C $(HOST_BUILD_DIR2) all
200 endef
201
202 define SetupExtraArch
203 for app in $(TOOLCHAIN_DIR)/usr/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
204 [ -e $$$$app ] || continue; \
205 old_base=$$$$(basename $$$$app); \
206 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
207 sed -e "s/@CC_BASE@/$$$$old_base/" \
208 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
209 ./files/alternate-arch-cc.in > \
210 $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
211 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
212 done
213 endef
214
215 define Stage2/Install
216 $(GCC_MAKE) -C $(HOST_BUILD_DIR2) install
217 # Set up the symlinks to enable lying about target name.
218 set -e; \
219 (cd $(TOOLCHAIN_DIR)/usr; \
220 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
221 cd bin; \
222 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
223 ln -sf $$$${app} \
224 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
225 done; \
226 );
227 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
228 endef
229
230
231 define Host/Prepare
232 $(call Host/SetToolchainInfo)
233 $(call Host/Prepare/Default)
234 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
235 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
236 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(HOST_BUILD_DIR)/gcc/version.c
237 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(HOST_BUILD_DIR)/gcc/version.c
238 #(cd $(HOST_BUILD_DIR)/libstdc++-v3; autoconf;);
239 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(HOST_BUILD_DIR)/libstdc++-v3/configure
240 $(call Stage0/Configure)
241 $(call Stage0/Compile)
242 $(call Stage0/Install)
243 endef
244
245 define Host/Configure
246 endef
247
248 define Host/Compile
249 $(call Stage1/Configure)
250 $(call Stage1/Compile)
251 $(call Stage1/Install)
252 endef
253
254 define Host/Install
255 $(call Stage2/Configure)
256 $(call Stage2/Compile)
257 $(call Stage2/Install)
258 endef
259
260 define Host/Clean
261 rm -rf \
262 $(HOST_BUILD_DIR) \
263 $(HOST_BUILD_DIR0) \
264 $(HOST_BUILD_DIR1) \
265 $(HOST_BUILD_DIR2) \
266 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
267 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME) \
268 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gc* \
269 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c*
270 endef
271
272 $(eval $(call HostBuild))
This page took 0.064921 seconds and 5 git commands to generate.