Subversion Repositories HelenOS

Rev

Rev 3191 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3191 Rev 3403
1
#!/bin/bash
1
#!/bin/bash
2
 
2
 
3
# Cross-Compiler Toolchain for ${PLATFORM}
3
# Cross-Compiler Toolchain for ${PLATFORM}
4
#  by Martin Decky <martin@decky.cz>
4
#  by Martin Decky <martin@decky.cz>
5
#
5
#
6
#  GPL'ed, copyleft
6
#  GPL'ed, copyleft
7
#
7
#
8
 
8
 
9
 
9
 
10
check_error() {
10
check_error() {
11
    if [ "$1" -ne "0" ]; then
11
    if [ "$1" -ne "0" ]; then
12
    echo
12
    echo
13
    echo "Script failed: $2"
13
    echo "Script failed: $2"
14
    exit
14
    exit
15
    fi
15
    fi
16
}
16
}
17
 
17
 
-
 
18
if [ -z "${CROSS_PREFIX}" ] ; then
-
 
19
    CROSS_PREFIX="/usr/local"
-
 
20
fi
-
 
21
 
18
BINUTILS_VERSION="2.18"
22
BINUTILS_VERSION="2.18"
19
GCC_VERSION="4.3.1"
23
GCC_VERSION="4.3.2"
20
 
24
 
21
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
25
BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
22
GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
26
GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
23
GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
27
GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
24
GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
28
GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
25
 
29
 
26
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
30
BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
27
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
31
GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
28
 
32
 
29
PLATFORM="ia64"
33
PLATFORM="ia64"
30
WORKDIR=`pwd`
34
WORKDIR=`pwd`
31
TARGET="${PLATFORM}-pc-linux-gnu"
35
TARGET="${PLATFORM}-pc-linux-gnu"
32
PREFIX="/usr/local/${PLATFORM}"
36
PREFIX="${CROSS_PREFIX}/${PLATFORM}"
33
INCLUDESDIR="${WORKDIR}/include"
37
INCLUDESDIR="${WORKDIR}/include"
34
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
38
BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
35
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
39
GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
36
OBJDIR="${WORKDIR}/gcc-obj"
40
OBJDIR="${WORKDIR}/gcc-obj"
37
 
41
 
38
echo ">>> Downloading tarballs"
42
echo ">>> Downloading tarballs"
39
 
43
 
40
if [ ! -f "${BINUTILS}" ]; then
44
if [ ! -f "${BINUTILS}" ]; then
41
    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
45
    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
42
    check_error $? "Error downloading binutils."
46
    check_error $? "Error downloading binutils."
43
fi
47
fi
44
if [ ! -f "${GCC_CORE}" ]; then
48
if [ ! -f "${GCC_CORE}" ]; then
45
    wget -c "${GCC_SOURCE}${GCC_CORE}"
49
    wget -c "${GCC_SOURCE}${GCC_CORE}"
46
    check_error $? "Error downloading GCC Core."
50
    check_error $? "Error downloading GCC Core."
47
fi
51
fi
48
if [ ! -f "${GCC_OBJC}" ]; then
52
if [ ! -f "${GCC_OBJC}" ]; then
49
    wget -c "${GCC_SOURCE}${GCC_OBJC}"
53
    wget -c "${GCC_SOURCE}${GCC_OBJC}"
50
    check_error $? "Error downloading GCC Objective C."
54
    check_error $? "Error downloading GCC Objective C."
51
fi
55
fi
52
if [ ! -f "${GCC_CPP}" ]; then
56
if [ ! -f "${GCC_CPP}" ]; then
53
    wget -c "${GCC_SOURCE}${GCC_CPP}"
57
    wget -c "${GCC_SOURCE}${GCC_CPP}"
54
    check_error $? "Error downloading GCC C++."
58
    check_error $? "Error downloading GCC C++."
55
fi
59
fi
56
 
60
 
57
echo ">>> Creating destionation directory"
61
echo ">>> Creating destionation directory"
58
if [ ! -d "${PREFIX}" ]; then
62
if [ ! -d "${PREFIX}" ]; then
59
    mkdir -p "${PREFIX}"
63
    mkdir -p "${PREFIX}"
60
    test -d "${PREFIX}"
64
    test -d "${PREFIX}"
61
    check_error $? "Unable to create ${PREFIX}."
65
    check_error $? "Unable to create ${PREFIX}."
62
fi
66
fi
63
 
67
 
64
echo ">>> Creating GCC work directory"
68
echo ">>> Creating GCC work directory"
65
if [ ! -d "${OBJDIR}" ]; then
69
if [ ! -d "${OBJDIR}" ]; then
66
    mkdir -p "${OBJDIR}"
70
    mkdir -p "${OBJDIR}"
67
    test -d "${OBJDIR}"
71
    test -d "${OBJDIR}"
68
    check_error $? "Unable to create ${OBJDIR}."
72
    check_error $? "Unable to create ${OBJDIR}."
69
fi
73
fi
70
 
74
 
71
echo ">>> Unpacking tarballs"
75
echo ">>> Unpacking tarballs"
72
tar -xvzf "${BINUTILS}"
76
tar -xvzf "${BINUTILS}"
73
check_error $? "Error unpacking binutils."
77
check_error $? "Error unpacking binutils."
74
tar -xvjf "${GCC_CORE}"
78
tar -xvjf "${GCC_CORE}"
75
check_error $? "Error unpacking GCC Core."
79
check_error $? "Error unpacking GCC Core."
76
tar -xvjf "${GCC_OBJC}"
80
tar -xvjf "${GCC_OBJC}"
77
check_error $? "Error unpacking GCC Objective C."
81
check_error $? "Error unpacking GCC Objective C."
78
tar -xvjf "${GCC_CPP}"
82
tar -xvjf "${GCC_CPP}"
79
check_error $? "Error unpacking GCC C++."
83
check_error $? "Error unpacking GCC C++."
80
 
84
 
81
echo ">>> Compiling and installing binutils"
85
echo ">>> Compiling and installing binutils"
82
cd "${BINUTILSDIR}"
86
cd "${BINUTILSDIR}"
83
check_error $? "Change directory failed."
87
check_error $? "Change directory failed."
84
./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
88
./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
85
check_error $? "Error configuring binutils."
89
check_error $? "Error configuring binutils."
86
make all install
90
make all install
87
check_error $? "Error compiling/installing binutils."
91
check_error $? "Error compiling/installing binutils."
88
 
92
 
89
echo ">>> Compiling and installing GCC"
93
echo ">>> Compiling and installing GCC"
90
cd "${OBJDIR}"
94
cd "${OBJDIR}"
91
check_error $? "Change directory failed."
95
check_error $? "Change directory failed."
92
"${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
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
93
check_error $? "Error configuring GCC."
97
check_error $? "Error configuring GCC."
94
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
98
PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
95
check_error $? "Error compiling/installing GCC."
99
check_error $? "Error compiling/installing GCC."
96
 
100
 
97
echo
101
echo
98
echo ">>> Cross-compiler for ${TARGET} installed."
102
echo ">>> Cross-compiler for ${TARGET} installed."
99
 
103