Makefile: change the way VERSION is generated

Issues:

  - If we're building from a release tarball, VERSION is not set
  - If we're building from another git repo (fork / packaging repo), and
    using our own tags, VERSION is set to something that doesn't not
    reflect the real version.

This patch fixes both issues, while keeping the default behavior when
building from the main git repo.