In #11097 we added a quick version string hack that seems to do the following:
When Gitian building, after generating the source tarball (a la make dist), we invoke make -C src obj/build.h, as make dist does not: https://github.com/bitcoin/bitcoin/blob/b499d8576f30d13dfe9000852afe47ee1c28cfbe/src/Makefile.am#L245-L248
We can see that this calls share/genbuild.sh, which generates a src/obj/build.h containing version information obtained from git: https://github.com/bitcoin/bitcoin/blob/b499d8576f30d13dfe9000852afe47ee1c28cfbe/share/genbuild.sh#L1-L53
Then, for each architecture we build, we neuter share/genbuild.sh (as normal make will try to regenerate obj/build.h, but now lacks the build information as we’re not in a git repository anymore) and copy over the generated src/obj/build.h mentioned above. All of this is being done before configureing, makeing, and make installing for the architecture: https://github.com/bitcoin/bitcoin/blob/b499d8576f30d13dfe9000852afe47ee1c28cfbe/contrib/gitian-descriptors/gitian-linux.yml#L168-L177
Perhaps what we can do is simply add src/obj/build.h to EXTRA_DIST, and generate it in a dist-hook? Do non-existent files in EXTRA_DIST get their targets called? Source: https://www.gnu.org/software/automake/manual/html_node/The-dist-Hook.html
@theuni @luke-jr would love some more context here.