Rev 905 | Rev 1964 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 905 | Rev 1420 | ||
---|---|---|---|
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 | BINUTILS_VERSION="2.16.1" |
18 | BINUTILS_VERSION="2.16.1" |
19 | GCC_VERSION="4.1.0" |
19 | GCC_VERSION="4.1.1" |
20 | 20 | ||
21 | BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz" |
21 | BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz" |
22 | GCC="gcc-core-${GCC_VERSION}.tar.bz2" |
22 | GCC="gcc-core-${GCC_VERSION}.tar.bz2" |
23 | 23 | ||
24 | BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/" |
24 | BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/" |
25 | GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/" |
25 | GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/" |
26 | 26 | ||
27 | PLATFORM="i686" |
27 | PLATFORM="i686" |
28 | WORKDIR=`pwd` |
28 | WORKDIR=`pwd` |
29 | TARGET="${PLATFORM}-pc-linux-gnu" |
29 | TARGET="${PLATFORM}-pc-linux-gnu" |
30 | HOST="i686-pc-linux-gnu" |
30 | HOST="i686-pc-linux-gnu" |
31 | PREFIX="/usr/local/${PLATFORM}" |
31 | PREFIX="/usr/local/${PLATFORM}" |
32 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" |
32 | BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}" |
33 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" |
33 | GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}" |
34 | OBJDIR="${WORKDIR}/gcc-obj" |
34 | OBJDIR="${WORKDIR}/gcc-obj" |
35 | 35 | ||
36 | echo ">>> Downloading tarballs" |
36 | echo ">>> Downloading tarballs" |
37 | 37 | ||
38 | if [ ! -f "${BINUTILS}" ]; then |
38 | if [ ! -f "${BINUTILS}" ]; then |
39 | wget -c "${BINUTILS_SOURCE}${BINUTILS}" |
39 | wget -c "${BINUTILS_SOURCE}${BINUTILS}" |
40 | check_error $? "Error downloading binutils." |
40 | check_error $? "Error downloading binutils." |
41 | fi |
41 | fi |
42 | if [ ! -f "${GCC}" ]; then |
42 | if [ ! -f "${GCC}" ]; then |
43 | wget -c "${GCC_SOURCE}${GCC}" |
43 | wget -c "${GCC_SOURCE}${GCC}" |
44 | check_error $? "Error downloading GCC." |
44 | check_error $? "Error downloading GCC." |
45 | fi |
45 | fi |
46 | 46 | ||
47 | echo ">>> Creating destionation directory" |
47 | echo ">>> Creating destionation directory" |
48 | if [ ! -d "${PREFIX}" ]; then |
48 | if [ ! -d "${PREFIX}" ]; then |
49 | mkdir -p "${PREFIX}" |
49 | mkdir -p "${PREFIX}" |
50 | test -d "${PREFIX}" |
50 | test -d "${PREFIX}" |
51 | check_error $? "Unable to create ${PREFIX}." |
51 | check_error $? "Unable to create ${PREFIX}." |
52 | fi |
52 | fi |
53 | 53 | ||
54 | echo ">>> Creating GCC work directory" |
54 | echo ">>> Creating GCC work directory" |
55 | if [ ! -d "${OBJDIR}" ]; then |
55 | if [ ! -d "${OBJDIR}" ]; then |
56 | mkdir -p "${OBJDIR}" |
56 | mkdir -p "${OBJDIR}" |
57 | test -d "${OBJDIR}" |
57 | test -d "${OBJDIR}" |
58 | check_error $? "Unable to create ${OBJDIR}." |
58 | check_error $? "Unable to create ${OBJDIR}." |
59 | fi |
59 | fi |
60 | 60 | ||
61 | echo ">>> Unpacking tarballs" |
61 | echo ">>> Unpacking tarballs" |
62 | tar -xvzf "${BINUTILS}" |
62 | tar -xvzf "${BINUTILS}" |
63 | check_error $? "Error unpacking binutils." |
63 | check_error $? "Error unpacking binutils." |
64 | tar -xvjf "${GCC}" |
64 | tar -xvjf "${GCC}" |
65 | check_error $? "Error unpacking GCC." |
65 | check_error $? "Error unpacking GCC." |
66 | 66 | ||
67 | echo ">>> Compiling and installing binutils" |
67 | echo ">>> Compiling and installing binutils" |
68 | cd "${BINUTILSDIR}" |
68 | cd "${BINUTILSDIR}" |
69 | check_error $? "Change directory failed." |
69 | check_error $? "Change directory failed." |
70 | ./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls" |
70 | ./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls" |
71 | check_error $? "Error configuring binutils." |
71 | check_error $? "Error configuring binutils." |
72 | make all install |
72 | make all install |
73 | check_error $? "Error compiling/installing binutils." |
73 | check_error $? "Error compiling/installing binutils." |
74 | 74 | ||
75 | echo ">>> Compiling and installing GCC" |
75 | echo ">>> Compiling and installing GCC" |
76 | cd "${OBJDIR}" |
76 | cd "${OBJDIR}" |
77 | check_error $? "Change directory failed." |
77 | check_error $? "Change directory failed." |
78 | "${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 --without-headers --disable-shared |
78 | "${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 --without-headers --disable-shared |
79 | check_error $? "Error configuring GCC." |
79 | check_error $? "Error configuring GCC." |
80 | PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc |
80 | PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc |
81 | check_error $? "Error compiling/installing GCC." |
81 | check_error $? "Error compiling/installing GCC." |
82 | 82 | ||
83 | echo |
83 | echo |
84 | echo ">>> Cross-compiler for ${TARGET} installed." |
84 | echo ">>> Cross-compiler for ${TARGET} installed." |
85 | 85 |