source: branches/backfire/toolchain/gcc/Makefile @ 29925

Last change on this file since 29925 was 29925, checked in by jow, 4 years ago

[backfire] scripts, toolchain: backport external toolchain integration and spec patching from trunk (#10822)

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