Now the server records the SVN revision in the log at startup.
[citadel.git] / citadel / mk_svn_revision.sh
1 #!/bin/sh
2 #
3 # Script to generate svn_revision.c
4 #
5
6 ECHO=/usr/bin/printf
7
8
9 CUR_DIR=`pwd`
10 C_FILE="$CUR_DIR/svn_revision.c"
11 H_FILE="$CUR_DIR/svn_revision.h"
12
13
14 # determine if this code base came from subversion.
15 if [ -d .svn ] ; then
16         echo "have subversion repository"
17         SVNVERSION=`which svnversion`
18         if [ -x $SVNVERSION ] ; then
19                 echo "have svnversion at $SVNVERSION"
20                 BUILD=`svnversion -n .`
21                 echo "This code base revision $BUILD"
22                 CAN_BUILD_SVN_REVISION="yes"
23         fi
24 fi
25
26 if [ $CAN_BUILD_SVN_REVISION == "yes" ] ; then
27
28 cat <<EOF > $C_FILE
29 /*
30  * Subversion revision functions
31  *
32  * Autogenerated at make/release time
33  *
34  * Do not modify this file
35  *
36  */
37  
38 const char *svn_revision (void)
39 {
40         const char *SVN_Version = "$BUILD";
41         return SVN_Version;
42 }
43 EOF
44
45 elif [ ! -f $C_FILE ] ; then
46
47 cat <<EOF > $C_FILE
48 /*
49  * Subversion revision functions
50  *
51  * Autogenerated at make time
52  *
53  * There should have been one with your source distribution
54  *
55  * Do not modify this file
56  *
57  */
58  
59 const char *svn_revision (void)
60 {
61         const char *SVN_Version = "**UNKNOWN** Built from source without svn and no $C_FILE accompanying";
62         return SVN_Version;
63 }
64 EOF
65
66 fi