Make a valid Emacs version string before building.

In certain cases there are version numbers that are valid to Emacs but
get translated into something different after parsing to a
list (version-to-list) and then back to a string (package-version-join).
So before we start passing around the original version string we simply
regenerate it using the Emacs functions so it is consistent during the
building process.

Fixes #1952
Fixes #2000