Code

Disable dynamic versionning for releases, and allow generating version out of subversion.
authorThomas Guyot-Sionnest <dermoth@aei.ca>
Wed, 26 Nov 2008 10:42:48 +0000 (05:42 -0500)
committerThomas Guyot-Sionnest <dermoth@aei.ca>
Wed, 26 Nov 2008 10:42:48 +0000 (05:42 -0500)
This should be a definitive fix for systems with non-compilant make programs as the version will be taken from $(PACKAGE_VERSION) instead.

At the same time I added code for generating svn-based version strings.

Makefile.am
NP-VERSION-GEN
configure.in
plugins-root/Makefile.am
plugins-scripts/Makefile.am
plugins/Makefile.am

index 3cd939aca62d6d7b46b6dfaf81881c5c64b98f48..70325781e3c1ba77fee9a13a6b10bc7ed66459f7 100644 (file)
@@ -19,7 +19,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\"
 
 dist-hook:
        make THANKS nagios-plugins.spec pkg/fedora/nagios-plugins.spec
-       echo ${VERSION} >$(distdir)/version
+       echo ${VERSION} >$(distdir)/release
 
 install-root:
        cd plugins-root && $(MAKE) $@
index 1169710766cc3ca69e75a6a99c0ebfa7efd5dbb0..f963e6373d0a4141f0ddd060d35cf92c7a40ddf9 100755 (executable)
@@ -11,12 +11,8 @@ DEF_VER=1.4.13.git
 LF='
 '
 
-# First see if there is a version file (included in release tarballs),
-# then try git-describe, then default.
-if test -f $SRC_ROOT/version
-then
-       VN=`cat $SRC_ROOT/version` || VN="$DEF_VER"
-elif test -d $SRC_ROOT/.git -o -f $SRC_ROOT/.git &&
+# First try git-describe, then svn info, then default.
+if test -d $SRC_ROOT/.git -o -f $SRC_ROOT/.git &&
        VN=`cd $SRC_ROOT; git describe --abbrev=4 HEAD 2>/dev/null` &&
        case "$VN" in
        *$LF*) (exit 1) ;;
@@ -27,6 +23,17 @@ elif test -d $SRC_ROOT/.git -o -f $SRC_ROOT/.git &&
        esac
 then
        VN=`echo "$VN" | sed -e 's/^release-//' | sed -e 's/-/./g'`;
+elif test -d $SRC_ROOT/.svn -o -f $SRC_ROOT/.svn &&
+       VN=`cd $SRC_ROOT; svn info 2>/dev/null | grep '^Revision'` &&
+       case "$VN" in
+       *$LF*) (exit 1) ;;
+       Revision:*)
+               VN=`echo $VN | awk '{print $NF}'`
+               test "`svn status 2>/dev/null | grep '^[AMD]' | wc -l`" = 0 ||
+               VN="$VN-dirty" ;;
+       esac
+then
+       VN=`echo "trunk.$VN" | sed -e 's/-/./g'`;
 else
        VN="$DEF_VER"
 fi
index 203166e424703eb4b719d29de7f4ace6c7f911d7..8cae534155ce93be68c2fdfbea7826f91d3843e6 100644 (file)
@@ -98,6 +98,9 @@ AC_SUBST(PKG_ARCH)
 AC_SUBST(REV_DATESTAMP)
 AC_SUBST(REV_TIMESTAMP)
 
+dnl Check if version file is present
+AM_CONDITIONAL([RELEASE_PRESENT], [test -f release])
+
 dnl Checks for programs.
 AC_PATH_PROG(PYTHON,python)
 AC_PATH_PROG(SH,sh)
index ba2e9a27843710be1626a72234dcf0b9fcea82ff..3fb62a24d507efe4f84f6d1185d544496b90be6c 100644 (file)
@@ -1,13 +1,13 @@
 ## Process this file with automake to produce Makefile.in
 
+if RELEASE_PRESENT
+NP_VERSION = $(PACKAGE_VERSION)
+else
 NP-VERSION-FILE: .FORCE-NP-VERSION-FILE
        @$(SHELL_PATH) $(top_srcdir)/NP-VERSION-GEN
 .FORCE-NP-VERSION-FILE:
-
-## This is undocumented and could possibly break in future versions of
-## automake. See:
-## http://article.gmane.org/gmane.comp.sysutils.automake.general/10036
-@am__include@ @am__quote@NP-VERSION-FILE@am__quote@
+-include NP-VERSION-FILE
+endif
 
 AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'
 
index 19702739d7d1db9968c30613adf1fef26cebeedb..5c073ca402687f5ea52c919fab1a01d103d62ba9 100644 (file)
@@ -1,13 +1,13 @@
 ## Process this file with automake to produce Makefile.in
 
+if RELEASE_PRESENT
+NP_VERSION = $(PACKAGE_VERSION)
+else
 NP-VERSION-FILE: .FORCE-NP-VERSION-FILE
        @$(SHELL_PATH) $(top_srcdir)/NP-VERSION-GEN
 .FORCE-NP-VERSION-FILE:
-
-## This is undocumented and could possibly break in future versions of
-## automake. See:
-## http://article.gmane.org/gmane.comp.sysutils.automake.general/10036
-@am__include@ @am__quote@NP-VERSION-FILE@am__quote@
+-include NP-VERSION-FILE
+endif
 
 SUFFIXES = .pl .sh
 
index fb1924fe377b82e16597268abd96e63780d65cf9..0f6fbb60a6401f5552e68478c77706d0a59bb628 100644 (file)
@@ -1,13 +1,13 @@
 ## Process this file with automake to produce Makefile.in
 
+if RELEASE_PRESENT
+NP_VERSION = $(PACKAGE_VERSION)
+else
 NP-VERSION-FILE: .FORCE-NP-VERSION-FILE
        @$(SHELL_PATH) $(top_srcdir)/NP-VERSION-GEN
 .FORCE-NP-VERSION-FILE:
-
-## This is undocumented and could possibly break in future versions of
-## automake. See:
-## http://article.gmane.org/gmane.comp.sysutils.automake.general/10036
-@am__include@ @am__quote@NP-VERSION-FILE@am__quote@
+-include NP-VERSION-FILE
+endif
 
 AM_CFLAGS = -DNP_VERSION='"$(NP_VERSION)"'