add support for OS X in the build script

X-Authored-By: @npinchot
X-Authored-By: @mn4367

See #1545 and #1689 for the original discussion related to this.