Subversion Repositories HelenOS

Rev

Rev 1962 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
138 decky 1
#!/bin/bash
2
 
3
# Cross-Compiler Toolchain for ${PLATFORM}
4
#  by Martin Decky <martin@decky.cz>
5
#
6
#  GPL'ed, copyleft
7
#
8
 
9
 
10
check_error() {
11
    if [ "$1" -ne "0" ]; then
12
    echo
13
    echo "Script failed: $2"
14
    exit
15
    fi
16
}
17
 
18
BINUTILS_VERSION="2.16"
19
GCC_VERSION="4.0.1"
20
 
21
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
22
GCC="gcc-core-${GCC_VERSION}.tar.bz2"
23
 
24
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
25
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
26
 
27
PLATFORM="ppc64"
28
WORKDIR=`pwd`
29
TARGET="${PLATFORM}-linux-gnu"
30
HOST="i686-pc-linux-gnu"
31
PREFIX="/usr/local/${PLATFORM}"
32
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
33
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
34
OBJDIR="${WORKDIR}/gcc-obj"
35
 
36
echo ">>> Downloading tarballs"
37
 
38
if [ ! -f "${BINUTILS}" ]; then
39
    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
40
    check_error $? "Error downloading binutils."
41
fi
42
if [ ! -f "${GCC}" ]; then
43
    wget -c "${GCC_SOURCE}${GCC}"
44
    check_error $? "Error downloading GCC."
45
fi
46
 
47
echo ">>> Creating destionation directory"
48
if [ ! -d "${PREFIX}" ]; then
49
    mkdir -p "${PREFIX}"
50
    test -d "${PREFIX}"
51
    check_error $? "Unable to create ${PREFIX}."
52
fi
53
 
54
echo ">>> Creating GCC work directory"
55
if [ ! -d "${OBJDIR}" ]; then
56
    mkdir -p "${OBJDIR}"
57
    test -d "${OBJDIR}"
58
    check_error $? "Unable to create ${OBJDIR}."
59
fi
60
 
61
echo ">>> Unpacking tarballs"
62
tar -xvzf "${BINUTILS}"
63
check_error $? "Error unpacking binutils."
64
tar -xvjf "${GCC}"
65
check_error $? "Error unpacking GCC."
66
 
67
echo ">>> Compiling and installing binutils"
68
cd "${BINUTILSDIR}"
69
check_error $? "Change directory failed."
260 decky 70
./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
138 decky 71
check_error $? "Error configuring binutils."
72
make all install
73
check_error $? "Error compiling/installing binutils."
74
 
75
echo ">>> Compiling and installing GCC"
76
cd "${OBJDIR}"
77
check_error $? "Change directory failed."
78
"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
79
check_error $? "Error configuring GCC."
80
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
81
check_error $? "Error compiling/installing GCC."
82
 
83
echo
84
echo ">>> Cross-compiler for ${TARGET} installed."