increase the version number of Dragora
[dragora.git] / stages / 1 / 05-gcc
blob2d4acd62c6f5009ff52cc2884a4ab2ac29817476
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 # Apply specific patches for the support in musl.
42 # http://port70.net/~nsz/musl/gcc-trunk/
44 patch -Np1 -i "${worktree}/patches/gcc/0001-libgcc_s.patch"
45 patch -Np1 -i "${worktree}/patches/gcc/0005-libatomic-test-fix.patch"
46 patch -Np1 -i "${worktree}/patches/gcc/0006-libgomp-test-fix.patch"
47 patch -Np1 -i "${worktree}/patches/gcc/0007-libitm-test-fix.patch"
48 patch -Np1 -i "${worktree}/patches/gcc/0008-libvtv-test-fix.patch"
50 # Hard code default paths to look in /tools
51 for file in \
52  gcc/config/linux.h gcc/config/i386/linux.h gcc/config/i386/linux64.h \
53  gcc/config/arm/linux-eabi.h gcc/config/arm/linux-elf.h \
54  gcc/config/mips/linux.h \
55  gcc/config/rs6000/linux64.h gcc/config/rs6000/sysv4.h \
56  gcc/config/aarch64/aarch64-linux.h \
57  gcc/config/microblaze/linux.h \
58  gcc/config/sh/linux.h ; \
60     if test ! -f "$file"
61     then
62         echo "WARNING: ${0}: Non-existent file: $file" 1>&2
63         continue;
64     fi
65     sed -i \
66      -e 's@/lib\(64\)\{0,1\}\(32\)\{0,1\}/ld@/tools&@g' \
67      -e 's@/usr@/tools@g' "$file"
68     echo '
69 #undef STANDARD_STARTFILE_PREFIX_1
70 #undef STANDARD_STARTFILE_PREFIX_2
71 #define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
72 #define STANDARD_STARTFILE_PREFIX_2 ""' >> "$file"
73 done
75 # Make symlinks for requisites
76 ln -s ../gmp-${gmp_version} gmp
77 ln -s ../mpfr-${mpfr_version} mpfr
78 ln -s ../mpc-${mpc_version} mpc
79 ln -s ../isl-${isl_version} isl
81 # Apply patches for MPFR
83     cd mpfr || exit 1
85     for file in "${worktree}"/patches/mpfr/patch??*
86     do
87         if test -f "$file"
88         then
89             rm -f PATCHES
90             patch -p1 < "$file"
91         fi
92     done
95 # Build in a separate directory
96 rm -rf ../gcc-build
97 mkdir ../gcc-build
98 cd ../gcc-build
100 # Import and export toolchain variables
101 . "${worktree}/stages/env.d/cross-staticenv"
103 ../gcc-${version}/configure \
104 AR="$AR" AS="$AS" LD="$LD" RANLIB="$RANLIB" READELF="$READELF" STRIP="$STRIP" \
105 CC="$BTCC" CXX="$BTCXX" \
106 CFLAGS="$BTCFLAGS" CXXFLAGS="$BTCXXFLAGS" LDFLAGS="$BTLDFLAGS" \
107  --prefix=/tools \
108  --libdir=/tools/lib${libSuffix} \
109  --build=$host \
110  --host=$target \
111  --target=$target \
112  --enable-languages=c,c++ \
113  --enable-clocale=generic \
114  --enable-tls \
115  --enable-libstdcxx-time \
116  --enable-install-libiberty \
117  --enable-fully-dynamic-string \
118  --disable-symvers \
119  --disable-bootstrap \
120  --disable-libstdcxx-pch \
121  --disable-gnu-indirect-function \
122  --disable-libmudflap \
123  --disable-libsanitizer \
124  --disable-libmpx \
125  --disable-nls \
126  --with-local-prefix=/tools \
127  --with-native-system-header-dir=/tools/include \
128  $multilib_options \
129  $gcc_options
131 make -j${jobs} \
132  AS_FOR_TARGET="$AS" \
133  LD_FOR_TARGET="$LD"
135 make -j${jobs} install
137 # Unset some imported variables from file
138 unset AR AS LD RANLIB READELF STRIP
140 cleanup()
142     cd -- "$TMPDIR" && rm -rf gcc-* gmp-* mpfr-* mpc-* isl-*