#!/bin/sh # # Based on the am-wrapper.pl script provided by MandrakeSoft # # This software may be freely redistributed under the terms of the GNU # public license. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ####################################################################### # # Executes the correct autoconf version. # # - defaults to automake-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 # ####################################################################### if [ "${0##*/}" = "am-wrapper.sh" ]; then echo "Don't call this script directly." >&2 exit 1 fi binary_1_4="${0}-1.4" binary_1_5="${0}-1.5" binary_1_6="${0}-1.6" binary_1_7="${0}-1.7" binary_1_8="${0}-1.8" binary="${binary_1_8}" # # autodetect routine # if [ "${WANT_AUTOMAKE}" != "1.8" ]; then if [ "${WANT_AUTOMAKE}" = "1.7" ]; then binary="${binary_1_7}" elif [ "${WANT_AUTOMAKE}" = "1.6" ]; then binary="${binary_1_6}" elif [ "${WANT_AUTOMAKE}" = "1.5" ]; then binary="${binary_1_5}" elif [ "${WANT_AUTOMAKE}" = "1.4" ]; then binary="${binary_1_4}" else if [ -r "Makefile.in" ]; then confversion_mf=$(perl -ne 'if (/^# Makefile\.in generated (?:automatically )?by automake (\S{3})/) { print $1; exit; }' Makefile.in) fi if [ -r "aclocal.m4" ]; then confversion_ac=$(perl -ne 'if (/generated automatically by aclocal (\S{3})/) { print $1; exit; }' aclocal.m4) confversion_am=$(perl -ne 'if (/^\s*\[?AM_AUTOMAKE_VERSION\(\[?([^\)]{2}[0-9]?)[^\)]*\]?\)/) { print $1; exit; }' aclocal.m4) fi if [ "${confversion_mf}" = "1.7" -o "${confversion_ac}" = "1.7" -o "${confversion_am}" = "1.7" ]; then binary="${binary_1_7}" elif [ "${confversion_mf}" = "1.6" -o "${confversion_ac}" = "1.6" -o "${confversion_am}" = "1.6" ]; then binary="${binary_1_6}" elif [ "${confversion_mf}" = "1.5" -o "${confversion_ac}" = "1.5" -o "${confversion_am}" = "1.5" ]; then binary="${binary_1_5}" elif [ "${confversion_mf}" = "1.4" -o "${confversion_ac}" = "1.4" -o "${confversion_am}" = "1.4" ]; then binary="${binary_1_4}" fi fi fi if [ "${WANT_AMWRAPPER_DEBUG}" ]; then if [ "${WANT_AUTOMAKE}" ]; then echo "am-wrapper: DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}" >&2 fi echo "am-wrapper: DEBUG: will execute <$binary>" >&2 fi # # for further consistency # if [ "${binary}" = "${binary_1_8}" ]; then export WANT_AUTOMAKE="1.8" elif [ "${binary}" = "${binary_1_7}" ]; then export WANT_AUTOMAKE="1.7" elif [ "${binary}" = "${binary_1_6}" ]; then export WANT_AUTOMAKE="1.6" elif [ "${binary}" = "${binary_1_5}" ]; then export WANT_AUTOMAKE="1.5" elif [ "${binary}" = "${binary_1_4}" ]; then export WANT_AUTOMAKE="1.4" fi if [ ! -x "${binary}" ]; then # this shouldn't happen echo "am-wrapper: $binary is missing or not executable." >&2 echo " Please try emerging the correct version of automake." >&2 exit 1 fi exec "$binary" "$@" echo "am-wrapper: was unable to exec $binary !?" >&2 exit 1