C:LoadWB - Compatability with AmigaOS 2.x
[AROS.git] / arch / m68k-amiga / doc / build-toolchain.sh
blob4c2c03433c34b68c7bbfb6ba858fe6f859c58055
1 #!/bin/sh -x
3 FETCH_ONLY=no
4 if [ "$1" = "--fetch-only" ]; then
5 FETCH_ONLY=yes
6 shift
7 fi
9 PREFIX="$1"
10 if [ -z "$PREFIX" ]; then
11 PREFIX="/opt/m68k-elf"
14 PATH=$PATH:`pwd`/fake
15 export PATH
17 BINUTILS_VERSION=2.22
18 GCC_VERSION=4.6.2
19 GMP_VERSION=5.0.1
20 MPFR_VERSION=3.0.1
21 MPC_VERSION=0.9
22 GDB_VERSION=7.3.1
23 NEWLIB_VERSION=1.19.0
25 fetch () {
26 mkdir -p download || exit 1
27 if [ ! -f download/`basename "$1"` ]; then
28 wget -c -O download/`basename "$1"` "$1" || exit 1
32 unpack () {
33 mkdir -p src || exit 1
34 unpackDST="$1"
35 if [ -n "$2" ]; then
36 shift
38 HERE=`pwd`
39 if [ -n "$STERILIZE" -o ! -f "src/$unpackDST/configure" ]; then
40 rm -rf "src/${unpackDST}"
41 while [ -n "$1" ]; do
42 unpackSRC="$1"
43 shift
44 tar -C src -jxvf `pwd`/download/"${unpackSRC}".tar.bz2 || exit 1
45 done
46 for d in `pwd`/download/"${unpackDST}"-*.patch; do
47 if [ -f "$d" ]; then
48 cd "src/${unpackDST}"
49 patch -p1 <$d || exit 1
50 cd "$HERE"
52 done
54 [ -f "src/$unpackDST/configure" ] || exit 1
57 config () {
58 [ -n "${STERILIZE}" ] && rm -rf "build/${configBASE}"
59 [ -e build/.$1.config -a build/.$1.config -nt src/$1-$2/configure ] && return 0
60 configBASE=$1
61 shift
62 configVERSION=$1
63 shift
65 mkdir -p build/${configBASE}
66 (cd build/${configBASE}
67 ../../src/${configBASE}-${configVERSION}/configure \
68 --without-headers \
69 --disable-threads \
70 --disable-libssp \
71 --disable-nls \
72 --disable-shared \
73 --disable-lto \
74 --without-pic \
75 --with-gmp="${PREFIX}" \
76 --with-mpfr="${PREFIX}" \
77 --with-mpc="${PREFIX}" \
78 --prefix="${PREFIX}" \
79 "$@" || exit 1
80 ) || exit $?
81 touch build/.${configBASE}.config
84 build () {
85 [ -e build/.$1.build -a build/.$1.build -nt build/.$1.config ] && return 0
86 make -C build/$1 || exit 1
87 touch build/.$1.build
90 deploy () {
91 [ -e build/.$1.deploy -a build/.$1.deploy -nt build/.$1.build ] && return 0
92 make -C build/$1 install || exit 1
93 touch build/.$1.deploy
96 fetch ftp://ftp.gnu.org/pub/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2
97 fetch ftp://ftp.gnu.org/pub/gnu/gcc/gcc-${GCC_VERSION}/gcc-core-${GCC_VERSION}.tar.bz2
98 fetch ftp://ftp.gnu.org/pub/gnu/gcc/gcc-${GCC_VERSION}/gcc-g++-${GCC_VERSION}.tar.bz2
99 fetch ftp://ftp.gnu.org/pub/gnu/gcc/gcc-${GCC_VERSION}/gcc-objc-${GCC_VERSION}.tar.bz2
100 fetch ftp://ftp.gnu.org/pub/gnu/gmp/gmp-${GMP_VERSION}.tar.bz2
101 fetch ftp://ftp.gnu.org/pub/gnu/mpfr/mpfr-${MPFR_VERSION}.tar.bz2
102 fetch ftp://ftp.gnu.org/pub/gnu/gdb/gdb-${GDB_VERSION}.tar.bz2
103 fetch http://www.evillabs.net/AROS/gcc-4.6.2-aros.patch
104 fetch http://www.multiprecision.org/mpc/download/mpc-${MPC_VERSION}.tar.gz
105 if [ download/mpc-${MPC_VERSION}.tar.gz -nt download/mpc-${MPC_VERSION}.tar.bz2 ]; then
106 (gzip -dc download/mpc-${MPC_VERSION}.tar.gz | bzip2 -c >download/mpc-${MPC_VERSION}.tar.bz2) || exit 1
108 fetch ftp://sources.redhat.com/pub/newlib/newlib-${NEWLIB_VERSION}.tar.gz
109 if [ download/newlib-${NEWLIB_VERSION}.tar.gz -nt download/newlib-${NEWLIB_VERSION}.tar.bz2 ]; then
110 (gzip -dc download/newlib-${NEWLIB_VERSION}.tar.gz | bzip2 -c >download/newlib-${NEWLIB_VERSION}.tar.bz2) || exit 1
113 if [ "${FETCH_ONLY}" = "yes" ]; then
114 exit 0
117 unpack binutils-${BINUTILS_VERSION}
118 unpack gcc-${GCC_VERSION} \
119 gcc-core-${GCC_VERSION} \
120 gcc-objc-${GCC_VERSION} \
121 gcc-g++-${GCC_VERSION}
122 unpack gmp-${GMP_VERSION}
123 unpack mpfr-${MPFR_VERSION}
124 unpack mpc-${MPC_VERSION}
125 unpack gdb-${GDB_VERSION}
126 unpack newlib-${NEWLIB_VERSION}
128 config binutils ${BINUTILS_VERSION} \
129 --target=m68k-elf \
130 --program-prefix=m68k-elf- \
131 --enable-languages=c
132 build binutils
133 deploy binutils
135 config gmp ${GMP_VERSION}
136 build gmp
137 deploy gmp
139 config mpfr ${MPFR_VERSION}
140 build mpfr
141 deploy mpfr
143 config mpc ${MPC_VERSION}
144 build mpc
145 deploy mpc
147 config gcc ${GCC_VERSION} \
148 --target=m68k-elf \
149 --program-prefix=m68k-elf- \
150 --without-target-libiberty \
151 --without-target-zlib \
152 --disable-bootstrap \
153 --enable-languages="c"
154 build gcc
155 deploy gcc
157 config gdb ${GDB_VERSION} \
158 --target=m68k-elf \
159 --program-prefix=m68k-elf-
160 build gdb
161 deploy gdb
163 # Minimal C library
164 config newlib ${NEWLIB_VERSION} \
165 --target=m68k-elf \
166 --program-prefix=m68k-elf- \
167 --enable-languages="c"
168 build newlib
169 deploy newlib
171 # Build C++ and ObjC
172 config gcc ${GCC_VERSION} \
173 --with-newlib \
174 --target=m68k-elf \
175 --program-prefix=m68k-elf- \
176 --disable-bootstrap \
177 --enable-languages="c c++ objc"
178 build gcc
179 deploy gcc