+#!/bin/sh
+#
+# Script to generate svn_revision.c
+#
+
+ECHO=/usr/bin/printf
+
+
+CUR_DIR=`pwd`
+C_FILE="$CUR_DIR/svn_revision.c"
+H_FILE="$CUR_DIR/svn_revision.h"
+
+
+# determine if this code base came from subversion.
+if [ -d .svn ] ; then
+ echo "have subversion repository"
+ SVNVERSION=`which svnversion`
+ if [ -x $SVNVERSION ] ; then
+ echo "have svnversion at $SVNVERSION"
+ BUILD=`svnversion -n .`
+ echo "This code base revision $BUILD"
+ CAN_BUILD_SVN_REVISION="yes"
+ fi
+fi
+
+if [ $CAN_BUILD_SVN_REVISION == "yes" ] ; then
+
+cat <<EOF > $C_FILE
+/*
+ * Subversion revision functions
+ *
+ * Autogenerated at make/release time
+ *
+ * Do not modify this file
+ *
+ */
+
+const char *svn_revision (void)
+{
+ const char *SVN_Version = "$BUILD";
+ return SVN_Version;
+}
+EOF
+
+elif [ ! -f $C_FILE ] ; then
+
+cat <<EOF > $C_FILE
+/*
+ * Subversion revision functions
+ *
+ * Autogenerated at make time
+ *
+ * There should have been one with your source distribution
+ *
+ * Do not modify this file
+ *
+ */
+
+const char *svn_revision (void)
+{
+ const char *SVN_Version = "**UNKNOWN** Built from source without svn and no $C_FILE accompanying";
+ return SVN_Version;
+}
+EOF
+
+fi