Build script refactor

This sets the stage for easy re-use of the build script for other software.  I will post a FluDAG version soon.