Building binutils and gcc
Step 1: Create a folder to keep binutils and gcc source code. <target> = CPU arch you want to build for.
$ mkdir <target>-build; cd <target>-build
Step 2: Clone or download binutils and gcc source code.
Step 3: Define the path where the built binaries will be saved.
$ export PREFIX=${HOME}/<target>
$ export PATH="${PREFIX}/bin:${PATH}"
Step 4: Configure and build binutils.
$ cd <binutils-source-folder>
$ ./configure --prefix="${PREFIX}" --target=<target> --disable-nls --disable-werror
$ make
$ make install
The –enable-nls option enables Native Language Support (NLS), which lets GCC output diagnostics in languages other than American English. Native Language Support is enabled by default if not doing a canadian cross build. The –disable-nls option disables NLS. GCC documentation
Step 5: Download or build from source gcc dependences. In this case we will just download them.
$ cd <gcc-source-folder>
$ ./contrib/download_prerequisites
Step 6: Build gcc.
$ mkdir build-gcc
$ cd build-gcc
$ ../gcc-x.y.z/configure --prefix="$PREFIX" --disable-nls --enable-languages=c,c++
$ make
$ make install