# List of files in AC_OUTPUT without Makefile.am, and their outputs.
@other_input_files = ();
-%other_output_files = ();
# Line number at which AC_OUTPUT seen.
$ac_output_line = 0;
}
else
{
- # Handle $local:$input syntax.
- local ($local, $input) = split (/:/, $arglist[0]);
- $input = $local if (!$input);
- $input =~ s/\.in$//;
+ # Handle $local:$input syntax. Note that we only examine
+ # the first ":" file to see if it is automake input; the
+ # rest are just taken verbatim. We still keep all the
+ # files around for dependency checking, however.
+ local ($local, $input, @rest) = split (/:/, $arglist[0]);
+ if (! $input)
+ {
+ $input = $local;
+ }
+ else
+ {
+ # Strip .in; later on .am is tacked on. That is how
+ # the automake input file is found. Maybe not the
+ # best way, but it is easy to explain. FIXME: should
+ # be error if .in is missing.
+ $input =~ s/\.in$//;
+ }
push (@input_files, $input);
- $output_files{$input} = $local;
+ $output_files{$input} = join (':', ($local, @rest));
}
shift (@arglist);
$in_file_name = $am_file_name . '.in';
$am_file_name .= '.am';
+ # $OUTPUT is encoded. If it contains a ":" then the first element
+ # is the real output file, and all remaining elements are input
+ # files. We don't scan or otherwise deal with these input file,
+ # other than to mark them as dependencies. See scan_configure for
+ # details.
+ local (@secondary_inputs);
+ ($output, @secondary_inputs) = split (/:/, $output);
+
&initialize_per_input;
$relative_dir = &dirname ($output);
$am_relative_dir = &dirname ($makefile);
&check_gnu_standards;
&check_gnits_standards;
- &handle_configure ($output, $makefile);
+ &handle_configure ($output, $makefile, @secondary_inputs);
&handle_gettext;
&handle_libraries;
&handle_programs;
&& cd $(srcdir) \\
&& automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
# Set strictness of output.
- . ($cygnus_mode ? ' --cygnus' : ('--' . $strictness_name))
+ . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
. "\n"
);
}
}
}
+# Rewrite a list of input files into a form suitable to put on a
+# dependency list. The idea is that if an input file has a directory
+# part the same as the current directory, then the directory part is
+# simply removed. But if the directory part is different, then
+# $(top_srcdir) is prepended. Among other things, this is used to
+# generate the dependency list for the output files generated by
+# AC_OUTPUT. Consider what the dependencies should look like in this
+# case:
+# AC_OUTPUT(src/out:src/in1:lib/in2)
+sub rewrite_inputs_into_dependencies
+{
+ local (@inputs) = @_;
+ local ($single, @newinputs);
+
+ foreach $single (@inputs)
+ {
+ if (&dirname ($single) eq $relative_dir)
+ {
+ push (@newinputs, &basename ($single));
+ }
+ else
+ {
+ push (@newinputs, '$(top_srcdir)/' . $single);
+ }
+ }
+
+ return @newinputs;
+}
+
# Handle remaking and configure stuff.
# We need the name of the input file, to do proper remaking rules.
sub handle_configure
{
- local ($local, $input) = @_;
+ local ($local, $input, @secondary_inputs) = @_;
# If SUBDIRS defined, require AC_PROG_MAKE_SET.
&am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
if &variable_defined ('SUBDIRS') && ! $seen_make_set;
local ($top_reldir);
- local ($xform) = ('s/\@ARGS\@/'
- . ($cygnus_mode ? ' --cygnus'
- : ('--' . $strictness_name))
- . '/;');
# Handle $local:$input syntax again.
local ($amfile, $infile, $colon_infile);
- if ($local eq $input)
+ $amfile = $input . '.am';
+ # We know we can always add '.in' because it really should be an
+ # error if the .in was missing originally.
+ $infile = '$(srcdir)/' . $input . '.in';
+ if ($local ne $input)
{
- $amfile = 'Makefile.am';
- $infile = '$(srcdir)/Makefile.in';
- $colon_infile = '';
- }
- else
- {
- $amfile = '$(top_srcdir)/' . $input . '.am';
- $infile = '$(top_srcdir)/' . $input . '.in';
$colon_infile = ':' . $input . '.in';
}
-
- # Quote the amfile, infile, and colon_infile for the regular expression.
- $amfile =~ s/([\$\(\)\/])/\\$1/g;
- $infile =~ s/([\$\(\)\/])/\\$1/g;
- $colon_infile =~ s/([\$\(\)\/])/\\$1/g;
-
- $xform .= 's/\@AMFILE\@/' . $amfile . '/;';
- $xform .= 's/\@INFILE\@/' . $infile . '/;';
- $xform .= 's/\@COLON_INFILE\@/' . $colon_infile . '/;';
+ $colon_infile .= ':' . join (':', @secondary_inputs)
+ if @secondary_inputs;
+
+ local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
+ # This rule remakes the Makefile.in. Note use of @MAINT@ forces
+ # us to abandon pretty-printing. Sigh.
+ $output_rules .= ($infile . ': ' . ($seen_maint_mode ? '@MAINT@ ' : '')
+ . $amfile . ' ' . '$(top_srcdir)/configure.in '
+ . join (' ', @rewritten) . "\n"
+ . "\tcd \$(top_srcdir) && automake "
+ . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
+ . ' ' . $input . $colon_infile . "\n\n");
+
+ # This rule remakes the Makefile.
+ $output_rules .= ($local . ': ' . $infile . ' '
+ . '$(top_builddir)/config.status $(BUILT_SOURCES)'
+ . "\n"
+ . "\tcd \$(top_builddir) \\\n"
+ . "\t && CONFIG_FILES="
+ # FIXME: is this right?
+ . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
+ . $colon_infile
+ . ' CONFIG_HEADERS= $(SHELL) ./config.status'
+ . "\n\n");
if ($relative_dir ne '.')
{
# In subdirectory.
- $output_rules .= &file_contents_with_transform ($xform, 'remake-subd');
$top_reldir = '../';
}
else
{
&handle_aclocal_m4;
- $output_rules .= &file_contents_with_transform ($xform, 'remake');
+ $output_rules .= &file_contents ('remake');
&examine_variable ('CONFIGURE_DEPENDENCIES');
$top_reldir = '';
}
# by config.status, and generate rules for them.
local (@actual_other_files) = ();
local ($file, $local);
- local (@inputs);
+ local (@inputs, $single);
foreach $file (@other_input_files)
{
- # Skip files not in this directory, any Makefile, and the
- # config header. These last two must be handled specially.
- next unless &dirname ($file) eq $relative_dir;
- next if $file eq $top_builddir . '/' . $config_name;
- ($local = $file) =~ s/^.*\///;
- next if $local eq 'Makefile';
-
- if ($local =~ /^(.*):(.*)$/)
+ if ($file =~ /^(.*):(.*)$/)
{
- # This is the ":" syntax of AC_OUTPUT. Note that the
- # first word on @inputs must be the name of the created
- # file.
+ # This is the ":" syntax of AC_OUTPUT.
@inputs = split (':', $2);
- $local = $1;
+ $file = $1;
+ $local = &basename ($file);
}
else
{
# Normal usage.
- @inputs = $local . '.in';
+ $local = &basename ($file);
+ @inputs = ($file . '.in');
}
+
+ # Skip files not in this directory.
+ next unless &dirname ($local) eq $relative_dir;
+
+ # Skip the config header.
+ next if $local eq $top_builddir . '/' . $config_name;
+
+ # Skip any Makefile.
+ next if $local eq 'Makefile';
+
+ @inputs = &rewrite_inputs_into_dependencies (@inputs);
+
# FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
# to $local:$input?
$output_rules .= ($local . ': '
%libsources = ();
local ($in_ac_output, $in_ac_replace) = (0, 0);
- local (@make_list, @make_input_list);
+ local (%make_list, @make_input_list);
local ($libobj_iter);
while (<CONFIGURE>)
{
{
next if $_ eq "\\";
- # Handle $local:$input syntax.
- local ($local, $input) = split (/:/);
- $input = $local if (!$input);
- $input =~ s/\.in$//;
+ # Handle $local:$input syntax. Note that we ignore
+ # every input file past the first, though we keep
+ # those around for later.
+ local ($local, $input, @rest) = split (/:/);
+ if (! $input)
+ {
+ $input = $local;
+ }
+ else
+ {
+ # FIXME: should be error if .in is missing.
+ $input =~ s/\.in$//;
+ }
if (-f $input . '.am')
{
+ # We have a file that automake should generate.
push (@make_input_list, $input);
- $make_list{$input} = $local;
+ $make_list{$input} = join (':', ($local, @rest));
}
else
{
- push (@other_input_files, $file);
- $other_output_files{$input} = $local;
+ # We have a file that automake should cause to be
+ # rebuilt, but shouldn't generate itself.
+ push (@other_input_files, $_);
}
}
}