aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2004-10-21 01:06:11 +0000
committerMike Frysinger <vapier@gentoo.org>2004-10-21 01:06:11 +0000
commit9db628b01ac216f4091eba045dc6f5bc10eb14bc (patch)
tree71d33046088c7d7ee9613bacb468f1509c4a966b
parentUpdate comments to show that we check for 2.13 and not 2.1. (diff)
downloadautotools-wrappers-9db628b01ac216f4091eba045dc6f5bc10eb14bc.tar.gz
autotools-wrappers-9db628b01ac216f4091eba045dc6f5bc10eb14bc.tar.bz2
autotools-wrappers-9db628b01ac216f4091eba045dc6f5bc10eb14bc.zip
initial import
Break the autoconf wrapper (ac-wrapper.pl) off into its own package. This updated version resolves #56670 and #66478.
-rw-r--r--[-rwxr-xr-x]ac-wrapper.pl141
1 files changed, 92 insertions, 49 deletions
diff --git a/ac-wrapper.pl b/ac-wrapper.pl
index 984ce67..f041cdb 100755..100644
--- a/ac-wrapper.pl
+++ b/ac-wrapper.pl
@@ -2,8 +2,9 @@
#
#
# Guillaume Cottenceau (gc@mandrakesoft.com)
+# Abel Cheung (deaddog@deaddog.org)
#
-# Copyright 2001 MandrakeSoft
+# Copyright 2001-2002, 2004 MandrakeSoft
#
# This software may be freely redistributed under the terms of the GNU
# public license.
@@ -12,72 +13,114 @@
# 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 autoconf-2.13
-# - runs autoconf-2.5x if it exists and...
-# - envvar WANT_AUTOCONF is set to `2.5'
+# - defaults to autoconf-2.59
+# - runs autoconf-2.13 only if:
+# - envvar WANT_AUTOCONF_2_1 is set to `1'
# -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.6 or superior, which
-# specifically needs autoconf-2.5x
+# - `configure' is already present and was generated by autoconf 2.13
+#
+#######################################################################
+#
+# ChangeLog:
+#
+# * Fri May 14 2004
+# - Use autoconf 2.59 by default, unless `configure' is generated by
+# autoconf 2.13, or WANT_AUTOCONF_2_1 is set.
+# - WANT_AUTOCONF_2_5 has no effect now
+#
+# * Thu May 27 2004
+# - Almost rewrite
+# - Introduce FORCE_AUTOCONF_2_5 (avoid misuse with WANT_*), which can be used
+# when you want to play with fire :-)
+# - More verbose and user oriented messages (gc et. al.)
#
+# * Sat Jul 03 2004
+# - require autoconf2.1 and remove special error message
+# - allow use of tools without configure.in or configure.ac (2.5 only)
+# required for autodetection by apps
-#use MDK::Common;
+use File::Basename qw(basename);
+use strict;
sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray ? @l : join '', @l }
-sub ac_version {
- return ((@versions = cat_(shift) =~ /^\s*\[?AC_PREREQ\(\[?([^\)]{3}[0-9]?)[^\)]*\]?\)/mg) ? ((sort @versions)[-1]) : '');
+
+sub errmsg {
+ my $dummy = 0;
+ my @msg = @_;
+ foreach (@msg) {
+ print STDERR (($dummy++ == 0)? "ac-wrapper: " : " ") . $_ . "\n";
+ }
+ exit 1;
}
-my $binary = "$0-2.13";
-my $binary_new = "$0-2.5x";
+errmsg ("Don't call this script directly.") if (basename("$0") eq "ac-wrapper.pl");
-# Autoconf is really getting out of hand, so rather start supporting
-# WANT_AUTOCONF = "2.5" the like. Unfortunately it override the old
-# variables, so if not set, just convert the old variables ....
-if ($ENV{WANT_AUTOCONF} eq "") {
+#
+# go away naughty guys/gals
+#
+if (($ENV{WANT_AUTOCONF_2_1}) && ($ENV{FORCE_AUTOCONF_2_5})) {
+ errmsg ("You can only set either WANT_AUTOCONF_2_1 or FORCE_AUTOCONF_2_5,",
+ "but not both.");
+}
+
+if (($ENV{WANT_AUTOCONF_2_1}) && (basename("$0") eq "autom4te")) {
+ errmsg ("Autoconf 2.13 doesn't contain autom4te.",
+ "Either unset WANT_AUTOCONF_2_1 or don't execute anything",
+ "that would use autom4te.");
+}
+
+my $binary_new = "$0-2.59";
+my $binary_old = "$0-2.13";
+my $binary = $binary_new;
+my $confversion = 'Undetected';
+
+if ((-f "configure.ac") || (-f "configure.in")) {
+#
+# autodetect routine
+#
if ($ENV{WANT_AUTOCONF_2_1}) {
- $ENV{WANT_AUTOCONF} = '2.1';
- } elsif ($ENV{WANT_AUTOCONF_2_5}) {
- $ENV{WANT_AUTOCONF} = '2.5';
+ if ((-f "configure.in") && (! -f "configure.ac")) {
+ $binary = $binary_old;
+ } else {
+ errmsg ("Since configure.ac is present, aclocal always use",
+ "autoconf 2.59, which conflicts with your choice and",
+ "causes error. You have two options:",
+ "1. Try execute command again after removing configure.ac",
+ "2. Don't set WANT_AUTOCONF_2_1 variable");
+ }
+ } elsif (!($ENV{FORCE_AUTOCONF_2_5})) {
+ # U > [0-9] in lexicon comparison
+ $confversion = (cat_('configure') =~ /^# Generated (by (?:GNU )?Autoconf|automatically using autoconf version) (\S+)/m ? $2 : 'Unknown');
+
+ if (("$confversion" lt '2.5') && (! -f "configure.ac")) {
+ $binary = $binary_old;
+ }
}
}
-if ($ENV{WANT_AUTOCONF} ne '2.1') {
- if ((! -x $binary) # handle stuff like autom4te, where only 2.5x have the binary
- || (-x $binary_new # user may have only 2.13
- && (($ENV{WANT_AUTOCONF} eq '2.5')
- || -r 'configure.ac'
- || ac_version('configure.in') gt '2.13'
- || (cat_('configure') =~ /^# Generated by Autoconf (\S+)/m ? $1 : '') gt '2.13'
- || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.6'
- || ac_version('aclocal.m4') gt '2.13'))) {
- $ENV{WANT_AUTOCONF} = '2.5'; # to prevent further "cats" and to enhance consistency (possible cwd etc)
- $binary = $binary_new;
- } else {
- $ENV{WANT_AUTOCONF} = '2.1'; # for further consistency
- }
+if ($ENV{WANT_ACWRAPPER_DEBUG}) {
+ print STDERR "ac-wrapper: DEBUG: Detected version is '$confversion'\n";
+ print STDERR "ac-wrapper: DEBUG: WANT_AUTOCONF_2_1 is set\n" if ($ENV{WANT_AUTOCONF_2_1});
+ print STDERR "ac-wrapper: DEBUG: FORCE_AUTOCONF_2_5 is set\n" if ($ENV{FORCE_AUTOCONF_2_5});
+ print STDERR "ac-wrapper: DEBUG: will execute <$binary>\n";
}
-# Set AUTOM4TE to the proper version (bug #40983).
-# Do not set it for 2.13 though, as it does not ship autom4te.
-if(($ENV{AUTOM4TE} eq "")
- && ($ENV{WANT_AUTOCONF} = '2.5')
- && ($0 ne 'autom4te')) {
- $ENV{AUTOM4TE} = "autom4te-2.5x";
-}
+#
+# for further consistency
+#
+$ENV{WANT_AUTOCONF_2_1} = 1 if ("$binary" eq "$binary_old");
+$ENV{FORCE_AUTOCONF_2_5} = 1 if ("$binary" eq "$binary_new");
-$ENV{WANT_ACWRAPPER_DEBUG} and print STDERR "ac-wrapper: will execute <$binary>\n";
+if (! -x "$binary") {
+ # this shouldn't happen
+ errmsg ("$binary is missing or not executable.",
+ "Something is very wrong.");
+}
exec $binary, @ARGV;
-die "ac-wrapper: ouch, couldn't call binary ($binary).\n";
+errmsg ("was unable to exec $binary !?");