comparison toolchain/build+install.sh @ 0:9beb566ded04

starting with the toolchain for building our loadagent
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 28 Apr 2013 17:36:07 +0000
parents
children 53b8d61c16a0
comparison
equal deleted inserted replaced
-1:000000000000 0:9beb566ded04
1 #!/bin/sh
2 #
3 # This script builds and installs binutils, gcc and newlib in the order
4 # necessary for the whole thing to work. The present version is based
5 # on OsmocomBB's gnu-arm-build.2.sh script, which is in turn based on
6 # yet another source. The present version has been concocted by
7 # Spacefalcon the Outlaw for use in the FreeCalypso project.
8 #
9 # This script needs to be invoked with two arguments:
10 #
11 # $1: the path to the directory containing the upstream binutils, gcc
12 # and newlib source tarballs;
13 #
14 # $2: the path to the directory where the built toolchain should be
15 # installed.
16 #
17 # Note that there isn't a single install step at the end, instead this
18 # script will build and install one component, then proceed to build the
19 # next component which depends on the previous one, etc. For this reason
20 # you should create a dedicated install directory that is writable by your
21 # regular (non-root) uid, then run this script to populate that directory
22 # with the toolchain.
23
24 if [ $# != 2 ]
25 then
26 echo "usage: $0 path-to-tarballs path-to-install"
27 exit 1
28 fi
29
30 set -ex
31
32 target_args="--target=arm-elf"
33
34 # binutils come first
35 tar xjf $1/binutils-2.21.1a.tar.bz2
36 mkdir -p binutils-build
37 cd binutils-build
38 ../binutils-2.21.1/configure --prefix=$2 ${target_args} --disable-nls
39 make all
40 make install
41 cd ..
42
43 # unpack gcc and newlib sources at the same time: the gcc build
44 # will be pointed to newlib headers
45 gcc_version=4.5.4
46 newlib_version=2.0.0
47 tar xjf $1/gcc-core-${gcc_version}.tar.bz2
48 tar xzf $1/newlib-${newlib_version}.tar.gz
49
50 # gcc depends on binutils - add our install destination dir to the PATH
51 # we prepend it to avoid surprises if some other arm-elf- toolchain
52 # happens to be present already
53 PATH=$2/bin:$PATH
54 export PATH
55
56 mkdir -p gcc-build
57 cd gcc-build
58 ../gcc-${gcc_version}/configure --prefix=$2 ${target_args} \
59 --enable-interwork --enable-multilib \
60 --with-cpu=arm7tdmi --with-float=soft \
61 --enable-languages=c --with-newlib \
62 --with-headers=`pwd`/newlib-${newlib_version}/newlib/libc/include \
63 --with-system-zlib --disable-shared \
64 --disable-nls
65 make all-gcc
66 make install-gcc
67 cd ..
68
69 # now we can build newlib
70 mkdir newlib-build
71 cd newlib-build
72 ../newlib-${newlib_version}/configure --prefix=$2 ${target_args} \
73 --enable-interwork --enable-multilib \
74 --enable-target-optspace --enable-newlib-reent-small \
75 --disable-newlib-supplied-syscalls \
76 --disable-nls
77 make all
78 make install
79 cd ..
80
81 # and finally, libgcc
82 cd gcc-build
83 make all
84 make install
85 cd ..