Installation of GCC toolchain for MIPS architecture

Download the sources

For simplicity, assume we use $HOME/src directory. Download the sources to $HOME/src:

Create installation directory

We will install the toolchain into directory /usr/local/mips-gcc-A.B.C, where A.B.C is the version of GCC compiler. It will simplify the future upgrade.

sudo mkdir /usr/local/mips-gcc-4.8.1
sudo chown $USER /usr/local/mips-gcc-4.8.1

Build binutils

Unpack:

cd $HOME/src
tar xvzf binutils-2.23.2.tar.gz

Build and install binutils:

mkdir $HOME/src/binutils-mips
cd $HOME/src/binutils-mips
../binutils-2.23.2/configure --target=mips-elf --prefix=/usr/local/mips-gcc-4.8.1 --disable-nls
make
make install

Build gcc

GCC requires the GMP, MPFR and MPC packages. As these packages may not be included in your host distribution, they will be built with GCC.

Unpack, configure and install libraries:

cd $HOME/src
tar xvjf gmp-5.1.3.tar.bz2
tar xvjf mpfr-3.1.2.tar.bz2
tar xvzf mpc-1.0.1.tar.gz
cd $HOME/src/gmp-5.1.3
./configure --prefix=/usr/local/mips-gcc-4.8.1 --disable-shared
make
make install
cd $HOME/src/mpfr-3.1.2
./configure --prefix=/usr/local/mips-gcc-4.8.1 --disable-shared --with-gmp=/usr/local/mips-gcc-4.8.1
make
make install
cd $HOME/src/mpc-1.0.1.tar.gz
./configure --prefix=/usr/local/mips-gcc-4.8.1 --disable-shared --with-gmp=/usr/local/mips-gcc-4.8.1
make
make install

Unpack GCC:

cd $HOME/src
tar xvjf gcc-4.8.1.tar.bz2

Build and install the compiler:

mkdir $HOME/src/gcc-mips
cd $HOME/src/gcc-mips
../gcc-4.8.1/configure --target=mips-elf \
    --prefix=/usr/local/mips-gcc-4.8.1 \
    --enable-languages=c,c++ \
    --with-arch-32=mips32r2 \
    --with-mpfr=/usr/local/mips-gcc-4.8.1 \
    --with-gmp=/usr/local/mips-gcc-4.8.1 \
    --with-mpc=/usr/local/mips-gcc-4.8.1 \
    --enable-lto \
    --disable-nls \
    --disable-shared \
    --disable-libstdc___v3 \
    --disable-decimal-float \
    --disable-threads \
    --disable-libmudflap \
    --disable-libssp \
    --disable-libgomp \
    --disable-libquadmath
make
make install

Build gdb

Unpack:

cd $HOME/src
tar xvjf gdb-7.7.1.tar.bz2

Build and install the compiler:

mkdir $HOME/src/gdb-mips
cd $HOME/src/gdb-mips
../gdb-7.7.1/configure --target=mips-elf --prefix=/usr/local/mips-gcc-4.8.1 --disable-nls --enable-tui
make
make install