-
Notifications
You must be signed in to change notification settings - Fork 45
/
BuildCrossCompiler
executable file
·44 lines (33 loc) · 1.19 KB
/
BuildCrossCompiler
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
#!/bin/bash
set -e
set -x
BINUTILS=binutils-2.33.1
GCC=gcc-6.5.0
if [[ ${ARCH} == "amd64" ]] ; then
TRIPLE=x86_64-none-elf
elif [[ ${ARCH} == "armv7" ]]; then
TRIPLE=arm-elf-eabi
else
echo "Unknown architecture '${ARCH}' in BuildCrossCompiler"
exit 1
fi
PREFIX=${PWD}/.prefix/
PATH=${PREFIX}bin:${PATH}
if [[ -e ${PREFIX}${TRIPLE}-gcc ]]; then
exit 0
fi
mkdir -p .cross_build
cd .cross_build
BINUTILS_FNAME=${BINUTILS}.tar.bz2
GCC_FNAME=${GCC}.tar.xz
test -e ${BINUTILS}.tar.bz2 || wget http://ftp.gnu.org/gnu/binutils/${BINUTILS_FNAME}
test -e ${GCC_FNAME} || wget http://ftp.gnu.org/gnu/gcc/${GCC}/${GCC_FNAME}
test -e ${BINUTILS}/configure || tar -xf ${BINUTILS_FNAME}
test -e ${GCC}/configure || tar -xf ${GCC_FNAME}
cd ${GCC}
test -e mpfr || ./contrib/download_prerequisites
cd ..
mkdir -p ${ARCH}
cd ${ARCH}
(mkdir -p binutils && cd binutils && ../../${BINUTILS}/configure --prefix=${PREFIX} --disable-nls --target=${TRIPLE} && echo "MAKEINFO = :" >> Makefile && make -j 3 && make install)
(mkdir -p gcc && cd gcc && ../../${GCC}/configure --prefix=${PREFIX} --disable-nls --enable-langs=c --target=${TRIPLE} && make all-gcc all-target-libgcc -j 3 && make install-gcc install-target-libgcc)