-if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
- VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
+GIT_VERSION=`git describe --abbrev=6 --dirty --always`
+MAJOR_VERSION=`echo $GIT_VERSION | cut -f1 -d- | cut -f1 -d.`
+MINOR_VERSION=`echo $GIT_VERSION | cut -f1 -d- | cut -f2 -d.`
+MICRO_VERSION=`echo $GIT_VERSION | cut -f1 -d- | cut -f3 -d.`
+EXTRA_VERSION=`echo $GIT_VERSION | cut -f2 -d-`
+HASH_VERSION=`echo $GIT_VERSION | cut -f3 -d-`
+DIRTY_VERSION=`echo $GIT_VERSION | cut -f4 -d-`
+
+if test \( "x$EXTRA_VERSION" != "x" \); then
+ VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}git${EXTRA_VERSION}