Merge pull request #240 from t-b/update_openssl_to_101i
[msysgit.git] / bin / autoreconf
blobf1dfef26757d9b8105670feb09a41c333c8b1f9f
1 #! /bin/perl -w
2 # -*- perl -*-
3 # Generated from autoreconf.in; do not edit by hand.
5 eval 'case $# in 0) exec /bin/perl -S "$0";; *) exec /bin/perl -S "$0" "$@";; esac'
6 if 0;
8 # autoreconf - install the GNU Build System in a directory tree
9 # Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
15 # any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 # 02110-1301, USA.
27 # Written by David J. MacKenzie.
28 # Extended and rewritten in Perl by Akim Demaille.
30 BEGIN
32 my $datadir = $ENV{'autom4te_perllibdir'} || '/usr/share/autoconf';
33 unshift @INC, $datadir;
35 # Override SHELL. On DJGPP SHELL may not be set to a shell
36 # that can handle redirection and quote arguments correctly,
37 # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
38 # has detected.
39 $ENV{'SHELL'} = '/bin/sh' if ($^O eq 'dos');
42 use Autom4te::ChannelDefs;
43 use Autom4te::Channels;
44 use Autom4te::Configure_ac;
45 use Autom4te::FileUtils;
46 use Autom4te::General;
47 use Autom4te::XFile;
48 # Do not use Cwd::chdir, since it might hang.
49 use Cwd 'cwd';
50 use strict;
52 ## ----------- ##
53 ## Variables. ##
54 ## ----------- ##
56 # $HELP
57 # -----
58 $help = "Usage: $0 [OPTION] ... [DIRECTORY] ...
60 Run `autoconf' (and `autoheader', `aclocal', `automake', `autopoint'
61 (formerly `gettextize'), and `libtoolize' where appropriate)
62 repeatedly to remake the GNU Build System files in specified
63 DIRECTORIES and their subdirectories (defaulting to `.').
65 By default, it only remakes those files that are older than their
66 sources. If you install new versions of the GNU Build System,
67 you can make `autoreconf' remake all of the files by giving it the
68 `--force' option.
70 Operation modes:
71 -h, --help print this help, then exit
72 -V, --version print version number, then exit
73 -v, --verbose verbosely report processing
74 -d, --debug don't remove temporary files
75 -f, --force consider all files obsolete
76 -i, --install copy missing auxiliary files
77 --no-recursive don't rebuild sub-packages
78 -s, --symlink with -i, install symbolic links instead of copies
79 -m, --make when applicable, re-run ./configure && make
80 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
82 " . Autom4te::ChannelDefs::usage . "
84 The environment variable \`WARNINGS\' is honored. Some subtools might
85 support other warning types, using \`all' is encouraged.
87 Library directories:
88 -B, --prepend-include=DIR prepend directory DIR to search path
89 -I, --include=DIR append directory DIR to search path
91 The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
92 AUTOPOINT, LIBTOOLIZE, M4 are honored.
94 Report bugs to <bug-autoconf\@gnu.org>.
97 # $VERSION
98 # --------
99 $version = "autoreconf (GNU Autoconf) 2.61
100 Copyright (C) 2006 Free Software Foundation, Inc.
101 This is free software. You may redistribute copies of it under the terms of
102 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
103 There is NO WARRANTY, to the extent permitted by law.
105 Written by David J. MacKenzie and Akim Demaille.
108 # Lib files.
109 my $autoconf = $ENV{'AUTOCONF'} || '/usr/bin/autoconf';
110 my $autoheader = $ENV{'AUTOHEADER'} || '/usr/bin/autoheader';
111 my $automake = $ENV{'AUTOMAKE'} || 'automake';
112 my $aclocal = $ENV{'ACLOCAL'} || 'aclocal';
113 my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
114 my $autopoint = $ENV{'AUTOPOINT'} || 'autopoint';
116 # --install -- as --add-missing in other tools.
117 my $install = 0;
118 # symlink -- when --install, use symlinks instead.
119 my $symlink = 0;
120 # Does aclocal support --force?
121 my $aclocal_supports_force = 0;
122 # Does automake support --force-missing?
123 my $automake_supports_force_missing = 0;
125 my @prepend_include;
126 my @include;
128 # List of command line warning requests.
129 my @warning;
131 # Rerun `./configure && make'?
132 my $make = 0;
134 # Recurse into subpackages
135 my $recursive = 1;
137 ## ---------- ##
138 ## Routines. ##
139 ## ---------- ##
142 # parse_args ()
143 # -------------
144 # Process any command line arguments.
145 sub parse_args ()
147 my $srcdir;
149 getopt ("W|warnings=s" => \@warning,
150 'I|include=s' => \@include,
151 'B|prepend-include=s' => \@prepend_include,
152 'i|install' => \$install,
153 's|symlink' => \$symlink,
154 'm|make' => \$make,
155 'recursive!' => \$recursive);
157 # Split the warnings as a list of elements instead of a list of
158 # lists.
159 @warning = map { split /,/ } @warning;
160 parse_WARNINGS;
161 parse_warnings '--warnings', @warning;
163 # Even if the user specified a configure.ac, trim to get the
164 # directory, and look for configure.ac again. Because (i) the code
165 # is simpler, and (ii) we are still able to diagnose simultaneous
166 # presence of configure.ac and configure.in.
167 @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
168 push @ARGV, '.' unless @ARGV;
170 if ($verbose && $debug)
172 for my $prog ($autoconf, $autoheader,
173 $automake, $aclocal,
174 $autopoint,
175 $libtoolize)
177 xsystem ("$prog --version | sed 1q >&2");
178 print STDERR "\n";
182 $aclocal_supports_force = `$aclocal --help` =~ /--force/;
183 $automake_supports_force_missing = `$automake --help` =~ /--force-missing/;
185 # Dispatch autoreconf's option to the tools.
186 # --include;
187 $autoconf .= join (' --include=', '', @include);
188 $autoconf .= join (' --prepend-include=', '', @prepend_include);
189 $autoheader .= join (' --include=', '', @include);
190 $autoheader .= join (' --prepend-include=', '', @prepend_include);
192 # --install and --symlink;
193 if ($install)
195 $automake .= ' --add-missing';
196 $automake .= ' --copy' unless $symlink;
197 $libtoolize .= ' --copy' unless $symlink;
199 # --force;
200 if ($force)
202 $aclocal .= ' --force'
203 if $aclocal_supports_force;
204 $autoconf .= ' --force';
205 $autoheader .= ' --force';
206 $automake .= ' --force-missing'
207 if $automake_supports_force_missing;
208 $autopoint .= ' --force';
209 $libtoolize .= ' --force';
211 else
213 # The implementation of --no-force is bogus in all implementations
214 # of Automake up to 1.8, so we avoid it in these cases. (Automake
215 # 1.8 is the first version where aclocal supports force, hence
216 # the condition.)
217 $automake .= ' --no-force'
218 if $aclocal_supports_force;
220 # --verbose --verbose or --debug;
221 if ($verbose > 1 || $debug)
223 $autoconf .= ' --verbose';
224 $autoheader .= ' --verbose';
225 $automake .= ' --verbose';
226 $aclocal .= ' --verbose';
228 if ($debug)
230 $autoconf .= ' --debug';
231 $autoheader .= ' --debug';
232 $libtoolize .= ' --debug';
234 # --warnings;
235 if (@warning)
237 my $warn = ' --warnings=' . join (',', @warning);
238 $autoconf .= $warn;
239 $autoheader .= $warn;
240 $automake .= $warn
241 if `$automake --help` =~ /--warnings/;
246 # &run_aclocal ($ACLOCAL, $FLAGS)
247 # -------------------------------
248 # Update aclocal.m4 as lazily as possible, as aclocal pre-1.8 always
249 # overwrites aclocal.m4, hence triggers autoconf, autoheader, automake
250 # etc. uselessly. aclocal 1.8+ does not need this.
251 sub run_aclocal ($$)
253 my ($aclocal, $flags) = @_;
255 # aclocal 1.8+ does all this for free. It can be recognized by its
256 # --force support.
257 if ($aclocal_supports_force)
259 xsystem ("$aclocal $flags");
261 else
263 xsystem ("$aclocal $flags --output=aclocal.m4t");
264 # aclocal may produce no output.
265 if (-f 'aclocal.m4t')
267 update_file ('aclocal.m4t', 'aclocal.m4');
268 # Make sure that the local m4 files are older than
269 # aclocal.m4.
271 # Why is not always the case? Because we already run
272 # aclocal at first (before tracing), which, for instance,
273 # can find Gettext's macros in .../share/aclocal, so we may
274 # have had the right aclocal.m4 already. Then autopoint is
275 # run, and installs locally these M4 files. Then
276 # autoreconf, via update_file, sees it is the _same_
277 # aclocal.m4, and doesn't change its timestamp. But later,
278 # Automake's Makefile expresses that aclocal.m4 depends on
279 # these local files, which are newer, so it triggers aclocal
280 # again.
282 # To make sure aclocal.m4 is no older, we change the
283 # modification times of the local M4 files to be not newer
284 # than it.
286 # First, where are the local files?
287 my $aclocal_local_dir = '.';
288 if ($flags =~ /-I\s+(\S+)/)
290 $aclocal_local_dir = $1;
292 # All the local files newer than aclocal.m4 are to be
293 # made not newer than it.
294 my $aclocal_m4_mtime = mtime ('aclocal.m4');
295 for my $file (glob ("$aclocal_local_dir/*.m4"), 'acinclude.m4')
297 if ($aclocal_m4_mtime < mtime ($file))
299 debug "aging $file to be not newer than aclocal.m4";
300 utime $aclocal_m4_mtime, $aclocal_m4_mtime, $file;
307 # &autoreconf_current_directory
308 # -----------------------------
309 sub autoreconf_current_directory ()
311 my $configure_ac = find_configure_ac;
313 # ---------------------- #
314 # Is it using Autoconf? #
315 # ---------------------- #
317 my $uses_autoconf;
318 my $uses_gettext;
319 if (-f $configure_ac)
321 my $configure_ac_file = new Autom4te::XFile $configure_ac;
322 while ($_ = $configure_ac_file->getline)
324 s/#.*//;
325 s/dnl.*//;
326 $uses_autoconf = 1 if /AC_INIT/;
327 # See below for why we look for gettext here.
328 $uses_gettext = 1 if /^AM_GNU_GETTEXT_VERSION/;
331 if (!$uses_autoconf)
333 verb "$configure_ac: not using Autoconf";
334 return;
338 # ------------------- #
339 # Running autopoint. #
340 # ------------------- #
342 # Gettext is a bit of a problem: its macros are not necessarily
343 # visible to aclocal, so if we start with a completely striped down
344 # package (think of a fresh CVS checkout), running `aclocal' first
345 # will fail: the Gettext macros are missing.
347 # Therefore, we can't use the traces to decide if we use Gettext or
348 # not. I guess that once Gettext move to 2.5x we will be able to,
349 # but in the meanwhile forget it.
351 # We can only grep for AM_GNU_GETTEXT_VERSION in configure.ac. You
352 # might think this approach is naive, and indeed it is, as it
353 # prevents one to embed AM_GNU_GETTEXT_VERSION in another *.m4, but
354 # anyway we don't limit the generality, since... that's what
355 # autopoint does. Actually, it is even more restrictive, as it
356 # greps for `^AM_GNU_GETTEXT_VERSION('. We did this above, while
357 # scanning configure.ac.
358 if (!$uses_gettext)
360 verb "$configure_ac: not using Gettext";
362 elsif (!$install)
364 verb "$configure_ac: not running autopoint: --install not given";
366 else
368 xsystem "$autopoint";
372 # ----------------- #
373 # Running aclocal. #
374 # ----------------- #
376 # Run it first: it might discover new macros to add, e.g.,
377 # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is
378 # used.
380 # Always run it. Tracking its sources for up-to-dateness is too
381 # complex and too error prone. The best we can do is avoiding
382 # nuking the time stamp.
383 my $uses_aclocal = 1;
385 # Nevertheless, if aclocal.m4 exists and is not made by aclocal,
386 # don't run aclocal.
388 if (-f 'aclocal.m4')
390 my $aclocal_m4 = new Autom4te::XFile 'aclocal.m4';
391 $_ = $aclocal_m4->getline;
392 $uses_aclocal = 0
393 unless defined ($_) && /generated.*by aclocal/;
396 # If there are flags for aclocal in Makefile.am, use them.
397 my $aclocal_flags = '';
398 if ($uses_aclocal && -f 'Makefile.am')
400 my $makefile = new Autom4te::XFile 'Makefile.am';
401 while ($_ = $makefile->getline)
403 if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
405 $aclocal_flags = $1;
406 last;
411 if (!$uses_aclocal)
413 verb "$configure_ac: not using aclocal";
415 else
417 # Some file systems have sub-second time stamps, and if so we may
418 # run into trouble later, after we rerun autoconf and set the
419 # time stamps of input files to be no greater than aclocal.m4,
420 # because the time-stamp-setting operation (utime) has a
421 # resolution of only 1 second. Work around the problem by
422 # ensuring that there is at least a one-second window before the
423 # time stamp of aclocal.m4t in which no file time stamps can
424 # fall.
425 sleep 1;
427 run_aclocal ($aclocal, $aclocal_flags);
430 # We might have to rerun aclocal if Libtool (or others) imports new
431 # macros.
432 my $rerun_aclocal = 0;
436 # ------------------------------- #
437 # See what tools will be needed. #
438 # ------------------------------- #
440 # Perform a single trace reading to avoid --force forcing a rerun
441 # between two --trace, that's useless. If there is no AC_INIT, then
442 # we are not interested: it looks like a Cygnus thingy.
443 my $aux_dir;
444 my $uses_gettext_via_traces;
445 my $uses_libtool;
446 my $uses_libltdl;
447 my $uses_autoheader;
448 my $uses_automake;
449 my @subdir;
450 verb "$configure_ac: tracing";
451 my $traces = new Autom4te::XFile
452 ("$autoconf"
453 . join (' --trace=', '',
454 # If you change this list, update the
455 # `Autoreconf-preselections' section of autom4te.in.
456 'AC_CONFIG_AUX_DIR:AC_CONFIG_AUX_DIR:\$1',
457 'AC_CONFIG_HEADERS',
458 'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1',
459 'AC_INIT',
460 'AC_PROG_LIBTOOL',
461 'LT_INIT',
462 'LT_CONFIG_LTDL_DIR',
463 'AM_GNU_GETTEXT',
464 'AM_INIT_AUTOMAKE',
466 . ' |');
467 while ($_ = $traces->getline)
469 $aux_dir = $1 if /AC_CONFIG_AUX_DIR:(.*)/;
470 $uses_autoconf = 1 if /AC_INIT/;
471 $uses_gettext_via_traces = 1 if /AM_GNU_GETTEXT/;
472 $uses_libtool = 1 if /(AC_PROG_LIBTOOL|LT_INIT)/;
473 $uses_libltdl = 1 if /LT_CONFIG_LTDL_DIR/;
474 $uses_autoheader = 1 if /AC_CONFIG_HEADERS/;
475 $uses_automake = 1 if /AM_INIT_AUTOMAKE/;
476 push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/ && $recursive;
479 # The subdirs are *optional*, they may not exist.
480 foreach (@subdir)
482 if (-d)
484 verb "$configure_ac: adding subdirectory $_ to autoreconf";
485 autoreconf ($_);
487 else
489 verb "$configure_ac: subdirectory $_ not present";
493 # Gettext consistency checks...
494 error "$configure_ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION"
495 if $uses_gettext_via_traces && ! $uses_gettext;
496 error "$configure_ac: AM_GNU_GETTEXT_VERSION is used, but not AM_GNU_GETTEXT"
497 if $uses_gettext && ! $uses_gettext_via_traces;
500 # ---------------------------- #
501 # Setting up the source tree. #
502 # ---------------------------- #
504 # libtoolize, automake --add-missing etc. will drop files in the
505 # $AUX_DIR. But these tools fail to install these files if the
506 # directory itself does not exist, which valid: just imagine a CVS
507 # repository with hand written code only (there is not even a need
508 # for a Makefile.am!).
510 if (defined $aux_dir && ! -d $aux_dir)
512 verb "$configure_ac: creating directory $aux_dir";
513 mkdir $aux_dir, 0755
514 or error "cannot create $aux_dir: $!";
518 # -------------------- #
519 # Running libtoolize. #
520 # -------------------- #
522 if (!$uses_libtool)
524 verb "$configure_ac: not using Libtool";
526 elsif ($install)
528 if ($uses_libltdl)
530 $libtoolize .= " --ltdl";
532 xsystem ($libtoolize);
533 $rerun_aclocal = 1;
535 else
537 verb "$configure_ac: not running libtoolize: --install not given";
542 # ------------------- #
543 # Rerunning aclocal. #
544 # ------------------- #
546 # If we re-installed Libtool or Gettext, the macros might have changed.
547 # Automake also needs an up-to-date aclocal.m4.
548 if ($rerun_aclocal)
550 if (!$uses_aclocal)
552 verb "$configure_ac: not using aclocal";
554 else
556 run_aclocal ($aclocal, $aclocal_flags);
561 # ------------------ #
562 # Running autoconf. #
563 # ------------------ #
565 # Don't try to be smarter than `autoconf', which does its own up to
566 # date checks.
568 # We prefer running autoconf before autoheader, because (i) the
569 # latter runs the former, and (ii) autoconf is stricter than
570 # autoheader. So all in all, autoconf should give better error
571 # messages.
572 xsystem ($autoconf);
575 # -------------------- #
576 # Running autoheader. #
577 # -------------------- #
579 # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
580 # is used too.
582 # Just as for autoconf, up to date ness is performed by the tool
583 # itself.
585 # Run it before automake, since the latter checks the presence of
586 # config.h.in when it sees an AC_CONFIG_HEADERS.
587 if (!$uses_autoheader)
589 verb "$configure_ac: not using Autoheader";
591 else
593 xsystem ($autoheader);
597 # ------------------ #
598 # Running automake. #
599 # ------------------ #
601 if (!$uses_automake)
603 verb "$configure_ac: not using Automake";
605 else
607 # We should always run automake, and let it decide whether it shall
608 # update the file or not. In fact, the effect of `$force' is already
609 # included in `$automake' via `--no-force'.
610 xsystem ($automake);
614 # -------------- #
615 # Running make. #
616 # -------------- #
618 if ($make)
620 if (!-f "config.status")
622 verb "no config.status: cannot re-make";
624 else
626 xsystem ("./config.status --recheck");
627 xsystem ("./config.status");
628 if (!-f "Makefile")
630 verb "no Makefile: cannot re-make";
632 else
634 xsystem ("make");
641 # &autoreconf ($DIRECTORY)
642 # ------------------------
643 # Reconf the $DIRECTORY.
644 sub autoreconf ($)
646 my ($directory) = @_;
647 my $cwd = cwd;
649 # The format for this message is not free: taken from Emacs, itself
650 # using GNU Make's format.
651 verb "Entering directory `$directory'";
652 chdir $directory
653 or error "cannot chdir to $directory: $!";
655 autoreconf_current_directory;
657 # The format is not free: taken from Emacs, itself using GNU Make's
658 # format.
659 verb "Leaving directory `$directory'";
660 chdir $cwd
661 or error "cannot chdir to $cwd: $!";
665 ## ------ ##
666 ## Main. ##
667 ## ------ ##
669 # When debugging, it is convenient that all the related temporary
670 # files be at the same place.
671 mktmpdir ('ar');
672 $ENV{'TMPDIR'} = $tmp;
673 parse_args;
675 # Autoreconf all the given configure.ac. Unless `--no-recursive' is passed,
676 # AC_CONFIG_SUBDIRS will be traversed in &autoreconf_current_directory.
677 for my $directory (@ARGV)
679 require_configure_ac ($directory);
680 autoreconf ($directory);
683 ### Setup "GNU" style for perl-mode and cperl-mode.
684 ## Local Variables:
685 ## perl-indent-level: 2
686 ## perl-continued-statement-offset: 2
687 ## perl-continued-brace-offset: 0
688 ## perl-brace-offset: 0
689 ## perl-brace-imaginary-offset: 0
690 ## perl-label-offset: -2
691 ## cperl-indent-level: 2
692 ## cperl-brace-offset: 0
693 ## cperl-continued-brace-offset: 0
694 ## cperl-label-offset: -2
695 ## cperl-extra-newline-before-brace: t
696 ## cperl-merge-trailing-else: nil
697 ## cperl-continued-statement-offset: 2
698 ## End: