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 Free Software Foundation, Inc.
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 3, or (at your option)
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 # Written by Tom Tromey <tromey@redhat.com>, and
27 # Alexandre Duret-Lutz <adl@gnu.org>.
31 my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
32 unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
38 use Automake::General;
39 use Automake::Configure_ac;
40 use Automake::Channels;
41 use Automake::ChannelDefs;
43 use Automake::FileUtils;
50 # We do not operate in threaded mode.
53 # Include paths for searching macros. We search macros in this order:
54 # user-supplied directories first, then the directory containing the
55 # automake macros, and finally the system-wide directories for
56 # third-party macro. @user_includes can be augmented with -I.
57 # @system_includes can be augmented with the `dirlist' file. Also
58 # --acdir will reset both @automake_includes and @system_includes.
59 my @user_includes = ();
60 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
61 my @system_includes = ('@datadir@/aclocal');
63 # Whether we should copy M4 file in $user_includes[0].
72 # configure.ac or configure.in.
76 my $output_file = 'aclocal.m4';
81 # Modification time of the youngest dependency.
82 my $greatest_mtime = 0;
84 # Which macros have been seen.
87 # Remember the order into which we scanned the files.
88 # It's important to output the contents of aclocal.m4 in the opposite order.
89 # (Definitions in first files we have scanned should override those from
90 # later files. So they must appear last in the output.)
93 # Map macro names to file names.
96 # Ditto, but records the last definition of each macro as returned by --trace.
97 my %map_traced_defs = ();
99 # Map basenames to macro names.
102 # Map file names to file contents.
103 my %file_contents = ();
105 # Map file names to file types.
107 use constant FT_USER => 1;
108 use constant FT_AUTOMAKE => 2;
109 use constant FT_SYSTEM => 3;
111 # Map file names to included files (transitively closed).
112 my %file_includes = ();
114 # Files which have already been added.
117 # Files that have already been scanned.
118 my %scanned_configure_dep = ();
120 # Serial numbers, for files that have one.
121 # The key is the basename of the file,
122 # the value is the serial number represented as a list.
125 # Matches a macro definition.
126 # AC_DEFUN([macroname], ...)
128 # AC_DEFUN(macroname, ...)
129 # When macroname is `['-quoted , we accept any character in the name,
130 # except `]'. Otherwise macroname stops on the first `]', `,', `)',
131 # or `\n' encountered.
133 "(?:AU_ALIAS|A[CU]_DEFUN|AC_DEFUN_ONCE)\\((?:\\[([^]]+)\\]|([^],)\n]+))";
135 # Matches an AC_REQUIRE line.
136 my $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
138 # Matches an m4_include line.
139 my $m4_include_rx = "(m4_|m4_s|s)include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
141 # Match a serial number.
142 my $serial_line_rx = '^#\s*serial\s+(\S*)';
143 my $serial_number_rx = '^\d+(?:\.\d+)*$';
146 # Set by trace_used_macros.
149 # If set, names a temporary file that must be erased on abnormal exit.
152 ################################################################
154 # Erase temporary file ERASE_ME. Handle signals.
161 verb "caught SIG$sig, bailing out";
163 if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
165 fatal "could not remove `$erase_me': $!";
169 # reraise default handler.
172 $SIG{$sig} = 'DEFAULT';
177 $SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
180 # Check macros in acinclude.m4. If one is not used, warn.
181 sub check_acinclude ()
183 foreach my $key (keys %map)
185 # FIXME: should print line number of acinclude.m4.
186 msg ('syntax', "warning: macro `$key' defined in "
187 . "acinclude.m4 but never used")
188 if $map{$key} eq 'acinclude.m4' && ! exists $macro_seen{$key};
198 %map_traced_defs = ();
203 %scanned_configure_dep = ();
209 # install_file ($SRC, $DEST)
210 sub install_file ($$)
212 my ($src, $dest) = @_;
216 || !exists $file_contents{$dest}
217 || $file_contents{$src} ne $file_contents{$dest})
221 msg 'note', "overwriting `$dest' with `$src'";
226 msg 'note', "installing `$dest' from `$src'";
231 if (! defined $diff_dest)
233 # $dest does not exist. We create an empty one just to
234 # run diff, and we erase it afterward. Using the real
235 # the destination file (rather than a temporary file) is
236 # good when diff is run with options that display the
239 # If creating $dest fails, fall back to /dev/null. At
240 # least one diff implementation (Tru64's) cannot deal
241 # with /dev/null. However working around this is not
242 # worth the trouble since nobody run aclocal on a
243 # read-only tree anyway.
245 my $f = new IO::File "> $dest";
249 $diff_dest = '/dev/null';
257 my @cmd = (@diff_command, $diff_dest, $src);
259 verb "running: @cmd";
260 my $res = system (@cmd);
261 Automake::FileUtils::handle_exec_errors "@cmd", 1
267 xsystem ('cp', $src, $dest);
272 # Compare two lists of numbers.
273 sub list_compare (\@\@)
281 return (0 == @r) ? 0 : -1;
287 elsif ($l[0] < $r[0])
291 elsif ($l[0] > $r[0])
300 ################################################################
302 # scan_m4_dirs($TYPE, @DIRS)
303 # --------------------------
304 # Scan all M4 files installed in @DIRS for new macro definitions.
305 # Register each file as of type $TYPE (one of the FT_* constants).
306 sub scan_m4_dirs ($@)
308 my ($type, @dirlist) = @_;
310 foreach my $m4dir (@dirlist)
312 if (! opendir (DIR, $m4dir))
314 fatal "couldn't open directory `$m4dir': $!";
317 # We reverse the directory contents so that foo2.m4 gets
318 # used in preference to foo1.m4.
319 foreach my $file (reverse sort grep (! /^\./, readdir (DIR)))
321 # Only examine .m4 files.
322 next unless $file =~ /\.m4$/;
324 # Skip some files when running out of srcdir.
325 next if $file eq 'aclocal.m4';
327 my $fullfile = File::Spec->canonpath ("$m4dir/$file");
328 &scan_file ($type, $fullfile, 'aclocal');
334 # Scan all the installed m4 files and construct a map.
337 # First, scan configure.ac. It may contain macro definitions,
338 # or may include other files that define macros.
339 &scan_file (FT_USER, $configure_ac, 'aclocal');
341 # Then, scan acinclude.m4 if it exists.
342 if (-f 'acinclude.m4')
344 &scan_file (FT_USER, 'acinclude.m4', 'aclocal');
347 # Finally, scan all files in our search paths.
348 scan_m4_dirs (FT_USER, @user_includes);
349 scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
350 scan_m4_dirs (FT_SYSTEM, @system_includes);
352 # Construct a new function that does the searching. We use a
353 # function (instead of just evaluating $search in the loop) so that
354 # "die" is correctly and easily propagated if run.
355 my $search = "sub search {\nmy \$found = 0;\n";
356 foreach my $key (reverse sort keys %map)
358 $search .= ('if (/\b\Q' . $key . '\E(?!\w)/) { & add_macro ("' . $key
359 . '"); $found = 1; }' . "\n");
361 $search .= "return \$found;\n};\n";
363 prog_error "$@\n search is $search" if $@;
366 ################################################################
368 # Add a macro to the output.
373 # Ignore unknown required macros. Either they are not really
374 # needed (e.g., a conditional AC_REQUIRE), in which case aclocal
375 # should be quiet, or they are needed and Autoconf itself will
376 # complain when we trace for macro usage later.
377 return unless defined $map{$macro};
379 verb "saw macro $macro";
380 $macro_seen{$macro} = 1;
381 &add_file ($map{$macro});
384 # scan_configure_dep ($file)
385 # --------------------------
386 # Scan a configure dependency (configure.ac, or separate m4 files)
387 # for uses of known macros and AC_REQUIREs of possibly unknown macros.
388 # Recursively scan m4_included files.
389 sub scan_configure_dep ($)
392 # Do not scan a file twice.
394 if exists $scanned_configure_dep{$file};
395 $scanned_configure_dep{$file} = 1;
397 my $mtime = mtime $file;
398 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
400 my $contents = exists $file_contents{$file} ?
401 $file_contents{$file} : contents $file;
406 foreach (split ("\n", $contents))
409 # Remove comments from current line.
412 # Avoid running all the following regexes on white lines.
415 while (/$m4_include_rx/go)
417 my $ifile = $2 || $3;
418 # Skip missing `sinclude'd files.
419 next if $1 ne 'm4_' && ! -f $ifile;
423 while (/$ac_require_rx/go)
425 push (@rlist, $1 || $2);
428 # The search function is constructed dynamically by
429 # scan_m4_files. The last parenthetical match makes sure we
430 # don't match things that look like macro assignments or
432 if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
434 # Macro not found, but AM_ prefix found.
435 # Make this just a warning, because we do not know whether
436 # the macro is actually used (it could be called conditionally).
437 msg ('unsupported', "$file:$line",
438 "warning: macro `$2' not found in library");
442 add_macro ($_) foreach (@rlist);
443 &scan_configure_dep ($_) foreach @ilist;
448 # Add $FILE to output.
453 # Only add a file once.
454 return if ($file_added{$file});
455 $file_added{$file} = 1;
457 scan_configure_dep $file;
460 # Point to the documentation for underquoted AC_DEFUN only once.
461 my $underquoted_manual_once = 0;
463 # scan_file ($TYPE, $FILE, $WHERE)
464 # --------------------------------
465 # Scan a single M4 file ($FILE), and all files it includes.
466 # Return the list of included files.
467 # $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending
468 # on where the file comes from.
469 # $WHERE is the location to use in the diagnostic if the file
473 my ($type, $file, $where) = @_;
474 my $basename = basename $file;
476 # Do not scan the same file twice.
477 return @{$file_includes{$file}} if exists $file_includes{$file};
478 # Prevent potential infinite recursion (if two files include each other).
479 return () if exists $file_contents{$file};
481 unshift @file_order, $file;
483 $file_type{$file} = $type;
485 fatal "$where: file `$file' does not exist" if ! -e $file;
487 my $fh = new Automake::XFile $file;
494 my $serial_older = 0;
496 while ($_ = $fh->getline)
504 if ($line =~ /$serial_line_rx/go)
507 if ($number !~ /$serial_number_rx/go)
509 msg ('syntax', "$file:$.",
510 "warning: ill-formed serial number `$number', "
511 . "expecting a version string with only digits and dots");
515 # aclocal removes all definitions from M4 file with the
516 # same basename if a greater serial number is found.
517 # Encountering a serial after some macros will undefine
519 msg ('syntax', "$file:$.",
520 'the serial number must appear before any macro definition');
522 # We really care about serials only for non-automake macros
523 # and when --install is used. But the above diagnostics are
524 # made regardless of this, because not using --install is
525 # not a reason not the fix macro files.
526 elsif ($install && $type != FT_AUTOMAKE)
529 my @new = split (/\./, $number);
531 verb "$file:$.: serial $number";
533 if (!exists $serial{$basename}
534 || list_compare (@new, @{$serial{$basename}}) > 0)
536 # Delete any definition we knew from the old macro.
537 foreach my $def (@{$invmap{$basename}})
539 verb "$file:$.: ignoring previous definition of $def";
542 $invmap{$basename} = [];
543 $serial{$basename} = \@new;
552 # Remove comments from current line.
553 # Do not do it earlier, because the serial line is a comment.
554 $line =~ s/\bdnl\b.*$//;
557 while ($line =~ /$ac_defun_rx/go)
562 msg ('syntax', "$file:$.", "warning: underquoted definition of $2"
563 . "\n run info '(automake)Extending aclocal'\n"
564 . " or see http://sources.redhat.com/automake/"
565 . "automake.html#Extending-aclocal")
566 unless $underquoted_manual_once;
567 $underquoted_manual_once = 1;
570 # If this macro does not have a serial and we have already
571 # seen a macro with the same basename earlier, we should
572 # ignore the macro (don't exit immediately so we can still
573 # diagnose later #serial numbers and underquoted macros).
574 $serial_older ||= ($type != FT_AUTOMAKE
575 && !$serial_seen && exists $serial{$basename});
577 my $macro = $1 || $2;
578 if (!$serial_older && !defined $map{$macro})
580 verb "found macro $macro in $file: $.";
581 $map{$macro} = $file;
582 push @{$invmap{$basename}}, $macro;
586 # Note: we used to give an error here if we saw a
587 # duplicated macro. However, this turns out to be
588 # extremely unpopular. It causes actual problems which
589 # are hard to work around, especially when you must
590 # mix-and-match tool versions.
591 verb "ignoring macro $macro in $file: $.";
595 while ($line =~ /$m4_include_rx/go)
597 my $ifile = $2 || $3;
598 # Skip missing `sinclude'd files.
599 next if $1 ne 'm4_' && ! -f $ifile;
600 push (@inc_files, $ifile);
601 $inc_lines{$ifile} = $.;
605 # Ignore any file that has an old serial (or no serial if we know
606 # another one with a serial).
609 ($type != FT_AUTOMAKE && !$serial_seen && exists $serial{$basename}));
611 $file_contents{$file} = $contents;
613 # For some reason I don't understand, it does not work
614 # to do `map { scan_file ($_, ...) } @inc_files' below.
615 # With Perl 5.8.2 it undefines @inc_files.
616 my @copy = @inc_files;
617 my @all_inc_files = (@inc_files,
618 map { scan_file ($type, $_,
619 "$file:$inc_lines{$_}") } @copy);
620 $file_includes{$file} = \@all_inc_files;
621 return @all_inc_files;
624 # strip_redundant_includes (%FILES)
625 # ---------------------------------
626 # Each key in %FILES is a file that must be present in the output.
627 # However some of these files might already include other files in %FILES,
628 # so there is no point in including them another time.
629 # This removes items of %FILES which are already included by another file.
630 sub strip_redundant_includes (%)
634 # Always include acinclude.m4, even if it does not appear to be used.
635 $files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
636 # File included by $configure_ac are redundant.
637 $files{$configure_ac} = 1;
639 # Files at the end of @file_order should override those at the beginning,
640 # so it is important to preserve these trailing files. We can remove
641 # a file A if it is going to be output before a file B that includes
642 # file A, not the converse.
643 foreach my $file (reverse @file_order)
645 next unless exists $files{$file};
646 foreach my $ifile (@{$file_includes{$file}})
648 next unless exists $files{$ifile};
649 delete $files{$ifile};
650 verb "$ifile is already included by $file";
654 # configure.ac is implicitly included.
655 delete $files{$configure_ac};
660 sub trace_used_macros ()
662 my %files = map { $map{$_} => 1 } keys %macro_seen;
663 %files = strip_redundant_includes %files;
665 my $traces = ($ENV{AUTOM4TE} || 'autom4te');
666 $traces .= " --language Autoconf-without-aclocal-m4 ";
667 # All candidate files.
668 $traces .= join (' ',
670 (grep { exists $files{$_} } @file_order))) . " ";
671 # All candidate macros.
672 $traces .= join (' ',
673 (map { "--trace='$_:\$f::\$n::\$1'" }
677 '_AM_AUTOCONF_VERSION')),
678 # Do not trace $1 for all other macros as we do
679 # not need it and it might contains harmful
680 # characters (like newlines).
681 (map { "--trace='$_:\$f::\$n'" } (keys %macro_seen)));
683 verb "running $traces $configure_ac";
685 my $tracefh = new Automake::XFile ("$traces $configure_ac |");
689 while ($_ = $tracefh->getline)
692 my ($file, $macro, $arg1) = split (/::/);
694 $traced{$macro} = 1 if exists $macro_seen{$macro};
696 $map_traced_defs{$arg1} = $file
697 if ($macro eq 'AC_DEFUN'
698 || $macro eq 'AC_DEFUN_ONCE'
699 || $macro eq 'AU_DEFUN');
701 $ac_version = $arg1 if $macro eq '_AM_AUTOCONF_VERSION';
709 sub scan_configure ()
711 # Make sure we include acinclude.m4 if it exists.
712 if (-f 'acinclude.m4')
714 add_file ('acinclude.m4');
716 scan_configure_dep ($configure_ac);
719 ################################################################
722 # Return 0 iff some files were installed locally.
723 sub write_aclocal ($@)
725 my ($output_file, @macros) = @_;
729 # Get the list of files containing definitions for the macros used.
730 # (Filter out unused macro definitions with $map_traced_defs. This
731 # can happen when an Autoconf macro is conditionally defined:
732 # aclocal sees the potential definition, but this definition is
733 # actually never processed and the Autoconf implementation is used
738 if (exists $map_traced_defs{$m}
739 && $map{$m} eq $map_traced_defs{$m});
741 # Do not explicitly include a file that is already indirectly included.
742 %files = strip_redundant_includes %files;
746 for my $file (grep { exists $files{$_} } @file_order)
748 # Check the time stamp of this file, and of all files it includes.
749 for my $ifile ($file, @{$file_includes{$file}})
751 my $mtime = mtime $ifile;
752 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
755 # If the file to add looks like outside the project, copy it
756 # to the output. The regex catches filenames starting with
757 # things like `/', `\', or `c:\'.
758 if ($file_type{$file} != FT_USER
759 || $file =~ m,^(?:\w:)?[\\/],)
761 if (!$install || $file_type{$file} != FT_SYSTEM)
763 # Copy the file into aclocal.m4.
764 $output .= $file_contents{$file} . "\n";
768 # Install the file (and any file it includes).
770 for my $ifile (@{$file_includes{$file}}, $file)
772 $dest = "$user_includes[0]/" . basename $ifile;
773 verb "installing $ifile to $dest";
774 install_file ($ifile, $dest);
781 # Otherwise, simply include the file.
782 $output .= "m4_include([$file])\n";
788 verb "running aclocal anew, because some files were installed locally";
792 # Nothing to output?!
793 # FIXME: Shouldn't we diagnose this?
794 return 1 if ! length ($output);
798 # Do not use "$output_file" here for the same reason we do not
799 # use it in the header below. autom4te will output the name of
800 # the file in the diagnostic anyway.
801 $output = "m4_ifndef([AC_AUTOCONF_VERSION],
802 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
803 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
804 [m4_warning([this file was generated for autoconf $ac_version.
805 You have another version of autoconf. It may work, but is not guaranteed to.
806 If you have problems, you may need to regenerate the build system entirely.
807 To do so, use the procedure documented by the package, typically `autoreconf'.])])
812 # We used to print `# $output_file generated automatically etc.' But
813 # this creates spurious differences when using autoreconf. Autoreconf
814 # creates aclocal.m4t and then rename it to aclocal.m4, but the
815 # rebuild rules generated by Automake create aclocal.m4 directly --
816 # this would gives two ways to get the same file, with a different
817 # name in the header.
818 $output = "# generated automatically by aclocal $VERSION -*- Autoconf -*-
820 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
821 # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
822 # This file is free software; the Free Software Foundation
823 # gives unlimited permission to copy and/or distribute it,
824 # with or without modifications, as long as this notice is preserved.
826 # This program is distributed in the hope that it will be useful,
827 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
828 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
829 # PARTICULAR PURPOSE.
833 # We try not to update $output_file unless necessary, because
834 # doing so invalidate Autom4te's cache and therefore slows down
835 # tools called after aclocal.
837 # We need to overwrite $output_file in the following situations.
838 # * The --force option is in use.
839 # * One of the dependencies is younger.
840 # (Not updating $output_file in this situation would cause
841 # make to call aclocal in loop.)
842 # * The contents of the current file are different from what
845 && $greatest_mtime < mtime ($output_file)
846 && $output eq contents ($output_file))
848 verb "$output_file unchanged";
852 verb "writing $output_file";
856 if (-e $output_file && !unlink $output_file)
858 fatal "could not remove `$output_file': $!";
860 my $out = new Automake::XFile "> $output_file";
866 ################################################################
868 # Print usage and exit.
873 print "Usage: aclocal [OPTIONS] ...
875 Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
878 --acdir=DIR directory holding config files (for debugging)
879 --diff[=COMMAND] run COMMAND [diff -u] on M4 files that would be
880 changed (implies --install and --dry-run)
881 --dry-run pretend to, but do not actually update any file
882 --force always update output file
883 --help print this help, then exit
884 -I DIR add directory to search list for .m4 files
885 --install copy third-party files to the first -I directory
886 --output=FILE put output in FILE (default aclocal.m4)
887 --print-ac-dir print name of directory holding m4 files, then exit
888 --verbose don't be silent
889 --version print version number, then exit
890 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
892 Warning categories include:
893 `syntax' dubious syntactic constructs (default)
894 `unsupported' unknown macros (default)
895 `all' all the warnings (default)
896 `no-CATEGORY' turn off warnings in CATEGORY
897 `none' turn off all the warnings
898 `error' treat warnings as errors
900 Report bugs to <bug-automake\@gnu.org>.\n";
905 # Print version and exit.
909 aclocal (GNU $PACKAGE) $VERSION
910 Copyright (C) 2009 Free Software Foundation, Inc.
911 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
912 This is free software: you are free to change and redistribute it.
913 There is NO WARRANTY, to the extent permitted by law.
915 Written by Tom Tromey <tromey\@redhat.com>
916 and Alexandre Duret-Lutz <adl\@gnu.org>.
921 # Parse command line.
922 sub parse_arguments ()
924 my $print_and_exit = 0;
929 'acdir=s' => sub # Setting --acdir overrides both the
930 { # automake (versioned) directory and the
931 # public (unversioned) system directory.
932 @automake_includes = ();
933 @system_includes = ($_[1])
935 'diff:s' => \$diff_command,
936 'dry-run' => \$dry_run,
937 'force' => \$force_output,
938 'I=s' => \@user_includes,
939 'install' => \$install,
940 'output=s' => \$output_file,
941 'print-ac-dir' => \$print_and_exit,
942 'verbose' => sub { setup_channel 'verb', silent => 0; },
943 'W|warnings=s' => \&parse_warnings,
946 Getopt::Long::config ("bundling", "pass_through");
948 # See if --version or --help is used. We want to process these before
949 # anything else because the GNU Coding Standards require us to
950 # `exit 0' after processing these options, and we can't guarantee this
951 # if we treat other options first. (Handling other options first
952 # could produce error diagnostics, and in this condition it is
953 # confusing if aclocal does `exit 0'.)
954 my %cli_options_1st_pass =
956 'version' => \&version,
957 'help' => sub { usage(0); },
958 # Recognize all other options (and their arguments) but do nothing.
959 map { $_ => sub {} } (keys %cli_options)
961 my @ARGV_backup = @ARGV;
962 Getopt::Long::GetOptions %cli_options_1st_pass
964 @ARGV = @ARGV_backup;
966 # Now *really* process the options. This time we know that --help
967 # and --version are not present, but we specify them nonetheless so
968 # that ambiguous abbreviation are diagnosed.
969 Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
975 for my $k (keys %cli_options)
979 map { $argopts{(length ($_) == 1)
980 ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
983 if (exists $argopts{$ARGV[0]})
985 fatal ("option `$ARGV[0]' requires an argument\n"
986 . "Try `$0 --help' for more information.");
990 fatal ("unrecognized option `$ARGV[0]'\n"
991 . "Try `$0 --help' for more information.");
997 print "@system_includes\n";
1001 if (defined $diff_command)
1003 $diff_command = 'diff -u' if $diff_command eq '';
1004 @diff_command = split (' ', $diff_command);
1009 if ($install && !@user_includes)
1011 fatal ("--install should copy macros in the directory indicated by the"
1012 . "\nfirst -I option, but no -I was supplied.");
1015 if (! -d $system_includes[0])
1017 # By default $(datadir)/aclocal doesn't exist. We don't want to
1018 # get an error in the case where we are searching the default
1019 # directory and it hasn't been created. (We know
1020 # @system_includes has its default value if @automake_includes
1021 # is not empty, because --acdir is the only way to change this.)
1022 @system_includes = () if @automake_includes;
1026 # Finally, adds any directory listed in the `dirlist' file.
1027 if (open (DIRLIST, "$system_includes[0]/dirlist"))
1033 # strip off newlines and end-of-line comments
1036 foreach my $dir (glob)
1038 push (@system_includes, $dir) if -d $dir;
1046 ################################################################
1048 parse_WARNINGS; # Parse the WARNINGS environment variable.
1050 $configure_ac = require_configure_ac;
1052 # We may have to rerun aclocal if some file have been installed, but
1053 # it should not happen more than once. The reason we must run again
1054 # is that once the file has been moved from /usr/share/aclocal/ to the
1055 # local m4/ directory it appears at a new place in the search path,
1056 # hence it should be output at a different position in aclocal.m4. If
1057 # we did not rerun aclocal, the next run of aclocal would produce a
1058 # different aclocal.m4.
1063 prog_error "Too many loops." if $loop > 2;
1069 my %macro_traced = trace_used_macros;
1070 last if write_aclocal ($output_file, keys %macro_traced);
1077 ### Setup "GNU" style for perl-mode and cperl-mode.
1079 ## perl-indent-level: 2
1080 ## perl-continued-statement-offset: 2
1081 ## perl-continued-brace-offset: 0
1082 ## perl-brace-offset: 0
1083 ## perl-brace-imaginary-offset: 0
1084 ## perl-label-offset: -2
1085 ## cperl-indent-level: 2
1086 ## cperl-brace-offset: 0
1087 ## cperl-continued-brace-offset: 0
1088 ## cperl-label-offset: -2
1089 ## cperl-extra-newline-before-brace: t
1090 ## cperl-merge-trailing-else: nil
1091 ## cperl-continued-statement-offset: 2