[global] Use realpath in case HOMEBREW_PREFIX is a symlink

https://github.com/Homebrew/homebrew/issues/26524

HOMEBREW_PREFIX is set to the parent of the dirname of HOMEBREW_BREW_FILE.
If HOMEBREW_PREFIX is a symlink, Keg.link_dir computes the wrong
relative paths when installing targets.