Rely on file creation and dependencies instead of .PHONY targets.
Files will be rebuilt when changing version as the main `Makefile` will
have been updated. All steps are re-done on version change.
When deleting patches, the '.prepare' step should be redone thanks
to the included 'patch-dep.inc' file (TODO TEST ME).
Implementation in order:
* '.git': means the repository has been cloned.
* '.git-downloaded': Fetches the wanted version
* '.git-prepared': will clean checkout the version and apply patches
This should prevent issues where the Makefile use 'PKG_BUILDDIR' before
them being defined.
This will also allow changing the state targets to be file targets.
Once the repo is downloaded, the version is not checked gain. This
means that even if a package's Makefile is touched, that will only
cause a rebuild of the previously downloaded version. For packages
that are normally not deleted, like edbg, this renders PKG_VERSION
bumps ineffective, unless the user manually deletes the repo
directory.
This patch fixes that by always checking that the repo is at the
right commit.
Use fixed identity when applying patches, it fixes issues when they are
not set in the build computer or if HOME is not exported.
The commits are only used in the build system so adding the building user
information is useless.