-
Notifications
You must be signed in to change notification settings - Fork 110
/
build-cross-compiler.sh
executable file
·63 lines (49 loc) · 1.25 KB
/
build-cross-compiler.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
#!/bin/sh
GCC="gcc-8.2.0"
BINUTILS="binutils-2.31.1"
GDB="gdb-9.1"
CURRDIR=`pwd`
PREFIX=$CURRDIR/cross
WORKDIR=`mktemp -d`
echo "Installing cross-compiler to $PREFIX"
echo "Building in directory $WORKDIR"
cd "$WORKDIR"
# get and extract sources
if [ ! -d $BINUTILS ]
then
curl --insecure -O https://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.gz
tar -zxf $BINUTILS.tar.gz
fi
if [ ! -d $GCC ]
then
curl --insecure -O https://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.gz
tar -zxf $GCC.tar.gz
fi
if [ ! -d $GDB ]
then
curl --insecure -O http://ftp.gnu.org/gnu/gdb/$GDB.tar.gz
tar -zxf $GDB.tar.gz
fi
# build and install libtools
cd $BINUTILS
./configure --prefix="$PREFIX" --target=i686-elf --disable-nls --disable-werror --with-sysroot
make && make install
cd ..
# download gcc prerequisites
cd $GCC
./contrib/download_prerequisites
cd ..
# build and install gcc
mkdir $GCC-elf-objs
cd $GCC-elf-objs
../$GCC/configure --prefix="$PREFIX" --target=i686-elf --disable-nls --enable-languages=c --without-headers
make all-gcc && make all-target-libgcc && make install-gcc && make install-target-libgcc
cd ..
# build and install GDB
mkdir ${GDB}-build
cd ${GDB}-build
../${GDB}/configure --prefix="$PREFIX" --target=i686-elf
make && make install
cd ..
cd "$CURRDIR"
rm -rf "$WORKDIR"