-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoolchain.sh
executable file
·74 lines (62 loc) · 1.76 KB
/
toolchain.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
mkdir -p ~/.local/bin/cross_compiler/x86_64/
cd ~/.local/bin/cross_compiler/x86_64/
set -e
set -x
PREFIX="$(pwd)"
TARGET=x86_64-elf
BINUTILSVERSION=2.35
GCCVERSION=10.2.0
GDBVERSION=10.1
THREADS=9
if [ -z "$MAKEFLAGS" ]; then
MAKEFLAGS="$1"
fi
export MAKEFLAGS
export PATH="$PREFIX/bin:$PATH"
if [ -x "$(command -v gmake)" ]; then
mkdir -p "$PREFIX/bin"
cat <<EOF >"$PREFIX/bin/make"
#!/usr/bin/env sh
gmake "\$@"
EOF
chmod +x "$PREFIX/bin/make"
fi
mkdir -p build
cd build
if [ ! -f binutils-$BINUTILSVERSION.tar.gz ]; then
wget -4 https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz # Force IPv4 otherwise wget hangs
fi
if [ ! -f gcc-$GCCVERSION.tar.gz ]; then
wget -4 https://ftp.gnu.org/gnu/gcc/gcc-$GCCVERSION/gcc-$GCCVERSION.tar.gz # Same as above
fi
if [ ! -f gdb-$GDBVERSION.tar.gz ]; then
wget -4 https://ftp.gnu.org/gnu/gdb/gdb-$GDBVERSION.tar.gz # Same as above
fi
tar -xf binutils-$BINUTILSVERSION.tar.gz
tar -xf gcc-$GCCVERSION.tar.gz
tar -xf gdb-$GDBVERSION.tar.gz
rm -rf build-gcc build-binutils build-gdb
mkdir -p build-binutils
cd build-binutils
../binutils-$BINUTILSVERSION/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j"$THREADS"
make install -j"$THREADS"
cd ..
cd gcc-$GCCVERSION
contrib/download_prerequisites
cd ..
mkdir -p build-gcc
cd build-gcc
../gcc-$GCCVERSION/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc -j"$THREADS"
make all-target-libgcc -j"$THREADS"
make install-gcc -j"$THREADS"
make install-target-libgcc -j"$THREADS"
cd ..
mkdir -p build-gdb
cd build-gdb
../gdb-$GDBVERSION/configure --target=$TARGET --prefix="$PREFIX"
make -j"$THREADS"
make install -j"$THREADS"
cd ..