Get configure.ac version values from git
[claws.git] / configure.ac
index 2669bdc6907ed3495fd05b180997699c1bc8ac66..cb318b6001426dce506452a209eded61f0c48942 100644 (file)
@@ -7,19 +7,36 @@ AC_CONFIG_MACRO_DIR([m4])
 PACKAGE=claws-mail
 
 dnl version number
-MAJOR_VERSION=3
-MINOR_VERSION=9
-MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=128
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
-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}
 else
-    VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}cvs${EXTRA_VERSION}${EXTRA_GTK2_VERSION}
+    VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
+    EXTRA_VERSION=0
+fi
+
+if test \( "x$HASH_VERSION" != "x" \); then
+    if test \( "x$DIRTY_VERSION" != "x" \); then
+        VERSION=${VERSION}+${HASH_VERSION}+local
+    else
+        VERSION=${VERSION}+${HASH_VERSION}
+    fi
+fi
+
+if test \( "x$EXTRA_RELEASE" != "x" \); then
+    VERSION=${VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
 fi
 
 dnl set $target
@@ -35,6 +52,8 @@ AC_SUBST(MAJOR_VERSION)
 AC_SUBST(MINOR_VERSION)
 AC_SUBST(MICRO_VERSION)
 AC_SUBST(EXTRA_VERSION)
+AC_SUBST(GIT_VERSION)
+AC_SUBST(HASH_VERSION)
 
 AC_CHECK_PROG(HAVE_GTK_ICON_CACHE, gtk-update-icon-cache, yes, no)
 AM_CONDITIONAL(UPDATE_GTK_ICON_CACHE, test x"$HAVE_GTK_ICON_CACHE" = xyes)