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