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
28 export REVISION=`cd "$1"; svnversion || svn info | sed -n 's/^Revision: \(.*\)/\1/p'`
32 HEADER="$2/autorevision.h"
36 if [ ! -f "$HEADER" ] ; then
37 touch -t 197001010101 "$HEADER"
41 # Extract the revision from SVN/git/etc
42 if [ -d "$1/.git/svn" ] ; then
44 elif [ -d "$1/../.git/svn" ] ; then
45 get_git_svn_id "$1/.."
46 elif [ -d "$1/../../.git/svn" ] ; then
47 get_git_svn_id "$1/../.."
48 elif [ -d "$1/.svn" ] ; then
51 elif [ -d "$1/_svn" ] ; then
57 # Allow overriding both REVISION and DEVEL_VERSION
58 if [ -f "$2/autorevision.conf" ] ; then
60 . "$2/autorevision.conf"
64 # Abort if the header is newer
65 if [ "$COMPARE" -ot "$HEADER" ] ; then return; fi
68 # Set the development version string
69 if [ x = "x$DEVEL_VERSION" ] ; then
70 if [ x != "x$REVISION" ] ; then
71 if [ $SCM = svn ] ; then
72 DEVEL_VERSION="SVN r$REVISION"
73 elif [ $SCM = git-svn ] ; then
74 DEVEL_VERSION="SVN r$REVISION (via git)"
75 elif [ $SCM = manual ] ; then
76 DEVEL_VERSION="$REVISION (manually configured)"
83 if [ x != "x$DEVEL_VERSION" ] ; then
84 echo "#define SHOW_EXTRA_INFO" > "$HEADER"
85 echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER"