File Coverage

blib/lib/auto/share/dist/Alien-autoconf/bin/autoreconf
Criterion Covered Total %
statement 83 321 25.8
branch 2 166 1.2
condition 20 112 17.8
subroutine 18 27 66.6
pod n/a
total 123 626 19.6


line stmt bran cond sub pod time code
1             #! /usr/local/bin/perl
2             BEGIN {
3 1     1   6204 use strict;
  1         3  
  1         79  
4 1     1   6 use warnings;
  1         2  
  1         69  
5 1     1   6 use File::Spec;
  1         3  
  1         271  
6 1     1   35 my($v,$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));
7 1         16 my @d = File::Spec->splitdir($d);
8 1         5 pop @d for 1..2;
9 1         21 my $dist_dir = File::Spec->catpath($v,File::Spec->catdir(@d), '');
10 1   33     28 $ENV{AUTOM4TE} ||= File::Spec->catfile($dist_dir, 'bin/autom4te');
11 1   33     25 $ENV{autom4te_perllibdir} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
12 1   33     19 $ENV{AC_MACRODIR} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
13 1   33     40 $ENV{AUTOCONF} ||= File::Spec->catfile($dist_dir, 'bin/autoconf');
14 1   33     15 $ENV{AUTOHEADER} ||= File::Spec->catfile($dist_dir, 'bin/autoheader');
15 1 50 33     29 $ENV{AUTOM4TE_CFG} ||= File::Spec->catfile($dist_dir, 'share/autoconf/autom4te.blib.cfg')
      33        
16             if $d[-5] eq 'lib' && $d[-6] eq 'blib';
17 1   33     72 $ENV{trailer_m4} ||= File::Spec->catdir($dist_dir, 'share/autoconf/autoconf/trailer.m4');
18             }
19             # -*- perl -*-
20             # Generated from bin/autoreconf.in; do not edit by hand.
21              
22 1         218481 eval 'case $# in 0) exec /usr/local/bin/perl -S "$0";; *) exec /usr/local/bin/perl -S "$0" "$@";; esac'
23             if 0;
24              
25             # autoreconf - install the GNU Build System in a directory tree
26             # Copyright (C) 1994, 1999-2017, 2020-2023 Free Software Foundation,
27             # Inc.
28              
29             # This program is free software: you can redistribute it and/or modify
30             # it under the terms of the GNU General Public License as published by
31             # the Free Software Foundation, either version 3 of the License, or
32             # (at your option) any later version.
33              
34             # This program is distributed in the hope that it will be useful,
35             # but WITHOUT ANY WARRANTY; without even the implied warranty of
36             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37             # GNU General Public License for more details.
38              
39             # You should have received a copy of the GNU General Public License
40             # along with this program. If not, see .
41              
42             # Written by David J. MacKenzie.
43             # Extended and rewritten in Perl by Akim Demaille.
44              
45 1     1   20 use 5.006;
  1         4  
46 1     1   6 use strict;
  1         2  
  1         37  
47 1     1   6 use warnings FATAL => 'all';
  1         2  
  1         191  
48              
49 1         2 my $buildauxdir;
50             BEGIN
51             {
52 1   50 1   8 my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/share/autoconf';
53 1         3 unshift @INC, $pkgdatadir;
54              
55 1   33     7 $buildauxdir = $ENV{'autom4te_buildauxdir'} || $pkgdatadir . '/build-aux';
56              
57             # Override SHELL. On DJGPP SHELL may not be set to a shell
58             # that can handle redirection and quote arguments correctly,
59             # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
60             # has detected.
61 1 50       37 $ENV{'SHELL'} = '/bin/bash' if ($^O eq 'dos');
62             }
63              
64             # Do not use Cwd::chdir, since it might hang.
65 1     1   6 use Cwd qw (cwd);
  1         2  
  1         81  
66 1     1   608 use File::Copy qw (copy);
  1         16788  
  1         88  
67 1     1   1042 use File::Temp qw (tempfile);
  1         31570  
  1         107  
68              
69 1     1   770 use Autom4te::ChannelDefs;
  1         3  
  1         200  
70 1     1   9 use Autom4te::Channels;
  1         2  
  1         170  
71 1     1   694 use Autom4te::Configure_ac;
  1         3  
  1         119  
72 1     1   694 use Autom4te::FileUtils;
  1         4  
  1         212  
73 1     1   707 use Autom4te::General;
  1         6  
  1         204  
74 1     1   817 use Autom4te::XFile;
  1         5  
  1         117820  
75              
76             ## ----------- ##
77             ## Variables. ##
78             ## ----------- ##
79              
80             # $HELP
81             # -----
82 1         35 $help = "Usage: $0 [OPTION]... [DIRECTORY]...
83              
84             Run 'autoconf' and, when needed, 'aclocal', 'autoheader', 'automake',
85             'autopoint' (formerly 'gettextize'), 'libtoolize', 'intltoolize', and
86             'gtkdocize' to regenerate the GNU Build System files in specified
87             DIRECTORIES and their subdirectories (defaulting to '.').
88              
89             By default, it only remakes those files that are older than their
90             sources. If you install new versions of the GNU Build System,
91             you can make 'autoreconf' remake all of the files by giving it the
92             '--force' option.
93              
94             Operation modes:
95             -h, --help print this help, then exit
96             -V, --version print version number, then exit
97             -v, --verbose verbosely report processing
98             -d, --debug don't remove temporary files
99             -f, --force consider all generated and standard files obsolete
100             -i, --install copy missing standard auxiliary files
101             --no-recursive don't rebuild sub-packages
102             -s, --symlink with -i, install symbolic links instead of copies
103             -m, --make when applicable, re-run ./configure && make
104             -W, --warnings=CATEGORY report the warnings falling in CATEGORY
105             (comma-separated list accepted)
106              
107             " . Autom4te::ChannelDefs::usage . "
108              
109             Library directories:
110             -B, --prepend-include=DIR prepend directory DIR to search path
111             -I, --include=DIR append directory DIR to search path
112              
113             The environment variables AUTOCONF, ACLOCAL, AUTOHEADER, AUTOM4TE,
114             AUTOMAKE, AUTOPOINT, GTKDOCIZE, INTLTOOLIZE, LIBTOOLIZE, M4, MAKE,
115             and WARNINGS are honored.
116              
117             Report bugs to .
118              
119             The full documentation for Autoconf can be read via 'info autoconf',
120             or on the Web at .
121             ";
122              
123             # $VERSION
124             # --------
125 1         5 $version = "autoreconf (GNU Autoconf) 2.72
126             Copyright (C) 2023 Free Software Foundation, Inc.
127             License GPLv3+/Autoconf: GNU GPL version 3 or later
128             ,
129             This is free software: you are free to change and redistribute it.
130             There is NO WARRANTY, to the extent permitted by law.
131              
132             Written by David J. MacKenzie and Akim Demaille.
133             ";
134              
135             # Lib files.
136 1   50     8 my $autoconf = $ENV{'AUTOCONF'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/bin/autoconf';
137 1   50     5 my $autoheader = $ENV{'AUTOHEADER'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/bin/autoheader';
138 1   50     6 my $autom4te = $ENV{'AUTOM4TE'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/bin/autom4te';
139 1   50     12 my $automake = $ENV{'AUTOMAKE'} || 'automake';
140 1   50     7 my $aclocal = $ENV{'ACLOCAL'} || 'aclocal';
141 1   50     7 my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
142 1   50     6 my $intltoolize = $ENV{'INTLTOOLIZE'} || 'intltoolize';
143 1   50     7 my $gtkdocize = $ENV{'GTKDOCIZE'} || 'gtkdocize';
144 1   50     6 my $autopoint = $ENV{'AUTOPOINT'} || 'autopoint';
145 1   50     5 my $make = $ENV{'MAKE'} || 'make';
146              
147             # --install -- as --add-missing in other tools.
148 1         3 my $install = 0;
149             # symlink -- when --install, use symlinks instead.
150 1         3 my $symlink = 0;
151              
152 1         3 my @prepend_include;
153             my @include;
154              
155             # Rerun './configure && make'?
156 1         3 my $run_make = 0;
157              
158             # Recurse into subpackages
159 1         2 my $recursive = 1;
160              
161             ## ---------- ##
162             ## Routines. ##
163             ## ---------- ##
164              
165              
166             # parse_args ()
167             # -------------
168             # Process any command line arguments.
169             sub parse_args ()
170             {
171 1     1   4 my $srcdir;
172              
173             # List of command line warning requests.
174             my @warning;
175              
176 1         8 getopt ("W|warnings=s" => \@warning,
177             'I|include=s' => \@include,
178             'B|prepend-include=s' => \@prepend_include,
179             'i|install' => \$install,
180             's|symlink' => \$symlink,
181             'm|make' => \$run_make,
182             'recursive!' => \$recursive);
183              
184             # Split the warnings as a list of elements instead of a list of
185             # lists.
186 0           @warning = map { split /,/ } @warning;
  0            
187 0           parse_WARNINGS;
188 0           parse_warnings @warning;
189              
190             # Even if the user specified a configure.ac, trim to get the
191             # directory, and look for configure.ac again. Because (i) the code
192             # is simpler, and (ii) we are still able to diagnose simultaneous
193             # presence of configure.ac and configure.in.
194 0 0         @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
  0            
195 0 0         push @ARGV, '.' unless @ARGV;
196              
197 0 0 0       if ($verbose && $debug)
198             {
199 0           for my $prog ($autoconf, $autoheader,
200             $automake, $aclocal,
201             $autopoint,
202             $libtoolize,
203             $intltoolize,
204             $gtkdocize)
205             {
206 0           xsystem ("$prog --version | sed 1q >&2");
207 0           print STDERR "\n";
208             }
209             }
210              
211             # Dispatch autoreconf's option to the tools.
212             # --include;
213 0           $aclocal .= join (' -I ', '', map { shell_quote ($_) } @include);
  0            
214 0           $autoconf .= join (' --include=', '', map { shell_quote ($_) } @include);
  0            
215 0           $autoconf .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include);
  0            
216 0           $autoheader .= join (' --include=', '', map { shell_quote ($_) } @include);
  0            
217 0           $autoheader .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include);
  0            
218              
219             # --install and --symlink;
220 0 0         if ($install)
221             {
222 0           $automake .= ' --add-missing';
223 0 0         $automake .= ' --copy' unless $symlink;
224 0 0         $libtoolize .= ' --copy' unless $symlink;
225 0 0         $intltoolize .= ' --copy' unless $symlink;
226 0 0         $gtkdocize .= ' --copy' unless $symlink;
227             }
228             # --force;
229 0 0         if ($force)
230             {
231 0           $aclocal .= ' --force';
232 0           $autoconf .= ' --force';
233 0           $autoheader .= ' --force';
234 0           $automake .= ' --force-missing';
235 0           $autopoint .= ' --force';
236 0           $libtoolize .= ' --force';
237 0           $intltoolize .= ' --force';
238             }
239             else
240             {
241 0           $automake .= ' --no-force';
242             }
243             # --verbose --verbose or --debug;
244 0 0 0       if ($verbose > 1 || $debug)
245             {
246 0           $autoconf .= ' --verbose';
247 0           $autoheader .= ' --verbose';
248 0           $automake .= ' --verbose';
249 0           $aclocal .= ' --verbose';
250             }
251 0 0         if ($debug)
252             {
253 0           $autoconf .= ' --debug';
254 0           $autoheader .= ' --debug';
255 0           $libtoolize .= ' --debug';
256             }
257              
258             # Pass down warnings via the WARNINGS environment variable, instead
259             # of via --warnings, so that unrecognized warning categories are
260             # silently ignored. We already issued diagnostics about warning
261             # categories *we* don't recognize; older subsidiary tools may not
262             # know all of them, and may treat unrecognized warning categories on
263             # the command line as a fatal error when -Werror is in effect.
264 0           $ENV{WARNINGS} = merge_WARNINGS @warning;
265 0           verb "export WARNINGS=$ENV{WARNINGS}";
266             }
267              
268              
269             ## ----------------------- ##
270             ## Handling of aux files. ##
271             ## ----------------------- ##
272              
273             # find_missing_aux_files
274             # ----------------------
275             # Look in $aux_dir (or, if that is empty, ., .., and ../..) for all of the
276             # files in @$aux_files; return a list of those that do not exist.
277             sub find_missing_aux_files
278             {
279 0     0     my ($aux_files, $aux_dir) = @_;
280 0           my @aux_dirs;
281 0 0         if ($aux_dir)
282             {
283 0           push @aux_dirs, $aux_dir;
284             }
285             else
286             {
287 0           @aux_dirs = qw(. .. ../..);
288             }
289              
290             # If we find all the aux files in _some_ directory in @aux_dirs, we're
291             # good. But if we don't find all of them in any directory in @aux_dirs,
292             # return the set of missing files from the _first_ directory in @aux_dirs;
293             # this will be less confusing in the common case where AC_CONFIG_AUX_DIR
294             # wasn't used and the parent directories don't provide any aux files.
295 0           my @missing_aux_files;
296             my @first_missing_aux_files;
297              
298 0           for my $dir (@aux_dirs)
299             {
300 0           @missing_aux_files = ();
301 0           for my $file (@{$aux_files})
  0            
302             {
303 0 0         push @missing_aux_files, $file
304             unless -e "${dir}/${file}";
305             }
306              
307 0 0         return () if !@missing_aux_files;
308              
309 0 0         @first_missing_aux_files = @missing_aux_files
310             unless @first_missing_aux_files;
311             }
312              
313 0           return @first_missing_aux_files;
314             }
315              
316             # can_install_aux_files
317             # ---------------------
318             # Report whether all of the files listed in @_ exist in $buildauxdir,
319             # which means we could install them.
320             sub can_install_aux_files
321             {
322 0     0     local $_;
323 0           for (@_)
324             {
325 0 0         return 0 unless -f "${buildauxdir}/$_";
326             }
327 0           return 1;
328             }
329              
330             # extract_time_stamp ($fname)
331             # ---------------------------
332             # Extract a timestamp line from $fname.
333             # This is hardwired to know what to look for in the files we currently install.
334             sub extract_time_stamp
335             {
336 0     0     my $fname = shift;
337 0 0         open my $fh, '<', $fname
338             or fatal "opening $fname: $!";
339 0           while (my $l = <$fh>)
340             {
341 0 0         if ($l =~ /^(?:scriptversion|timestamp)='?(\d\d\d\d-\d\d-\d\d(?:\.\d\d)?)/)
342             {
343 0           return $1;
344             }
345             }
346             # Old versions of install-sh did not have a timestamp line.
347 0           return '1970-01-01';
348             }
349              
350             # our_aux_file_is_newer ($dest, $src)
351             # -----------------------------------
352             # True if our copy of an aux file ($src) has a newer 'timestamp' line
353             # than the matching line in $dest.
354             sub our_aux_file_is_newer
355             {
356 0     0     my ($dest, $src) = @_;
357 0           my $dstamp = extract_time_stamp ($dest);
358 0           my $sstamp = extract_time_stamp ($src);
359 0           return $sstamp gt $dstamp;
360             }
361              
362             # try_install_aux_files
363             # ---------------------
364             # Install each of the aux files listed in @$auxfiles, that we are able
365             # to install, into $destdir.
366             # Remove the files we were able to install from @$auxfiles.
367             sub try_install_aux_files
368             {
369 0     0     my ($auxfiles, $destdir) = @_;
370 0           my @unable;
371 0           for my $f (@$auxfiles)
372             {
373 0           my $src = "${buildauxdir}/$f";
374 0 0         if (-f $src)
375             {
376 0           install_aux_file ($destdir, $f, $src);
377             }
378             else
379             {
380 0           push @unable, $f;
381             }
382             }
383 0           @$auxfiles = @unable;
384             }
385              
386             # install_aux_file
387             # ----------------
388             # Install the file $src as $destdir/$f, honoring --symlink and --force.
389             sub install_aux_file
390             {
391 0     0     my ($destdir, $f, $src) = @_;
392 0           my $dest = "${destdir}/$f";
393 0 0 0       if (-e $dest && ! our_aux_file_is_newer ($dest, $src))
394             {
395 0           return;
396             }
397              
398 0 0         if ($symlink)
399             {
400 0 0 0       if ($force || ! -l $dest || readlink $dest != $src)
      0        
401             {
402 0 0         if (-e $dest)
403             {
404 0 0         unlink $dest
405             or fatal "rm -f $dest: $!";
406             }
407 0           verb "linking $dest to $src";
408 0 0         symlink $src, $dest
409             or fatal "ln -s $src $dest: $!";
410             }
411             }
412             else
413             {
414 0 0 0       if (-e $dest && ! -f $dest)
415             {
416 0 0         unlink $dest
417             or fatal "rm -f $dest: $!";
418             }
419 0           my ($temp, $tempname) = tempfile (UNLINK => 0, DIR => $destdir);
420 0 0         copy ($src, $tempname)
421             or fatal "copying $src to $tempname: $!";
422 0 0         make_executable ($tempname) if -x $src;
423 0           update_file ($tempname, $dest, $force);
424             }
425             }
426              
427             # make_executable
428             # ---------------
429             # Make the file $f be executable by all users it is currently readable by.
430             sub make_executable
431             {
432 0     0     my $f = shift;
433 0           my $perm = (stat $f)[2] & 07777;
434 0 0         $perm |= 0100 if ($perm & 0400);
435 0 0         $perm |= 0010 if ($perm & 0040);
436 0 0         $perm |= 0001 if ($perm & 0004);
437 0 0         chmod $perm, $f
438             or fatal "chmod $f: $!";
439             }
440              
441              
442             ## -------------------------- ##
443             ## Per-directory operations. ##
444             ## -------------------------- ##
445              
446             # &autoreconf_current_directory
447             # -----------------------------
448             sub autoreconf_current_directory ($)
449             {
450 0     0     my ($directory) = @_;
451 0           my $configure_ac = find_configure_ac;
452              
453             # ---------------------- #
454             # Is it using Autoconf? #
455             # ---------------------- #
456              
457 0           my $uses_autoconf;
458             my $uses_gettext;
459 0 0         if (-f $configure_ac)
460             {
461 0           my $configure_ac_file = new Autom4te::XFile ("$configure_ac", "<");
462 0           while ($_ = $configure_ac_file->getline)
463             {
464 0           s/#.*//;
465 0           s/dnl.*//;
466 0 0         $uses_autoconf = 1 if /AC_INIT/;
467             # See below for why we look for gettext here.
468 0 0         $uses_gettext = 1 if /^AM_GNU_GETTEXT_(?:REQUIRE_)?VERSION/;
469             }
470 0 0         if (!$uses_autoconf)
471             {
472 0           error "$configure_ac: AC_INIT not found; not an autoconf script?";
473 0           return;
474             }
475             }
476             else
477             {
478 0           verb "neither configure.ac nor configure.in present in $directory";
479 0           return;
480             }
481              
482              
483             # ------------------- #
484             # Running autopoint. #
485             # ------------------- #
486              
487             # Gettext is a bit of a problem: its macros are not necessarily
488             # visible to aclocal, so if we start with a completely stripped down
489             # package (think of a fresh CVS checkout), running 'aclocal' first
490             # will fail: the Gettext macros are missing.
491             #
492             # Therefore, we can't use the traces to decide if we use Gettext or
493             # not. I guess that once Gettext move to 2.5x we will be able to,
494             # but in the meanwhile forget it.
495             #
496             # We can only grep for AM_GNU_GETTEXT_(REQUIRE_)?VERSION in configure.ac.
497             # You might think this approach is naive, and indeed it is, as it prevents
498             # one to embed AM_GNU_GETTEXT_(REQUIRE_)?VERSION in another *.m4, but
499             # anyway we don't limit the generality, since... that's what autopoint does.
500             # Actually, it is even more restrictive, as it greps for
501             # '^AM_GNU_GETTEXT_(REQUIRE_)?VERSION('. We did this above, while
502             # scanning configure.ac.
503 0 0         if (!$uses_gettext)
    0          
504             {
505 0           verb "$configure_ac: not using Gettext";
506             }
507             elsif (!$install)
508             {
509 0           verb "$configure_ac: not running autopoint: --install not given";
510             }
511             else
512             {
513 0           xsystem_hint ("autopoint is needed because this package uses Gettext",
514             $autopoint);
515             }
516              
517              
518             # ----------------- #
519             # Running aclocal. #
520             # ----------------- #
521              
522             # Run it first: it might discover new macros to add, e.g.,
523             # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is
524             # used.
525             #
526             # Always run it. Tracking its sources for up-to-dateness is too
527             # complex and too error prone. The best we can do is avoiding
528             # nuking the timestamp.
529 0           my $uses_aclocal = 1;
530              
531             # Nevertheless, if aclocal.m4 exists and is not made by aclocal,
532             # don't run aclocal.
533              
534 0 0         if (-f 'aclocal.m4')
535             {
536 0           my $aclocal_m4 = new Autom4te::XFile 'aclocal.m4';
537 0           $_ = $aclocal_m4->getline;
538 0 0 0       $uses_aclocal = 0
539             unless defined ($_) && /generated.*by aclocal/;
540             }
541              
542             # If there are flags for aclocal in Makefile.am, use them.
543 0           my $aclocal_flags = '';
544 0 0 0       if ($uses_aclocal && -f 'Makefile.am')
545             {
546 0           my $makefile = new Autom4te::XFile 'Makefile.am';
547 0           while ($_ = $makefile->getline)
548             {
549 0 0         if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
550             {
551 0           $aclocal_flags = $1;
552 0           last;
553             }
554             }
555             }
556              
557 0 0         if (!$uses_aclocal)
558             {
559 0           verb "$configure_ac: not using aclocal";
560             }
561             else
562             {
563             # Some file systems have sub-second timestamps, and if so we may
564             # run into trouble later, after we rerun autoconf and set the
565             # timestamps of input files to be no greater than aclocal.m4,
566             # because the time-stamp-setting operation (utime) has a
567             # resolution of only 1 second. Work around the problem by
568             # ensuring that there is at least a one-second window before the
569             # timestamp of aclocal.m4t in which no file timestamps can
570             # fall.
571 0           sleep 1;
572              
573 0           xsystem ("$aclocal $aclocal_flags");
574             }
575              
576             # We might have to rerun aclocal if Libtool (or others) imports new
577             # macros.
578 0           my $rerun_aclocal = 0;
579              
580              
581              
582             # ------------------------------- #
583             # See what tools will be needed. #
584             # ------------------------------- #
585              
586             # Perform a single trace reading to avoid --force forcing a rerun
587             # between two --trace, that's useless. If there is no AC_INIT, then
588             # it's not an Autoconf script; ignore it.
589             # Suppress all warnings from this invocation; they may be spurious
590             # due to out-of-date files, and in any case they'll duplicate warnings
591             # from the final autoconf invocation.
592 0           my $aux_dir;
593             my @aux_files;
594 0           my $uses_gettext_via_traces;
595 0           my $uses_libtool;
596 0           my $uses_intltool;
597 0           my $uses_gtkdoc;
598 0           my $uses_libltdl;
599 0           my $uses_autoheader;
600 0           my $uses_automake;
601 0           my @subdir;
602 0           my $traces;
603 0           verb "$configure_ac: tracing";
604             {
605 0           local $ENV{WARNINGS} = 'none';
  0            
606             $traces = new Autom4te::XFile
607             ("$autoconf"
608             . join (' ',
609 0           map { ' --trace=' . $_ . ':\$n::\${::}%' }
  0            
610             # If you change this list, update the
611             # 'Autoreconf-preselections' section of autom4te.in.
612             'AC_CONFIG_AUX_DIR',
613             'AC_CONFIG_HEADERS',
614             'AC_CONFIG_SUBDIRS',
615             'AC_INIT',
616             'AC_REQUIRE_AUX_FILE',
617             'AC_PROG_LIBTOOL',
618             'AM_PROG_LIBTOOL',
619             'LT_INIT',
620             'LT_CONFIG_LTDL_DIR',
621             'AM_GNU_GETTEXT',
622             'AM_INIT_AUTOMAKE',
623             'GTK_DOC_CHECK',
624             'IT_PROG_INTLTOOL',
625             )
626             . ' |');
627             }
628 0           while ($_ = $traces->getline)
629             {
630 0           chomp;
631 0           my ($macro, @args) = split (/::/);
632 0 0         $aux_dir = $args[0] if $macro eq "AC_CONFIG_AUX_DIR";
633 0 0         push @aux_files, $args[0] if $macro eq "AC_REQUIRE_AUX_FILE";
634 0 0         $uses_autoconf = 1 if $macro eq "AC_INIT";
635 0 0         $uses_gettext_via_traces = 1 if $macro eq "AM_GNU_GETTEXT";
636 0 0 0       $uses_libtool = 1 if $macro eq "AC_PROG_LIBTOOL"
      0        
637             || $macro eq "AM_PROG_LIBTOOL"
638             || $macro eq "LT_INIT";
639 0 0         $uses_libltdl = 1 if $macro eq "LT_CONFIG_LTDL_DIR";
640 0 0         $uses_autoheader = 1 if $macro eq "AC_CONFIG_HEADERS";
641 0 0         $uses_automake = 1 if $macro eq "AM_INIT_AUTOMAKE";
642 0 0         $uses_intltool = 1 if $macro eq "IT_PROG_INTLTOOL";
643 0 0         $uses_gtkdoc = 1 if $macro eq "GTK_DOC_CHECK";
644 0 0 0       push @subdir, split (' ', $args[0] || '')
      0        
645             if $macro eq "AC_CONFIG_SUBDIRS"
646             && $recursive;
647             }
648 0           $traces->close;
649              
650             # The subdirs are *optional*, they may not exist.
651 0           foreach (@subdir)
652             {
653 0 0         if (-d)
654             {
655 0           verb "$configure_ac: adding subdirectory $_ to autoreconf";
656 0           autoreconf ($_);
657             }
658             else
659             {
660 0           verb "$configure_ac: subdirectory $_ not present";
661             }
662             }
663              
664             # Gettext consistency checks.
665             # Some projects intentionally don't call AM_GNU_GETTEXT_(REQUIRE_)VERSION
666             # because they have all of the gettext infrastructure checked into version
667             # control and they want us to _not_ run autopoint. Therefore, these
668             # diagnostics are only warnings.
669 0 0 0       msg('syntax', $configure_ac,
670             "AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION"
671             . " or AM_GNU_GETTEXT_REQUIRE_VERSION")
672             if $uses_gettext_via_traces && ! $uses_gettext;
673 0 0 0       msg('syntax', $configure_ac,
674             "AM_GNU_GETTEXT_VERSION or AM_GNU_GETTEXT_REQUIRE_VERSION is used,"
675             . " but not AM_GNU_GETTEXT")
676             if $uses_gettext && ! $uses_gettext_via_traces;
677              
678              
679             # ---------------------------- #
680             # Setting up the source tree. #
681             # ---------------------------- #
682              
683             # libtoolize, automake --add-missing etc. will drop files in the
684             # $AUX_DIR. But these tools fail to install these files if the
685             # directory itself does not exist, which valid: just imagine a CVS
686             # repository with hand written code only (there is not even a need
687             # for a Makefile.am!).
688              
689 0 0 0       if ($install && defined $aux_dir && ! -d $aux_dir)
      0        
690             {
691 0           verb "$configure_ac: creating directory $aux_dir";
692 0 0         mkdir $aux_dir, 0755
693             or error "cannot create $aux_dir: $!";
694             }
695              
696              
697             # -------------------- #
698             # Running libtoolize. #
699             # -------------------- #
700              
701 0 0         if (!$uses_libtool)
    0          
702             {
703 0           verb "$configure_ac: not using Libtool";
704             }
705             elsif ($install)
706             {
707 0 0         if ($uses_libltdl)
708             {
709 0           $libtoolize .= " --ltdl";
710             }
711 0           xsystem_hint ("libtoolize is needed because this package uses Libtool",
712             $libtoolize);
713 0           $rerun_aclocal = 1;
714             }
715             else
716             {
717 0           verb "$configure_ac: not running libtoolize: --install not given";
718             }
719              
720              
721             # --------------------- #
722             # Running intltoolize. #
723             # --------------------- #
724              
725 0 0         if (!$uses_intltool)
    0          
726             {
727 0           verb "$configure_ac: not using Intltool";
728             }
729             elsif ($install)
730             {
731 0           xsystem_hint ("intltoolize is needed because this package uses Intltool",
732             $intltoolize);
733             }
734             else
735             {
736 0           verb "$configure_ac: not running intltool: --install not given";
737             }
738              
739              
740             # ------------------- #
741             # Running gtkdocize. #
742             # ------------------- #
743              
744 0 0         if (!$uses_gtkdoc)
    0          
745             {
746 0           verb "$configure_ac: not using Gtkdoc";
747             }
748             elsif ($install)
749             {
750 0           xsystem_hint ("gtkdocize is needed because this package uses Gtkdoc",
751             $gtkdocize);
752             }
753             else
754             {
755 0           verb "$configure_ac: not running gtkdocize: --install not given";
756             }
757              
758              
759             # ------------------- #
760             # Rerunning aclocal. #
761             # ------------------- #
762              
763             # If we re-installed Libtool or Gettext, the macros might have changed.
764             # Automake also needs an up-to-date aclocal.m4.
765 0 0         if ($rerun_aclocal)
766             {
767 0 0         if (!$uses_aclocal)
768             {
769 0           verb "$configure_ac: not using aclocal";
770             }
771             else
772             {
773 0           xsystem ("$aclocal $aclocal_flags");
774             }
775             }
776              
777              
778             # ------------------ #
779             # Running autoconf. #
780             # ------------------ #
781              
782             # Don't try to be smarter than 'autoconf', which does its own up to
783             # date checks.
784             #
785             # We prefer running autoconf before autoheader, because (i) the
786             # latter runs the former, and (ii) autoconf is stricter than
787             # autoheader. So all in all, autoconf should give better error
788             # messages.
789 0           xsystem ($autoconf);
790              
791              
792             # -------------------- #
793             # Running autoheader. #
794             # -------------------- #
795              
796             # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
797             # is used too.
798             #
799             # Just as for autoconf, up to date ness is performed by the tool
800             # itself.
801             #
802             # Run it before automake, since the latter checks the presence of
803             # config.h.in when it sees an AC_CONFIG_HEADERS.
804 0 0         if (!$uses_autoheader)
805             {
806 0           verb "$configure_ac: not using Autoheader";
807             }
808             else
809             {
810 0           xsystem ($autoheader);
811             }
812              
813              
814             # ------------------ #
815             # Running automake. #
816             # ------------------ #
817              
818 0 0         if (!$uses_automake)
819             {
820 0           verb "$configure_ac: not using Automake";
821             }
822             else
823             {
824             # We should always run automake, and let it decide whether it shall
825             # update the file or not. In fact, the effect of '$force' is already
826             # included in '$automake' via '--no-force'.
827 0           xsystem ($automake);
828             }
829              
830             # ---------------------------------------------------- #
831             # Installing aux files and checking for missing ones. #
832             # ---------------------------------------------------- #
833 0 0 0       try_install_aux_files (\@aux_files, $aux_dir || '.')
      0        
834             if $install && $force;
835              
836 0           my @missing_aux_files = find_missing_aux_files (\@aux_files, $aux_dir);
837 0 0         if (@missing_aux_files)
838             {
839 0 0 0       try_install_aux_files (\@missing_aux_files, $aux_dir || '.')
      0        
840             if $install && !$force;
841              
842 0           for (0 .. $#missing_aux_files)
843             {
844 0           my $f = $missing_aux_files[$_];
845 0 0         if ($_ == $#missing_aux_files)
846             {
847             # Offer some advice if --install wasn't given and has a
848             # chance of helping.
849 0           my $trailer = "";
850 0 0 0       $trailer = "\n try running autoreconf --install"
      0        
851             if (!$install
852             && ($uses_automake
853             || $uses_libtool
854             || $uses_intltool
855             || $uses_gtkdoc
856             || can_install_aux_files @missing_aux_files));
857              
858 0           error $configure_ac, "required file '$f' not found$trailer";
859             }
860             else
861             {
862 0           error $configure_ac, "required file '$f' not found";
863             }
864             }
865             }
866              
867             # -------------- #
868             # Running make. #
869             # -------------- #
870              
871 0 0         if ($run_make)
872             {
873 0 0         if (!-f "config.status")
874             {
875 0           verb "no config.status: cannot re-make";
876             }
877             else
878             {
879 0           xsystem ("./config.status --recheck");
880 0           xsystem ("./config.status");
881 0 0         if (!-f "Makefile")
882             {
883 0           verb "no Makefile: cannot re-make";
884             }
885             else
886             {
887 0           xsystem ("$make");
888             }
889             }
890             }
891             }
892              
893              
894             # &autoreconf ($DIRECTORY)
895             # ------------------------
896             # Reconf the $DIRECTORY.
897             sub autoreconf ($)
898             {
899 0     0     my ($directory) = @_;
900 0           my $cwd = cwd;
901              
902             # The format for this message is not free: taken from Emacs, itself
903             # using GNU Make's format.
904 0           verb "Entering directory '$directory'";
905 0 0         chdir $directory
906             or error "cannot chdir to $directory: $!";
907              
908 0           autoreconf_current_directory ($directory);
909              
910             # The format is not free: taken from Emacs, itself using GNU Make's
911             # format.
912 0           verb "Leaving directory '$directory'";
913 0 0         chdir $cwd
914             or error "cannot chdir to $cwd: $!";
915             }
916              
917              
918             ## ------ ##
919             ## Main. ##
920             ## ------ ##
921              
922             # When debugging, it is convenient that all the related temporary
923             # files be at the same place.
924 1         9 mktmpdir ('ar');
925 1         19 $ENV{'TMPDIR'} = $tmp;
926 1         8 parse_args;
927              
928             # Autoreconf all the given configure.ac. Unless '--no-recursive' is passed,
929             # AC_CONFIG_SUBDIRS will be traversed in &autoreconf_current_directory.
930 0         0 $ENV{'AUTOM4TE'} = $autom4te;
931 0         0 for my $directory (@ARGV)
932             {
933 0         0 require_configure_ac ($directory);
934 0         0 autoreconf ($directory);
935             }
936              
937 0         0 exit $exit_code;
938              
939             ### Setup "GNU" style for perl-mode and cperl-mode.
940             ## Local Variables:
941             ## perl-indent-level: 2
942             ## perl-continued-statement-offset: 2
943             ## perl-continued-brace-offset: 0
944             ## perl-brace-offset: 0
945             ## perl-brace-imaginary-offset: 0
946             ## perl-label-offset: -2
947             ## cperl-indent-level: 2
948             ## cperl-brace-offset: 0
949             ## cperl-continued-brace-offset: 0
950             ## cperl-label-offset: -2
951             ## cperl-extra-newline-before-brace: t
952             ## cperl-merge-trailing-else: nil
953             ## cperl-continued-statement-offset: 2
954             ## End: