fix build script on OS X

readlink -f doesn't exist on OS X.

The new code breaks if build.sh was run from PATH or a symlink, but that seems improbable.