GHC needs a binary GHC available for compilation. There are precompiled GHC binaries, but they were created against new versions of glibc
RHEL 5 has glibc 2.5, so you can use GHC 6.8 and bootstrap. Typically, GHC can boot using $ VERSION-2 or later (the exact version is documented with the initial downloads ).
You will also need a newer version of gcc. @ alex-iliev assumes gcc 4.3 is enough, which is available on RHEL 5. Your alternative is to use Gentoo Prefix to install -date gcc.
Download and install the precompiled 6.8 into the directory:
wget http://www.haskell.org/ghc/dist/6.8.3/ghc-6.8.3-x86_64-unknown-linux.tar.bz2 bunzip2 ghc-6.8.3-x86_64-unknown-linux.tar.bz2 tar -xf ghc-6.8.3-x86_64-unknown-linux.tar cd ghc-6.8.3 mkdir ~/ghc_bootstrap_6_8 ./configure --prefix=/home/wilfred/ghc_bootstrap_6_8/ make install
Compilation 6.12:
wget http://www.haskell.org/ghc/dist/6.12.3/ghc-6.12.3-src.tar.bz2 bunzip2 ghc-6.12.3-src.tar.bz2 tar -xf ghc-6.12.3-src.tar cd ghc-6.12.3 mkdir ~/ghc_bootstrap_6_12 PATH=/home/wilfred/ghc_bootstrap_6_8/bin:$PATH ./configure --prefix=/home/wilfred/ghc_bootstrap_6_12/ make make install
Compiling 7.2 and 7.6 is the same process as 6.12. Compilation can take several hours, so you can see fast builds (although you need a normal build for the final version of GHC).
If you go down from the root of Gentoo Prefix, just upload your path to GHC 7.2. You can then modify $EPREFIX/usr/portage/eclass/ghc-package.eclass to add the line:
PATH=/home/wilfred/ghc_bootstrap_7_2/bin:$PATH
just add ghcbootstrap to your USE flags and:
emerge --nodeps ghc
source share