Subversion Repositories HelenOS-historic

Rev

Rev 532 | Rev 905 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
145 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
INCLUDES="ia64-pc-gnu-linux_includes.tar.bz2"
22
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
23
GCC="gcc-core-${GCC_VERSION}.tar.bz2"
24
 
25
INCLUDES_SOURCE="http://download.decky.cz/"
26
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
27
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
28
 
29
PLATFORM="ia64"
30
WORKDIR=`pwd`
31
TARGET="${PLATFORM}-pc-linux-gnu"
32
HOST="i686-pc-linux-gnu"
33
PREFIX="/usr/local/${PLATFORM}"
34
INCLUDESDIR="${WORKDIR}/include"
35
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
36
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
37
OBJDIR="${WORKDIR}/gcc-obj"
38
 
39
echo ">>> Downloading tarballs"
40
 
41
if [ ! -f "${INCLUDES}" ]; then
42
    wget -c "${INCLUDES_SOURCE}${INCLUDES}"
43
    check_error $? "Error downloading includes."
44
fi
45
if [ ! -f "${BINUTILS}" ]; then
46
    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
47
    check_error $? "Error downloading binutils."
48
fi
49
if [ ! -f "${GCC}" ]; then
50
    wget -c "${GCC_SOURCE}${GCC}"
51
    check_error $? "Error downloading GCC."
52
fi
53
 
54
echo ">>> Creating destionation directory"
55
if [ ! -d "${PREFIX}" ]; then
56
    mkdir -p "${PREFIX}"
57
    test -d "${PREFIX}"
58
    check_error $? "Unable to create ${PREFIX}."
59
fi
60
 
61
echo ">>> Creating GCC work directory"
62
if [ ! -d "${OBJDIR}" ]; then
63
    mkdir -p "${OBJDIR}"
64
    test -d "${OBJDIR}"
65
    check_error $? "Unable to create ${OBJDIR}."
66
fi
67
 
68
echo ">>> Unpacking tarballs"
69
tar -xvjf "${INCLUDES}"
70
check_error $? "Error unpacking includes."
71
tar -xvzf "${BINUTILS}"
72
check_error $? "Error unpacking binutils."
73
tar -xvjf "${GCC}"
74
check_error $? "Error unpacking GCC."
75
 
76
echo ">>> Compiling and installing binutils"
77
cd "${BINUTILSDIR}"
78
check_error $? "Change directory failed."
260 decky 79
./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
145 decky 80
check_error $? "Error configuring binutils."
81
make all install
82
check_error $? "Error compiling/installing binutils."
83
 
84
echo ">>> Compiling and installing GCC"
85
cd "${OBJDIR}"
86
check_error $? "Change directory failed."
87
"${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 "--with-headers=${INCLUDESDIR}" --disable-shared
88
check_error $? "Error configuring GCC."
89
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
90
check_error $? "Error compiling/installing GCC."
91
 
92
echo
93
echo ">>> Cross-compiler for ${TARGET} installed."