Ported over the scons script improvements from TripleGit.