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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
11 # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2, or (at your option)
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # Written by Tom Tromey <tromey@redhat.com>, and
28 # Alexandre Duret-Lutz <adl@gnu.org>.
32 my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
33 unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
39 use Automake::General;
40 use Automake::Configure_ac;
41 use Automake::Channels;
42 use Automake::ChannelDefs;
44 use Automake::FileUtils;
51 # We do not operate in threaded mode.
54 # Include paths for searching macros. We search macros in this order:
55 # user-supplied directories first, then the directory containing the
56 # automake macros, and finally the system-wide directories for
58 # @user_includes can be augmented with -I.
59 # @automake_includes can be reset with the `--automake-acdir' option.
60 # @system_includes can be augmented with the `dirlist' file, and reset
61 # with the `--system-acdir' option.
62 my @user_includes = ();
63 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
64 my @system_includes = ('@datadir@/aclocal');
66 # Whether we should copy M4 file in $user_includes[0].
75 # configure.ac or configure.in.
79 my $output_file = 'aclocal.m4';
84 # Modification time of the youngest dependency.
85 my $greatest_mtime = 0;
87 # Which macros have been seen.
90 # Remember the order into which we scanned the files.
91 # It's important to output the contents of aclocal.m4 in the opposite order.
92 # (Definitions in first files we have scanned should override those from
93 # later files. So they must appear last in the output.)
96 # Map macro names to file names.
99 # Ditto, but records the last definition of each macro as returned by --trace.
100 my %map_traced_defs = ();
102 # Map basenames to macro names.
105 # Map file names to file contents.
106 my %file_contents = ();
108 # Map file names to file types.
110 use constant FT_USER => 1;
111 use constant FT_AUTOMAKE => 2;
112 use constant FT_SYSTEM => 3;
114 # Map file names to included files (transitively closed).
115 my %file_includes = ();
117 # Files which have already been added.
120 # Files that have already been scanned.
121 my %scanned_configure_dep = ();
123 # Serial numbers, for files that have one.
124 # The key is the basename of the file,
125 # the value is the serial number represented as a list.
128 # Matches a macro definition.
129 # AC_DEFUN([macroname], ...)
131 # AC_DEFUN(macroname, ...)
132 # When macroname is `['-quoted , we accept any character in the name,
133 # except `]'. Otherwise macroname stops on the first `]', `,', `)',
134 # or `\n' encountered.
136 "(?:AU_ALIAS|A[CU]_DEFUN|AC_DEFUN_ONCE)\\((?:\\[([^]]+)\\]|([^],)\n]+))";
138 # Matches an AC_REQUIRE line.
139 my $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
141 # Matches an m4_include line.
142 my $m4_include_rx = "(m4_|m4_s|s)include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
144 # Match a serial number.
145 my $serial_line_rx = '^#\s*serial\s+(\S*)';
146 my $serial_number_rx = '^\d+(?:\.\d+)*$';
149 # Set by trace_used_macros.
152 # If set, names a temporary file that must be erased on abnormal exit.
155 ################################################################
157 # Erase temporary file ERASE_ME. Handle signals.
164 verb "caught SIG$sig, bailing out";
166 if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
168 fatal "could not remove `$erase_me': $!";
172 # reraise default handler.
175 $SIG{$sig} = 'DEFAULT';
180 $SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
183 # Check macros in acinclude.m4. If one is not used, warn.
184 sub check_acinclude ()
186 foreach my $key (keys %map)
188 # FIXME: should print line number of acinclude.m4.
189 msg ('syntax', "macro `$key' defined in acinclude.m4 but never used")
190 if $map{$key} eq 'acinclude.m4' && ! exists $macro_seen{$key};
200 %map_traced_defs = ();
205 %scanned_configure_dep = ();
211 # install_file ($SRC, $DEST)
212 sub install_file ($$)
214 my ($src, $dest) = @_;
218 || !exists $file_contents{$dest}
219 || $file_contents{$src} ne $file_contents{$dest})
223 msg 'note', "overwriting `$dest' with `$src'";
228 msg 'note', "installing `$dest' from `$src'";
233 if (! defined $diff_dest)
235 # $dest does not exist. We create an empty one just to
236 # run diff, and we erase it afterward. Using the real
237 # the destination file (rather than a temporary file) is
238 # good when diff is run with options that display the
241 # If creating $dest fails, fall back to /dev/null. At
242 # least one diff implementation (Tru64's) cannot deal
243 # with /dev/null. However working around this is not
244 # worth the trouble since nobody run aclocal on a
245 # read-only tree anyway.
247 my $f = new IO::File "> $dest";
251 $diff_dest = '/dev/null';
259 my @cmd = (@diff_command, $diff_dest, $src);
261 verb "running: @cmd";
262 my $res = system (@cmd);
263 Automake::FileUtils::handle_exec_errors "@cmd", 1
269 xsystem ('cp', $src, $dest);
274 # Compare two lists of numbers.
275 sub list_compare (\@\@)
283 return (0 == @r) ? 0 : -1;
289 elsif ($l[0] < $r[0])
293 elsif ($l[0] > $r[0])
302 ################################################################
304 # scan_m4_dirs($TYPE, @DIRS)
305 # --------------------------
306 # Scan all M4 files installed in @DIRS for new macro definitions.
307 # Register each file as of type $TYPE (one of the FT_* constants).
308 sub scan_m4_dirs ($@)
310 my ($type, @dirlist) = @_;
312 foreach my $m4dir (@dirlist)
314 if (! opendir (DIR, $m4dir))
316 fatal "couldn't open directory `$m4dir': $!";
319 # We reverse the directory contents so that foo2.m4 gets
320 # used in preference to foo1.m4.
321 foreach my $file (reverse sort grep (! /^\./, readdir (DIR)))
323 # Only examine .m4 files.
324 next unless $file =~ /\.m4$/;
326 # Skip some files when running out of srcdir.
327 next if $file eq 'aclocal.m4';
329 my $fullfile = File::Spec->canonpath ("$m4dir/$file");
330 &scan_file ($type, $fullfile, 'aclocal');
336 # Scan all the installed m4 files and construct a map.
339 # First, scan configure.ac. It may contain macro definitions,
340 # or may include other files that define macros.
341 &scan_file (FT_USER, $configure_ac, 'aclocal');
343 # Then, scan acinclude.m4 if it exists.
344 if (-f 'acinclude.m4')
346 &scan_file (FT_USER, 'acinclude.m4', 'aclocal');
349 # Finally, scan all files in our search paths.
350 scan_m4_dirs (FT_USER, @user_includes);
351 scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
352 scan_m4_dirs (FT_SYSTEM, @system_includes);
354 # Construct a new function that does the searching. We use a
355 # function (instead of just evaluating $search in the loop) so that
356 # "die" is correctly and easily propagated if run.
357 my $search = "sub search {\nmy \$found = 0;\n";
358 foreach my $key (reverse sort keys %map)
360 $search .= ('if (/\b\Q' . $key . '\E(?!\w)/) { & add_macro ("' . $key
361 . '"); $found = 1; }' . "\n");
363 $search .= "return \$found;\n};\n";
365 prog_error "$@\n search is $search" if $@;
368 ################################################################
370 # Add a macro to the output.
375 # Ignore unknown required macros. Either they are not really
376 # needed (e.g., a conditional AC_REQUIRE), in which case aclocal
377 # should be quiet, or they are needed and Autoconf itself will
378 # complain when we trace for macro usage later.
379 return unless defined $map{$macro};
381 verb "saw macro $macro";
382 $macro_seen{$macro} = 1;
383 &add_file ($map{$macro});
386 # scan_configure_dep ($file)
387 # --------------------------
388 # Scan a configure dependency (configure.ac, or separate m4 files)
389 # for uses of known macros and AC_REQUIREs of possibly unknown macros.
390 # Recursively scan m4_included files.
391 sub scan_configure_dep ($)
394 # Do not scan a file twice.
396 if exists $scanned_configure_dep{$file};
397 $scanned_configure_dep{$file} = 1;
399 my $mtime = mtime $file;
400 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
402 my $contents = exists $file_contents{$file} ?
403 $file_contents{$file} : contents $file;
408 foreach (split ("\n", $contents))
411 # Remove comments from current line.
414 # Avoid running all the following regexes on white lines.
417 while (/$m4_include_rx/go)
419 my $ifile = $2 || $3;
420 # Skip missing `sinclude'd files.
421 next if $1 ne 'm4_' && ! -f $ifile;
425 while (/$ac_require_rx/go)
427 push (@rlist, $1 || $2);
430 # The search function is constructed dynamically by
431 # scan_m4_files. The last parenthetical match makes sure we
432 # don't match things that look like macro assignments or
434 if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
436 # Macro not found, but AM_ prefix found.
437 # Make this just a warning, because we do not know whether
438 # the macro is actually used (it could be called conditionally).
439 msg ('unsupported', "$file:$line",
440 "macro `$2' not found in library");
444 add_macro ($_) foreach (@rlist);
445 &scan_configure_dep ($_) foreach @ilist;
450 # Add $FILE to output.
455 # Only add a file once.
456 return if ($file_added{$file});
457 $file_added{$file} = 1;
459 scan_configure_dep $file;
462 # Point to the documentation for underquoted AC_DEFUN only once.
463 my $underquoted_manual_once = 0;
465 # scan_file ($TYPE, $FILE, $WHERE)
466 # --------------------------------
467 # Scan a single M4 file ($FILE), and all files it includes.
468 # Return the list of included files.
469 # $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending
470 # on where the file comes from.
471 # $WHERE is the location to use in the diagnostic if the file
475 my ($type, $file, $where) = @_;
476 my $basename = basename $file;
478 # Do not scan the same file twice.
479 return @{$file_includes{$file}} if exists $file_includes{$file};
480 # Prevent potential infinite recursion (if two files include each other).
481 return () if exists $file_contents{$file};
483 unshift @file_order, $file;
485 $file_type{$file} = $type;
487 fatal "$where: file `$file' does not exist" if ! -e $file;
489 my $fh = new Automake::XFile $file;
496 my $serial_older = 0;
498 while ($_ = $fh->getline)
506 if ($line =~ /$serial_line_rx/go)
509 if ($number !~ /$serial_number_rx/go)
511 msg ('syntax', "$file:$.",
512 "ill-formed serial number `$number', "
513 . "expecting a version string with only digits and dots");
517 # aclocal removes all definitions from M4 file with the
518 # same basename if a greater serial number is found.
519 # Encountering a serial after some macros will undefine
521 msg ('syntax', "$file:$.",
522 'the serial number must appear before any macro definition');
524 # We really care about serials only for non-automake macros
525 # and when --install is used. But the above diagnostics are
526 # made regardless of this, because not using --install is
527 # not a reason not the fix macro files.
528 elsif ($install && $type != FT_AUTOMAKE)
531 my @new = split (/\./, $number);
533 verb "$file:$.: serial $number";
535 if (!exists $serial{$basename}
536 || list_compare (@new, @{$serial{$basename}}) > 0)
538 # Delete any definition we knew from the old macro.
539 foreach my $def (@{$invmap{$basename}})
541 verb "$file:$.: ignoring previous definition of $def";
544 $invmap{$basename} = [];
545 $serial{$basename} = \@new;
554 # Remove comments from current line.
555 # Do not do it earlier, because the serial line is a comment.
556 $line =~ s/\bdnl\b.*$//;
559 while ($line =~ /$ac_defun_rx/go)
564 msg ('syntax', "$file:$.", "underquoted definition of $2"
565 . "\n run info Automake 'Extending aclocal'\n"
566 . " or see http://www.gnu.org/software/automake/manual/"
567 . "automake.html#Extending-aclocal")
568 unless $underquoted_manual_once;
569 $underquoted_manual_once = 1;
572 # If this macro does not have a serial and we have already
573 # seen a macro with the same basename earlier, we should
574 # ignore the macro (don't exit immediately so we can still
575 # diagnose later #serial numbers and underquoted macros).
576 $serial_older ||= ($type != FT_AUTOMAKE
577 && !$serial_seen && exists $serial{$basename});
579 my $macro = $1 || $2;
580 if (!$serial_older && !defined $map{$macro})
582 verb "found macro $macro in $file: $.";
583 $map{$macro} = $file;
584 push @{$invmap{$basename}}, $macro;
588 # Note: we used to give an error here if we saw a
589 # duplicated macro. However, this turns out to be
590 # extremely unpopular. It causes actual problems which
591 # are hard to work around, especially when you must
592 # mix-and-match tool versions.
593 verb "ignoring macro $macro in $file: $.";
597 while ($line =~ /$m4_include_rx/go)
599 my $ifile = $2 || $3;
600 # Skip missing `sinclude'd files.
601 next if $1 ne 'm4_' && ! -f $ifile;
602 push (@inc_files, $ifile);
603 $inc_lines{$ifile} = $.;
607 # Ignore any file that has an old serial (or no serial if we know
608 # another one with a serial).
611 ($type != FT_AUTOMAKE && !$serial_seen && exists $serial{$basename}));
613 $file_contents{$file} = $contents;
615 # For some reason I don't understand, it does not work
616 # to do `map { scan_file ($_, ...) } @inc_files' below.
617 # With Perl 5.8.2 it undefines @inc_files.
618 my @copy = @inc_files;
619 my @all_inc_files = (@inc_files,
620 map { scan_file ($type, $_,
621 "$file:$inc_lines{$_}") } @copy);
622 $file_includes{$file} = \@all_inc_files;
623 return @all_inc_files;
626 # strip_redundant_includes (%FILES)
627 # ---------------------------------
628 # Each key in %FILES is a file that must be present in the output.
629 # However some of these files might already include other files in %FILES,
630 # so there is no point in including them another time.
631 # This removes items of %FILES which are already included by another file.
632 sub strip_redundant_includes (%)
636 # Always include acinclude.m4, even if it does not appear to be used.
637 $files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
638 # File included by $configure_ac are redundant.
639 $files{$configure_ac} = 1;
641 # Files at the end of @file_order should override those at the beginning,
642 # so it is important to preserve these trailing files. We can remove
643 # a file A if it is going to be output before a file B that includes
644 # file A, not the converse.
645 foreach my $file (reverse @file_order)
647 next unless exists $files{$file};
648 foreach my $ifile (@{$file_includes{$file}})
650 next unless exists $files{$ifile};
651 delete $files{$ifile};
652 verb "$ifile is already included by $file";
656 # configure.ac is implicitly included.
657 delete $files{$configure_ac};
662 sub trace_used_macros ()
664 my %files = map { $map{$_} => 1 } keys %macro_seen;
665 %files = strip_redundant_includes %files;
667 my $traces = ($ENV{AUTOM4TE} || '@am_AUTOM4TE@');
668 $traces .= " --language Autoconf-without-aclocal-m4 ";
669 # All candidate files.
670 $traces .= join (' ',
672 (grep { exists $files{$_} } @file_order))) . " ";
673 # All candidate macros.
674 $traces .= join (' ',
675 (map { "--trace='$_:\$f::\$n::\$1'" }
679 '_AM_AUTOCONF_VERSION')),
680 # Do not trace $1 for all other macros as we do
681 # not need it and it might contains harmful
682 # characters (like newlines).
683 (map { "--trace='$_:\$f::\$n'" } (keys %macro_seen)));
685 verb "running $traces $configure_ac";
687 my $tracefh = new Automake::XFile ("$traces $configure_ac |");
691 while ($_ = $tracefh->getline)
694 my ($file, $macro, $arg1) = split (/::/);
696 $traced{$macro} = 1 if exists $macro_seen{$macro};
698 $map_traced_defs{$arg1} = $file
699 if ($macro eq 'AC_DEFUN'
700 || $macro eq 'AC_DEFUN_ONCE'
701 || $macro eq 'AU_DEFUN');
703 $ac_version = $arg1 if $macro eq '_AM_AUTOCONF_VERSION';
711 sub scan_configure ()
713 # Make sure we include acinclude.m4 if it exists.
714 if (-f 'acinclude.m4')
716 add_file ('acinclude.m4');
718 scan_configure_dep ($configure_ac);
721 ################################################################
724 # Return 0 iff some files were installed locally.
725 sub write_aclocal ($@)
727 my ($output_file, @macros) = @_;
731 # Get the list of files containing definitions for the macros used.
732 # (Filter out unused macro definitions with $map_traced_defs. This
733 # can happen when an Autoconf macro is conditionally defined:
734 # aclocal sees the potential definition, but this definition is
735 # actually never processed and the Autoconf implementation is used
740 if (exists $map_traced_defs{$m}
741 && $map{$m} eq $map_traced_defs{$m});
743 # Do not explicitly include a file that is already indirectly included.
744 %files = strip_redundant_includes %files;
748 for my $file (grep { exists $files{$_} } @file_order)
750 # Check the time stamp of this file, and of all files it includes.
751 for my $ifile ($file, @{$file_includes{$file}})
753 my $mtime = mtime $ifile;
754 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
757 # If the file to add looks like outside the project, copy it
758 # to the output. The regex catches filenames starting with
759 # things like `/', `\', or `c:\'.
760 if ($file_type{$file} != FT_USER
761 || $file =~ m,^(?:\w:)?[\\/],)
763 if (!$install || $file_type{$file} != FT_SYSTEM)
765 # Copy the file into aclocal.m4.
766 $output .= $file_contents{$file} . "\n";
770 # Install the file (and any file it includes).
772 for my $ifile (@{$file_includes{$file}}, $file)
774 $dest = "$user_includes[0]/" . basename $ifile;
775 verb "installing $ifile to $dest";
776 install_file ($ifile, $dest);
783 # Otherwise, simply include the file.
784 $output .= "m4_include([$file])\n";
790 verb "running aclocal anew, because some files were installed locally";
794 # Nothing to output?!
795 # FIXME: Shouldn't we diagnose this?
796 return 1 if ! length ($output);
800 # Do not use "$output_file" here for the same reason we do not
801 # use it in the header below. autom4te will output the name of
802 # the file in the diagnostic anyway.
803 $output = "m4_ifndef([AC_AUTOCONF_VERSION],
804 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
805 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
806 [m4_warning([this file was generated for autoconf $ac_version.
807 You have another version of autoconf. It may work, but is not guaranteed to.
808 If you have problems, you may need to regenerate the build system entirely.
809 To do so, use the procedure documented by the package, typically `autoreconf'.])])
814 # We used to print `# $output_file generated automatically etc.' But
815 # this creates spurious differences when using autoreconf. Autoreconf
816 # creates aclocal.m4t and then rename it to aclocal.m4, but the
817 # rebuild rules generated by Automake create aclocal.m4 directly --
818 # this would gives two ways to get the same file, with a different
819 # name in the header.
820 $output = "# generated automatically by aclocal $VERSION -*- Autoconf -*-
822 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
823 # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
825 # This file is free software; the Free Software Foundation
826 # gives unlimited permission to copy and/or distribute it,
827 # with or without modifications, as long as this notice is preserved.
829 # This program is distributed in the hope that it will be useful,
830 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
831 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
832 # PARTICULAR PURPOSE.
836 # We try not to update $output_file unless necessary, because
837 # doing so invalidate Autom4te's cache and therefore slows down
838 # tools called after aclocal.
840 # We need to overwrite $output_file in the following situations.
841 # * The --force option is in use.
842 # * One of the dependencies is younger.
843 # (Not updating $output_file in this situation would cause
844 # make to call aclocal in loop.)
845 # * The contents of the current file are different from what
848 && $greatest_mtime < mtime ($output_file)
849 && $output eq contents ($output_file))
851 verb "$output_file unchanged";
855 verb "writing $output_file";
859 if (-e $output_file && !unlink $output_file)
861 fatal "could not remove `$output_file': $!";
863 my $out = new Automake::XFile "> $output_file";
869 ################################################################
871 # Print usage and exit.
876 print "Usage: aclocal [OPTION]...
878 Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
881 --automake-acdir=DIR directory holding automake-provided m4 files
882 --system-acdir=DIR directory holding third-party system-wide files
883 --diff[=COMMAND] run COMMAND [diff -u] on M4 files that would be
884 changed (implies --install and --dry-run)
885 --dry-run pretend to, but do not actually update any file
886 --force always update output file
887 --help print this help, then exit
888 -I DIR add directory to search list for .m4 files
889 --install copy third-party files to the first -I directory
890 --output=FILE put output in FILE (default aclocal.m4)
891 --print-ac-dir print name of directory holding system-wide
892 third-party m4 files, then exit
893 --verbose don't be silent
894 --version print version number, then exit
895 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
897 Warning categories include:
898 `syntax' dubious syntactic constructs (default)
899 `unsupported' unknown macros (default)
900 `all' all the warnings (default)
901 `no-CATEGORY' turn off warnings in CATEGORY
902 `none' turn off all the warnings
903 `error' treat warnings as errors
905 " . 'Report bugs to <@PACKAGE_BUGREPORT@>.
906 GNU Automake home page: <@PACKAGE_URL@>.
907 General help using GNU software: <http://www.gnu.org/gethelp/>.
913 # Print version and exit.
917 aclocal (GNU $PACKAGE) $VERSION
918 Copyright (C) 2011 Free Software Foundation, Inc.
919 License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
920 This is free software: you are free to change and redistribute it.
921 There is NO WARRANTY, to the extent permitted by law.
923 Written by Tom Tromey <tromey\@redhat.com>
924 and Alexandre Duret-Lutz <adl\@gnu.org>.
929 # Using --acdir overrides both the automake (versioned) directory and
930 # the public (unversioned) system directory. This usage is obsolete.
931 sub handle_acdir_option ($$)
933 msg 'obsolete', '', "`--acdir' is deprecated\n";
934 @system_includes = ($_[1]);
935 @automake_includes = ();
938 # Parse command line.
939 sub parse_arguments ()
941 my $print_and_exit = 0;
946 'acdir=s' => \&handle_acdir_option,
947 'system-acdir=s' => sub { shift; @system_includes = @_; },
948 'automake-acdir=s' => sub { shift; @automake_includes = @_; },
949 'diff:s' => \$diff_command,
950 'dry-run' => \$dry_run,
951 'force' => \$force_output,
952 'I=s' => \@user_includes,
953 'install' => \$install,
954 'output=s' => \$output_file,
955 'print-ac-dir' => \$print_and_exit,
956 'verbose' => sub { setup_channel 'verb', silent => 0; },
957 'W|warnings=s' => \&parse_warnings,
960 Getopt::Long::config ("bundling", "pass_through");
962 # See if --version or --help is used. We want to process these before
963 # anything else because the GNU Coding Standards require us to
964 # `exit 0' after processing these options, and we can't guarantee this
965 # if we treat other options first. (Handling other options first
966 # could produce error diagnostics, and in this condition it is
967 # confusing if aclocal does `exit 0'.)
968 my %cli_options_1st_pass =
970 'version' => \&version,
971 'help' => sub { usage(0); },
972 # Recognize all other options (and their arguments) but do nothing.
973 map { $_ => sub {} } (keys %cli_options)
975 my @ARGV_backup = @ARGV;
976 Getopt::Long::GetOptions %cli_options_1st_pass
978 @ARGV = @ARGV_backup;
980 # Now *really* process the options. This time we know that --help
981 # and --version are not present, but we specify them nonetheless so
982 # that ambiguous abbreviation are diagnosed.
983 Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
989 for my $k (keys %cli_options)
993 map { $argopts{(length ($_) == 1)
994 ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
997 if (exists $argopts{$ARGV[0]})
999 fatal ("option `$ARGV[0]' requires an argument.\n"
1000 . "Try `$0 --help' for more information");
1004 fatal ("unrecognized option `$ARGV[0]'\n"
1005 . "Try `$0 --help' for more information");
1009 if ($print_and_exit)
1011 print "@system_includes\n";
1015 if (defined $diff_command)
1017 $diff_command = 'diff -u' if $diff_command eq '';
1018 @diff_command = split (' ', $diff_command);
1023 if ($install && !@user_includes)
1025 fatal ("--install should copy macros in the directory indicated by the"
1026 . "\nfirst -I option, but no -I was supplied");
1029 # Finally, adds any directory listed in the `dirlist' file.
1030 if (open (DIRLIST, "$system_includes[0]/dirlist"))
1036 # strip off newlines and end-of-line comments
1039 foreach my $dir (glob)
1041 push (@system_includes, $dir) if -d $dir;
1048 ################################################################
1050 parse_WARNINGS; # Parse the WARNINGS environment variable.
1052 $configure_ac = require_configure_ac;
1054 # We may have to rerun aclocal if some file have been installed, but
1055 # it should not happen more than once. The reason we must run again
1056 # is that once the file has been moved from /usr/share/aclocal/ to the
1057 # local m4/ directory it appears at a new place in the search path,
1058 # hence it should be output at a different position in aclocal.m4. If
1059 # we did not rerun aclocal, the next run of aclocal would produce a
1060 # different aclocal.m4.
1065 prog_error "too many loops" if $loop > 2;
1071 my %macro_traced = trace_used_macros;
1072 last if write_aclocal ($output_file, keys %macro_traced);
1079 ### Setup "GNU" style for perl-mode and cperl-mode.
1081 ## perl-indent-level: 2
1082 ## perl-continued-statement-offset: 2
1083 ## perl-continued-brace-offset: 0
1084 ## perl-brace-offset: 0
1085 ## perl-brace-imaginary-offset: 0
1086 ## perl-label-offset: -2
1087 ## cperl-indent-level: 2
1088 ## cperl-brace-offset: 0
1089 ## cperl-continued-brace-offset: 0
1090 ## cperl-label-offset: -2
1091 ## cperl-extra-newline-before-brace: t
1092 ## cperl-merge-trailing-else: nil
1093 ## cperl-continued-statement-offset: 2