summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorrmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d>2008-05-28 11:16:28 +0000
committerrmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d>2008-05-28 11:16:28 +0000
commitad4cb12fbbcac74cf5876fe27b5ade25464ec7a6 (patch)
treecf996a0cf41076e3c16f5879ca468396f39806f4 /bin
parent316f5201b71af3ca6c244879a74089ac366cce20 (diff)
Added automatic SVN revision computation in "revision.h".
git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@24 2592e710-e01b-42a5-8df0-11608a6cc53d
Diffstat (limited to 'bin')
-rwxr-xr-xbin/svn-revision61
1 files changed, 61 insertions, 0 deletions
diff --git a/bin/svn-revision b/bin/svn-revision
new file mode 100755
index 0000000..0d88b3b
--- /dev/null
+++ b/bin/svn-revision
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#
+# $Id: svn-revision 12303 2006-11-11 08:11:46Z cbiere $
+#
+# Copyright (c) 2006, Raphael Manfredi
+#
+# You may redistribute only under the terms of the Artistic Licence,
+# as specified in the README file that comes with the distribution.
+# You may reuse parts of this distribution only within the terms of
+# that same Artistic Licence; a copy of which may be found at the root
+# of the source tree for dist 4.0.
+#
+# Computes SVN current revision number, if possible, emitting it in
+# the form of a #define for C perusal.
+#
+
+LC_ALL=C
+export LC_ALL
+
+TOP="$1"
+FILE="$2"
+
+if [ "x$FILE" = x ]; then
+ FILE="&1"
+ oldrev=''
+else
+ oldrev=`grep REVISION "$FILE" 2>/dev/null | head -n1 | cut -d' ' -f3`
+fi
+
+if test -d "$TOP/.svn"; then
+ revnum=`svn info "$TOP" 2>/dev/null | grep '^Revision' | head -n1 | cut -d' ' -f2`
+else
+ revnum="$oldrev" # keep as is
+fi
+
+if [ "x$revnum" = "x$oldrev" ]; then
+ exit 0
+fi
+
+{
+stamp=`date +"%Y-%m-%d %H:%M:%d %z"`
+cat <<EOF
+/*
+ * THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
+ *
+ * Generated by $0.
+ */
+
+EOF
+
+if [ "x$revnum" = x ]; then
+ echo '/* Subversion information not available */'
+else
+ cat <<EOF
+#define REVISION $revnum
+EOF
+fi
+
+} > "$FILE"
+