Add new libraries to MacOS X build script.

Also move some general stuff into a separate script so
it can be shared by the MacOS X and the Linux build.