First we will be compiling our i686-elf toolchain used for compiling our bootloader as well as our kernel. We will grab the latest versions of binutils as wel as gcc and proceed to compile them on our Linux machines. We will be building this for our current user only ($HOME/opt/cross), but if you want the cross toolchain to be globally available you may install into the (/usr/local/cross) directory.
Some flags that appear in the configuring that should be explained:
--disable-nls: This disables native language support which is optional but reduces compile time
--without-headers: This tells the make file not to compile and include any of the standard C libraries for this target
--enable-languages: This tells the make file not to compile all the other language subsets it finds except for the ones listed (c and c++)
Code
#create a directory to hold all your sources
cd ~
mkdir i686-elf
cd i686-elf
#download all your sources, these are the latest as of June, 15, 2014
wget http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.gz
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
wget https://ftp.gnu.org/gnu/gmp/gmp-6.0.0a.tar.xz
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.gz
wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
tar -zxvf gcc-4.9.0.tar.gz
tar -zxvf binutils-2.24.tar.gz
tar -xvf gmp-6.0.0a.tar.xz
tar -zxvf mpfr-3.1.2.tar.gz
tar -zxvf mpc-1.0.2.tar.gz
#move, configure, build, and install the binutils source
cd binutils-2.24
./configure --target=i686-elf --prefix="$HOME/opt/cross" --disable-nls --disable-werror
make && make install
#move the related gcc sources into the gcc folder and then move, configure, make, and install gcc
cd ..
mv gmp-6.0.0 gcc-4.9.0/gmp
mv mpfr-3.1.2 gcc-4.9.0/mpfr
mv mpc-1.0.2 gcc-4.9.0/mpc
cd gcc-4.9.0
./configure --target=i686-elf --prefix="$HOME/opt/cross" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
#check if gcc is installed correctly and functioning
~/opt/cross/bin/i686-elf-gcc --version
#i686-elf-gcc (GCC) 4.9.0
#update your path variable (might want to update your .bashrc or else you will be fixing your path every session)
export PATH="$HOME/opt/cross/bin:$PATH"