5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # aclocal - scan configure.in and generate aclocal.m4.
11 $VERSION = "@VERSION@";
12 $PACKAGE = "@PACKAGE@";
14 $acdir = "@datadir@/@PACKAGE@";
25 $output_file = 'aclocal.m4';
27 # Which files have been seen.
55 $obsolete_rx = '(' . join ('|', @obsolete_macros) . ')';
59 &parse_arguments (@ARGV);
68 ################################################################
70 # Print usage and exit.
75 print "Usage: aclocal [OPTIONS] ...\n";
77 --acdir=DIR directory holding config files
78 --help print this help, then exit
79 --output=FILE put output in FILE (default aclocal.m4)
80 --verbose don't be silent
81 --version print version number, then exit\n";
89 local (@arglist) = @_;
93 if ($arglist[0] =~ /^--acdir=(.+)$/)
97 elsif ($arglist[0] =~/^--output=(.+)$/)
101 elsif ($arglist[0] eq '--verbose')
105 elsif ($arglist[0] eq '--version')
107 print "aclocal - $PACKAGE $VERSION\n";
110 elsif ($arglist[0] eq '--help')
123 ################################################################
127 # First, construct list of regexps to match the things we actually
129 opendir (DIR, $acdir)
130 || die "aclocal: couldn't open directory \`$acdir': $!\n";
131 local ($search, $elt);
132 foreach (sort grep (! /^\./, readdir (DIR)))
134 # Only examine .m4 files.
135 next unless s/\.m4$//;
137 # Skip some files when running out of srcdir. Eg "aclocal.m4"
139 next unless /^[A-Za-z]+_[A-Z_]+$/;
141 print STDERR "Finding $_\n" if $verbosity;
142 ($elt = $_) =~ s/(\W)/\\$1/g;
143 $search .= "&add_file (\"$elt\") if /$elt/;\n";
147 # Construct a new function that does the searching. We use a
148 # function (instead of just evalling $search in the loop) so that
149 # "die" is correctly and easily propagated if run.
150 eval 'sub search { ' . $search . '};';
152 open (CONFIGURE, "configure.in")
153 || die "aclocal: couldn't open \`configure.in': $!\n";
157 # Remove comments from current line.
164 warn "configure.in: $.: obsolete macro \`$_'\n";
169 # Search for things we know about. The "search" sub is
170 # constructed dynamically, above.
176 # Include this file if it exists
177 if (-f 'acinclude.m4')
179 &add_file ('acinclude.m4');
183 ################################################################
185 # Add a file to output.
189 local ($fullfile) = $file;
191 return if ($file_seen{$file});
192 $file_seen{$file} = 1;
196 $fullfile = $acdir . '/' . $file . '.m4';
199 # Maybe the file is an Autoconf built-in. Check the only
200 # way we know how. Suggestions on how to make this better
202 return if $file =~ /^AC_[A-Z_]+$/;
203 die "aclocal: file \`$file' not found\n";
207 open (FILE, $fullfile)
208 || die "aclocal: couldn't open \`$fullfile': $!\n";
214 # See if some other macro is required.
215 if (/AC_REQUIRE\(\[?([^])]*)\]?\)/)
223 foreach $file (@rlist)
229 ################################################################
236 print STDERR "Writing aclocal.m4\n" if $verbosity;
238 open (ACLOCAL, "> aclocal.m4")
239 || die "aclocal: couldn't open \`aclocal.m4' for writing: $!\n";
240 print ACLOCAL "dnl aclocal.m4 generated automatically by aclocal $VERSION\n\n";
241 print ACLOCAL $output;