diff --git a/main/Makefile.am b/main/Makefile.am index 2234c2753..c24d91e0f 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -12,7 +12,10 @@ trunk_version.h: fi \ elif test -d ../.git ; then \ GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`; \ - if test ../.git/refs/heads/$$GIT_BRANCH -nt trunk_version.h; then \ + if test \! -e ../.git/refs/heads/$$GIT_BRANCH -o ../.git/refs/heads/$$GIT_BRANCH -nt trunk_version.h; then \ + if GIT_TAG=$$(git describe --exact-match $$GIT_BRANCH 2>/dev/null) ; then \ + GIT_BRANCH="$$GIT_TAG"; \ + fi; \ GIT_HASH=`git rev-parse --short HEAD`; \ echo '#define TRUNK_VERSION "'$$GIT_HASH' ('$$GIT_BRANCH')"' > trunk_version.h; \ echo '#define TRUNK_VERSION_GIT 1' >> trunk_version.h; \