Building a GNU ARM cross-compiler toolchain on Mac OS X

I’m starting a new embedded project with ARM7 processor in March so I wanted to play around with the GNU ARM toolchain. Basically I’m interested in doing cross development on my Macbook Pro on Mac OS X, using a GCC cross compiler together with Eclipse CDT. We’ll see if that works out. 😉

So as a first step, here is how I built a GNU ARM toolchain on Mac OS X (this should be no different than building the toolchain on Linux):

First download and unpack the necessary packages: binutils, gcc, newlib and gdb.

$ mkdir ~/crossgcc && cd ~/crossgcc
$ wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.18.50.tar.bz2
$ tar jxf binutils-2.18.50.tar.bz2
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.2.3/gcc-4.2.3.tar.bz2
$ tar jxf gcc-4.2.3.tar.bz2
$ wget ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz
$ tar zxf newlib-1.16.0.tar.gz
$ wget http://ftp.gnu.org/pub/gnu/gdb/gdb-6.6.tar.gz
$ tar zxf gdb-6.6.tar.gz

The installation directory should be /usr/local/crossgcc.

$ sudo mkdir /usr/local/crossgcc
$ sudo chmod 777 /usr/local/crossgcc

First we build the binutils:

$ mkdir build-binutils && cd build-binutils
$ ../binutils-2.18.50/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log
$ export PATH=$PATH:/usr/local/crossgcc/bin

Build the gcc compiler with C/C++ support:

$ cd ../gcc-4.2.3
$ ln -s ../newlib-1.16.0/newlib .
$ ln -s ../newlib-1.16.0/libgloss .
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.2.3/configure --target=arm-elf \
--prefix=/usr/local/crossgcc/ --with-newlib \
--with-gnu-as --with-gnu-ld --enable-languages=c,c++ 2>&1 | tee configure.log
$ make all install 2>&1 | tee make.log

Build the gdb debugger:

$ cd ..
$ mkdir build-gdb && cd build-gdb
$ ../gdb-6.6/configure --target=arm-elf --prefix=/usr/local/crossgcc/
$ make all install 2>&1 | tee make.log