aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xam-wrapper.sh106
1 files changed, 53 insertions, 53 deletions
diff --git a/am-wrapper.sh b/am-wrapper.sh
index f3704d5..dd0920f 100755
--- a/am-wrapper.sh
+++ b/am-wrapper.sh
@@ -1,50 +1,20 @@
#!/bin/sh
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-6.sh,v 1.1 2011/10/02 19:51:17 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-7.sh,v 1.1 2012/04/26 05:42:10 vapier Exp $
# Based on the am-wrapper.pl script provided by MandrakeSoft
# Rewritten in bash by Gregorio Guidi
#
# Executes the correct automake version.
#
-# - defaults to newest version available (hopefully automake-1.10)
-# - runs automake-1.9 if:
-# - envvar WANT_AUTOMAKE is set to `1.9'
+# - defaults to newest version available (hopefully automake-1.12)
+# - runs automake-1.X (where X is a valid automake version) if:
+# - envvar WANT_AUTOMAKE is set to `1.X'
# -or-
-# - `Makefile.in' was generated by automake-1.9
+# - `Makefile.in' was generated by automake-1.X
# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.9
-# - runs automake-1.8 if:
-# - envvar WANT_AUTOMAKE is set to `1.8'
-# -or-
-# - `Makefile.in' was generated by automake-1.8
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.8
-# - runs automake-1.7 if:
-# - envvar WANT_AUTOMAKE is set to `1.7'
-# -or-
-# - `Makefile.in' was generated by automake-1.7
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.7
-# - runs automake-1.6 if:
-# - envvar WANT_AUTOMAKE is set to `1.6'
-# -or-
-# - `Makefile.in'
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.6
-# - runs automake-1.5 if:
-# - envvar WANT_AUTOMAKE is set to `1.5'
-# -or-
-# - `Makefile.in' was generated by automake-1.5
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.5
-# - runs automake-1.4 if:
-# - envvar WANT_AUTOMAKE is set to `1.4'
-# -or-
-# - `Makefile.in' was generated by automake-1.4
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.4
+# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.X
warn() { printf 'am-wrapper: %s: %b\n' "${argv0}" "$*" 1>&2; }
err() { warn "$@"; exit 1; }
@@ -81,22 +51,51 @@ if [ "${argv0}" = "am-wrapper.sh" ] ; then
err "Don't call this script directly"
fi
-vers="1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4"
+if ! seq 0 0 2>/dev/null 1>&2 ; then #338518
+ seq() {
+ local f l i
+ case $# in
+ 1) f=1 i=1 l=$1;;
+ 2) f=$1 i=1 l=$2;;
+ 3) f=$1 i=$2 l=$3;;
+ esac
+ while :; do
+ [ $l -lt $f -a $i -gt 0 ] && break
+ [ $f -lt $l -a $i -lt 0 ] && break
+ echo $f
+ : $(( f += i ))
+ done
+ return 0
+ }
+fi
#
-# Export the proper variable/versions and try to locate a usuable
-# default (newer versions are preferred)
+# Set up bindings between actual version and WANT_AUTOMAKE;
+# Start with last known versions to speed up lookup process.
#
+LAST_KNOWN_AUTOMAKE_VER="12"
+vers=$(printf '1.%s ' `seq ${LAST_KNOWN_AUTOMAKE_VER} -1 4`)
+
+find_binary() {
+ local v
+ all_vers="${all_vers} $*"
+ for v in "$@" ; do
+ if [ -x "${full_argv0}-${v}" ] ; then
+ binary="${full_argv0}-${v}"
+ return 0
+ fi
+ done
+ return 1
+}
binary=""
-for v in ${vers} ; do
- if [ -z "${binary}" ] && [ -x "${full_argv0}-${v}" ] ; then
- binary="${full_argv0}-${v}"
- break
- fi
-done
+all_vers=""
+if ! find_binary ${vers} ; then
+ find_binary $(printf '1.%s ' `seq 99 -1 ${LAST_KNOWN_AUTOMAKE_VER}`)
+fi
+
if [ -z "${binary}" ] ; then
err "Unable to locate any usuable version of automake.\n" \
- "\tI tried these versions: ${vers}\n" \
+ "\tI tried these versions:${all_vers}\n" \
"\tWith a base name of '${full_argv0}'."
fi
@@ -154,11 +153,11 @@ if [ -z "${WANT_AUTOMAKE}" ] ; then
done
fi
-if [ "${WANT_AMWRAPPER_DEBUG}" ] ; then
- if [ "${WANT_AUTOMAKE}" ] ; then
+if [ -n "${WANT_AMWRAPPER_DEBUG}" ] ; then
+ if [ -n "${WANT_AUTOMAKE}" ] ; then
warn "DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}"
fi
- warn "DEBUG: will execute <$binary>"
+ warn "DEBUG: will execute <${binary}>"
fi
#
@@ -175,10 +174,11 @@ done
# Now try to run the binary
#
if [ ! -x "${binary}" ] ; then
- err "$binary is missing or not executable.\n" \
+ # this shouldn't happen
+ err "${binary} is missing or not executable.\n" \
"\tPlease try emerging the correct version of automake."
fi
-exec "$binary" "$@"
+exec "${binary}" "$@"
-err "was unable to exec $binary !?"
+err "was unable to exec ${binary} !?"