The steps were performed on a Ubuntu 18 machine with gcc 7.5.0. If your host environment differs you may have to adjust a few steps. This comes with no libraries, not even libgcc.
PrerequisitesGet these from your distro repo
gcc, binutils, make, gmp, mpfr, mpc
Sourceshttps://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gzhttps://ftp.gnu.org/gnu/gcc/gcc-4.7.0/gcc-4.7.0.tar.bz2InstallationCreate the directory where you want to install it. Create build directories outside of the source directories. PREFIX is the installation directory.
binutils
"$BINUTILS_SRC_DIR/configure" --prefix="$PREFIX" --target=mep-elf --disable-shared --disable-nls --disable-werror
make -j$(nproc)
make install
gcc
"$GCC_SRC_DIR/configure" --prefix="$PREFIX" --enable-languages=c --target=mep-elf --disable-libgcc --disable-libquadmath --disable-libssp --disable-multilib --disable-nls --disable-shared MAKEINFO="$GCC_SRC_DIR/missing"
make -j$(nproc)
make install