#!/usr/bin/perl # # # Guillaume Cottenceau (gc@mandrakesoft.com) # Abel Cheung (deaddog@deaddog.org) # # Copyright 2001-2002, 2004 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 autoconf-2.59 # - runs autoconf-2.13 only if: # - envvar WANT_AUTOCONF is set to `2.1' # -or- # - `configure' is already present and was generated by autoconf 2.13 # ####################################################################### use strict; sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ } sub cat_ { open(my $F, $_[0]) or return; my @l = <$F>; wantarray() ? @l : join '', @l } sub errmsg { my $dummy = 0; my @msg = @_; foreach (@msg) { print STDERR (($dummy++ == 0)? "ac-wrapper: " : " ") . $_ . "\n"; } exit 1; } errmsg ("Don't call this script directly.") if (basename("$0") eq "ac-wrapper.pl"); if (($ENV{WANT_AUTOCONF} eq '2.1') && (basename("$0") eq "autom4te")) { errmsg ("Autoconf 2.13 doesn't contain autom4te.", "Either unset WANT_AUTOCONF 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; if ((-f "configure.ac") || (-f "configure.in")) { # # autodetect routine # if ($ENV{WANT_AUTOCONF} ne '2.5') { if ($ENV{WANT_AUTOCONF} eq '2.1') { if (! -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"); } } else { # U > [0-9] in lexicon comparison $confversion = (cat_('configure') =~ /^# Generated (by (?:GNU )?Autoconf|automatically using autoconf version) (\S{3})/m ? $2 : 'Unknown'); if (("$confversion" eq '2.1') && (! -f "configure.ac")) { $binary = $binary_old; } } } } if ($ENV{WANT_ACWRAPPER_DEBUG}) { print STDERR "ac-wrapper: DEBUG: WANT_AUTOCONF is set to $ENV{WANT_AUTOCONF}\n" if ($ENV{WANT_AUTOCONF}); print STDERR "ac-wrapper: DEBUG: will execute <$binary>\n"; } # # for further consistency # $ENV{WANT_AUTOCONF} = '2.5' if ("$binary" eq "$binary_new"); $ENV{WANT_AUTOCONF} = '2.1' if ("$binary" eq "$binary_old"); if (! -x "$binary") { # this shouldn't happen errmsg ("$binary is missing or not executable.", "Please try emerging the correct version of autoconf."); } exec $binary, @ARGV; errmsg ("was unable to exec $binary !?");