Fix call to readlink on OS X

readlink -f is a GNU coreutils extension, so not available on OS X and possibly other platforms.