3 # Copyright 2008 Paul Wise
5 # This package is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of
8 # the License, or (at your option) any later version.
10 # This package is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
18 export REVISION=`cd "$1"; git svn find-rev HEAD`
19 export COMPARE="$1/.git/"
20 if [ x = "x$REVISION" ] ; then
21 # The extra M at the end is for Modified
22 export REVISION=`cd "$1"; git svn find-rev \`git rev-list --max-count=1 --grep='git-svn-id: ' HEAD\``M
24 export REVISION="$REVISION"`cd "$1"; git diff --quiet HEAD || echo M`
30 export REVISION=`cd "$1"; svnversion || svn info | sed -n 's/^Revision: \(.*\)/\1/p'`
34 HEADER="$2/autorevision.h"
38 if [ ! -f "$HEADER" ] ; then
39 touch -t 197001010101 "$HEADER"
43 # Extract the revision from SVN/git/etc
44 if [ -d "$1/.git/svn" ] ; then
46 elif [ -d "$1/../.git/svn" ] ; then
47 get_git_svn_id "$1/.."
48 elif [ -d "$1/../../.git/svn" ] ; then
49 get_git_svn_id "$1/../.."
50 elif [ -d "$1/.svn" ] ; then
53 elif [ -d "$1/_svn" ] ; then
59 # Allow overriding both REVISION and DEVEL_VERSION
60 if [ -f "$2/autorevision.conf" ] ; then
62 . "$2/autorevision.conf"
66 # Abort if the header is newer
67 if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi
70 # Set the development version string
71 if [ x = "x$DEVEL_VERSION" ] ; then
72 if [ x != "x$REVISION" ] ; then
73 if [ $SCM = svn ] ; then
74 DEVEL_VERSION="SVN r$REVISION"
75 elif [ $SCM = git-svn ] ; then
76 DEVEL_VERSION="SVN r$REVISION (via git)"
77 elif [ $SCM = manual ] ; then
78 DEVEL_VERSION="$REVISION (manually configured)"
85 if [ x != "x$DEVEL_VERSION" ] ; then
86 echo "#define SHOW_EXTRA_INFO" > "$HEADER"
87 echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER"