Note: this tutorial may be a bit out of date. Please consider using the http://crosstool-ng.org
This page describes how to build a cross compiler (GCC). I have done this under the Cygwin (1.3.22) environment as well as under Linux (2.4.20). The target architecture was powerpc-elf and powerpc-eabi.
Just follow the steps to get a working C and C++ cross compiler, library inclusive.
You will need the following packages in order to build the cross compiler:
Maybe the build procedure works for newer/other versions of those packages as well, but I haven’t tested any other versions, yet.
$ mkdir src
$ mkdir build
$ mkdir build/binutils-2.13.92
$ mkdir build/gcc-2.95.3
$ mkdir build/newlib-1.11.0
$ mkdir prefix
$ cd src
$ tar -xjf binutils-2.13.92-src.tar.bz2
$ tar -xzf gcc-2.95.3-src.tar.gz
$ tar -xzf newlib-1.11.0-src.tar.gz
$ cd ..
$ export TARGET=powerpc-elf
$ export ROOT=`pwd`
$ export SRC=$ROOT/src
$ export BUILD=$BUILD/build
$ export PREFIX=$ROOT/prefix
$ export PATH=$PREFIX/bin:$PATH
Maybe you like to install the cross compiler in /usr/local
, just define the variable
You have to do that before the definition of the PATH variable. To build for an powerpc-eabi target (instead of powerpc-elf) just define the variable:
$ cd $BUILD/binutils-2.13.92/
$ $SRC/binutils-2.13.92/configure \
--prefix=$PREFIX \
--target=$TARGET 2>&1 | tee configure.log
$ make all install 2>&1 | tee make-install.log
$ cd $BUILD/gcc-2.95.3/
$ $SRC/gcc-2.95.3/configure \
--prefix=$PREFIX \
--target=$TARGET \
--with-newlib \
--without-headers \
--enable-languages=c,c++ 2>&1 | tee configure.log
$ make all-gcc 2>&1 | tee make-gcc.log
$ make install-gcc 2>&1 | tee install-gcc.log
$ cd $BUILD/newlib-1.11.0/
$ $SRC/newlib-1.11.0/configure \
--prefix=$PREFIX \
--target=$TARGET \
--enable-newlib-hw-fp 2>&1 | tee configure.log
$ make 2>&1 | tee make.log
$ make install 2>&1 | tee install.log