]> granicus.if.org Git - mutt/commitdiff
version.sh: support building outside of source directory
authorDavid Champion <dgc@bikeshed.us>
Wed, 29 Jun 2011 16:57:12 +0000 (11:57 -0500)
committerDavid Champion <dgc@bikeshed.us>
Wed, 29 Jun 2011 16:57:12 +0000 (11:57 -0500)
Reported by Emanuele Giaquinta <e.giaquinta@glauco.it>. Thanks also
to Michael Elkins <me@sigpipe.org>.

configure.ac
version.sh

index bbcf5f8e596050aba9137953374a7a315100c9d9..f4609172444658440386aa589f98f3bb3d9e6411 100644 (file)
@@ -7,11 +7,11 @@ AC_PREREQ([2.54])
 AC_INIT([mutt.h])
 AM_CONFIG_HEADER([config.h])
 
-mutt_cv_version=`cat $srcdir/VERSION`
+mutt_cv_version=`cat "$srcdir/VERSION"`
 AM_INIT_AUTOMAKE(mutt, $mutt_cv_version)
 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
 
-MUTT_VERSION=`sh ./version.sh`
+MUTT_VERSION=`env HGROOT="$srcdir" sh "$srcdir/version.sh"`
 AC_DEFINE_UNQUOTED(MUTT_VERSION,"$MUTT_VERSION", [Full textual version string.])
 
 AC_GNU_SOURCE
index cd902bd3845ecbea4f13f106d21aa133bde15394..1286a274473913df0e89b01e6fc14401525b4a16 100644 (file)
@@ -1,13 +1,17 @@
 #!/bin/sh
 
+# Adopt $HGROOT from the environment, if present
+HG=hg
+[ -n "$HGROOT" ] && HG="$HG -R '$HGROOT'"
+
 # Ensure that we have a repo here and that mercurial is installed.  If
 # not, just cat the VERSION file; it contains the latest release number.
-{ [ -d .hg ] && hg >/dev/null 2>&1; } || exec cat VERSION
+{ [ -d "$HGROOT/.hg" ] && $HG >/dev/null 2>&1; } || exec cat VERSION
 
 # This is a mercurial repo and we have the hg command.
 
 # Get essential properties of the current working copy
-set -- `hg parents --template='{rev} {node|short}\n'`
+set -- `$HG parents --template='{rev} {node|short}\n'`
 rev="$1"
 node="$2"
 
@@ -21,7 +25,7 @@ cleantag () {
 
 getdistance_old () {
        # fudge it
-       set -- `hg tags | sort -n +1 | egrep 'mutt-.*rel' | tail -1 | cut -d: -f1`
+       set -- `$HG tags | sort -n +1 | egrep 'mutt-.*rel' | tail -1 | cut -d: -f1`
        latesttag="$1"
        latestrev="$2"
        distance=`expr $rev - $latestrev`
@@ -29,12 +33,12 @@ getdistance_old () {
 }
 
 getdistance_new () {
-       hg parents --template='{latesttag} {latesttagdistance}\n'
+       $HG parents --template='{latesttag} {latesttagdistance}\n'
 }
 
 
 # latesttag appeared in hg 1.4.  Test for it.
-[ "`hg log -r . --template='{latesttag}'`" = '' ] && 
+[ "`$HG log -r . --template='{latesttag}'`" = '' ] && 
 set -- `getdistance_old` ||
 set -- `getdistance_new`
 
@@ -48,7 +52,7 @@ else
 fi
 
 # if we have mq patches applied, mention it
-qparent=`hg log -r qparent --template='{rev}\n' 2>/dev/null || echo $rev`
+qparent=`$HG log -r qparent --template='{rev}\n' 2>/dev/null || echo $rev`
 qdelta=`expr $rev - $qparent`
 if [ $qdelta -eq 0 ]; then
        qdist=""