summaryrefslogtreecommitdiffstats
path: root/build-helpers/package-version
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-06-21 15:54:52 +0200
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-07-19 01:13:31 +0200
commitbd8a638e9caa2fa508f8865d9532c821f81fa909 (patch)
tree0ecc9aba522c50ae5f4f9e2c00c969d3f67daaae /build-helpers/package-version
parentafcce7e37a5308198cd524f5b1e83f03eb580158 (diff)
downloadndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.tar.gz
ndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.tar.xz
ndim-git-utils-bd8a638e9caa2fa508f8865d9532c821f81fa909.zip
Generate version information from git info
Diffstat (limited to 'build-helpers/package-version')
-rwxr-xr-xbuild-helpers/package-version27
1 files changed, 27 insertions, 0 deletions
diff --git a/build-helpers/package-version b/build-helpers/package-version
new file mode 100755
index 0000000..61a3018
--- /dev/null
+++ b/build-helpers/package-version
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Syntax:
+# $0 <path-to-top_srcdir> <version-stamp-file>
+#
+# <path-to-top_srcdir> may be relative
+# <version-stamp-file> is relative to src/build topdir
+
+top_srcdir="${1-.}"
+test -d "$top_srcdir" || { \
+ echo "Could not change to top_srcdir '$1'" >&2; \
+ exit 1; \
+}
+version_stamp="${2-version-stamp}"
+
+# If GIT_DIR is set, use it. If not, try top_srcdir/.git.
+if test -n "$GIT_DIR"; then :;
+else GIT_DIR="$top_srcdir/.git"; export GIT_DIR
+fi
+
+if test -f "$top_srcdir/$version_stamp"; then # dist source tree
+ cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012'
+elif test -d "$GIT_DIR"; then # git source tree
+ git_describe=`${GIT-git} describe 2>/dev/null || echo devel`
+ echo "$git_describe" | ${SED-sed} 's/^v//;s/-/./;s/-g/-/' | ${TR-tr} -d '\012'
+else # ???
+ echo "devel" | ${TR-tr} -d '\012'
+fi