GCC cross-compiler building for ARM target on Mac OS

Author: fransedano  |  Category: Flight sim, software

 

I’m building a new controller based on an ARM CPU and running Linux. So, time to install gcc cross-compiling toolchain on the development machines.

alias wget=’curl -O’

sudo mount -o resvport -t nfs 192.168.30.245:/data1/arm-nfs-root /private/nfs

mkdir ~/crossgcc && cd ~/crossgcc
$ wget ftp://sourceware.org/pub/binutils/snapshots/binutils-2.21.52.tar.bz2
$ tar jxf binutils-2.21.52.tar.bz2
$ wget http://ftp.gnu.org/pub/gnu/gcc/gcc-4.6.0/gcc-4.6.0.tar.bz2
$ tar jxf gcc-4.6.0.tar.bz2
$ wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz
$ tar zxf newlib-1.19.0.tar.gz
$ wget http://ftp.gnu.org/pub/gnu/gdb/gdb-7.2.tar.gz
$ tar zxf gdb-7.2.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/ –enable-werror=no
$ make all install 2>&1 | tee make.log
$ export PATH=$PATH:/usr/local/crossgcc/bin

Build gcc prereqs

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
tar jxvf gmp-4.3.2.tar.bz2
cd gmp-4.3.2
./configure –prefix=/usr/local/crossgcc/ –enable-cxx
make install
make check

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
tar jxvf mpfr-2.4.2.tar.bz2
cd mpfr-2.4.2
./configure –prefix=/usr/local/crossgcc/ –with-gmp=/usr/local/crossgcc
make
make install

wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar jxvf mpc-0.8.1.tar.gz
cd mpc-0.8.1
sudo ln -s /usr/local/crossgcc/lib/libgmp.la /usr/local/lib/
./configure –prefix=/usr/local/crossgcc/ –with-gmp-lib=/usr/local/crossgcc/lib/ –with-mpfr=/usr/local/crossgcc/
make
make install

wget ftp://ftp.cs.unipr.it/pub/ppl/releases/0.11.2/ppl-0.11.2.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.11.tar.gz

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

$ cd ../gcc-4.6.0
$ ln -s ../newlib-1.19.0/newlib .
$ ln -s ../newlib-1.19.0/libgloss .
$ cd ..
$ mkdir build-gcc && cd build-gcc
$ ../gcc-4.6.0/configure –target=arm-unknown-linux-gnu –prefix=/usr/local/crossgcc/ –with-newlib –with-gnu-as –with-gnu-ld –enable-languages=c,c++ –with-arch=armv4 –with-float=soft –enable-threads=posix –enable-symvers=gnu –enable-c99 –enable-long-long –with-gmp=/usr/local/crossgcc –with-mpfr=/usr/local/crosgcc

$ 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

Share on Facebook