-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcross-compiler.sh
More file actions
executable file
·55 lines (41 loc) · 1.17 KB
/
cross-compiler.sh
File metadata and controls
executable file
·55 lines (41 loc) · 1.17 KB
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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Supply one parameter: the target to use!!"
exit 1
fi
if [ -z "${BINUTILS}" ]; then
BINUTILS="binutils-2.38"
fi
echo "Using ${BINUTILS}"
if [ -z "${GCC}" ]; then
GCC="gcc-11.4.0"
fi
echo "Using ${GCC}"
echo "Installing dependencies... (root might be needed)"
sudo apt install libgmp3-dev libmpfr-dev libisl-dev libmpc-dev texinfo -y
cd "$(dirname "$0")"
mkdir -pv out/{src,path}
cd out/src
rm -rvf $BINUTILS.tar.xz $GCC.tar.xz
wget https://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.xz
wget https://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.xz
echo "Extracting Binutils..."
tar -xf $BINUTILS.tar.xz
echo "Extracting GCC..."
tar -xf $GCC.tar.xz
export PREFIX="$(pwd)/../path/"
export TARGET=$1
export PATH="$PREFIX/bin:$PATH"
mkdir build-binutils
cd build-binutils
../$BINUTILS/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j $(nproc)
make install
cd ..
mkdir build-gcc
cd build-gcc
../$GCC/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make -j $(nproc) all-gcc
make -j $(nproc) all-target-libgcc
make install-gcc
make install-target-libgcc