Fix generating the version header when building outside of the source tree

Also silence this command in silent builds.
Merge pull request #1181 from mstorsjo/generate-version

Fix generating the version header when building outside of the source tree