#!/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.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 # ####################################################################### 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)? "am-wrapper: " : " ") . $_ . "\n"; } exit 1; } errmsg ("Don't call this script directly.") if (basename("$0") eq "am-wrapper.pl"); my $binary_1_4 = "$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"; my $binary = $binary_1_8; my $confversion_mf; my $confversion_ac; my $confversion_am; # # autodetect routine # if ($ENV{WANT_AUTOMAKE} ne '1.8') { if ($ENV{WANT_AUTOMAKE} eq '1.7') { $binary = $binary_1_7; } elsif ($ENV{WANT_AUTOMAKE} eq '1.6') { $binary = $binary_1_6; } elsif ($ENV{WANT_AUTOMAKE} eq '1.5') { $binary = $binary_1_5; } elsif ($ENV{WANT_AUTOMAKE} eq '1.4') { $binary = $binary_1_4; } else { $confversion_mf = cat_('Makefile.in') =~ /^# Makefile\.in generated (?:automatically )?by automake (\S{3})/ ? $1 : ''; $confversion_ac = cat_('aclocal.m4') =~ /generated automatically by aclocal (\S{3})/ ? $1 : ''; $confversion_am = cat_('aclocal.m4') =~ /^\s*\[?AM_AUTOMAKE_VERSION\(\[?([^\)]{2}[0-9]?)[^\)]*\]?\)/mg ? $1 : ''; if ($confversion_mf eq '1.7' || $confversion_ac eq '1.7' || $confversion_am eq '1.7') { $binary = $binary_1_7; } elsif ($confversion_mf eq '1.6' || $confversion_ac eq '1.6' || $confversion_am eq '1.6') { $binary = $binary_1_6; } elsif ($confversion_mf eq '1.5' || $confversion_ac eq '1.5' || $confversion_am eq '1.5') { $binary = $binary_1_5; } elsif ($confversion_mf eq '1.4' || $confversion_ac eq '1.4' || $confversion_am eq '1.4') { $binary = $binary_1_4; } } } if ($ENV{WANT_AMWRAPPER_DEBUG}) { print STDERR "am-wrapper: DEBUG: WANT_AUTOMAKE is set to $ENV{WANT_AUTOMAKE}\n" if ($ENV{WANT_AUTOMAKE}); print STDERR "am-wrapper: DEBUG: will execute <$binary>\n"; } # # for further consistency # $ENV{WANT_AUTOMAKE} = '1.8' if ("$binary" eq "$binary_1_8"); $ENV{WANT_AUTOMAKE} = '1.7' if ("$binary" eq "$binary_1_7"); $ENV{WANT_AUTOMAKE} = '1.6' if ("$binary" eq "$binary_1_6"); $ENV{WANT_AUTOMAKE} = '1.5' if ("$binary" eq "$binary_1_5"); $ENV{WANT_AUTOMAKE} = '1.4' if ("$binary" eq "$binary_1_4"); 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 !?");