]>
Commit | Line | Data |
---|---|---|
abe05a73 | 1 | #!/usr/bin/env bash |
ea8adc8c XL |
2 | |
3 | set -ex | |
4 | source shared.sh | |
5 | ||
6 | ARCH=$1 | |
7 | LIB_ARCH=$2 | |
8 | APT_ARCH=$3 | |
cdc7bbd5 | 9 | MANUFACTURER=$4 |
ea8adc8c | 10 | BINUTILS=2.28.1 |
5869c6ff | 11 | GCC=6.5.0 |
ea8adc8c | 12 | |
cdc7bbd5 | 13 | TARGET=${ARCH}-${MANUFACTURER}-solaris2.10 |
6a06907d | 14 | |
ea8adc8c XL |
15 | # First up, build binutils |
16 | mkdir binutils | |
17 | cd binutils | |
18 | ||
19 | curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf - | |
20 | mkdir binutils-build | |
21 | cd binutils-build | |
6a06907d | 22 | hide_output ../binutils-$BINUTILS/configure --target=$TARGET |
ea8adc8c XL |
23 | hide_output make -j10 |
24 | hide_output make install | |
25 | ||
26 | cd ../.. | |
27 | rm -rf binutils | |
28 | ||
29 | # Next, download and install the relevant solaris packages | |
30 | mkdir solaris | |
31 | cd solaris | |
32 | ||
33 | dpkg --add-architecture $APT_ARCH | |
34 | apt-get update | |
f25598a0 | 35 | apt-get install -y --download-only \ |
ee023bcb | 36 | libc:$APT_ARCH \ |
ee023bcb FG |
37 | liblgrp:$APT_ARCH \ |
38 | libm-dev:$APT_ARCH \ | |
39 | libpthread:$APT_ARCH \ | |
40 | libresolv:$APT_ARCH \ | |
41 | librt:$APT_ARCH \ | |
ee023bcb FG |
42 | libsendfile:$APT_ARCH \ |
43 | libsocket:$APT_ARCH \ | |
44 | system-crt:$APT_ARCH \ | |
f25598a0 | 45 | system-header:$APT_ARCH |
ea8adc8c | 46 | |
f25598a0 | 47 | for deb in /var/cache/apt/archives/*$APT_ARCH.deb; do |
ea8adc8c XL |
48 | dpkg -x $deb . |
49 | done | |
f25598a0 | 50 | apt-get clean |
ea8adc8c | 51 | |
fc512014 XL |
52 | # The -dev packages are not available from the apt repository we're using. |
53 | # However, those packages are just symlinks from *.so to *.so.<version>. | |
54 | # This makes all those symlinks. | |
55 | for lib in $(find -name '*.so.*'); do | |
56 | target=${lib%.so.*}.so | |
57 | [ -e $target ] || ln -s ${lib##*/} $target | |
58 | done | |
59 | ||
ea8adc8c XL |
60 | # Remove Solaris 11 functions that are optionally used by libbacktrace. |
61 | # This is for Solaris 10 compatibility. | |
62 | rm usr/include/link.h | |
63 | patch -p0 << 'EOF' | |
64 | --- usr/include/string.h | |
65 | +++ usr/include/string10.h | |
66 | @@ -93 +92,0 @@ | |
67 | -extern size_t strnlen(const char *, size_t); | |
68 | EOF | |
69 | ||
6a06907d XL |
70 | mkdir /usr/local/$TARGET/usr |
71 | mv usr/include /usr/local/$TARGET/usr/include | |
72 | mv usr/lib/$LIB_ARCH/* /usr/local/$TARGET/lib | |
73 | mv lib/$LIB_ARCH/* /usr/local/$TARGET/lib | |
ea8adc8c | 74 | |
6a06907d XL |
75 | ln -s usr/include /usr/local/$TARGET/sys-include |
76 | ln -s usr/include /usr/local/$TARGET/include | |
ea8adc8c XL |
77 | |
78 | cd .. | |
79 | rm -rf solaris | |
80 | ||
81 | # Finally, download and build gcc to target solaris | |
82 | mkdir gcc | |
83 | cd gcc | |
84 | ||
85 | curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | tar xJf - | |
86 | cd gcc-$GCC | |
87 | ||
88 | mkdir ../gcc-build | |
89 | cd ../gcc-build | |
90 | hide_output ../gcc-$GCC/configure \ | |
91 | --enable-languages=c,c++ \ | |
6a06907d | 92 | --target=$TARGET \ |
ea8adc8c XL |
93 | --with-gnu-as \ |
94 | --with-gnu-ld \ | |
95 | --disable-multilib \ | |
96 | --disable-nls \ | |
97 | --disable-libgomp \ | |
98 | --disable-libquadmath \ | |
99 | --disable-libssp \ | |
100 | --disable-libvtv \ | |
101 | --disable-libcilkrts \ | |
102 | --disable-libada \ | |
103 | --disable-libsanitizer \ | |
104 | --disable-libquadmath-support \ | |
105 | --disable-lto | |
106 | ||
107 | hide_output make -j10 | |
108 | hide_output make install | |
109 | ||
110 | cd ../.. | |
111 | rm -rf gcc |