Subversion Repositories HelenOS

Rev

Rev 3386 | 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
 
3369 decky 18
if [ -z "${CROSS_PREFIX}" ] ; then
19
    CROSS_PREFIX="/usr/local"
20
fi
21
 
4153 mejdrech 22
BINUTILS_VERSION="2.19"
23
GCC_VERSION="4.3.2"
145 decky 24
 
25
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
2077 decky 26
GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
27
GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
28
GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
145 decky 29
 
30
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
31
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
32
 
33
PLATFORM="ia64"
34
WORKDIR=`pwd`
35
TARGET="${PLATFORM}-pc-linux-gnu"
3369 decky 36
PREFIX="${CROSS_PREFIX}/${PLATFORM}"
2084 decky 37
INCLUDESDIR="${WORKDIR}/include"
145 decky 38
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
39
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
40
OBJDIR="${WORKDIR}/gcc-obj"
41
 
42
echo ">>> Downloading tarballs"
43
 
44
if [ ! -f "${BINUTILS}" ]; then
45
    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
46
    check_error $? "Error downloading binutils."
47
fi
2077 decky 48
if [ ! -f "${GCC_CORE}" ]; then
49
    wget -c "${GCC_SOURCE}${GCC_CORE}"
50
    check_error $? "Error downloading GCC Core."
145 decky 51
fi
2077 decky 52
if [ ! -f "${GCC_OBJC}" ]; then
53
    wget -c "${GCC_SOURCE}${GCC_OBJC}"
54
    check_error $? "Error downloading GCC Objective C."
55
fi
56
if [ ! -f "${GCC_CPP}" ]; then
57
    wget -c "${GCC_SOURCE}${GCC_CPP}"
58
    check_error $? "Error downloading GCC C++."
59
fi
145 decky 60
 
61
echo ">>> Creating destionation directory"
62
if [ ! -d "${PREFIX}" ]; then
63
    mkdir -p "${PREFIX}"
64
    test -d "${PREFIX}"
65
    check_error $? "Unable to create ${PREFIX}."
66
fi
67
 
68
echo ">>> Creating GCC work directory"
69
if [ ! -d "${OBJDIR}" ]; then
70
    mkdir -p "${OBJDIR}"
71
    test -d "${OBJDIR}"
72
    check_error $? "Unable to create ${OBJDIR}."
73
fi
74
 
75
echo ">>> Unpacking tarballs"
76
tar -xvzf "${BINUTILS}"
77
check_error $? "Error unpacking binutils."
2077 decky 78
tar -xvjf "${GCC_CORE}"
79
check_error $? "Error unpacking GCC Core."
80
tar -xvjf "${GCC_OBJC}"
81
check_error $? "Error unpacking GCC Objective C."
82
tar -xvjf "${GCC_CPP}"
83
check_error $? "Error unpacking GCC C++."
145 decky 84
 
85
echo ">>> Compiling and installing binutils"
86
cd "${BINUTILSDIR}"
87
check_error $? "Change directory failed."
2139 decky 88
./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
145 decky 89
check_error $? "Error configuring binutils."
90
make all install
91
check_error $? "Error compiling/installing binutils."
92
 
93
echo ">>> Compiling and installing GCC"
94
cd "${OBJDIR}"
95
check_error $? "Change directory failed."
3177 jermar 96
"${GCCDIR}/configure" "--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 --disable-shared
145 decky 97
check_error $? "Error configuring GCC."
98
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
99
check_error $? "Error compiling/installing GCC."
100
 
101
echo
102
echo ">>> Cross-compiler for ${TARGET} installed."