stages/*: change license to Apache 2.0
[dragora.git] / stages / 0 / 05-gcc-final
blob6ab9a53f4bbc5c6ad8d888ec3eaeb0706e51cf15
1 # Build script for gcc.
3 # Copyright (c) 2016-2017 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 version=6.4.0
19 # Prerequisites
20 gmp_version=6.1.2
21 mpfr_version=3.1.6
22 mpc_version=1.0.3
23 isl_version=0.18
25 # Unpack sources
26 rm -rf -- "${TMPDIR}/gcc-${version}"
27 rm -rf -- "${TMPDIR}/gmp-${gmp_version}"
28 rm -rf -- "${TMPDIR}/mpfr-${mpfr_version}"
29 rm -rf -- "${TMPDIR}/mpc-${mpc_version}"
30 rm -rf -- "${TMPDIR}/isl-${isl_version}"
31 untar "${worktree}/sources/gcc-${version}.tar.gz" "$TMPDIR"
32 untar "${worktree}"/sources/gmp-${gmp_version}.tar.lz "$TMPDIR"
33 untar "${worktree}"/sources/mpfr-${mpfr_version}.tar.bz2 "$TMPDIR"
34 untar "${worktree}"/sources/mpc-${mpc_version}.tar.gz "$TMPDIR"
35 untar "${worktree}"/sources/isl-${isl_version}.tar.bz2 "$TMPDIR"
37 # Build instructions
38 cd -- "${TMPDIR}/gcc-${version}"
40 # Make symlinks for requisites
41 ln -s ../gmp-${gmp_version} gmp
42 ln -s ../mpfr-${mpfr_version} mpfr
43 ln -s ../mpc-${mpc_version} mpc
44 ln -s ../isl-${isl_version} isl
46 # Apply patches for MPFR
48     cd mpfr || exit 1
50     for file in "${worktree}"/patches/mpfr/patch??*
51     do
52         if test -f "$file"
53         then
54             rm -f PATCHES
55             patch -p1 < "$file"
56         fi
57     done
60 # Apply specific patches for the support in musl.
62 # http://port70.net/~nsz/musl/gcc-trunk/
64 patch -Np1 -i "${worktree}/patches/gcc/0001-libgcc_s.patch"
65 patch -Np1 -i "${worktree}/patches/gcc/0005-libatomic-test-fix.patch"
66 patch -Np1 -i "${worktree}/patches/gcc/0006-libgomp-test-fix.patch"
67 patch -Np1 -i "${worktree}/patches/gcc/0007-libitm-test-fix.patch"
68 patch -Np1 -i "${worktree}/patches/gcc/0008-libvtv-test-fix.patch"
70 # Build in a separate directory
71 rm -rf ../gcc-build
72 mkdir ../gcc-build
73 cd ../gcc-build
75 option_list="
76  --prefix="$crossdir" \
77  --libdir="${crossdir}/lib${libSuffix}" \
78  --build=$host \
79  --host=$host \
80  --target=$target \
81  --enable-languages=c,c++ \
82  --enable-clocale=generic \
83  --enable-tls \
84  --enable-libstdcxx-time \
85  --enable-checking=release \
86  --enable-fully-dynamic-string \
87  --disable-symvers \
88  --disable-gnu-indirect-function \
89  --disable-libmudflap \
90  --disable-libsanitizer \
91  --disable-libmpx \
92  --disable-nls \
93  --disable-lto-plugin \
94  --with-sysroot="${crossdir}/$target" \
95  $multilib_options \
96  $gcc_options
99 if test -n "$IS_DARKCRUSADE"
100 then
101     ../gcc-${version}/configure CC="$BTCC" CXX="$BTCXX" AR="ar" \
102     CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
103     $option_list
104 else
105     ../gcc-${version}/configure AR="ar" \
106     CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
107     $option_list
110 unset option_list IS_DARKCRUSADE
112 make -j${jobs} all \
113  AS_FOR_TARGET="${target}-as" \
114  LD_FOR_TARGET="${target}-ld"
116 make -j${jobs} install
118 cleanup()
120     cd -- "$TMPDIR" && rm -rf gcc-* gmp-* mpfr-* mpc-* isl-*