Use Homebrew LLVM over Xcode
You change the script - or better use a build system makefile, cmake, waf etc to have the full path to the C++ compiler and not rely on the $PATH.

Alternatively see of the package has been ported to Homebrew and use that or if only to fink or MAcPorts see how they changed the script.

Lastly make the build as a Homebrew formula making use of Homebrew's own build tools