#!/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 it exists and... # - envvar WANT_AUTOMAKE is set to `1.7' # -or- # - `Makefile.in' was generated by automake-1.7, which # specifically needs automake-1.7 # -or- # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.7 # - 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, which # specifically needs automake-1.6 # -or- # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.6 # - runs automake-1.5 if it exists and... # - envvar WANT_AUTOMAKE is set to `1.5' # -or- # - `Makefile.in' was generated by automake-1.5, which # specifically needs automake-1.5 # -or- # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.5 # - runs automake-1.4 if it exists and... # - envvar WANT_AUTOMAKE is set to `1.4' # -or- # - `Makefile.in' was generated by automake-1.4, which # specifically needs automake-1.4 # -or- # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.4 # #use MDK::Common; sub cat_ { local *F; open F, $_[0] or return; my @l = ; wantarray ? @l : join '', @l } sub am_version { return (@versions = cat_(shift) =~ /^\s*\[?AM_AUTOMAKE_VERSION\(\[?([^\)]{2}[0-9]?)[^\)]*\]?\)/mg) ? ((sort @versions)[-1]) : ''; } 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 = "$0-1.8"; # Automake is really getting out of hand, so rather start supporting # WANT_AUTOMAKE = "1.7" the like. Unfortunately it override the old # variables, so if not set, just convert the old variables .... if ($ENV{WANT_AUTOMAKE} eq "") { if ($ENV{WANT_AUTOMAKE_1_4}) { $ENV{WANT_AUTOMAKE} = '1.4'; } elsif ($ENV{WANT_AUTOMAKE_1_5}) { $ENV{WANT_AUTOMAKE} = '1.5'; } elsif ($ENV{WANT_AUTOMAKE_1_6}) { $ENV{WANT_AUTOMAKE} = '1.6'; } } if ($ENV{WANT_AUTOMAKE} ne '1.8') { if (-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{3})/ ? $1 : '') eq '1.7' || (cat_('aclocal.m4') =~ /generated automatically by aclocal (\S{3})/ ? $1 : '') eq '1.7' || am_version('aclocal.m4') eq '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{3})/ ? $1 : '') eq '1.6' || (cat_('aclocal.m4') =~ /generated automatically by aclocal (\S{3})/ ? $1 : '') eq '1.6' || am_version('aclocal.m4') eq '1.6')) { $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 not have 1.5 ... && (($ENV{WANT_AUTOMAKE} eq '1.5') || (cat_('Makefile.in') =~ /^# Makefile\.in generated automatically by automake (\S{3})/ ? $1 : '') eq '1.5' || (cat_('aclocal.m4') =~ /generated automatically by aclocal (\S{3})/ ? $1 : '') eq '1.5' || am_version('aclocal.m4') eq '1.5')) { $ENV{WANT_AUTOMAKE} = '1.5'; # to prevent further "cats" and to enhance consistency (possible cwd etc) $binary = $binary_1_5; } elsif (-x $binary_1_4 # user may not have 1.4 ... && (($ENV{WANT_AUTOMAKE} eq '1.4') || (cat_('Makefile.in') =~ /^# Makefile\.in generated automatically by automake (\S{3})/ ? $1 : '') eq '1.4' || (cat_('aclocal.m4') =~ /generated automatically by aclocal (\S{3})/ ? $1 : '') eq '1.4' || am_version('aclocal.m4') eq '1.4')) { $ENV{WANT_AUTOMAKE} = '1.4'; # to prevent further "cats" and to enhance consistency (possible cwd etc) $binary = $binary_1_4; } else { $ENV{WANT_AUTOMAKE} = '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";