Annotation of /trunk/autoconf/ac-wrapper-4.pl
Parent Directory | Revision Log
Revision 144 -
(hide annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File MIME type: text/plain
File size: 2785 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File MIME type: text/plain
File size: 2785 byte(s)
-import
1 | niro | 144 | #!/usr/bin/perl |
2 | # | ||
3 | # | ||
4 | # Guillaume Cottenceau (gc@mandrakesoft.com) | ||
5 | # | ||
6 | # Copyright 2001 MandrakeSoft | ||
7 | # | ||
8 | # This software may be freely redistributed under the terms of the GNU | ||
9 | # public license. | ||
10 | # | ||
11 | # You should have received a copy of the GNU General Public License | ||
12 | # along with this program; if not, write to the Free Software | ||
13 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
14 | # | ||
15 | # | ||
16 | # Executes the correct autoconf version. | ||
17 | # | ||
18 | # - defaults to autoconf-2.13 | ||
19 | # - runs autoconf-2.5x if it exists and... | ||
20 | # - envvar WANT_AUTOCONF is set to `2.5' | ||
21 | # -or- | ||
22 | # - configure.ac is present | ||
23 | # -or- | ||
24 | # - `configure.in' contains AC_PREREQ and the value's 3 first letters | ||
25 | # are stringwise greater than '2.13' | ||
26 | # -or- | ||
27 | # - `configure' is already present and was generated by autoconf greater than | ||
28 | # '2.13' | ||
29 | # -or- | ||
30 | # - `Makefile.in' was generated by automake-1.6 or superior, which | ||
31 | # specifically needs autoconf-2.5x | ||
32 | # | ||
33 | |||
34 | #use MDK::Common; | ||
35 | |||
36 | sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray ? @l : join '', @l } | ||
37 | sub ac_version { | ||
38 | return ((@versions = cat_(shift) =~ /^\s*\[?AC_PREREQ\(\[?([^\)]{3}[0-9]?)[^\)]*\]?\)/mg) ? ((sort @versions)[-1]) : ''); | ||
39 | } | ||
40 | |||
41 | my $binary = "$0-2.13"; | ||
42 | my $binary_new = "$0-2.5x"; | ||
43 | |||
44 | # Autoconf is really getting out of hand, so rather start supporting | ||
45 | # WANT_AUTOCONF = "2.5" the like. Unfortunately it override the old | ||
46 | # variables, so if not set, just convert the old variables .... | ||
47 | if ($ENV{WANT_AUTOCONF} eq "") { | ||
48 | if ($ENV{WANT_AUTOCONF_2_1}) { | ||
49 | $ENV{WANT_AUTOCONF} = '2.1'; | ||
50 | } elsif ($ENV{WANT_AUTOCONF_2_5}) { | ||
51 | $ENV{WANT_AUTOCONF} = '2.5'; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | if ($ENV{WANT_AUTOCONF} ne '2.1') { | ||
56 | if ((! -x $binary) # handle stuff like autom4te, where only 2.5x have the binary | ||
57 | || (-x $binary_new # user may have only 2.13 | ||
58 | && (($ENV{WANT_AUTOCONF} eq '2.5') | ||
59 | || -r 'configure.ac' | ||
60 | || ac_version('configure.in') gt '2.13' | ||
61 | || (cat_('configure') =~ /^# Generated by Autoconf (\S+)/m ? $1 : '') gt '2.13' | ||
62 | || (cat_('Makefile.in') =~ /^# Makefile\.in generated by automake (\S+)/ ? $1 : '') ge '1.6' | ||
63 | || ac_version('aclocal.m4') gt '2.13'))) { | ||
64 | $ENV{WANT_AUTOCONF} = '2.5'; # to prevent further "cats" and to enhance consistency (possible cwd etc) | ||
65 | $binary = $binary_new; | ||
66 | } else { | ||
67 | $ENV{WANT_AUTOCONF} = '2.1'; # for further consistency | ||
68 | } | ||
69 | } | ||
70 | |||
71 | # Set AUTOM4TE to the proper version (bug #40983). | ||
72 | # Do not set it for 2.13 though, as it does not ship autom4te. | ||
73 | if(($ENV{AUTOM4TE} eq "") | ||
74 | && ($ENV{WANT_AUTOCONF} = '2.5') | ||
75 | && ($0 ne 'autom4te')) { | ||
76 | $ENV{AUTOM4TE} = "autom4te-2.5x"; | ||
77 | } | ||
78 | |||
79 | $ENV{WANT_ACWRAPPER_DEBUG} and print STDERR "ac-wrapper: will execute <$binary>\n"; | ||
80 | |||
81 | exec $binary, @ARGV; | ||
82 | |||
83 | die "ac-wrapper: ouch, couldn't call binary ($binary).\n"; |