summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2004-11-14 05:32:54 +0000
committerMike Frysinger <vapier@gentoo.org>2004-11-14 05:32:54 +0000
commita748dea265c018d4b717987f68b53b05f1907837 (patch)
treeab1e307d3fd677da35ae6ad8f34471dd8f15274f
parentinitial ebuild (diff)
downloadautotools-wrappers-am-1.tar.gz
autotools-wrappers-am-1.tar.bz2
autotools-wrappers-am-1.zip
Punt perl version of wrapper in favor of bash by Gregorio Guidi #66478.am-1
-rwxr-xr-xam-wrapper.pl137
-rwxr-xr-xam-wrapper.sh120
2 files changed, 120 insertions, 137 deletions
diff --git a/am-wrapper.pl b/am-wrapper.pl
deleted file mode 100755
index 4deff78..0000000
--- a/am-wrapper.pl
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/perl
-#
-#
-# Author: Guillaume Cottenceau (gc@mandrakesoft.com)
-# Modified by: Martin Schlemmer (azarah@gentoo.org)
-#
-# Copyright 2001 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.4
-# - runs automake-1.8 if it exists and...
-# - envvar WANT_AUTOMAKE is set to `1.8'
-# -or-
-# - `Makefile.in' was generated by automake-1.8 or superior, which
-# specifically needs automake-1.8
-# -or_
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.8
-# - runs automake-1.7 if it exists and...
-# - envvar WANT_AUTOMAKE is set to `1.7'
-# -or-
-# - `Makefile.in' was generated by automake-1.7 or superior, which
-# specifically needs automake-1.7
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifyint the use of 1.7
-# -or-
-# - runs automake-1.6 if it exists and...
-# - envvar WANT_AUTOMAKE is set to `1.6'
-# -or-
-# - `Makefile.in' was generated by automake-1.6 or superior, which
-# specifically needs automake-1.6
-# -or-
-# - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifyint the use of 1.6
-# -or-
-# - `configure.in' contains AC_PREREQ and the value's 3 first letters
-# are stringwise greater than '2.53c'
-# -or-
-# - `configure' is already present and was generated by autoconf greater than
-# '2.53c'
-# - runs automake-1.5 if it exists and...
-# - envvar WANT_AUTOMAKE is set to `1.5'
-# -or-
-# - configure.ac is present
-# -or-
-# - `configure.in' contains AC_PREREQ and the value's 3 first letters
-# are stringwise greater than '2.13'
-# -or-
-# - `configure' is already present and was generated by autoconf greater than
-# '2.13'
-# -or-
-# - `Makefile.in' was generated by automake-1.5 or superior, which
-# specifically needs automake-1.5
-#
-#use MDK::Common;
-
-sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray ? @l : join '', @l }
-sub am_version {
- my $file = cat_(shift);
- return (@versions = $file =~ /^\s*\[?AM_AUTOMAKE_VERSION\(\[?([^\)]{3}[0-9]?)[^\)]*\]?\)/mg) ? ((sort @versions)[-1]) : '';
-}
-sub ac_version {
- my $file = cat_(shift);
- return (@versions = $file =~ /^\s*\[?AC_PREREQ\(\[?([^\)]{3}[0-9]?)[^\)]*\]?\)/mg) ? ((sort @versions)[-1]) : '';
-}
-
-
-
-my $binary = "$0-1.4";
-my $binary_1_5 = "$0-1.5";
-my $binary_1_6 = "$0-1.6";
-my $binary_1_7 = "$0-1.7";
-my $binary_1_8 = "$0-1.8";
-
-# question here is do we really want 1.5 or 1.6? Out of a KDE outlook, it
-# should rather be 1.5, and since most people would rather have migrated to
-# 1.5, and then stay with it for a bit (those 1.4 die hards ..), only have
-# the 'configure.ac' test for 1.5 ...
-if ($ENV{WANT_AUTOMAKE} ne '1.4') {
- if (-x $binary_1_8 # user may not have _1_8 ...
- && (($ENV{WANT_AUTOMAKE} eq '1.8')
- || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.8'
- || (cat_('aclocal.m4') =~ /^# aclocal.m4 generated automatically by aclocal (\S+)/ ? $1 : '') ge '1.8'
- || am_version('aclocal.m4') ge '1.8')) {
- $ENV{WANT_AUTOMAKE} = '1.8'; # to prevent further "cats" and to enhance consistency (possible cwd etc)
- $binary = $binary_1_8;
- } elsif (-x $binary_1_7 # user may not have 1.7 ...
- && (($ENV{WANT_AUTOMAKE} eq '1.7')
- || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.7'
- || (cat_('aclocal.m4') =~ /^# aclocal.m4 generated automatically by aclocal (\S+)/ ? $1 : '') ge '1.7'
- || am_version('aclocal.m4') ge '1.7')) {
- $ENV{WANT_AUTOMAKE} = '1.7'; # to prevent further "cats" and to enhance consistency (possible cwd etc)
- $binary = $binary_1_7;
- } elsif (-x $binary_1_6 # user may not have 1.6 ...
- && (($ENV{WANT_AUTOMAKE} eq '1.6')
- || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.6'
- || (cat_('aclocal.m4') =~ /^# aclocal.m4 generated automatically by aclocal (\S+)/ ? $1 : '') ge '1.6'
- || am_version('aclocal.m4') ge '1.6'
- # Autoconf 2.53d and later need automake-1.6c, so enable 1.6 for 2.53
- # and up .....
- || ac_version('configure.in') gt '2.52'
- || (cat_('configure') =~ /^# Generated by Autoconf (\S+)/m ? $1 : '') gt '2.52'
- || ac_version('aclocal.m4') gt '2.52')) {
- $ENV{WANT_AUTOMAKE} = '1.6'; # to prevent further "cats" and to enhance consistency (possible cwd etc)
- $binary = $binary_1_6;
- } elsif (-x $binary_1_5 # user may have only 1.4 ...
- && (($ENV{WANT_AUTOMAKE} eq '1.5')
- || -r 'configure.ac'
- || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.5'
- || (cat_('aclocal.m4') =~ /^# aclocal.m4 generated automatically by aclocal (\S+)/ ? $1 : '') ge '1.5'
- || ac_version('configure.in') gt '2.13'
- || (cat_('configure') =~ /^# Generated by Autoconf (\S+)/m ? $1 : '') gt '2.13'
- || ac_version('aclocal.m4') gt '2.13')) {
- $ENV{WANT_AUTOMAKE} = '1.5'; # to prevent further "cats" and to enhance consistency (possible cwd etc)
- $binary = $binary_1_5;
- } else {
- if (-r 'configure.in' || -r 'configure.ac') {
- $ENV{WANT_AUTOMAKE} = '1.4'; # for further consistency
- } else {
- $ENV{WANT_AUTOMAKE} = '1.8';
- $binary = $binary_1_8;
- }
- }
-}
-
-$ENV{WANT_AMWRAPPER_DEBUG} and print STDERR "am-wrapper: will execute <$binary>\n";
-
-exec $binary, @ARGV;
-
-die "am-wrapper: ouch, couldn't call binary ($binary).\n";
diff --git a/am-wrapper.sh b/am-wrapper.sh
new file mode 100755
index 0000000..6733f65
--- /dev/null
+++ b/am-wrapper.sh
@@ -0,0 +1,120 @@
+#!/bin/bash
+# Copyright 1999-2004 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-1.sh,v 1.1 2004/11/14 05:32:54 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 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
+
+vers="$(seq 1.9 -0.1 1.4)"
+
+for v in ${vers} ; do
+ eval binary_${v/./_}="${0}-${v}"
+done
+binary="binary_1_9"
+
+#
+# autodetect routine
+#
+for v in ${vers} x ; do
+ if [ "${v}" = "x" ] ; then
+ unset WANT_AUTOMAKE
+ break
+ fi
+
+ if [ "${WANT_AUTOMAKE}" = "${v}" ] ; then
+ binary="binary_${v/./_}"
+ binary="${!binary}"
+ break
+ fi
+done
+
+do_awk() {
+ local file=$1 ; shift
+ local arg=$1 ; shift
+ echo $(awk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" ${file})
+}
+
+if [ -z "${WANT_AUTOMAKE}" ] ; then
+ if [ -r "Makefile.in" ] ; then
+ confversion_mf=$(do_awk Makefile.in 2 "^# Makefile.in generated (automatically )?by automake ([0-9].[0-9])")
+ fi
+ if [ -r "aclocal.m4" ] ; then
+ confversion_ac=$(do_awk aclocal.m4 1 'generated automatically by aclocal ([0-9].[0-9])')
+ confversion_am=$(do_awk aclocal.m4 1 '[[:space:]]*\\[?AM_AUTOMAKE_VERSION\\(\\[?([0-9].[0-9])[^)]*\\]?\\)')
+ fi
+
+ for v in ${vers} ; do
+ if [ "${confversion_mf}" = "${v}" ] \
+ || [ "${confversion_ac}" = "${v}" ] \
+ || [ "${confversion_am}" = "${v}" ] ; then
+ binary="binary_${v/./_}"
+ binary="${!binary}"
+ break
+ fi
+ done
+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
+#
+for v in ${vers} ; do
+ mybin="binary_${v/./_}"
+ if [ "${binary}" = "${!mybin}" ] ; then
+ export WANT_AUTOMAKE="${v}"
+ fi
+done
+
+#
+# Now try to run the binary
+#
+if [ ! -x "${binary}" ] ; then
+ 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