+v=""
+if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
+ git update-index --refresh --unmerged > /dev/null
+ descr=$(git describe --match=v* 2>/dev/null)
+ if [ $? -eq 0 ]; then
+ # on git builds check that the version number above
+ # is correct...
+ if [ "${descr%%-*}" = "v$VERSION" ]; then
+ v="${descr#v}"
+ if git diff-index --name-only HEAD | read dummy ; then
+ v="$v"-dirty
+ fi
+ fi
+ fi
+fi
+
+# set to the default version when failed to get the version
+# information with git
+if [ -z "${v}" ]; then
+ v="$VERSION"