5 eval 'case $# in 0) exec /bin/perl -S "$0";; *) exec /bin/perl -S "$0" "$@";; esac'
8 # autoreconf - install the GNU Build System in a directory tree
9 # Copyright (C) 1994, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Written by David J. MacKenzie.
27 # Extended and rewritten in Perl by Akim Demaille.
31 my $perllibdir = $ENV{'autom4te_perllibdir'} || '/usr/share/autoconf';
32 unshift @INC, "$perllibdir";
35 use Autom4te
::General
;
37 # Do not use Cwd::chdir, since it might hang.
47 $help = "Usage: $0 [OPTION] ... [CONFIGURE-AC or DIRECTORY] ...
49 Run `autoconf' (and `autoheader', `aclocal', `automake', `autopoint'
50 (formerly `gettextize'), and `libtoolize' where appropriate)
51 repeatedly to remake the GNU Build System files in the DIRECTORIES or
52 the directory trees driven by CONFIGURE-AC (defaulting to `.').
54 By default, it only remakes those files that are older than their
55 predecessors. If you install new versions of the GNU Build System,
56 running `autoreconf' remakes all of the files by giving it the
60 -h, --help print this help, then exit
61 -V, --version print version number, then exit
62 -v, --verbose verbosely report processing
63 -d, --debug don't remove temporary files
64 -f, --force consider all files obsolete
65 -i, --install copy missing auxiliary files
66 -s, --symlink with -i, install symbolic links instead of copies
67 -m, --make when applicable, re-run ./configure && make
68 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
70 Warning categories include:
71 \`cross\' cross compilation issues
72 \`obsolete\' obsolete constructs
73 \`portability\' portability issues
74 \`syntax\' dubious syntactic constructs
75 \`all\' all the warnings
76 \`no-CATEGORY\' turn off the warnings on CATEGORY
77 \`none\' turn off all the warnings
78 \`error\' warnings are error
80 The environment variable \`WARNINGS\' is honored. Some subtools might
81 support other warning types, using \`all' is encouraged.
84 -B, --prepend-include=DIR prepend directory DIR to search path
85 -I, --include=DIR append directory DIR to search path
87 The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
88 AUTOPOINT, LIBTOOLIZE are honored.
90 Report bugs to <bug-autoconf\@gnu.org>.
95 $version = "autoreconf (GNU Autoconf) 2.56
96 Written by David J. MacKenzie and Akim Demaille.
98 Copyright 2002 Free Software Foundation, Inc.
99 This is free software; see the source for copying conditions. There is NO
100 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
104 my $autoconf = $ENV{'AUTOCONF'} || '/usr/bin/autoconf';
105 my $autoheader = $ENV{'AUTOHEADER'} || '/usr/bin/autoheader';
106 my $automake = $ENV{'AUTOMAKE'} || 'automake';
107 my $aclocal = $ENV{'ACLOCAL'} || 'aclocal';
108 my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
109 my $autopoint = $ENV{'AUTOPOINT'} || 'autopoint';
111 # --install -- as --add-missing in other tools.
113 # symlink -- when --install, use symlinks instead.
122 # Rerun `./configure && make'?
132 # Process any command line arguments.
137 getopt
("W|warnings=s" => \
@warning,
138 'I|include=s' => \
@include,
139 'B|prepend-include=s' => \
@prepend_include,
140 'i|install' => \
$install,
141 's|symlink' => \
$symlink,
144 # Split the warnings as a list of elements instead of a list of
146 @warning = map { split /,/ } @warning;
148 # Even if the user specified a configure.ac, trim to get the
149 # directory, and look for configure.ac again. Because (i) the code
150 # is simpler, and (ii) we are still able to diagnose simultaneous
151 # presence of configure.ac and configure.in.
152 @ARGV = map { /configure\.(ac|in)$/ ? dirname
($_) : $_ } @ARGV;
153 push @ARGV, '.' unless @ARGV;
155 if ($verbose && $debug)
157 for my $prog ($autoconf, $autoheader,
162 xsystem
("$prog --version | sed 1q >&2");
167 # Dispatch autoreconf's option to the tools.
169 $autoconf .= join (' --include=', '', @include);
170 $autoconf .= join (' --prepend-include=', '', @prepend_include);
171 $autoheader .= join (' --include=', '', @include);
172 $autoheader .= join (' --prepend-include=', '', @prepend_include);
174 # --install and --symlink;
177 $automake .= ' --add-missing';
178 $automake .= ' --copy' unless $symlink;
179 $libtoolize .= ' --copy' unless $symlink;
184 $autoconf .= ' --force';
185 $autoheader .= ' --force';
186 $automake .= ' --force-missing';
187 $autopoint .= ' --force';
188 $libtoolize .= ' --force';
192 $automake .= ' --no-force';
197 $autoconf .= ' --verbose --debug';
198 $autoheader .= ' --verbose --debug';
199 $automake .= ' --verbose';
200 $aclocal .= ' --verbose';
201 $libtoolize .= ' --debug';
206 $autoconf .= ' --warnings=' . join (',', @warning);
207 $autoheader .= ' --warnings=' . join (',', @warning);
208 $automake .= ' --warnings=' . join (',', @warning)
209 if `$automake --help` =~ /--warnings/;
214 # &autoreconf_current_directory
215 # -----------------------------
216 sub autoreconf_current_directory
()
218 my $configure_ac = find_configure_ac
;
219 error
"cannot find `configure.ac'"
220 unless $configure_ac;
222 # ---------------------- #
223 # Is it using Autoconf? #
224 # ---------------------- #
228 my $configure_ac_file = new Autom4te
::XFile
$configure_ac;
229 while ($_ = $configure_ac_file->getline)
233 $uses_autoconf = 1 if /AC_INIT/;
234 # See below for why we look for gettext here.
235 $uses_gettext = 1 if /^AM_GNU_GETTEXT_VERSION/;
240 verbose
"$configure_ac: not using Autoconf";
245 # ------------------- #
246 # Running autopoint. #
247 # ------------------- #
249 # Gettext is a bit of a problem: its macros are not necessarily
250 # visible to aclocal, so if we start with a completely striped down
251 # package (think of a fresh CVS checkout), running `aclocal' first
252 # will fail: the Gettext macros are missing.
254 # Therefore, we can't use the traces to decide if we use Gettext or
255 # not. I guess that once Gettext move to 2.5x we will be able to,
256 # but in the meanwhile forget it.
258 # We can only grep for AM_GNU_GETTEXT_VERSION in configure.ac. You
259 # might think this approach is naive, and indeed it is, as it
260 # prevents one to embed AM_GNU_GETTEXT_VERSION in another *.m4, but
261 # anyway we don't limit the generality, since... that's what
262 # autopoint does. Actually, it is even more restrictive, as it
263 # greps for `^AM_GNU_GETTEXT_VERSION('. We did this above, while
264 # scanning configure.ac.
267 verbose
"$configure_ac: not using Gettext";
271 verbose
"$configure_ac: not running autopoint: --install not given";
275 xsystem
"$autopoint";
279 # ----------------- #
281 # ----------------- #
283 # Run it first: it might discover new macros to add, e.g.,
284 # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is
287 # Always run it. Tracking its sources for up-to-dateness is too
288 # complex and too error prone. The best we can do is avoiding
289 # nuking the time stamp.
290 my $uses_aclocal = 1;
292 # Nevertheless, if aclocal.m4 exists and is not made by aclocal,
297 my $aclocal_m4 = new Autom4te
::XFile
'aclocal.m4';
298 $_ = $aclocal_m4->getline;
300 unless /generated.*by aclocal/;
303 # If there are flags for aclocal in Makefile.am, use them.
304 my $aclocal_flags = '';
305 if ($uses_aclocal && -f
'Makefile.am')
307 my $makefile = new Autom4te
::XFile
'Makefile.am';
308 while ($_ = $makefile->getline)
310 if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
320 verbose
"$configure_ac: not using aclocal";
324 # Some filesystems have sub-second time stamps, and if so we may
325 # run into trouble later, after we rerun autoconf and set the
326 # time stamps of input files to be no greater than aclocal.m4,
327 # because the time-stamp-setting operation (utime) has a
328 # resolution of only 1 second. Work around the problem by
329 # ensuring that there is at least a one-second window before the
330 # time stamp of aclocal.m4t in which no file time stamps can
334 xsystem
("$aclocal $aclocal_flags --output=aclocal.m4t");
335 # aclocal may produce no output.
336 update_file
('aclocal.m4t', 'aclocal.m4')
340 # We might have to rerun aclocal if Libtool (or others) imports new
342 my $rerun_aclocal = 0;
346 # ------------------------------- #
347 # See what tools will be needed. #
348 # ------------------------------- #
350 # Perform a single trace reading to avoid --force forcing a rerun
351 # between two --trace, that's useless. If there is no AC_INIT, then
352 # we are not interested: it looks like a Cygnus thingy.
353 my $uses_gettext_via_traces;
357 verbose
"$configure_ac: tracing";
358 my $traces = new Autom4te
::XFile
360 . join (' --trace=', '',
361 # If you change this list, update the
362 # `Autoreconf-preselections' section of autom4te.in.
364 'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1',
370 while ($_ = $traces->getline)
372 $uses_autoconf = 1 if /AC_INIT/;
373 $uses_gettext_via_traces = 1 if /AM_GNU_GETTEXT/;
374 $uses_libtool = 1 if /AC_PROG_LIBTOOL/;
375 $uses_autoheader = 1 if /AC_CONFIG_HEADERS/;
376 push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/;
379 # The subdirs are *optional*, they may not exist.
384 verbose
"$configure_ac: subdirectory $_ to autoreconf";
389 verbose
"$configure_ac: subdirectory $_ not present";
393 # Gettext consistency checks...
394 error
"$configure_ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION"
395 if $uses_gettext_via_traces && ! $uses_gettext;
396 error
"$configure_ac: AM_GNU_GETTEXT_VERSION is used, but not AM_GNU_GETTEXT"
397 if $uses_gettext && ! $uses_gettext_via_traces;
400 # -------------------- #
401 # Running libtoolize. #
402 # -------------------- #
406 verbose
"$configure_ac: not using Libtool";
410 xsystem
($libtoolize);
415 verbose
"$configure_ac: not running libtoolize: --install not given";
420 # ------------------- #
421 # Rerunning aclocal. #
422 # ------------------- #
424 # If we re-installed Libtool or Gettext, the macros might have changed.
425 # Automake also needs an up-to-date aclocal.m4.
430 verbose
"$configure_ac: not using aclocal";
434 xsystem
("$aclocal $aclocal_flags --output=aclocal.m4t");
435 # aclocal may produce no output.
436 if (-f
'aclocal.m4t')
438 update_file
('aclocal.m4t', 'aclocal.m4');
439 # Make sure that the local m4 files are older than
442 # Why is not always the case? Because we already run
443 # aclocal at first (before tracing), which, for instance,
444 # can find Gettext's macros in .../share/aclocal, so we
445 # may have had the right aclocal.m4 already. Then
446 # autopoint is run, and installs locally these M4
447 # files. Then autoreconf, via update_file, sees it is
448 # the _same_ aclocal.m4, and doesn't change its
449 # timestamp. But later, Automake's Makefile expresses
450 # that aclocal.m4 depends on these local files, which
451 # are newer, so it triggers aclocal again.
453 # To make sure aclocal.m4 is no older, we change the
454 # modification times of the local M4 files to be
457 # First, where are the local files?
458 my $aclocal_local_dir = '.';
459 if ($aclocal_flags =~ /-I\s+(\S+)/)
461 $aclocal_local_dir = $1;
463 # All the local files newer than aclocal.m4 are to be
464 # made not newer than it.
465 my $aclocal_m4_mtime = mtime
('aclocal.m4');
466 for my $file (glob ("$aclocal_local_dir/*.m4"), 'acinclude.m4')
468 if ($aclocal_m4_mtime < mtime
($file))
470 debug
"aging $file to be not newer than aclocal.m4";
471 utime $aclocal_m4_mtime, $aclocal_m4_mtime, $file;
479 # ------------------ #
480 # Running autoconf. #
481 # ------------------ #
483 # Don't try to be smarter than `autoconf', which does its own up to
486 # We prefer running autoconf before autoheader, because (i) the
487 # latter runs the former, and (ii) autoconf is stricter than
488 # autoheader. So all in all, autoconf should give better error
493 # -------------------- #
494 # Running autoheader. #
495 # -------------------- #
497 # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
500 # Just as for autoconf, up to date ness is performed by the tool
503 # Run it before automake, since the latter checks the presence of
504 # config.h.in when it sees an AC_CONFIG_HEADERS.
505 if (!$uses_autoheader)
507 verbose
"$configure_ac: not using Autoheader";
511 xsystem
($autoheader);
515 # ------------------ #
516 # Running automake. #
517 # ------------------ #
519 # Assumes that there is a Makefile.am in the topmost directory.
520 if (!-f
'Makefile.am')
522 verbose
"$configure_ac: not using Automake";
526 # We should always run automake, and let it decide whether it shall
527 # update the file or not. In fact, the effect of `$force' is already
528 # included in `$automake' via `--no-force'.
539 if (!-f
"config.status")
541 verbose
"no config.status: cannot re-make";
545 xsystem
("./config.status --recheck");
546 xsystem
("./config.status");
549 verbose
"no Makefile: cannot re-make";
560 # &autoreconf ($DIRECTORY)
561 # ------------------------
562 # Reconf the $DIRECTORY.
565 my ($directory) = @_;
568 # The format for this message is not free: taken from Emacs, itself
569 # using GNU Make's format.
570 verbose
"Entering directory `$directory'";
572 or error
"cannot chdir to $directory: $!";
574 autoreconf_current_directory
;
576 # The format is not free: taken from Emacs, itself using GNU Make's
578 verbose
"Leaving directory `$directory'";
580 or error
"cannot chdir to $cwd: $!";
588 # When debugging, it is convenient that all the related temporary
589 # files be at the same place.
591 $ENV{'TMPDIR'} = $tmp;
594 # Autoreconf all the given configure.ac. A while loop, not a for,
595 # since the list can change at runtime because of AC_CONFIG_SUBDIRS.
596 for my $directory (@ARGV)
598 autoreconf
($directory);
601 ### Setup "GNU" style for perl-mode and cperl-mode.
603 ## perl-indent-level: 2
604 ## perl-continued-statement-offset: 2
605 ## perl-continued-brace-offset: 0
606 ## perl-brace-offset: 0
607 ## perl-brace-imaginary-offset: 0
608 ## perl-label-offset: -2
609 ## cperl-indent-level: 2
610 ## cperl-brace-offset: 0
611 ## cperl-continued-brace-offset: 0
612 ## cperl-label-offset: -2
613 ## cperl-extra-newline-before-brace: t
614 ## cperl-merge-trailing-else: nil
615 ## cperl-continued-statement-offset: 2