1) Obtain and install Xcode 3.1.4, the last version that will
run on 10.5. This includes gcc 4.2. Consider replacing your
/usr/bin/gcc and /usr/bin/g++ symlinks with ones pointing at
gcc-4.2 and g++-4.2 -- I did, though this is not strictly
necessary.
This version of Xcode can be obtained from the Apple developer
website, most of the way down the page of all developer downloads.
2) Invoke build.sh with -V HOST_CC=gcc-4.2 -V HOST_CXX=g++-4.2
-V HOST_CFLAGS="-O2 -pipe -m64" -V HOST_CXXFLAGS="-O2 -pipe -m64"
-V HOST_LDFLAGS="-m64"