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