build: check .git directory existence in srcdir (for out-of-tree builds)

So that $(VERSION) and version.stamp uses the git-describe -based
version data instead of the content of `version' file.

For consistency also the git commands in Makefile[.local] target
`verify-no-dirty-code' uses the git --git-dir=$srcdir/.git ...
commands (inside ifeq($(IS_GIT),yes)). Attempting to make this
target outside of the tree will fail in any case.