# Some globals.
+# configure.ac or configure.in.
+my $configure_ac = require_configure_ac;
+
# Exit status.
$exit_status = 0;
sub scan_configure ()
{
- require_configure_ac;
-
- if (! open (CONFIGURE, $configure_ac))
- {
- print STDERR "aclocal: couldn't open `$configure_ac': $!\n";
- exit 1;
- }
+ if (! open (CONFIGURE, $configure_ac))
+ {
+ print STDERR "aclocal: couldn't open `$configure_ac': $!\n";
+ exit 1;
+ }
- my $mtime = mtime $configure_ac;
- $greatest_mtime = $mtime if $greatest_mtime < $mtime;
+ my $mtime = mtime $configure_ac;
+ $greatest_mtime = $mtime if $greatest_mtime < $mtime;
- # Make sure we include acinclude.m4 if it exists.
- if (-f 'acinclude.m4')
+ # Make sure we include acinclude.m4 if it exists.
+ if (-f 'acinclude.m4')
{
- &add_file ('acinclude.m4');
+ &add_file ('acinclude.m4');
}
- while (<CONFIGURE>)
+ while (<CONFIGURE>)
{
- # Remove comments from current line.
- s/\bdnl\b.*$//;
- s/\#.*$//;
-
- # Search for things we know about. The "search" sub is
- # constructed dynamically by scan_m4_files. The last
- # parenthethical match makes sure we don't match things that
- # look like macro assignments or AC_SUBSTs.
- if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
+ # Remove comments from current line.
+ s/\bdnl\b.*$//;
+ s/\#.*$//;
+
+ # Search for things we know about. The "search" sub is
+ # constructed dynamically by scan_m4_files. The last
+ # parenthethical match makes sure we don't match things that
+ # look like macro assignments or AC_SUBSTs.
+ if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
{
- # Macro not found, but AM_ prefix found.
- warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
- $exit_status = 1;
+ # Macro not found, but AM_ prefix found.
+ warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
+ $exit_status = 1;
}
}
- close (CONFIGURE);
+ close (CONFIGURE);
}
################################################################
# Add a file to output.
sub add_file ($)
{
- local ($file) = @_;
+ local ($file) = @_;
- # Only add a file once.
- return if ($file_seen{$file});
- $file_seen{$file} = 1;
+ # Only add a file once.
+ return if ($file_seen{$file});
+ $file_seen{$file} = 1;
- my $mtime = mtime $file;
- $greatest_mtime = $mtime if $greatest_mtime < $mtime;
+ my $mtime = mtime $file;
+ $greatest_mtime = $mtime if $greatest_mtime < $mtime;
- # If the file to add looks like path outside the project,
- # copy it to the output.
- # The regex catches filenames starting with things like
- # / \ c:\ ../ ./../ etc.
- if ($file =~ m,^(?:(?:\w:)?[\\/]|(?:\.[\\/]+)*\.\.[\\/]),)
- {
- $output .= $file_contents{$file} . "\n";
- }
- else
- {
- # Otherwise, simply include the file.
- $output .= "m4_include([$file])\n";
- }
- my (@rlist);
- foreach (split ("\n", $file_contents{$file}))
+ # If the file to add looks like path outside the project,
+ # copy it to the output.
+ # The regex catches filenames starting with things like
+ # / \ c:\ ../ ./../ etc.
+ if ($file =~ m,^(?:(?:\w:)?[\\/]|(?:\.[\\/]+)*\.\.[\\/]),)
+ {
+ $output .= $file_contents{$file} . "\n";
+ }
+ else
+ {
+ # Otherwise, simply include the file.
+ $output .= "m4_include([$file])\n";
+ }
+ my (@rlist);
+ foreach (split ("\n", $file_contents{$file}))
{
- # Remove comments from current line.
- s/\bdnl\b.*$//;
- s/\#.*$//;
+ # Remove comments from current line.
+ s/\bdnl\b.*$//;
+ s/\#.*$//;
- if (/$ac_require_rx/g)
+ if (/$ac_require_rx/g)
{
- push (@rlist, $1 || $2);
+ push (@rlist, $1 || $2);
}
- # The search function is constructed dynamically by
- # scan_m4_files. The last parenthethical match makes sure we
- # don't match things that look like macro assignments or
- # AC_SUBSTs.
- if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
+ # The search function is constructed dynamically by
+ # scan_m4_files. The last parenthethical match makes sure we
+ # don't match things that look like macro assignments or
+ # AC_SUBSTs.
+ if (! &search && /(^|\s+)(AM_[A-Z0-9_]+)($|[^\]\)=A-Z0-9_])/)
{
- # Macro not found, but AM_ prefix found.
- warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
- $exit_status = 1;
+ # Macro not found, but AM_ prefix found.
+ warn "aclocal: $configure_ac: $.: macro `$2' not found in library\n";
+ $exit_status = 1;
}
}
- local ($macro);
- foreach $macro (@rlist)
+ local ($macro);
+ foreach $macro (@rlist)
{
- &add_macro ($macro);
+ &add_macro ($macro);
}
}
## Variables filled during files scanning. ##
## ---------------------------------------- ##
+# Name of the configure.ac file.
+my $configure_ac = require_configure_ac;
+
# Files found by scanning configure.ac for LIBOBJS.
my %libsources = ();
# &scan_aclocal_m4
# ----------------
# If aclocal.m4 creation is automated, return the list of its dependencies.
-sub scan_aclocal_m4
+sub scan_aclocal_m4 ()
{
- my $regen_aclocal = 0;
+ my $regen_aclocal = 0;
- set_seen 'CONFIG_STATUS_DEPENDENCIES';
- set_seen 'CONFIGURE_DEPENDENCIES';
+ set_seen 'CONFIG_STATUS_DEPENDENCIES';
+ set_seen 'CONFIGURE_DEPENDENCIES';
- if (-f 'aclocal.m4')
+ if (-f 'aclocal.m4')
{
- &push_dist_common ('aclocal.m4')
- if $relative_dir eq '.';
- &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
+ &push_dist_common ('aclocal.m4')
+ if $relative_dir eq '.';
+ &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
- my $aclocal = new Automake::XFile "< aclocal.m4";
- my $line = $aclocal->getline;
- $regen_aclocal = $line =~ 'generated automatically by aclocal';
+ my $aclocal = new Automake::XFile "< aclocal.m4";
+ my $line = $aclocal->getline;
+ $regen_aclocal = $line =~ 'generated automatically by aclocal';
}
- my @ac_deps = ();
+ my @ac_deps = ();
- if (set_seen ('ACLOCAL_M4_SOURCES'))
+ if (set_seen ('ACLOCAL_M4_SOURCES'))
{
- push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
- msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
- "`ACLOCAL_M4_SOURCES' is obsolete.\n"
- . "It should be safe to simply remove it.");
+ push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
+ msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
+ "`ACLOCAL_M4_SOURCES' is obsolete.\n"
+ . "It should be safe to simply remove it.");
}
- # Note that it might be possible that aclocal.m4 doesn't exist but
- # should be auto-generated. This case probably isn't very
- # important.
+ # Note that it might be possible that aclocal.m4 doesn't exist but
+ # should be auto-generated. This case probably isn't very
+ # important.
- return ($regen_aclocal, @ac_deps);
+ return ($regen_aclocal, @ac_deps);
}
my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
- my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
+ my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
# -------------------------------------------
# Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
# (or AC_OUTPUT).
-sub scan_autoconf_config_files
+sub scan_autoconf_config_files ($)
{
- my ($config_files) = @_;
- # Look at potential Makefile.am's.
- foreach (split ' ', $config_files)
+ my ($config_files) = @_;
+ # Look at potential Makefile.am's.
+ foreach (split ' ', $config_files)
{
- # Must skip empty string for Perl 4.
- next if $_ eq "\\" || $_ eq '';
+ # Must skip empty string for Perl 4.
+ next if $_ eq "\\" || $_ eq '';
- # Handle $local:$input syntax. Note that we ignore
- # every input file past the first, though we keep
- # those around for later.
- my ($local, $input, @rest) = split (/:/);
- if (! $input)
+ # Handle $local:$input syntax. Note that we ignore
+ # every input file past the first, though we keep
+ # those around for later.
+ my ($local, $input, @rest) = split (/:/);
+ if (! $input)
{
- $input = $local;
+ $input = $local;
}
- else
+ else
{
- # FIXME: should be error if .in is missing.
- $input =~ s/\.in$//;
+ # FIXME: should be error if .in is missing.
+ $input =~ s/\.in$//;
}
- if (-f $input . '.am')
+ if (-f $input . '.am')
{
- # We have a file that automake should generate.
- $make_list{$input} = join (':', ($local, @rest));
+ # We have a file that automake should generate.
+ $make_list{$input} = join (':', ($local, @rest));
}
- else
+ else
{
- # We have a file that automake should cause to be
- # rebuilt, but shouldn't generate itself.
- push (@other_input_files, $_);
+ # We have a file that automake should cause to be
+ # rebuilt, but shouldn't generate itself.
+ push (@other_input_files, $_);
}
}
}
# Check whether we use `configure.ac' or `configure.in'.
# Scan it (and possibly `aclocal.m4') for interesting things.
# We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
-sub scan_autoconf_files
+sub scan_autoconf_files ()
{
- # Reinitialize libsources here. This isn't really necessary,
- # since we currently assume there is only one configure.ac. But
- # that won't always be the case.
- %libsources = ();
+ # Reinitialize libsources here. This isn't really necessary,
+ # since we currently assume there is only one configure.ac. But
+ # that won't always be the case.
+ %libsources = ();
- scan_autoconf_traces (require_configure_ac);
+ scan_autoconf_traces ($configure_ac);
- # Set input and output files if not specified by user.
- if (! @input_files)
+ # Set input and output files if not specified by user.
+ if (! @input_files)
{
- @input_files = sort keys %make_list;
- %output_files = %make_list;
+ @input_files = sort keys %make_list;
+ %output_files = %make_list;
}
- @configure_input_files = sort keys %make_list;
+ @configure_input_files = sort keys %make_list;
- if (! $seen_init_automake)
- {
- err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
- . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
- . "\nthat aclocal.m4 is present in the top-level directory,\n"
- . "and that aclocal.m4 was recently regenerated "
- . "(using aclocal).");
- }
- else
- {
- if (! $seen_automake_version)
- {
- if (-f 'aclocal.m4')
- {
- error ($seen_init_automake,
- "your implementation of AM_INIT_AUTOMAKE comes from " .
- "an\nold Automake version. You should recreate " .
- "aclocal.m4\nwith aclocal and run automake again.\n");
- }
- else
- {
- error ($seen_init_automake,
- "no proper implementation of AM_INIT_AUTOMAKE was " .
- "found,\nprobably because aclocal.m4 is missing...\n" .
- "You should run aclocal to create this file, then\n" .
- "run automake again.\n");
- }
- }
- }
+ if (! $seen_init_automake)
+ {
+ err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
+ . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
+ . "\nthat aclocal.m4 is present in the top-level directory,\n"
+ . "and that aclocal.m4 was recently regenerated "
+ . "(using aclocal).");
+ }
+ else
+ {
+ if (! $seen_automake_version)
+ {
+ if (-f 'aclocal.m4')
+ {
+ error ($seen_init_automake,
+ "your implementation of AM_INIT_AUTOMAKE comes from " .
+ "an\nold Automake version. You should recreate " .
+ "aclocal.m4\nwith aclocal and run automake again.\n");
+ }
+ else
+ {
+ error ($seen_init_automake,
+ "no proper implementation of AM_INIT_AUTOMAKE was " .
+ "found,\nprobably because aclocal.m4 is missing...\n" .
+ "You should run aclocal to create this file, then\n" .
+ "run automake again.\n");
+ }
+ }
+ }
- # Look for some files we need. Always check for these. This
- # check must be done for every run, even those where we are only
- # looking at a subdir Makefile. We must set relative_dir so that
- # the file-finding machinery works.
- # FIXME: Is this broken because it needs dynamic scopes.
- # My tests seems to show it's not the case.
- $relative_dir = '.';
- require_conf_file ($configure_ac, FOREIGN,
- 'install-sh', 'mkinstalldirs', 'missing');
- err_am "`install.sh' is an anachronism; use `install-sh' instead"
- if -f $config_aux_path[0] . '/install.sh';
+ # Look for some files we need. Always check for these. This
+ # check must be done for every run, even those where we are only
+ # looking at a subdir Makefile. We must set relative_dir so that
+ # the file-finding machinery works.
+ # FIXME: Is this broken because it needs dynamic scopes.
+ # My tests seems to show it's not the case.
+ $relative_dir = '.';
+ require_conf_file ($configure_ac, FOREIGN,
+ 'install-sh', 'mkinstalldirs', 'missing');
+ err_am "`install.sh' is an anachronism; use `install-sh' instead"
+ if -f $config_aux_path[0] . '/install.sh';
- # Preserve dist_common for later.
- $configure_dist_common = variable_value ('DIST_COMMON') || '';
+ # Preserve dist_common for later.
+ $configure_dist_common = variable_value ('DIST_COMMON') || '';
}
################################################################
################################################################
+# generate_makefile ($OUTPUT, $MAKEFILE)
+# --------------------------------------
# Generate a Makefile.in given the name of the corresponding Makefile and
# the name of the file output by config.status.
-sub generate_makefile
+sub generate_makefile ($$)
{
my ($output, $makefile) = @_;