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_OBJC
="gcc-objc-${GCC_VERSION}.tar.bz2"
24 GCC_CPP
="gcc-g++-${GCC_VERSION}.tar.bz2"
26 BINUTILS_SOURCE
="ftp://ftp.gnu.org/gnu/binutils/"
27 GCC_SOURCE
="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
31 TARGET
="${PLATFORM}-linux-gnu"
32 HOST
="i686-pc-linux-gnu"
33 PREFIX
="/usr/local/${PLATFORM}"
34 BINUTILSDIR
="${WORKDIR}/binutils-${BINUTILS_VERSION}"
35 GCCDIR
="${WORKDIR}/gcc-${GCC_VERSION}"
36 OBJDIR
="${WORKDIR}/gcc-obj"
38 echo ">>> Downloading tarballs"
40 if [ ! -f "${BINUTILS}" ]; then
41 wget
-c "${BINUTILS_SOURCE}${BINUTILS}"
42 check_error $?
"Error downloading binutils."
44 if [ ! -f "${GCC_CORE}" ]; then
45 wget
-c "${GCC_SOURCE}${GCC_CORE}"
46 check_error $?
"Error downloading GCC Core."
48 if [ ! -f "${GCC_OBJC}" ]; then
49 wget
-c "${GCC_SOURCE}${GCC_OBJC}"
50 check_error $?
"Error downloading GCC Objective C."
52 if [ ! -f "${GCC_CPP}" ]; then
53 wget
-c "${GCC_SOURCE}${GCC_CPP}"
54 check_error $?
"Error downloading GCC C++."
57 echo ">>> Creating destionation directory"
58 if [ ! -d "${PREFIX}" ]; then
61 check_error $?
"Unable to create ${PREFIX}."
64 echo ">>> Creating GCC work directory"
65 if [ ! -d "${OBJDIR}" ]; then
68 check_error $?
"Unable to create ${OBJDIR}."
71 echo ">>> Unpacking tarballs"
72 tar -xvzf "${BINUTILS}"
73 check_error $?
"Error unpacking binutils."
74 tar -xvjf "${GCC_CORE}"
75 check_error $?
"Error unpacking GCC Core."
76 tar -xvjf "${GCC_OBJC}"
77 check_error $?
"Error unpacking GCC Objective C."
78 tar -xvjf "${GCC_CPP}"
79 check_error $?
"Error unpacking GCC C++."
81 echo ">>> Compiling and installing binutils"
83 check_error $?
"Change directory failed."
84 .
/configure
"--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
85 check_error $?
"Error configuring binutils."
87 check_error $?
"Error compiling/installing binutils."
89 echo ">>> Compiling and installing GCC"
91 check_error $?
"Change directory failed."
92 "${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c
,objc
,c
++,obj-c
++ --disable-multilib --disable-libgcj --without-headers --disable-shared
93 check_error $?
"Error configuring GCC."
94 PATH
="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
95 check_error $?
"Error compiling/installing GCC."
98 echo ">>> Cross-compiler for ${TARGET} installed."