3 # Makefile. Generated from Makefile.in by configure.
5 eval 'case $# in 0) exec /bin/perl -S "$0";; *) exec /bin/perl -S "$0" "$@";; esac'
8 # aclocal - create aclocal.m4 by scanning configure.ac
10 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
11 # 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 2, 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, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 # Written by Tom Tromey <tromey@redhat.com>.
32 my $perllibdir = $ENV{'perllibdir'} || '/usr/share/automake-1.7';
33 unshift @INC, $perllibdir;
36 use Automake
::General
;
42 $PACKAGE = 'automake';
43 # Note that this isn't pkgdatadir, but a separate directory.
44 # Note also that the versioned directory is handled later.
45 $acdir = '/usr/share/aclocal';
46 $default_acdir = $acdir;
47 # contains a list of directories, one per line, to be added
48 # to the dirlist in addition to $acdir, as if -I had been
49 # added to the command line. If acdir has been redirected,
50 # we will also check the specified acdir (this is done later).
51 $default_dirlist = "$default_acdir/dirlist";
58 # Name of the top autoconf input: `configure.ac' or `configure.in'.
59 $configure_ac = find_configure_ac
;
65 $output_file = 'aclocal.m4';
67 # Which macros have been seen.
70 # Which files have been seen.
73 # Map macro names to file names.
76 # Map file names to file contents.
82 # Matches a macro definition.
83 # AC_DEFUN([macroname], ...)
85 # AC_DEFUN(macroname, ...)
86 # When macroname is `['-quoted , we accept any character in the name,
87 # except `]'. Otherwise macroname stops on the first `]', `,', `)',
88 # or `\n' encountered.
89 $ac_defun_rx = "A[CU]_DEFUN\\((?:\\[([^]]+)\\]|([^],)\n]+))";
91 # Matches an AC_REQUIRE line.
92 $ac_require_rx = "AC_REQUIRE\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)";
96 local (@dirlist) = &parse_arguments
(@ARGV);
97 &scan_m4_files
(@dirlist);
107 ################################################################
109 # Print usage and exit.
112 local ($status) = @_;
114 print "Usage: aclocal [OPTIONS] ...\n\n";
116 Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
118 --acdir=DIR directory holding config files
119 --help print this help, then exit
120 -I DIR add directory to search list for .m4 files
121 --output=FILE put output in FILE (default aclocal.m4)
122 --print-ac-dir print name of directory holding m4 files
123 --verbose don't be silent
124 --version print version number, then exit
126 Report bugs to <bug-automake\@gnu.org>.\n";
131 # Parse command line.
132 sub parse_arguments
(@
)
134 local (@arglist) = @_;
136 local ($print_and_exit) = 0;
140 if ($arglist[0] =~ /^--acdir=(.+)$/)
144 elsif ($arglist[0] =~/^--output=(.+)$/)
148 elsif ($arglist[0] eq '-I')
151 push (@dirlist, $arglist[0]);
153 elsif ($arglist[0] eq '--print-ac-dir')
157 elsif ($arglist[0] eq '--verbose')
161 elsif ($arglist[0] eq '--version')
163 print "aclocal (GNU $PACKAGE) $VERSION\n\n";
164 print "Copyright (C) 2002 Free Software Foundation, Inc.\n";
165 print "This is free software; see the source for copying conditions. There is NO\n";
166 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
167 print "Written by Tom Tromey <tromey\@redhat.com>\n";
170 elsif ($arglist[0] eq '--help')
176 die "aclocal: unrecognized option -- `$arglist[0]'\nTry `aclocal --help' for more information.\n";
188 $default_dirlist="$acdir/dirlist"
189 if $acdir ne $default_acdir;
191 # Search the versioned directory near the end, and then the
192 # unversioned directory last. Only do this if the user didn't
194 push (@dirlist, "$acdir-$APIVERSION")
195 if $acdir eq $default_acdir;
197 # By default $(datadir)/aclocal doesn't exist. We don't want to
198 # get an error in the case where we are searching the default
199 # directory and it hasn't been created.
200 push (@dirlist, $acdir)
201 unless $acdir eq $default_acdir && ! -d
$acdir;
203 # Finally, adds any directory listed in the `dirlist' file.
204 if (open (DEFAULT_DIRLIST
, $default_dirlist))
206 while (<DEFAULT_DIRLIST
>)
210 # strip off newlines and end-of-line comments
212 chomp ($contents=$_);
215 push (@dirlist, $contents);
218 close (DEFAULT_DIRLIST
);
225 ################################################################
227 sub scan_configure
()
229 die "aclocal: `configure.ac' or `configure.in' is required\n"
232 open (CONFIGURE
, $configure_ac)
233 || die "aclocal: couldn't open `$configure_ac': $!\n";
235 # Make sure we include acinclude.m4 if it exists.
236 if (-f
'acinclude.m4')
238 &add_file
('acinclude.m4');
243 # Remove comments from current line.
247 # Search for things we know about. The "search" sub is
248 # constructed dynamically by scan_m4_files. The last
249 # parenthethical match makes sure we don't match things that
250 # look like macro assignments or AC_SUBSTs.
251 if (! &search
&& /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
253 # Macro not found, but AM_ prefix found.
254 warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
262 ################################################################
264 # Check macros in acinclude.m4. If one is not used, warn.
265 sub check_acinclude
()
269 foreach $key (keys %map)
271 next unless $map{$key} eq 'acinclude.m4';
272 if (! $macro_seen{$key})
274 # FIXME: should print line number of acinclude.m4.
275 warn "aclocal: macro `$key' defined in acinclude.m4 but never used\n";
280 ################################################################
282 # Scan all the installed m4 files and construct a map.
283 sub scan_m4_files
(@
)
285 local (@dirlist) = @_;
287 # First, scan acinclude.m4 if it exists.
288 if (-f
'acinclude.m4')
290 $file_contents{'acinclude.m4'} = &scan_file
('acinclude.m4');
294 foreach $m4dir (@dirlist)
296 opendir (DIR
, $m4dir)
297 || die "aclocal: couldn't open directory `$m4dir': $!\n";
298 local ($file, $fullfile);
299 foreach $file (sort grep (! /^\./, readdir (DIR
)))
301 # Only examine .m4 files.
302 next unless $file =~ /\.m4$/;
304 # Skip some files when running out of srcdir.
305 next if $file eq 'aclocal.m4';
307 $fullfile = $m4dir . '/' . $file;
308 $file_contents{$fullfile} = &scan_file
($fullfile);
313 # Construct a new function that does the searching. We use a
314 # function (instead of just evalling $search in the loop) so that
315 # "die" is correctly and easily propagated if run.
316 my $search = "sub search {\nmy \$found = 0;\n";
317 foreach my $key (reverse sort keys %map)
319 $search .= ('if (/\b\Q' . $key . '\E(?!\w)/) { & add_macro ("' . $key
320 . '"); $found = 1; }' . "\n");
322 $search .= "return \$found;\n};\n";
324 die "internal error: $@\n search is $search" if $@
;
327 ################################################################
329 # Add a macro to the output.
334 # We want to ignore AC_ macros. However, if an AC_ macro is
335 # defined in (eg) acinclude.m4, then we want to make sure we mark
337 return if $macro =~ /^AC_/ && ! defined $map{$macro};
339 if (! defined $map{$macro})
341 warn "aclocal: macro `$macro' required but not defined\n";
346 print STDERR
"aclocal: saw macro $macro\n" if $verbose;
347 $macro_seen{$macro} = 1;
348 &add_file
($map{$macro});
351 # Add a file to output.
356 # Only add a file once.
357 return if ($file_seen{$file});
358 $file_seen{$file} = 1;
360 $output .= $file_contents{$file} . "\n";
362 foreach (split ("\n", $file_contents{$file}))
364 # Remove comments from current line.
368 if (/$ac_require_rx/g)
370 push (@rlist, $1 || $2);
373 # The search function is constructed dynamically by
374 # scan_m4_files. The last parenthethical match makes sure we
375 # don't match things that look like macro assignments or
377 if (! &search
&& /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
379 # Macro not found, but AM_ prefix found.
380 warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
386 foreach $macro (@rlist)
392 # Scan a single M4 file. Return contents.
397 my $fh = new Automake
::XFile
$file;
399 while ($_ = $fh->getline)
408 if (! defined $map{$1 || $2})
410 $map{$1 || $2} = $file;
413 # Note: we used to give an error here if we saw a
414 # duplicated macro. However, this turns out to be
415 # extremely unpopular. It causes actual problems which
416 # are hard to work around, especially when you must
417 # mix-and-match tool versions.
419 print STDERR
"aclocal: found macro $1 in $file: $.\n" if $verbose;
426 ################################################################
431 return if ! length ($output);
433 print STDERR
"aclocal: writing $output_file\n" if $verbose;
435 my $out = new Automake
::XFile
"> $output_file";
437 # We used to print `# $output_file generated automatically etc.' But
438 # this creates spurious differences when using autoreconf. Autoreconf
439 # creates aclocal.m4t and then rename it to aclocal.m4, but the
440 # rebuild rules generated by Automake create aclocal.m4 directly --
441 # this would gives two ways to get the same file, with a different
442 # name in the header.
444 "# generated automatically by aclocal $VERSION -*- Autoconf -*-
446 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
447 # Free Software Foundation, Inc.
448 # This file is free software; the Free Software Foundation
449 # gives unlimited permission to copy and/or distribute it,
450 # with or without modifications, as long as this notice is preserved.
452 # This program is distributed in the hope that it will be useful,
453 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
454 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
455 # PARTICULAR PURPOSE.
460 ### Setup "GNU" style for perl-mode and cperl-mode.
462 ## perl-indent-level: 2
463 ## perl-continued-statement-offset: 2
464 ## perl-continued-brace-offset: 0
465 ## perl-brace-offset: 0
466 ## perl-brace-imaginary-offset: 0
467 ## perl-label-offset: -2
468 ## cperl-indent-level: 2
469 ## cperl-brace-offset: 0
470 ## cperl-continued-brace-offset: 0
471 ## cperl-label-offset: -2
472 ## cperl-extra-newline-before-brace: t
473 ## cperl-merge-trailing-else: nil
474 ## cperl-continued-statement-offset: 2