5 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
8 # aclocal - create aclocal.m4 by scanning configure.ac
10 # Copyright (C) 1996-2012 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)
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, see <http://www.gnu.org/licenses/>.
25 # Written by Tom Tromey <tromey@redhat.com>, and
26 # Alexandre Duret-Lutz <adl@gnu.org>.
30 my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
31 unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
37 use Automake::General;
38 use Automake::Configure_ac;
39 use Automake::Channels;
40 use Automake::ChannelDefs;
42 use Automake::FileUtils;
49 # We do not operate in threaded mode.
52 # Include paths for searching macros. We search macros in this order:
53 # user-supplied directories first, then the directory containing the
54 # automake macros, and finally the system-wide directories for
56 # @user_includes can be augmented with -I.
57 # @automake_includes can be reset with the `--automake-acdir' option.
58 # @system_includes can be augmented with the `dirlist' file or the
59 # ACLOCAL_PATH environment variable, and reset with the `--system-acdir'
61 my @user_includes = ();
62 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
63 my @system_includes = ('@datadir@/aclocal');
65 # Whether we should copy M4 file in $user_includes[0].
74 # configure.ac or configure.in.
78 my $output_file = 'aclocal.m4';
83 # Modification time of the youngest dependency.
84 my $greatest_mtime = 0;
86 # Which macros have been seen.
89 # Remember the order into which we scanned the files.
90 # It's important to output the contents of aclocal.m4 in the opposite order.
91 # (Definitions in first files we have scanned should override those from
92 # later files. So they must appear last in the output.)
95 # Map macro names to file names.
98 # Ditto, but records the last definition of each macro as returned by --trace.
99 my %map_traced_defs = ();
101 # Map basenames to macro names.
104 # Map file names to file contents.
105 my %file_contents = ();
107 # Map file names to file types.
109 use constant FT_USER => 1;
110 use constant FT_AUTOMAKE => 2;
111 use constant FT_SYSTEM => 3;
113 # Map file names to included files (transitively closed).
114 my %file_includes = ();
116 # Files which have already been added.
119 # Files that have already been scanned.
120 my %scanned_configure_dep = ();
122 # Serial numbers, for files that have one.
123 # The key is the basename of the file,
124 # the value is the serial number represented as a list.
127 # Matches a macro definition.
128 # AC_DEFUN([macroname], ...)
130 # AC_DEFUN(macroname, ...)
131 # When macroname is `['-quoted , we accept any character in the name,
132 # except `]'. Otherwise macroname stops on the first `]', `,', `)',
133 # or `\n' encountered.
135 "(?:AU_ALIAS|A[CU]_DEFUN|AC_DEFUN_ONCE)\\((?:\\[([^]]+)\\]|([^],)\n]+))";
137 # Matches an AC_REQUIRE line.
138 my $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
140 # Matches an m4_include line.
141 my $m4_include_rx = "(m4_|m4_s|s)include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
143 # Match a serial number.
144 my $serial_line_rx = '^#\s*serial\s+(\S*)';
145 my $serial_number_rx = '^\d+(?:\.\d+)*$';
148 # Set by trace_used_macros.
151 # If set, names a temporary file that must be erased on abnormal exit.
154 ################################################################
156 # Erase temporary file ERASE_ME. Handle signals.
163 verb "caught SIG$sig, bailing out";
165 if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
167 fatal "could not remove `$erase_me': $!";
171 # reraise default handler.
174 $SIG{$sig} = 'DEFAULT';
179 $SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
182 # Check macros in acinclude.m4. If one is not used, warn.
183 sub check_acinclude ()
185 foreach my $key (keys %map)
187 # FIXME: should print line number of acinclude.m4.
188 msg ('syntax', "macro `$key' defined in acinclude.m4 but never used")
189 if $map{$key} eq 'acinclude.m4' && ! exists $macro_seen{$key};
199 %map_traced_defs = ();
204 %scanned_configure_dep = ();
210 # install_file ($SRC, $DEST)
211 sub install_file ($$)
213 my ($src, $dest) = @_;
217 || !exists $file_contents{$dest}
218 || $file_contents{$src} ne $file_contents{$dest})
222 msg 'note', "overwriting `$dest' with `$src'";
227 msg 'note', "installing `$dest' from `$src'";
232 if (! defined $diff_dest)
234 # $dest does not exist. We create an empty one just to
235 # run diff, and we erase it afterward. Using the real
236 # the destination file (rather than a temporary file) is
237 # good when diff is run with options that display the
240 # If creating $dest fails, fall back to /dev/null. At
241 # least one diff implementation (Tru64's) cannot deal
242 # with /dev/null. However working around this is not
243 # worth the trouble since nobody run aclocal on a
244 # read-only tree anyway.
246 my $f = new IO::File "> $dest";
250 $diff_dest = '/dev/null';
258 my @cmd = (@diff_command, $diff_dest, $src);
260 verb "running: @cmd";
261 my $res = system (@cmd);
262 Automake::FileUtils::handle_exec_errors "@cmd", 1
268 xsystem ('cp', $src, $dest);
273 # Compare two lists of numbers.
274 sub list_compare (\@\@)
282 return (0 == @r) ? 0 : -1;
288 elsif ($l[0] < $r[0])
292 elsif ($l[0] > $r[0])
301 ################################################################
303 # scan_m4_dirs($TYPE, @DIRS)
304 # --------------------------
305 # Scan all M4 files installed in @DIRS for new macro definitions.
306 # Register each file as of type $TYPE (one of the FT_* constants).
307 sub scan_m4_dirs ($@)
309 my ($type, @dirlist) = @_;
311 foreach my $m4dir (@dirlist)
313 if (! opendir (DIR, $m4dir))
315 fatal "couldn't open directory `$m4dir': $!";
318 # We reverse the directory contents so that foo2.m4 gets
319 # used in preference to foo1.m4.
320 foreach my $file (reverse sort grep (! /^\./, readdir (DIR)))
322 # Only examine .m4 files.
323 next unless $file =~ /\.m4$/;
325 # Skip some files when running out of srcdir.
326 next if $file eq 'aclocal.m4';
328 my $fullfile = File::Spec->canonpath ("$m4dir/$file");
329 &scan_file ($type, $fullfile, 'aclocal');
335 # Scan all the installed m4 files and construct a map.
338 # First, scan configure.ac. It may contain macro definitions,
339 # or may include other files that define macros.
340 &scan_file (FT_USER, $configure_ac, 'aclocal');
342 # Then, scan acinclude.m4 if it exists.
343 if (-f 'acinclude.m4')
345 &scan_file (FT_USER, 'acinclude.m4', 'aclocal');
348 # Finally, scan all files in our search paths.
349 scan_m4_dirs (FT_USER, @user_includes);
350 scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
351 scan_m4_dirs (FT_SYSTEM, @system_includes);
353 # Construct a new function that does the searching. We use a
354 # function (instead of just evaluating $search in the loop) so that
355 # "die" is correctly and easily propagated if run.
356 my $search = "sub search {\nmy \$found = 0;\n";
357 foreach my $key (reverse sort keys %map)
359 $search .= ('if (/\b\Q' . $key . '\E(?!\w)/) { & add_macro ("' . $key
360 . '"); $found = 1; }' . "\n");
362 $search .= "return \$found;\n};\n";
364 prog_error "$@\n search is $search" if $@;
367 ################################################################
369 # Add a macro to the output.
374 # Ignore unknown required macros. Either they are not really
375 # needed (e.g., a conditional AC_REQUIRE), in which case aclocal
376 # should be quiet, or they are needed and Autoconf itself will
377 # complain when we trace for macro usage later.
378 return unless defined $map{$macro};
380 verb "saw macro $macro";
381 $macro_seen{$macro} = 1;
382 &add_file ($map{$macro});
385 # scan_configure_dep ($file)
386 # --------------------------
387 # Scan a configure dependency (configure.ac, or separate m4 files)
388 # for uses of known macros and AC_REQUIREs of possibly unknown macros.
389 # Recursively scan m4_included files.
390 sub scan_configure_dep ($)
393 # Do not scan a file twice.
395 if exists $scanned_configure_dep{$file};
396 $scanned_configure_dep{$file} = 1;
398 my $mtime = mtime $file;
399 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
401 my $contents = exists $file_contents{$file} ?
402 $file_contents{$file} : contents $file;
407 foreach (split ("\n", $contents))
410 # Remove comments from current line.
413 # Avoid running all the following regexes on white lines.
416 while (/$m4_include_rx/go)
418 my $ifile = $2 || $3;
419 # Skip missing `sinclude'd files.
420 next if $1 ne 'm4_' && ! -f $ifile;
424 while (/$ac_require_rx/go)
426 push (@rlist, $1 || $2);
429 # The search function is constructed dynamically by
430 # scan_m4_files. The last parenthetical match makes sure we
431 # don't match things that look like macro assignments or
433 if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
435 # Macro not found, but AM_ prefix found.
436 # Make this just a warning, because we do not know whether
437 # the macro is actually used (it could be called conditionally).
438 msg ('unsupported', "$file:$line",
439 "macro `$2' not found in library");
443 add_macro ($_) foreach (@rlist);
444 &scan_configure_dep ($_) foreach @ilist;
449 # Add $FILE to output.
454 # Only add a file once.
455 return if ($file_added{$file});
456 $file_added{$file} = 1;
458 scan_configure_dep $file;
461 # Point to the documentation for underquoted AC_DEFUN only once.
462 my $underquoted_manual_once = 0;
464 # scan_file ($TYPE, $FILE, $WHERE)
465 # --------------------------------
466 # Scan a single M4 file ($FILE), and all files it includes.
467 # Return the list of included files.
468 # $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending
469 # on where the file comes from.
470 # $WHERE is the location to use in the diagnostic if the file
474 my ($type, $file, $where) = @_;
475 my $basename = basename $file;
477 # Do not scan the same file twice.
478 return @{$file_includes{$file}} if exists $file_includes{$file};
479 # Prevent potential infinite recursion (if two files include each other).
480 return () if exists $file_contents{$file};
482 unshift @file_order, $file;
484 $file_type{$file} = $type;
486 fatal "$where: file `$file' does not exist" if ! -e $file;
488 my $fh = new Automake::XFile $file;
495 my $serial_older = 0;
497 while ($_ = $fh->getline)
505 if ($line =~ /$serial_line_rx/go)
508 if ($number !~ /$serial_number_rx/go)
510 msg ('syntax', "$file:$.",
511 "ill-formed serial number `$number', "
512 . "expecting a version string with only digits and dots");
516 # aclocal removes all definitions from M4 file with the
517 # same basename if a greater serial number is found.
518 # Encountering a serial after some macros will undefine
520 msg ('syntax', "$file:$.",
521 'the serial number must appear before any macro definition');
523 # We really care about serials only for non-automake macros
524 # and when --install is used. But the above diagnostics are
525 # made regardless of this, because not using --install is
526 # not a reason not the fix macro files.
527 elsif ($install && $type != FT_AUTOMAKE)
530 my @new = split (/\./, $number);
532 verb "$file:$.: serial $number";
534 if (!exists $serial{$basename}
535 || list_compare (@new, @{$serial{$basename}}) > 0)
537 # Delete any definition we knew from the old macro.
538 foreach my $def (@{$invmap{$basename}})
540 verb "$file:$.: ignoring previous definition of $def";
543 $invmap{$basename} = [];
544 $serial{$basename} = \@new;
553 # Remove comments from current line.
554 # Do not do it earlier, because the serial line is a comment.
555 $line =~ s/\bdnl\b.*$//;
558 while ($line =~ /$ac_defun_rx/go)
563 msg ('syntax', "$file:$.", "underquoted definition of $2"
564 . "\n run info Automake 'Extending aclocal'\n"
565 . " or see http://www.gnu.org/software/automake/manual/"
566 . "automake.html#Extending-aclocal")
567 unless $underquoted_manual_once;
568 $underquoted_manual_once = 1;
571 # If this macro does not have a serial and we have already
572 # seen a macro with the same basename earlier, we should
573 # ignore the macro (don't exit immediately so we can still
574 # diagnose later #serial numbers and underquoted macros).
575 $serial_older ||= ($type != FT_AUTOMAKE
576 && !$serial_seen && exists $serial{$basename});
578 my $macro = $1 || $2;
579 if (!$serial_older && !defined $map{$macro})
581 verb "found macro $macro in $file: $.";
582 $map{$macro} = $file;
583 push @{$invmap{$basename}}, $macro;
587 # Note: we used to give an error here if we saw a
588 # duplicated macro. However, this turns out to be
589 # extremely unpopular. It causes actual problems which
590 # are hard to work around, especially when you must
591 # mix-and-match tool versions.
592 verb "ignoring macro $macro in $file: $.";
596 while ($line =~ /$m4_include_rx/go)
598 my $ifile = $2 || $3;
599 # Skip missing `sinclude'd files.
600 next if $1 ne 'm4_' && ! -f $ifile;
601 push (@inc_files, $ifile);
602 $inc_lines{$ifile} = $.;
606 # Ignore any file that has an old serial (or no serial if we know
607 # another one with a serial).
610 ($type != FT_AUTOMAKE && !$serial_seen && exists $serial{$basename}));
612 $file_contents{$file} = $contents;
614 # For some reason I don't understand, it does not work
615 # to do `map { scan_file ($_, ...) } @inc_files' below.
616 # With Perl 5.8.2 it undefines @inc_files.
617 my @copy = @inc_files;
618 my @all_inc_files = (@inc_files,
619 map { scan_file ($type, $_,
620 "$file:$inc_lines{$_}") } @copy);
621 $file_includes{$file} = \@all_inc_files;
622 return @all_inc_files;
625 # strip_redundant_includes (%FILES)
626 # ---------------------------------
627 # Each key in %FILES is a file that must be present in the output.
628 # However some of these files might already include other files in %FILES,
629 # so there is no point in including them another time.
630 # This removes items of %FILES which are already included by another file.
631 sub strip_redundant_includes (%)
635 # Always include acinclude.m4, even if it does not appear to be used.
636 $files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
637 # File included by $configure_ac are redundant.
638 $files{$configure_ac} = 1;
640 # Files at the end of @file_order should override those at the beginning,
641 # so it is important to preserve these trailing files. We can remove
642 # a file A if it is going to be output before a file B that includes
643 # file A, not the converse.
644 foreach my $file (reverse @file_order)
646 next unless exists $files{$file};
647 foreach my $ifile (@{$file_includes{$file}})
649 next unless exists $files{$ifile};
650 delete $files{$ifile};
651 verb "$ifile is already included by $file";
655 # configure.ac is implicitly included.
656 delete $files{$configure_ac};
661 sub trace_used_macros ()
663 my %files = map { $map{$_} => 1 } keys %macro_seen;
664 %files = strip_redundant_includes %files;
666 my $traces = ($ENV{AUTOM4TE} || '@am_AUTOM4TE@');
667 $traces .= " --language Autoconf-without-aclocal-m4 ";
668 # All candidate files.
669 $traces .= join (' ',
671 (grep { exists $files{$_} } @file_order))) . " ";
672 # All candidate macros.
673 $traces .= join (' ',
674 (map { "--trace='$_:\$f::\$n::\$1'" }
678 '_AM_AUTOCONF_VERSION')),
679 # Do not trace $1 for all other macros as we do
680 # not need it and it might contains harmful
681 # characters (like newlines).
682 (map { "--trace='$_:\$f::\$n'" } (keys %macro_seen)));
684 verb "running $traces $configure_ac";
686 my $tracefh = new Automake::XFile ("$traces $configure_ac |");
690 while ($_ = $tracefh->getline)
693 my ($file, $macro, $arg1) = split (/::/);
695 $traced{$macro} = 1 if exists $macro_seen{$macro};
697 $map_traced_defs{$arg1} = $file
698 if ($macro eq 'AC_DEFUN'
699 || $macro eq 'AC_DEFUN_ONCE'
700 || $macro eq 'AU_DEFUN');
702 $ac_version = $arg1 if $macro eq '_AM_AUTOCONF_VERSION';
710 sub scan_configure ()
712 # Make sure we include acinclude.m4 if it exists.
713 if (-f 'acinclude.m4')
715 add_file ('acinclude.m4');
717 scan_configure_dep ($configure_ac);
720 ################################################################
723 # Return 0 iff some files were installed locally.
724 sub write_aclocal ($@)
726 my ($output_file, @macros) = @_;
730 # Get the list of files containing definitions for the macros used.
731 # (Filter out unused macro definitions with $map_traced_defs. This
732 # can happen when an Autoconf macro is conditionally defined:
733 # aclocal sees the potential definition, but this definition is
734 # actually never processed and the Autoconf implementation is used
739 if (exists $map_traced_defs{$m}
740 && $map{$m} eq $map_traced_defs{$m});
742 # Do not explicitly include a file that is already indirectly included.
743 %files = strip_redundant_includes %files;
747 for my $file (grep { exists $files{$_} } @file_order)
749 # Check the time stamp of this file, and of all files it includes.
750 for my $ifile ($file, @{$file_includes{$file}})
752 my $mtime = mtime $ifile;
753 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
756 # If the file to add looks like outside the project, copy it
757 # to the output. The regex catches filenames starting with
758 # things like `/', `\', or `c:\'.
759 if ($file_type{$file} != FT_USER
760 || $file =~ m,^(?:\w:)?[\\/],)
762 if (!$install || $file_type{$file} != FT_SYSTEM)
764 # Copy the file into aclocal.m4.
765 $output .= $file_contents{$file} . "\n";
769 # Install the file (and any file it includes).
771 for my $ifile (@{$file_includes{$file}}, $file)
773 $dest = "$user_includes[0]/" . basename $ifile;
774 verb "installing $ifile to $dest";
775 install_file ($ifile, $dest);
782 # Otherwise, simply include the file.
783 $output .= "m4_include([$file])\n";
789 verb "running aclocal anew, because some files were installed locally";
793 # Nothing to output?!
794 # FIXME: Shouldn't we diagnose this?
795 return 1 if ! length ($output);
799 # Do not use "$output_file" here for the same reason we do not
800 # use it in the header below. autom4te will output the name of
801 # the file in the diagnostic anyway.
802 $output = "m4_ifndef([AC_AUTOCONF_VERSION],
803 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
804 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
805 [m4_warning([this file was generated for autoconf $ac_version.
806 You have another version of autoconf. It may work, but is not guaranteed to.
807 If you have problems, you may need to regenerate the build system entirely.
808 To do so, use the procedure documented by the package, typically `autoreconf'.])])
813 # We used to print `# $output_file generated automatically etc.' But
814 # this creates spurious differences when using autoreconf. Autoreconf
815 # creates aclocal.m4t and then rename it to aclocal.m4, but the
816 # rebuild rules generated by Automake create aclocal.m4 directly --
817 # this would gives two ways to get the same file, with a different
818 # name in the header.
819 $output = "# generated automatically by aclocal $VERSION -*- Autoconf -*-
821 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
822 # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
824 # This file is free software; the Free Software Foundation
825 # gives unlimited permission to copy and/or distribute it,
826 # with or without modifications, as long as this notice is preserved.
828 # This program is distributed in the hope that it will be useful,
829 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
830 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
831 # PARTICULAR PURPOSE.
835 # We try not to update $output_file unless necessary, because
836 # doing so invalidate Autom4te's cache and therefore slows down
837 # tools called after aclocal.
839 # We need to overwrite $output_file in the following situations.
840 # * The --force option is in use.
841 # * One of the dependencies is younger.
842 # (Not updating $output_file in this situation would cause
843 # make to call aclocal in loop.)
844 # * The contents of the current file are different from what
847 && $greatest_mtime < mtime ($output_file)
848 && $output eq contents ($output_file))
850 verb "$output_file unchanged";
854 verb "writing $output_file";
858 if (-e $output_file && !unlink $output_file)
860 fatal "could not remove `$output_file': $!";
862 my $out = new Automake::XFile "> $output_file";
868 ################################################################
870 # Print usage and exit.
875 print "Usage: aclocal [OPTION]...
877 Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
880 --automake-acdir=DIR directory holding automake-provided m4 files
881 --system-acdir=DIR directory holding third-party system-wide files
882 --diff[=COMMAND] run COMMAND [diff -u] on M4 files that would be
883 changed (implies --install and --dry-run)
884 --dry-run pretend to, but do not actually update any file
885 --force always update output file
886 --help print this help, then exit
887 -I DIR add directory to search list for .m4 files
888 --install copy third-party files to the first -I directory
889 --output=FILE put output in FILE (default aclocal.m4)
890 --print-ac-dir print name of directory holding system-wide
891 third-party m4 files, then exit
892 --verbose don't be silent
893 --version print version number, then exit
894 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
896 Warning categories include:
897 `syntax' dubious syntactic constructs (default)
898 `unsupported' unknown macros (default)
899 `all' all the warnings (default)
900 `no-CATEGORY' turn off warnings in CATEGORY
901 `none' turn off all the warnings
902 `error' treat warnings as errors
904 " . 'Report bugs to <@PACKAGE_BUGREPORT@>.
905 GNU Automake home page: <@PACKAGE_URL@>.
906 General help using GNU software: <http://www.gnu.org/gethelp/>.
912 # Print version and exit.
916 aclocal (GNU $PACKAGE) $VERSION
917 Copyright (C) 2011 Free Software Foundation, Inc.
918 License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
919 This is free software: you are free to change and redistribute it.
920 There is NO WARRANTY, to the extent permitted by law.
922 Written by Tom Tromey <tromey\@redhat.com>
923 and Alexandre Duret-Lutz <adl\@gnu.org>.
928 # Using --acdir overrides both the automake (versioned) directory and
929 # the public (unversioned) system directory. This usage is obsolete.
930 sub handle_acdir_option ($$)
932 msg 'obsolete', '', "`--acdir' is deprecated\n";
933 @system_includes = ($_[1]);
934 @automake_includes = ();
937 # Parse command line.
938 sub parse_arguments ()
940 my $print_and_exit = 0;
945 'help' => sub { usage(0); },
946 'version' => \&version,
947 'acdir=s' => \&handle_acdir_option,
948 'system-acdir=s' => sub { shift; @system_includes = @_; },
949 'automake-acdir=s' => sub { shift; @automake_includes = @_; },
950 'diff:s' => \$diff_command,
951 'dry-run' => \$dry_run,
952 'force' => \$force_output,
953 'I=s' => \@user_includes,
954 'install' => \$install,
955 'output=s' => \$output_file,
956 'print-ac-dir' => \$print_and_exit,
957 'verbose' => sub { setup_channel 'verb', silent => 0; },
958 'W|warnings=s' => \&parse_warnings,
961 use Automake::Getopt ();
962 Automake::Getopt::parse_options %cli_options;
966 print "@system_includes\n";
970 if (defined $diff_command)
972 $diff_command = 'diff -u' if $diff_command eq '';
973 @diff_command = split (' ', $diff_command);
978 if ($install && !@user_includes)
980 fatal ("--install should copy macros in the directory indicated by the"
981 . "\nfirst -I option, but no -I was supplied");
984 # Finally, adds any directory listed in the `dirlist' file.
985 if (open (DIRLIST, "$system_includes[0]/dirlist"))
991 # strip off newlines and end-of-line comments
994 foreach my $dir (glob)
996 push (@system_includes, $dir) if -d $dir;
1003 # Add any directory listed in the `ACLOCAL_PATH' environment variable
1004 # to the list of system include directories.
1005 sub parse_ACLOCAL_PATH ()
1007 return if not defined $ENV{"ACLOCAL_PATH"};
1008 # Directories in ACLOCAL_PATH should take precedence over system
1009 # directories, so we use unshift. However, directories that
1010 # come first in ACLOCAL_PATH take precedence over directories
1011 # coming later, which is why the result of split is reversed.
1012 foreach my $dir (reverse split /:/, $ENV{"ACLOCAL_PATH"})
1014 unshift (@system_includes, $dir) if $dir ne '' && -d $dir;
1018 ################################################################
1020 parse_WARNINGS; # Parse the WARNINGS environment variable.
1023 $configure_ac = require_configure_ac;
1025 # We may have to rerun aclocal if some file have been installed, but
1026 # it should not happen more than once. The reason we must run again
1027 # is that once the file has been moved from /usr/share/aclocal/ to the
1028 # local m4/ directory it appears at a new place in the search path,
1029 # hence it should be output at a different position in aclocal.m4. If
1030 # we did not rerun aclocal, the next run of aclocal would produce a
1031 # different aclocal.m4.
1036 prog_error "too many loops" if $loop > 2;
1042 my %macro_traced = trace_used_macros;
1043 last if write_aclocal ($output_file, keys %macro_traced);
1050 ### Setup "GNU" style for perl-mode and cperl-mode.
1052 ## perl-indent-level: 2
1053 ## perl-continued-statement-offset: 2
1054 ## perl-continued-brace-offset: 0
1055 ## perl-brace-offset: 0
1056 ## perl-brace-imaginary-offset: 0
1057 ## perl-label-offset: -2
1058 ## cperl-indent-level: 2
1059 ## cperl-brace-offset: 0
1060 ## cperl-continued-brace-offset: 0
1061 ## cperl-label-offset: -2
1062 ## cperl-extra-newline-before-brace: t
1063 ## cperl-merge-trailing-else: nil
1064 ## cperl-continued-statement-offset: 2