3 # Cross-Compiler Toolchain for ${PLATFORM}
4 # by Martin Decky <martin@decky.cz>
11 if [ "$1" -ne "0" ]; then
13 echo "Script failed: $2"
18 BINUTILS_VERSION="2.17"
21 BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
22 GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
23 GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
25 BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
26 GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
30 TARGET="${PLATFORM}-linux-gnu"
31 PREFIX="/opt/toolchain/${PLATFORM}"
32 BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
33 GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
34 OBJDIR="${WORKDIR}/gcc-obj"
36 echo ">>> Downloading tarballs"
38 if [ ! -f "${BINUTILS}" ]; then
39 wget -c "${BINUTILS_SOURCE}${BINUTILS}"
40 check_error $? "Error downloading binutils."
42 if [ ! -f "${GCC_CORE}" ]; then
43 wget -c "${GCC_SOURCE}${GCC_CORE}"
44 check_error $? "Error downloading GCC Core."
46 if [ ! -f "${GCC_CPP}" ]; then
47 wget -c "${GCC_SOURCE}${GCC_CPP}"
48 check_error $? "Error downloading GCC C++."
51 echo ">>> Creating destionation directory"
52 if [ ! -d "${PREFIX}" ]; then
55 check_error $? "Unable to create ${PREFIX}."
58 echo ">>> Creating GCC work directory"
59 if [ ! -d "${OBJDIR}" ]; then
62 check_error $? "Unable to create ${OBJDIR}."
65 echo ">>> Unpacking tarballs"
66 tar -xvzf "${BINUTILS}"
67 check_error $? "Error unpacking binutils."
68 tar -xvjf "${GCC_CORE}"
69 check_error $? "Error unpacking GCC Core."
70 tar -xvjf "${GCC_CPP}"
71 check_error $? "Error unpacking GCC C++."
73 echo ">>> Compiling and installing binutils"
75 check_error $? "Change directory failed."
76 ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
77 check_error $? "Error configuring binutils."
79 check_error $? "Error compiling/installing binutils."
81 echo ">>> Compiling and installing GCC"
83 check_error $? "Change directory failed."
84 "${GCCDIR}/configure" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c,c++ --disable-multilib --disable-libgcj --without-headers --disable-shared
85 check_error $? "Error configuring GCC."
86 PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
87 check_error $? "Error compiling/installing GCC."
90 echo ">>> Cross-compiler for ${TARGET} installed."