-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-toolchain.sh
executable file
·75 lines (66 loc) · 2.2 KB
/
build-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
#!/bin/bash
source "config/config.cfg"
# binutils 2.24 requires gcc 4
if [ -z "${CXX}" ]; then
CXX="g++"
fi
CXXMAJORVERSION=$(${CXX} -dumpversion | cut -d "." -f 1)
if [ "${CXXMAJORVERSION}" -ne 4 ]; then
echo "g++ 4 is required. If it is installed set CXX variable accordingly."
exit -1
fi
if [ -z "${CC}" ]; then
CC="gcc"
fi
CCMAJORVERSION=$(${CC} -dumpversion | cut -d "." -f 1)
if [ "${CCMAJORVERSION}" -ne 4 ]; then
echo "gcc 4 is required. If it is installed set CC variable accordingly."
exit -1
fi
#
# Make binutils and gcc for compiling linux
#
# NOTE1: buildroot compiles its own toolchains (can we change this?)
# NOTE2: firmware (iop modules) needs the ps2sdk toolchain
#
cd "${TOOLCHAIN_DIR}"
# Change to another binutils branch?
# cd "${BINUTILS_DIR}"
# git checkout ps2-v2.24 || exit -1
# cd ..
# Change to another gcc branch?
# cd "${GCC_DIR}"
# git checkout ps2-v4.9.0 || exit -1
# cd ..
# Remove the next line to rebuild the entire toolchain
# rm -rf build
if [ ! -d build ]; then
mkdir build || exit -1
fi
cd build
# Remove the next line to rebuild binutils
# rm -rf "${BINUTILS_DIR}"
if [ ! -d "${BINUTILS_DIR}" ]; then
mkdir "${BINUTILS_DIR}" || exit -1
fi
if [ ! -f "${BINUTILS_DIR}/binutils/readelf" ]; then
cd "${BINUTILS_DIR}"
../../${BINUTILS_DIR}/configure --program-prefix="${TOOLCHAIN_PROGRAMPREFIX}" --target=${TOOLCHAIN_TARGET} --enable-targets=${TOOLCHAIN_TARGET} --enable-shared --enable-plugins || exit -1
make -j 5 || exit -1
sudo make install || exit -1
cd ..
fi
# Remove the next line to rebuild gcc
# rm -rf "${GCC_DIR}"
if [ ! -d "${GCC_DIR}" ]; then
mkdir "${GCC_DIR}" || exit -1
fi
if [ ! -f "${GCC_DIR}/gcc/cc1" ]; then
cd "${GCC_DIR}"
../../${GCC_DIR}/configure --program-prefix="${TOOLCHAIN_PROGRAMPREFIX}" --target=${TOOLCHAIN_TARGET} --enable-languages=c --disable-nls --disable-shared --disable-libssp --disable-libmudflap --disable-threads --disable-libgomp --disable-libquadmath --disable-target-libiberty --disable-target-zlib --without-ppl --without-cloog --with-headers=no --disable-libada --disable-libatomic || exit -1
make -j 5 || exit -1
sudo make install || exit -1
cd ..
fi
cd ..
cd ..