File: mk_svn_revision.sh

package info (click to toggle)
citadel 902-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,904 kB
  • ctags: 4,359
  • sloc: ansic: 54,083; sh: 4,226; yacc: 651; makefile: 413; xml: 40
file content (78 lines) | stat: -rwxr-xr-x 1,415 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# Script to generate svn_revision.c
#

ECHO=/usr/bin/printf


SCRIPT_DIR=`dirname $0`
SRC_DIR=`dirname $SCRIPT_DIR`
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 test -d $SRC_DIR/.svn  ; then
	echo "have subversion repository"
	SVNVERSION=`which svnversion`
	if test -x $SVNVERSION  ; then
		echo "have svnversion at $SVNVERSION"
		BUILD=`svnversion -n .`
		echo "This code base svn-revision: $BUILD"
		CAN_BUILD_SVN_REVISION="yes"
	fi
else 
    if test -d $SRC_DIR/../.git  ; then
	echo "have Git repository."
	BUILD=`/usr/bin/git log -1 --pretty=%h . `
	echo "This code base git-revision: $BUILD"
	CAN_BUILD_SVN_REVISION="yes"
    else
	if test -f $C_FILE; then
	    exit
	fi
    fi
fi

if [ "$CAN_BUILD_SVN_REVISION" = "yes" ] ; then

cat <<EOF > $C_FILE
/*
 * Subversion / GIT 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 test ! -f $C_FILE  ; then

cat <<EOF > $C_FILE
/*
 * Subversion / GIT 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)";
	return SVN_Version;
}
EOF

fi