Subversion Repositories HelenOS

Rev

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