Avoid rebuilds if the version header hasn't changed

When generating the version header, don't overwrite it if the
new version is identical to the old one.
Merge pull request #1642 from mstorsjo/avoid-rebuilds

Avoid rebuilds if the version header hasn't changed