How to compile gcc-4.0 on Mountain Lion?
Someone on serverfault answered the same question. So here's the way to compile gcc-4.0 on OS X Mountain Lion (copied from serverfault):

First get the old 4.0 package that was included with XCode 3.1 from Apple's Open Source page

Download the gcc-5493 package and build using:

mkdir darwin
cd darwin
../configure --prefix=/tmp/testplace --enable-languages=objc,c++
make bootstrap
make install