Wish I was able to compile gcc...
How do you guys do this, it seems everybody and their grandmother can do it, only just not me...
May be I should write a blog post on how to compile this. For the time being, I'm explaining it in brief.
I prefer cross-compiling GCC as it's much faster (even from a VM) than CygWin or MSYS. Also my current antivirus freaks out every time I executes a script through MSYS.
1) You need a cross-compiler first. First install GMP-devel, MPFR-devel package on Linux. Then build BinUtils as-
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install
Basically we need a binutils installation which can emit Windows executables on Linux.
2) Then extract mingw-runtime & runtime-devel, w32api packages to
<BinUtils-Install-Dir>/i686-pc-mingw32 folder.
3) Add
<BinUtils-Install-Dir> to path and configure & compile cross-gcc as-
export PATH=<BinUtils-Install-Dir>/bin:$PATH
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install
4) Now build GMP and MPFR as -
./configure --target=i686-pc-mingw32 --prefix=<BinUtils-Install-Dir> && make install
This part you need to check the actual command to be used. Basic idea is to cross-compile them and install them to
<BinUtils-Install-Dir> folder.
5) Now build GCC for MinGW as-
./configure --host=i686-pc-mingw32 --target=i686-pc-mingw32 --prefix=/mingw && make
Edit 1: You can get the extract newly compiled binary by issuing the following command.
make DESTDIR=<compiled-mingw-dir> install
<compiled-mingw-dir> can be any folder you want (e.g., /home/<Username>/foo). Only caveat is all your packages will be extracted to one folder. There should be a way to separate different language packages. But I don't know how to do that.
Hope this helps.