5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # aclocal - scan configure.in and generate aclocal.m4.
11 $VERSION = "@VERSION@";
13 $acdir = "@datadir@/@PACKAGE@";
23 # Which files have been seen.
51 $obsolete_rx = '(' . join ('|', @obsolete_macros) . ')';
55 &parse_arguments (@ARGV);
64 ################################################################
66 # Print usage and exit.
71 print "Usage: aclocal [OPTIONS] ...\n";
73 --acdir=DIR directory holding config files
74 --help print this help, then exit
75 --verbose don't be silent
76 --version print version number, then exit\n";
84 local (@arglist) = @_;
88 if ($arglist[0] =~ /^--acdir=(.+)$/)
92 elsif ($arglist[0] eq '--verbose')
96 elsif ($arglist[0] eq '--version')
98 print "aclocal - Autosystem $VERSION\n";
101 elsif ($arglist[0] eq '--help')
114 ################################################################
118 # First, construct list of regexps to match the things we actually
120 opendir (DIR, $acdir)
121 || die "aclocal: couldn't open directory \`$acdir': $!\n";
122 local ($search, $elt);
123 foreach (sort grep (! /^\./, readdir (DIR)))
125 # Only examine .m4 files.
126 next unless s/\.m4$//;
128 # Skip some files when running out of srcdir. Eg "aclocal.m4"
130 next unless /^[A-Za-z]+_[A-Z_]+$/;
132 print STDERR "Finding $_\n" if $verbosity;
133 ($elt = $_) =~ s/(\W)/\\$1/g;
134 $search .= "&add_file (\"$elt\") if /$elt/;\n";
138 # Construct a new function that does the searching. We use a
139 # function (instead of just evalling $search in the loop) so that
140 # "die" is correctly and easily propagated if run.
141 eval 'sub search { ' . $search . '};';
143 open (CONFIGURE, "configure.in")
144 || die "aclocal: couldn't open \`configure.in': $!\n";
148 # Remove comments from current line.
155 warn "configure.in: $.: obsolete macro \`$_'\n";
160 # Search for things we know about. The "search" sub is
161 # constructed dynamically, above.
167 # Include this file if it exists
168 if (-f 'acinclude.m4')
170 &add_file ('acinclude.m4');
174 ################################################################
176 # Add a file to output.
180 local ($fullfile) = $file;
182 return if ($file_seen{$file});
183 $file_seen{$file} = 1;
187 $fullfile = $acdir . '/' . $file . '.m4';
190 # Maybe the file is an Autoconf built-in. Check the only
191 # way we know how. Suggestions on how to make this better
193 return if $file =~ /^AC_[A-Z_]+$/;
194 die "aclocal: file \`$file' not found\n";
198 open (FILE, $fullfile)
199 || die "aclocal: couldn't open \`$fullfile': $!\n";
205 # See if some other macro is required.
206 if (/AC_REQUIRE\(\[?([^])]*)\]?\)/)
214 foreach $file (@rlist)
220 ################################################################
227 print STDERR "Writing aclocal.m4\n" if $verbosity;
229 open (ACLOCAL, "> aclocal.m4")
230 || die "aclocal: couldn't open \`aclocal.m4' for writing: $!\n";
231 print ACLOCAL "dnl aclocal.m4 generated automatically by aclocal $VERSION\n\n";
232 print ACLOCAL $output;