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;
48 # We do not operate in threaded mode.
51 # Include paths for searching macros. We search macros in this order:
52 # user-supplied directories first, then the directory containing the
53 # automake macros, and finally the system-wide directories for
55 # @user_includes can be augmented with -I.
56 # @automake_includes can be reset with the '--automake-acdir' option.
57 # @system_includes can be augmented with the 'dirlist' file or the
58 # ACLOCAL_PATH environment variable, and reset with the '--system-acdir'
60 my @user_includes = ();
61 my @automake_includes = ("@datadir@/aclocal-$APIVERSION");
62 my @system_includes = ('@datadir@/aclocal');
64 # Whether we should copy M4 file in $user_includes[0].
73 # configure.ac or configure.in.
77 my $output_file = 'aclocal.m4';
82 # Modification time of the youngest dependency.
83 my $greatest_mtime = 0;
85 # Which macros have been seen.
88 # Remember the order into which we scanned the files.
89 # It's important to output the contents of aclocal.m4 in the opposite order.
90 # (Definitions in first files we have scanned should override those from
91 # later files. So they must appear last in the output.)
94 # Map macro names to file names.
97 # Ditto, but records the last definition of each macro as returned by --trace.
98 my %map_traced_defs = ();
100 # Map basenames to macro names.
103 # Map file names to file contents.
104 my %file_contents = ();
106 # Map file names to file types.
108 use constant FT_USER => 1;
109 use constant FT_AUTOMAKE => 2;
110 use constant FT_SYSTEM => 3;
112 # Map file names to included files (transitively closed).
113 my %file_includes = ();
115 # Files which have already been added.
118 # Files that have already been scanned.
119 my %scanned_configure_dep = ();
121 # Serial numbers, for files that have one.
122 # The key is the basename of the file,
123 # the value is the serial number represented as a list.
126 # Matches a macro definition.
127 # AC_DEFUN([macroname], ...)
129 # AC_DEFUN(macroname, ...)
130 # When macroname is '['-quoted , we accept any character in the name,
131 # except ']'. Otherwise macroname stops on the first ']', ',', ')',
132 # or '\n' encountered.
134 "(?:AU_ALIAS|A[CU]_DEFUN|AC_DEFUN_ONCE)\\((?:\\[([^]]+)\\]|([^],)\n]+))";
136 # Matches an AC_REQUIRE line.
137 my $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
139 # Matches an m4_include line.
140 my $m4_include_rx = "(m4_|m4_s|s)include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
142 # Match a serial number.
143 my $serial_line_rx = '^#\s*serial\s+(\S*)';
144 my $serial_number_rx = '^\d+(?:\.\d+)*$';
147 # Set by trace_used_macros.
150 # If set, names a temporary file that must be erased on abnormal exit.
153 ################################################################
155 # Erase temporary file ERASE_ME. Handle signals.
162 verb "caught SIG$sig, bailing out";
164 if (defined $erase_me && -e $erase_me && !unlink ($erase_me))
166 fatal "could not remove '$erase_me': $!";
170 # reraise default handler.
173 $SIG{$sig} = 'DEFAULT';
178 $SIG{'INT'} = $SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = 'unlink_tmp';
186 if -d $dir or eval { File::Path::mkpath $dir };
188 $@ =~ s/\s+at\s.*\bline\s\d+.*$//;
189 fatal "could not create directory '$dir': $@";
192 # Check macros in acinclude.m4. If one is not used, warn.
193 sub check_acinclude ()
195 foreach my $key (keys %map)
197 # FIXME: should print line number of acinclude.m4.
198 msg ('syntax', "macro '$key' defined in acinclude.m4 but never used")
199 if $map{$key} eq 'acinclude.m4' && ! exists $macro_seen{$key};
209 %map_traced_defs = ();
214 %scanned_configure_dep = ();
220 # install_file ($SRC, $DESTDIR)
221 sub install_file ($$)
223 my ($src, $destdir) = @_;
224 my $dest = $destdir . "/" . basename ($src);
227 verb "installing $src to $dest";
230 || !exists $file_contents{$dest}
231 || $file_contents{$src} ne $file_contents{$dest})
235 msg 'note', "overwriting '$dest' with '$src'";
240 msg 'note', "installing '$dest' from '$src'";
245 if (! defined $diff_dest)
247 # $dest does not exist. We create an empty one just to
248 # run diff, and we erase it afterward. Using the real
249 # the destination file (rather than a temporary file) is
250 # good when diff is run with options that display the
253 # If creating $dest fails, fall back to /dev/null. At
254 # least one diff implementation (Tru64's) cannot deal
255 # with /dev/null. However working around this is not
256 # worth the trouble since nobody run aclocal on a
257 # read-only tree anyway.
259 my $f = new IO::File "> $dest";
263 $diff_dest = '/dev/null';
271 my @cmd = (@diff_command, $diff_dest, $src);
273 verb "running: @cmd";
274 my $res = system (@cmd);
275 Automake::FileUtils::handle_exec_errors "@cmd", 1
282 xsystem ('cp', $src, $dest);
287 # Compare two lists of numbers.
288 sub list_compare (\@\@)
296 return (0 == @r) ? 0 : -1;
302 elsif ($l[0] < $r[0])
306 elsif ($l[0] > $r[0])
315 ################################################################
317 # scan_m4_dirs($TYPE, @DIRS)
318 # --------------------------
319 # Scan all M4 files installed in @DIRS for new macro definitions.
320 # Register each file as of type $TYPE (one of the FT_* constants).
321 my $first_user_m4dir = 1;
322 sub scan_m4_dirs ($@)
324 my ($type, @dirlist) = @_;
326 foreach my $m4dir (@dirlist)
328 if (! opendir (DIR, $m4dir))
330 if ($install && $type == FT_USER && $first_user_m4dir)
332 # We will try to create this directory later, so don't
333 # complain if it doesn't exist.
334 # TODO: maybe we should avoid complaining only if errno
336 $first_user_m4dir = 0;
339 fatal "couldn't open directory '$m4dir': $!";
342 # We reverse the directory contents so that foo2.m4 gets
343 # used in preference to foo1.m4.
344 foreach my $file (reverse sort grep (! /^\./, readdir (DIR)))
346 # Only examine .m4 files.
347 next unless $file =~ /\.m4$/;
349 # Skip some files when running out of srcdir.
350 next if $file eq 'aclocal.m4';
352 my $fullfile = File::Spec->canonpath ("$m4dir/$file");
353 &scan_file ($type, $fullfile, 'aclocal');
359 # Scan all the installed m4 files and construct a map.
362 # First, scan configure.ac. It may contain macro definitions,
363 # or may include other files that define macros.
364 &scan_file (FT_USER, $configure_ac, 'aclocal');
366 # Then, scan acinclude.m4 if it exists.
367 if (-f 'acinclude.m4')
369 &scan_file (FT_USER, 'acinclude.m4', 'aclocal');
372 # Finally, scan all files in our search paths.
373 scan_m4_dirs (FT_USER, @user_includes);
374 scan_m4_dirs (FT_AUTOMAKE, @automake_includes);
375 scan_m4_dirs (FT_SYSTEM, @system_includes);
377 # Construct a new function that does the searching. We use a
378 # function (instead of just evaluating $search in the loop) so that
379 # "die" is correctly and easily propagated if run.
380 my $search = "sub search {\nmy \$found = 0;\n";
381 foreach my $key (reverse sort keys %map)
383 $search .= ('if (/\b\Q' . $key . '\E(?!\w)/) { & add_macro ("' . $key
384 . '"); $found = 1; }' . "\n");
386 $search .= "return \$found;\n};\n";
388 prog_error "$@\n search is $search" if $@;
391 ################################################################
393 # Add a macro to the output.
398 # Ignore unknown required macros. Either they are not really
399 # needed (e.g., a conditional AC_REQUIRE), in which case aclocal
400 # should be quiet, or they are needed and Autoconf itself will
401 # complain when we trace for macro usage later.
402 return unless defined $map{$macro};
404 verb "saw macro $macro";
405 $macro_seen{$macro} = 1;
406 &add_file ($map{$macro});
409 # scan_configure_dep ($file)
410 # --------------------------
411 # Scan a configure dependency (configure.ac, or separate m4 files)
412 # for uses of known macros and AC_REQUIREs of possibly unknown macros.
413 # Recursively scan m4_included files.
414 sub scan_configure_dep ($)
417 # Do not scan a file twice.
419 if exists $scanned_configure_dep{$file};
420 $scanned_configure_dep{$file} = 1;
422 my $mtime = mtime $file;
423 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
425 my $contents = exists $file_contents{$file} ?
426 $file_contents{$file} : contents $file;
431 foreach (split ("\n", $contents))
434 # Remove comments from current line.
437 # Avoid running all the following regexes on white lines.
440 while (/$m4_include_rx/go)
442 my $ifile = $2 || $3;
443 # Skip missing 'sinclude'd files.
444 next if $1 ne 'm4_' && ! -f $ifile;
448 while (/$ac_require_rx/go)
450 push (@rlist, $1 || $2);
453 # The search function is constructed dynamically by
454 # scan_m4_files. The last parenthetical match makes sure we
455 # don't match things that look like macro assignments or
457 if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
459 # Macro not found, but AM_ prefix found.
460 # Make this just a warning, because we do not know whether
461 # the macro is actually used (it could be called conditionally).
462 msg ('unsupported', "$file:$line",
463 "macro '$2' not found in library");
467 add_macro ($_) foreach (@rlist);
468 &scan_configure_dep ($_) foreach @ilist;
473 # Add $FILE to output.
478 # Only add a file once.
479 return if ($file_added{$file});
480 $file_added{$file} = 1;
482 scan_configure_dep $file;
485 # Point to the documentation for underquoted AC_DEFUN only once.
486 my $underquoted_manual_once = 0;
488 # scan_file ($TYPE, $FILE, $WHERE)
489 # --------------------------------
490 # Scan a single M4 file ($FILE), and all files it includes.
491 # Return the list of included files.
492 # $TYPE is one of FT_USER, FT_AUTOMAKE, or FT_SYSTEM, depending
493 # on where the file comes from.
494 # $WHERE is the location to use in the diagnostic if the file
498 my ($type, $file, $where) = @_;
499 my $basename = basename $file;
501 # Do not scan the same file twice.
502 return @{$file_includes{$file}} if exists $file_includes{$file};
503 # Prevent potential infinite recursion (if two files include each other).
504 return () if exists $file_contents{$file};
506 unshift @file_order, $file;
508 $file_type{$file} = $type;
510 fatal "$where: file '$file' does not exist" if ! -e $file;
512 my $fh = new Automake::XFile $file;
519 my $serial_older = 0;
521 while ($_ = $fh->getline)
529 if ($line =~ /$serial_line_rx/go)
532 if ($number !~ /$serial_number_rx/go)
534 msg ('syntax', "$file:$.",
535 "ill-formed serial number '$number', "
536 . "expecting a version string with only digits and dots");
540 # aclocal removes all definitions from M4 file with the
541 # same basename if a greater serial number is found.
542 # Encountering a serial after some macros will undefine
544 msg ('syntax', "$file:$.",
545 'the serial number must appear before any macro definition');
547 # We really care about serials only for non-automake macros
548 # and when --install is used. But the above diagnostics are
549 # made regardless of this, because not using --install is
550 # not a reason not the fix macro files.
551 elsif ($install && $type != FT_AUTOMAKE)
554 my @new = split (/\./, $number);
556 verb "$file:$.: serial $number";
558 if (!exists $serial{$basename}
559 || list_compare (@new, @{$serial{$basename}}) > 0)
561 # Delete any definition we knew from the old macro.
562 foreach my $def (@{$invmap{$basename}})
564 verb "$file:$.: ignoring previous definition of $def";
567 $invmap{$basename} = [];
568 $serial{$basename} = \@new;
577 # Remove comments from current line.
578 # Do not do it earlier, because the serial line is a comment.
579 $line =~ s/\bdnl\b.*$//;
582 while ($line =~ /$ac_defun_rx/go)
587 msg ('syntax', "$file:$.", "underquoted definition of $2"
588 . "\n run info Automake 'Extending aclocal'\n"
589 . " or see http://www.gnu.org/software/automake/manual/"
590 . "automake.html#Extending-aclocal")
591 unless $underquoted_manual_once;
592 $underquoted_manual_once = 1;
595 # If this macro does not have a serial and we have already
596 # seen a macro with the same basename earlier, we should
597 # ignore the macro (don't exit immediately so we can still
598 # diagnose later #serial numbers and underquoted macros).
599 $serial_older ||= ($type != FT_AUTOMAKE
600 && !$serial_seen && exists $serial{$basename});
602 my $macro = $1 || $2;
603 if (!$serial_older && !defined $map{$macro})
605 verb "found macro $macro in $file: $.";
606 $map{$macro} = $file;
607 push @{$invmap{$basename}}, $macro;
611 # Note: we used to give an error here if we saw a
612 # duplicated macro. However, this turns out to be
613 # extremely unpopular. It causes actual problems which
614 # are hard to work around, especially when you must
615 # mix-and-match tool versions.
616 verb "ignoring macro $macro in $file: $.";
620 while ($line =~ /$m4_include_rx/go)
622 my $ifile = $2 || $3;
623 # Skip missing 'sinclude'd files.
624 next if $1 ne 'm4_' && ! -f $ifile;
625 push (@inc_files, $ifile);
626 $inc_lines{$ifile} = $.;
630 # Ignore any file that has an old serial (or no serial if we know
631 # another one with a serial).
634 ($type != FT_AUTOMAKE && !$serial_seen && exists $serial{$basename}));
636 $file_contents{$file} = $contents;
638 # For some reason I don't understand, it does not work
639 # to do "map { scan_file ($_, ...) } @inc_files" below.
640 # With Perl 5.8.2 it undefines @inc_files.
641 my @copy = @inc_files;
642 my @all_inc_files = (@inc_files,
643 map { scan_file ($type, $_,
644 "$file:$inc_lines{$_}") } @copy);
645 $file_includes{$file} = \@all_inc_files;
646 return @all_inc_files;
649 # strip_redundant_includes (%FILES)
650 # ---------------------------------
651 # Each key in %FILES is a file that must be present in the output.
652 # However some of these files might already include other files in %FILES,
653 # so there is no point in including them another time.
654 # This removes items of %FILES which are already included by another file.
655 sub strip_redundant_includes (%)
659 # Always include acinclude.m4, even if it does not appear to be used.
660 $files{'acinclude.m4'} = 1 if -f 'acinclude.m4';
661 # File included by $configure_ac are redundant.
662 $files{$configure_ac} = 1;
664 # Files at the end of @file_order should override those at the beginning,
665 # so it is important to preserve these trailing files. We can remove
666 # a file A if it is going to be output before a file B that includes
667 # file A, not the converse.
668 foreach my $file (reverse @file_order)
670 next unless exists $files{$file};
671 foreach my $ifile (@{$file_includes{$file}})
673 next unless exists $files{$ifile};
674 delete $files{$ifile};
675 verb "$ifile is already included by $file";
679 # configure.ac is implicitly included.
680 delete $files{$configure_ac};
685 sub trace_used_macros ()
687 my %files = map { $map{$_} => 1 } keys %macro_seen;
688 %files = strip_redundant_includes %files;
690 my $traces = ($ENV{AUTOM4TE} || '@am_AUTOM4TE@');
691 $traces .= " --language Autoconf-without-aclocal-m4 ";
692 # All candidate files.
693 $traces .= join (' ',
695 (grep { exists $files{$_} } @file_order))) . " ";
696 # All candidate macros.
697 $traces .= join (' ',
698 (map { "--trace='$_:\$f::\$n::\$1'" }
702 '_AM_AUTOCONF_VERSION')),
703 # Do not trace $1 for all other macros as we do
704 # not need it and it might contains harmful
705 # characters (like newlines).
706 (map { "--trace='$_:\$f::\$n'" } (keys %macro_seen)));
708 verb "running $traces $configure_ac";
710 my $tracefh = new Automake::XFile ("$traces $configure_ac |");
714 while ($_ = $tracefh->getline)
717 my ($file, $macro, $arg1) = split (/::/);
719 $traced{$macro} = 1 if exists $macro_seen{$macro};
721 $map_traced_defs{$arg1} = $file
722 if ($macro eq 'AC_DEFUN'
723 || $macro eq 'AC_DEFUN_ONCE'
724 || $macro eq 'AU_DEFUN');
726 $ac_version = $arg1 if $macro eq '_AM_AUTOCONF_VERSION';
734 sub scan_configure ()
736 # Make sure we include acinclude.m4 if it exists.
737 if (-f 'acinclude.m4')
739 add_file ('acinclude.m4');
741 scan_configure_dep ($configure_ac);
744 ################################################################
747 # Return 0 iff some files were installed locally.
748 sub write_aclocal ($@)
750 my ($output_file, @macros) = @_;
754 # Get the list of files containing definitions for the macros used.
755 # (Filter out unused macro definitions with $map_traced_defs. This
756 # can happen when an Autoconf macro is conditionally defined:
757 # aclocal sees the potential definition, but this definition is
758 # actually never processed and the Autoconf implementation is used
763 if (exists $map_traced_defs{$m}
764 && $map{$m} eq $map_traced_defs{$m});
766 # Do not explicitly include a file that is already indirectly included.
767 %files = strip_redundant_includes %files;
771 for my $file (grep { exists $files{$_} } @file_order)
773 # Check the time stamp of this file, and of all files it includes.
774 for my $ifile ($file, @{$file_includes{$file}})
776 my $mtime = mtime $ifile;
777 $greatest_mtime = $mtime if $greatest_mtime < $mtime;
780 # If the file to add looks like outside the project, copy it
781 # to the output. The regex catches filenames starting with
782 # things like '/', '\', or 'c:\'.
783 if ($file_type{$file} != FT_USER
784 || $file =~ m,^(?:\w:)?[\\/],)
786 if (!$install || $file_type{$file} != FT_SYSTEM)
788 # Copy the file into aclocal.m4.
789 $output .= $file_contents{$file} . "\n";
793 # Install the file (and any file it includes).
795 for my $ifile (@{$file_includes{$file}}, $file)
797 install_file ($ifile, $user_includes[0]);
804 # Otherwise, simply include the file.
805 $output .= "m4_include([$file])\n";
811 verb "running aclocal anew, because some files were installed locally";
815 # Nothing to output?!
816 # FIXME: Shouldn't we diagnose this?
817 return 1 if ! length ($output);
821 # Do not use "$output_file" here for the same reason we do not
822 # use it in the header below. autom4te will output the name of
823 # the file in the diagnostic anyway.
824 $output = "m4_ifndef([AC_AUTOCONF_VERSION],
825 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
826 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
827 [m4_warning([this file was generated for autoconf $ac_version.
828 You have another version of autoconf. It may work, but is not guaranteed to.
829 If you have problems, you may need to regenerate the build system entirely.
830 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
835 # We used to print "# $output_file generated automatically etc." But
836 # this creates spurious differences when using autoreconf. Autoreconf
837 # creates aclocal.m4t and then rename it to aclocal.m4, but the
838 # rebuild rules generated by Automake create aclocal.m4 directly --
839 # this would gives two ways to get the same file, with a different
840 # name in the header.
841 $output = "# generated automatically by aclocal $VERSION -*- Autoconf -*-
843 # Copyright (C) 1996-$RELEASE_YEAR Free Software Foundation, Inc.
845 # This file is free software; the Free Software Foundation
846 # gives unlimited permission to copy and/or distribute it,
847 # with or without modifications, as long as this notice is preserved.
849 # This program is distributed in the hope that it will be useful,
850 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
851 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
852 # PARTICULAR PURPOSE.
856 # We try not to update $output_file unless necessary, because
857 # doing so invalidate Autom4te's cache and therefore slows down
858 # tools called after aclocal.
860 # We need to overwrite $output_file in the following situations.
861 # * The --force option is in use.
862 # * One of the dependencies is younger.
863 # (Not updating $output_file in this situation would cause
864 # make to call aclocal in loop.)
865 # * The contents of the current file are different from what
868 && $greatest_mtime < mtime ($output_file)
869 && $output eq contents ($output_file))
871 verb "$output_file unchanged";
875 verb "writing $output_file";
879 if (-e $output_file && !unlink $output_file)
881 fatal "could not remove '$output_file': $!";
883 my $out = new Automake::XFile "> $output_file";
889 ################################################################
891 # Print usage and exit.
897 Usage: aclocal [OPTION]...
899 Generate 'aclocal.m4' by scanning 'configure.ac' or 'configure.in'
902 --automake-acdir=DIR directory holding automake-provided m4 files
903 --system-acdir=DIR directory holding third-party system-wide files
904 --diff[=COMMAND] run COMMAND [diff -u] on M4 files that would be
905 changed (implies --install and --dry-run)
906 --dry-run pretend to, but do not actually update any file
907 --force always update output file
908 --help print this help, then exit
909 -I DIR add directory to search list for .m4 files
910 --install copy third-party files to the first -I directory
911 --output=FILE put output in FILE (default aclocal.m4)
912 --print-ac-dir print name of directory holding system-wide
913 third-party m4 files, then exit
914 --verbose don't be silent
915 --version print version number, then exit
916 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
918 Warning categories include:
919 syntax dubious syntactic constructs (default)
920 unsupported unknown macros (default)
921 all all the warnings (default)
922 no-CATEGORY turn off warnings in CATEGORY
923 none turn off all the warnings
924 error treat warnings as errors
926 Report bugs to <@PACKAGE_BUGREPORT@>.
927 GNU Automake home page: <@PACKAGE_URL@>.
928 General help using GNU software: <http://www.gnu.org/gethelp/>.
933 # Print version and exit.
937 aclocal (GNU $PACKAGE) $VERSION
938 Copyright (C) $RELEASE_YEAR Free Software Foundation, Inc.
939 License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
940 This is free software: you are free to change and redistribute it.
941 There is NO WARRANTY, to the extent permitted by law.
943 Written by Tom Tromey <tromey\@redhat.com>
944 and Alexandre Duret-Lutz <adl\@gnu.org>.
949 # Using --acdir overrides both the automake (versioned) directory and
950 # the public (unversioned) system directory. This usage is obsolete.
951 sub handle_acdir_option ($$)
953 msg 'obsolete', '', "'--acdir' is deprecated\n";
954 @system_includes = ($_[1]);
955 @automake_includes = ();
958 # Parse command line.
959 sub parse_arguments ()
961 my $print_and_exit = 0;
966 'help' => sub { usage(0); },
967 'version' => \&version,
968 'acdir=s' => \&handle_acdir_option,
969 'system-acdir=s' => sub { shift; @system_includes = @_; },
970 'automake-acdir=s' => sub { shift; @automake_includes = @_; },
971 'diff:s' => \$diff_command,
972 'dry-run' => \$dry_run,
973 'force' => \$force_output,
974 'I=s' => \@user_includes,
975 'install' => \$install,
976 'output=s' => \$output_file,
977 'print-ac-dir' => \$print_and_exit,
978 'verbose' => sub { setup_channel 'verb', silent => 0; },
979 'W|warnings=s' => \&parse_warnings,
982 use Automake::Getopt ();
983 Automake::Getopt::parse_options %cli_options;
987 fatal ("non-option arguments are not accepted: '$ARGV[0]'.\n"
988 . "Try '$0 --help' for more information.");
993 print "@system_includes\n";
997 if (defined $diff_command)
999 $diff_command = 'diff -u' if $diff_command eq '';
1000 @diff_command = split (' ', $diff_command);
1005 if ($install && !@user_includes)
1007 fatal ("--install should copy macros in the directory indicated by the"
1008 . "\nfirst -I option, but no -I was supplied");
1011 # Finally, adds any directory listed in the 'dirlist' file.
1012 if (open (DIRLIST, "$system_includes[0]/dirlist"))
1018 # strip off newlines and end-of-line comments
1021 foreach my $dir (glob)
1023 push (@system_includes, $dir) if -d $dir;
1030 # Add any directory listed in the 'ACLOCAL_PATH' environment variable
1031 # to the list of system include directories.
1032 sub parse_ACLOCAL_PATH ()
1034 return if not defined $ENV{"ACLOCAL_PATH"};
1035 # Directories in ACLOCAL_PATH should take precedence over system
1036 # directories, so we use unshift. However, directories that
1037 # come first in ACLOCAL_PATH take precedence over directories
1038 # coming later, which is why the result of split is reversed.
1039 foreach my $dir (reverse split /:/, $ENV{"ACLOCAL_PATH"})
1041 unshift (@system_includes, $dir) if $dir ne '' && -d $dir;
1045 ################################################################
1047 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