3 LC_ALL
="C" # what for ?
5 [ -z "$top_srcdir" ] && top_srcdir
="."
6 rev_file
=$top_srcdir'/geos_svn_revision.h'
10 if test -d $top_srcdir"/.svn"; then
12 elif test -d $top_srcdir"/.git"; then
15 echo "Can't fetch local revision (neither .svn nor .git found)" >&2
22 # TODO: test on old systems, I think I saw some `which`
23 # implementations returning "nothing found" or something
24 # like that, making the later if ( ! $svn_exe ) always false
27 if test -z "$git_exe"; then
28 echo "Can't fetch SVN revision: no git executable found" >&2
32 rev=`${git_exe} log --grep=git-svn -1 | grep git-svn | cut -d@ -f2 | cut -d' ' -f1`
34 if test -z "$rev"; then
35 echo "Can't fetch SVN revision from git log" >&2
44 # TODO: test on old systems, I think I saw some `which`
45 # implementations returning "nothing found" or something
46 # like that, making the later if ( ! $svn_exe ) always false
49 if test -z "$svn_exe"; then
50 echo "Can't fetch SVN revision: no svn executable found" >&2
54 svn_info
=`"${svn_exe}" info | grep 'Last Changed Rev:' | cut -d: -f2`
56 if test -z "$svn_info"; then
57 echo "Can't fetch SVN revision with `svn info`" >&2
68 # Do not override the file if new detected
69 # revision isn't zero nor different from the existing one
70 if test -f $rev_file; then
71 oldrev
=`grep GEOS_SVN_REVISION ${rev_file} | awk '{print $2}'`
72 if test "$rev" = 0 -o "$rev" = "$oldrev"; then
73 echo "Not updating existing rev file at $oldrev" >&2
78 echo "#define GEOS_SVN_REVISION $rev" |
tee $rev_file
79 echo "Wrote rev '$rev' in file '$rev_file'" >&2
82 # Read the svn revision number