From 06e0954d5ea575a5d555a5cf27f0dce52f27f091 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 19 Dec 2015 10:07:20 +0100 Subject: [PATCH] Add version support also at the source distribution --- Makefile.am | 6 +++++- autover.sh | 14 ++++++++++++++ configure.ac | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 autover.sh diff --git a/Makefile.am b/Makefile.am index 51916503..39dcd149 100644 --- a/Makefile.am +++ b/Makefile.am @@ -102,8 +102,12 @@ mkstream_SOURCES = \ cmdline/stream.c \ raid/memory.c +# Add the .version file in the distribution +dist-hook: + $(srcdir)/autover.sh > $(distdir)/.version + EXTRA_DIST = \ - autogen.sh \ + autogen.sh autover.sh \ README AUTHORS HISTORY INSTALL COPYING TODO CHECK INSTALL.windows \ snapraid.d snapraid.1 snapraid.txt \ test/test-par1.conf \ diff --git a/autover.sh b/autover.sh new file mode 100755 index 00000000..79256402 --- /dev/null +++ b/autover.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# + +if [ -d .git ]; then + # Get version from git tags, removing the 'v' prefix + VERSION=`git describe --match 'v*' | sed 's/^v//'` +elif [ -f .version ]; then + # Get version from the .version file + VERSION=`cat .version` +else + VERSION="none" +fi + +printf '%s' "$VERSION" diff --git a/configure.ac b/configure.ac index e26cae90..8450ff31 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) dnl Get version number from git -m4_define([git_revision], m4_esyscmd_s([git describe --match 'v*' | sed 's/^v//'])) +m4_define([git_revision], m4_esyscmd_s([./autover.sh])) AC_INIT([snapraid], [git_revision], [], [], [http://www.snapraid.it]) AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects]) AC_CONFIG_SRCDIR([cmdline/snapraid.c])