Export HOMEBREW_PREFIX to build environment

Constructing the path relative to a file in the repository is incorrect
on some supported configurations (i.e., the repository is located in a
different place than the prefix).

Closes #24418.
ENV strings are already frozen