| 1 |
#!/bin/bash
|
| 2 |
# Copyright 1999-2004 Gentoo Foundation
|
| 3 |
# Distributed under the terms of the GNU General Public License v2
|
| 4 |
# $Header: /var/cvsroot/gentoo-x86/sys-devel/autoconf-wrapper/files/ac-wrapper-2.sh,v 1.2 2005/05/14 17:40:25 vapier Exp $
|
| 5 |
|
| 6 |
# Based on the ac-wrapper.pl script provided by MandrakeSoft
|
| 7 |
# Rewritten in bash by Gregorio Guidi
|
| 8 |
#
|
| 9 |
# Executes the correct autoconf version.
|
| 10 |
#
|
| 11 |
# - defaults to latest version (2.5x)
|
| 12 |
# - runs autoconf 2.13 only if:
|
| 13 |
# - envvar WANT_AUTOCONF is set to `2.1'
|
| 14 |
# -or-
|
| 15 |
# - `configure' is already present and was generated by autoconf 2.13
|
| 16 |
|
| 17 |
if [ "${0##*/}" = "ac-wrapper.sh" ] ; then
|
| 18 |
echo "Don't call this script directly" >&2
|
| 19 |
exit 1
|
| 20 |
fi
|
| 21 |
|
| 22 |
if [ "${WANT_AUTOCONF}" = "2.1" -a "${0##*/}" = "autom4te" ] ; then
|
| 23 |
echo "ac-wrapper: Autoconf 2.13 doesn't contain autom4te." >&2
|
| 24 |
echo " Either unset WANT_AUTOCONF or don't execute anything" >&2
|
| 25 |
echo " that would use autom4te." >&2
|
| 26 |
exit 1
|
| 27 |
fi
|
| 28 |
|
| 29 |
binary_new="${0}-2.59"
|
| 30 |
binary_old="${0}-2.13"
|
| 31 |
binary="${binary_new}"
|
| 32 |
|
| 33 |
#
|
| 34 |
# autodetect routine
|
| 35 |
#
|
| 36 |
if [ "${WANT_AUTOCONF}" != "2.5" ] ; then
|
| 37 |
if [ "${WANT_AUTOCONF}" = "2.1" ] ; then
|
| 38 |
if [ ! -f "configure.ac" ] ; then
|
| 39 |
binary="${binary_old}"
|
| 40 |
else
|
| 41 |
echo "ac-wrapper: Since configure.ac is present, aclocal always use" >&2
|
| 42 |
echo " autoconf 2.59, which conflicts with your choice and" >&2
|
| 43 |
echo " causes error. You have two options:" >&2
|
| 44 |
echo " 1. Try execute command again after removing configure.ac" >&2
|
| 45 |
echo " 2. Don't set WANT_AUTOCONF" >&2
|
| 46 |
exit 1
|
| 47 |
fi
|
| 48 |
else
|
| 49 |
# Automake-1.7 and better requie autoconf-2.5x
|
| 50 |
case "${WANT_AUTOMAKE}" in
|
| 51 |
1.[7-9]) ;;
|
| 52 |
*)
|
| 53 |
if [ -r "configure" ] ; then
|
| 54 |
confversion=$(gawk \
|
| 55 |
'{
|
| 56 |
if (match($0,
|
| 57 |
"^# Generated (by (GNU )?Autoconf|automatically using autoconf version) ([0-9].[0-9])",
|
| 58 |
res))
|
| 59 |
{ print res[3]; exit }
|
| 60 |
}' configure)
|
| 61 |
fi
|
| 62 |
if [ "${confversion}" = "2.1" -a ! -f "configure.ac" ] ; then
|
| 63 |
binary="${binary_old}"
|
| 64 |
fi
|
| 65 |
esac
|
| 66 |
fi
|
| 67 |
fi
|
| 68 |
|
| 69 |
if [ "${WANT_ACWRAPPER_DEBUG}" ] ; then
|
| 70 |
if [ -n "${WANT_AUTOCONF}" ] ; then
|
| 71 |
echo "ac-wrapper: DEBUG: WANT_AUTOCONF is set to ${WANT_AUTOCONF}" >&2
|
| 72 |
fi
|
| 73 |
echo "ac-wrapper: DEBUG: will execute <$binary>" >&2
|
| 74 |
fi
|
| 75 |
|
| 76 |
#
|
| 77 |
# for further consistency
|
| 78 |
#
|
| 79 |
if [ "$binary" = "$binary_new" ] ; then
|
| 80 |
export WANT_AUTOCONF="2.5"
|
| 81 |
elif [ "$binary" = "$binary_old" ] ; then
|
| 82 |
export WANT_AUTOCONF="2.1"
|
| 83 |
fi
|
| 84 |
|
| 85 |
if [ ! -x "$binary" ] ; then
|
| 86 |
# this shouldn't happen
|
| 87 |
echo "ac-wrapper: $binary is missing or not executable." >&2
|
| 88 |
echo " Please try emerging the correct version of autoconf." >&2
|
| 89 |
exit 1
|
| 90 |
fi
|
| 91 |
|
| 92 |
exec "$binary" "$@"
|
| 93 |
|
| 94 |
echo "ac-wrapper: was unable to exec $binary !?" >&2
|
| 95 |
exit 1
|