build script fixes for Mac, thanks to @bqpd