summaryrefslogtreecommitdiff
path: root/devel/kdevelop/files/patch-admin-detect-autoconf.pl
diff options
context:
space:
mode:
Diffstat (limited to 'devel/kdevelop/files/patch-admin-detect-autoconf.pl')
-rw-r--r--devel/kdevelop/files/patch-admin-detect-autoconf.pl127
1 files changed, 106 insertions, 21 deletions
diff --git a/devel/kdevelop/files/patch-admin-detect-autoconf.pl b/devel/kdevelop/files/patch-admin-detect-autoconf.pl
index 75af1ec14f63..6ee621816523 100644
--- a/devel/kdevelop/files/patch-admin-detect-autoconf.pl
+++ b/devel/kdevelop/files/patch-admin-detect-autoconf.pl
@@ -1,5 +1,5 @@
---- admin/detect-autoconf.pl.orig 2007-10-08 13:35:17.000000000 +0200
-+++ admin/detect-autoconf.pl 2007-10-20 13:42:33.000000000 +0200
+--- admin/detect-autoconf.pl.orig 2008-02-13 14:19:34.000000000 +0100
++++ admin/detect-autoconf.pl 2008-02-27 15:46:54.000000000 +0100
@@ -3,6 +3,9 @@
# Try to locate best version of auto*
# By Michael Pyne <michael.pyne@kdemail.net>
@@ -10,10 +10,77 @@
# Copyright (c) 2005.
# This code is public domain. You may use it however you like (including
# relicensing).
-@@ -21,75 +24,6 @@
+@@ -21,155 +24,6 @@
return "";
}
+-# Subroutine to lexicographically compare two version strings, a and b.
+-# If a > b, 1 is returned.
+-# If a == b, 0 is returned.
+-# If a < b, -1 is returned.
+-#
+-# If the strings are of uneven number length then the shorter string is
+-# prepended by enough zeroes to make the two string lengths equal in order to
+-# allow an accurate comparison. Note that the zero-padding only occurs in
+-# between version separators (i.e. 1.6 and 1.10, results in 1.06 vs. 1.10).
+-# Parts of the version ending in -foo (or any other text) are not considered
+-# when doing the compare. (i.e. 2.53a vs 2.53 doesn't end up in 2.53a vs.
+-# 2.053)
+-sub compareVersions
+-{
+- my ($a, $b) = @_;
+-
+- # Split the strings up by '.' (version separator) and start comparing digit
+- # length.
+-
+- my @aParts = split(/\./, $a);
+- my @bParts = split(/\./, $b);
+-
+- # Make the arrays equal in length by adding missing zeroes to the end of the
+- # version.
+- push @aParts, '0' while scalar @aParts < scalar @bParts;
+- push @bParts, '0' while scalar @bParts < scalar @aParts;
+-
+- # Now compare each individual portion.
+- for (my $i = 0; $i < scalar @aParts; ++$i)
+- {
+- # Make sure that any portion that has numbers is contiguous. I'm sure
+- # there's a technique for saving stuff like 2.52a2 but I don't feel
+- # like implementing it.
+- if ($aParts[$i] !~ /^[^\d]*\d+[^\d]*$/ or
+- $bParts[$i] !~ /^[^\d]*\d+[^\d]*$/)
+- {
+- die "Not able to compare $a to $b!\n";
+- }
+-
+- my ($aDigits) = ($aParts[$i] =~ /(\d+)/);
+- my ($bDigits) = ($bParts[$i] =~ /(\d+)/);
+-
+- # Perl is $MODERATELY_INSULTING_TERM, don't remove the parentheses in
+- # the delta calculation below.
+- my $delta = (length $aDigits) - (length $bDigits);
+- if ($delta < 0) # b is longer
+- {
+- my $replacement = ('0' x (-$delta)) . $aDigits;
+- $aParts[$i] =~ s/$aDigits/$replacement/;
+- }
+- elsif ($delta > 0) # a is longer
+- {
+- my $replacement = ('0' x $delta) . $bDigits;
+- $bParts[$i] =~ s/$bDigits/$replacement/;
+- }
+- }
+-
+- # Arrays now have standardized version components, let's re-merge them
+- # to strings to do the compare.
+- my $newA = join('.', @aParts);
+- my $newB = join('.', @bParts);
+-
+- return 1 if ($newA gt $newB);
+- return -1 if ($newA lt $newB);
+- return 0;
+-}
+-
-# Subroutine to determine the highest installed version of the given program,
-# searching from the given paths.
-sub findBest
@@ -22,9 +89,10 @@
- my $best_version_found = '0'; # Deliberately a string.
- my %versions;
- my %minimumVersions = (
-- 'autoconf' => '2.5',
+- 'autoconf' => '2.5',
- 'automake' => '1.6',
- );
+- my $sgn; # Used for compareVersions results.
-
- # Allow user to use environment variable to override search.
- return $ENV{uc $program} if $ENV{uc $program};
@@ -38,9 +106,11 @@
- next unless -x $file;
-
- ($version) = $file =~ /$prefix\/$program-?(.*)$/;
-- $version =~ s/-|\.//g;
-- # Don't check the -wrapper ones
-- next if $version eq "wrapper";
+-
+- # Don't check the -wrapper ones (or any other non program one).
+- # The real deal should start with a version number, or have no
+- # suffix at all.
+- next if $version =~ /^[^\d]/;
-
- # Special case some programs to make sure it has a minimum version.
- if (not $version and exists $minimumVersions{$program})
@@ -49,15 +119,20 @@
- my $versionOutput = `$program --version 2>/dev/null | head -n 1`;
-
- # If we can't run the script to get the version it likely won't work later.
-- next unless $versionOutput;
+- next unless $versionOutput;
-
- # Use number.number for version (we don't need the excess in general).
-- ($versionOutput) = ($versionOutput =~ /(\d\.\d)/);
+- ($versionOutput) = ($versionOutput =~ /(\d+\.\d+)/);
+-
+- # compareVersions returns -1 if the left argument is less than
+- # the right argument. It can also die for invalid input so
+- # wrap with eval.
+- eval {
+- $sgn = compareVersions($versionOutput, $min_version);
+- };
-
-- # Use lt to do lexicographical comparison of strings (which should be
-- # equivalent and doesn't involve issues with floating point conversions).
-- if (not $versionOutput or $versionOutput lt $min_version)
-- {
+- # $@ would be set if an error was encountered.
+- if ($@ or not $versionOutput or $sgn == -1) {
- next;
- }
- }
@@ -73,7 +148,12 @@
- $versions{$version} = $file;
-
- # Use string comparison so that e.g. 253a will be > 253 but < 254.
-- if ($version gt $best_version_found)
+- # See above about the need for eval.
+- eval {
+- $sgn = compareVersions($version, $best_version_found);
+- };
+-
+- if (not $@ and $sgn == 1)
- {
- $best_version_found = $version;
- }
@@ -86,7 +166,7 @@
# Find an appropriate "which" program for later use by the shell script calling
# us.
sub findWhich
-@@ -103,17 +37,6 @@
+@@ -183,17 +37,6 @@
}
}
@@ -104,7 +184,7 @@
# SCRIPT STARTS.
# Search in path.
-@@ -123,49 +46,16 @@
+@@ -203,48 +46,16 @@
unshift @paths, '/usr/local/bin' unless grep $_ eq '/usr/local/bin', @paths;
unshift @paths, '/usr/bin' unless grep $_ eq '/usr/bin', @paths;
@@ -125,12 +205,12 @@
-
-($automake_suffix) = $automake =~ /.*automake(.*)$/;
-
--# Use unsermake if we found it.
--$automake = "$unsermake -c" if $unsermake;
--
-# Find matching automake companions.
-$aclocal = findProgram('aclocal', $automake_suffix);
-
+-# Use unsermake if we found it.
+-$automake = "$unsermake -c" if ($unsermake and $aclocal);
+-
$which = findWhich();
-# Make sure we have all of the needed programs.
@@ -138,8 +218,7 @@
-{
- unless(${$i})
- {
-- print "# Unable to find $i!!\n";
-- exit 1;
+- print STDERR "# Unable to find $i!!\n";
- }
-}
-
@@ -159,3 +238,9 @@
WHICH="$which"
+@@ -252,5 +63,3 @@
+ EOF
+
+ exit 0;
+-
+-# vim: set noet ts=8 sw=4: