Our cluster is still working off of CentOS 5.4, so GCC is a bit out of date for some scientific simulation programs out there, so begins the task of building GCC, but that is not the point of this posting. Rocks has the nifty command, rocks create package, to create an rpm package out of a given directory. This works without any issues until I tried it when I was working on rebuilding our our software stack to be based off of the latest GCC.
I had no issues with gcc or with making the package, it was later when building openmpi I discovered what was the issue. When openmpi had to link against a GCC library, it was asking the binary where it was, which in turn was using a hard coded location that no longer existed as this was not the orginal build machine. The fix is the use of DESTDIR. In this case I wanted gcc to be in /opt/gcc-4.7.1, so during the configure step, I set the prefix as such, yet I used the following during the install step: make DESTDIR=/tmp/gcc install, which will install gcc in $DESTDIR/$prefix. Now GCC knows to find its items in /opt/gcc-4.7.1 and not where it was previously on the build server.