[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: AC_CONFIG_FILES and multiple input files.
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: AC_CONFIG_FILES and multiple input files. |
Date: |
Tue, 23 Sep 2003 10:14:13 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
I'm checking this in.
This adds support for
AC_CONFIG_FILES([Makefile:top.in:Makefile.in:bot.in:...]
i.e., where Makefile.am is not necessary the first of the input files.
Additionally it fixes a few things related to subdirectory
handling. Although the patch doesn't emphasis it (I consider
this tricky) it's now possible to write things like
AC_CONFIG_FILES([sub/Makefile:mk/sub.in])
if mk/sub.am exists.
2003-09-23 Alexandre Duret-Lutz <address@hidden>
Support for multiple inputs in AC_CONFIG_FILES.
Requested long ago by Harlan Stenn.
* automake.in (handle_dist): Remove unused argument $makefile.
(handle_subdirs): Expect SUBDIRS elements in $relative_dir,
not $am_relative_dir.
(rewrite_inputs_into_dependencies): Allow $add_srcdir to
be a filename that must always be prefixed by $(srcdir) or
$(top_srcdir).
(handle_configure, generate_makefile): Revamp to make the
Makefile.am, Makefile.in, Makefile more independent.
(locate_am): New function.
(scan_configure_dep, parse_arguments): Use locate_am.
(MAIN): Adjust call to generate_makefile.
* lib/am/configure.am: Remove %MAKEFILE-IN% from the dependencies
of %MAKEFILE%. %MAKEFILE-IN% is already in %MAKEFILE-DEPS%.
* tests/output6.test, tests/output7.test: New files.
* tests/Makefile.am (TESTS): Add them.
* automake.texi (Requirements) <AC_CONFIG_FILES>: Document how
multiple inputs are scanned.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.227
diff -u -r1.227 NEWS
--- NEWS 6 Sep 2003 21:10:38 -0000 1.227
+++ NEWS 23 Sep 2003 07:49:41 -0000
@@ -95,6 +95,11 @@
will only be useful in projects generated with future versions of
these tools.
+ - When using AC_CONFIG_FILES with multiple input files, Automake
+ generates the first ".in" input file for which a ".am" exists.
+ (Former versions would try to use only the first of the input
+ files.)
+
* Obsolete features
- lisp_DATA is now allowed. If you are using the empty ELCFILES
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1504
diff -u -r1.1504 automake.in
--- automake.in 7 Sep 2003 09:55:35 -0000 1.1504
+++ automake.in 23 Sep 2003 07:49:45 -0000
@@ -3041,13 +3041,11 @@
}
-# handle_dist ($MAKEFILE)
-# -----------------------
+# handle_dist
+# -----------
# Handle 'dist' target.
-sub handle_dist
+sub handle_dist ()
{
- my ($makefile) = @_;
-
# `make dist' isn't used in a Cygnus-style tree.
# Omit the rules so that people don't try to use them.
return if option 'cygnus';
@@ -3260,9 +3258,9 @@
# Skip directories substituted by configure.
next if $dir =~ /address@hidden@$/;
- if (! -d $am_relative_dir . '/' . $dir)
+ if (! -d $relative_dir . '/' . $dir)
{
- err_var ('SUBDIRS', "required directory $am_relative_dir/$dir "
+ err_var ('SUBDIRS', "required directory $relative_dir/$dir "
. "does not exist");
next;
}
@@ -3328,8 +3326,11 @@
# AC_OUTPUT. Consider what the dependencies should look like in this
# case:
# AC_OUTPUT(src/out:src/in1:lib/in2)
-# The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
-# If 0 then files that require this addition will simply be ignored.
+# If the first argument, ADD_SRCDIR, is non-zero (e.g. 1), $(top_srcdir)
+# is added to files which are not in the current directory.
+# If ADD_SRCDIR is a filename and the filename occurs in INPUTS, it
+# will be prefixed with $(srcdir) unless already prefixed by $(top_srcdir)
+# by the above rule.
sub rewrite_inputs_into_dependencies ($@)
{
my ($add_srcdir, @inputs) = @_;
@@ -3339,62 +3340,57 @@
{
if (dirname ($single) eq $relative_dir)
{
- push (@newinputs, basename ($single));
+ push (@newinputs,
+ ($add_srcdir eq $single ? '$(srcdir)/' : '')
+ . basename ($single));
}
else
{
- push (@newinputs, ($add_srcdir ? '$(top_srcdir)/' : '') . $single);
+ push (@newinputs,
+ ($add_srcdir ? '$(top_srcdir)/' : '') . $single);
}
}
return @newinputs;
}
-# &handle_configure ($LOCAL, $INPUT, @SECONDARY_INPUTS)
-# -----------------------------------------------------
+# &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
+# ------------------------------------------------------------------
# Handle remaking and configure stuff.
# We need the name of the input file, to do proper remaking rules.
-sub handle_configure ($$@)
+sub handle_configure ($$$@)
{
- my ($local, $input, @secondary_inputs) = @_;
-
- my $input_base = basename ($input);
- my $local_base = basename ($local);
-
- my $amfile = $input_base . '.am';
- # We know we can always add '.in' because it really should be an
- # error if the .in was missing originally.
- my $infile = '$(srcdir)/' . $input_base . '.in';
- my $colon_infile = '';
- if ($local ne $input || @secondary_inputs)
- {
- $colon_infile = ':' . $input . '.in';
- }
- $colon_infile .= ':' . join (':', @secondary_inputs)
- if @secondary_inputs;
+ my ($makefile_am, $makefile_in, $makefile, @inputs) = @_;
- my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
+ prog_error 'empty @inputs'
+ unless @inputs;
+ my ($rel_makefile_am) = rewrite_inputs_into_dependencies (1, $makefile_am);
+ my ($rel_makefile_in) = rewrite_inputs_into_dependencies ($makefile_in,
+ $makefile_in);
+ my $rel_makefile = basename $makefile;
+
+ my $colon_infile = ':' . join (':', @inputs);
+ $colon_infile = '' if $colon_infile eq ":$makefile.in";
+ my @rewritten = rewrite_inputs_into_dependencies ($makefile_in, @inputs);
my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
-
-
define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
@configure_deps);
$output_rules .= file_contents
('configure',
new Automake::Location,
- MAKEFILE => $local_base,
+ MAKEFILE => $rel_makefile,
'MAKEFILE-DEPS' => "@rewritten",
'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
- 'MAKEFILE-IN' => $infile,
+ 'MAKEFILE-IN' => $rel_makefile_in,
'MAKEFILE-IN-DEPS' => "@include_stack",
- 'MAKEFILE-AM' => $amfile,
+ 'MAKEFILE-AM' => $rel_makefile_am,
STRICTNESS => global_option 'cygnus'
? 'cygnus' : $strictness_name,
'USE-DEPS' => global_option 'no-dependencies'
? ' --ignore-deps' : '',
- 'MAKEFILE-AM-SOURCES' => "$input$colon_infile",
+ 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile",
'REGEN-ACLOCAL-M4' => $regen_aclocal_m4,
ACLOCAL_M4_DEPS => "@aclocal_m4_deps");
@@ -3540,7 +3536,8 @@
}
# Automake files should not be stored in here, but in %MAKE_LIST.
- prog_error "$lfile in address@hidden"
+ prog_error ("$lfile in address@hidden"
+ . "address@hidden = (@other_input_files)")
if -f $file . '.am';
my $local = basename ($file);
@@ -4174,6 +4171,26 @@
return ($output, @inputs);
}
+# $input
+# locate_am (@POSSIBLE_SOURCES)
+# -----------------------------
+# AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
+# This functions returns the first *.in file for which a *.am exists.
+# It returns undef otherwise.
+sub locate_am (@)
+{
+ my (@rest) = @_;
+ my $input;
+ foreach my $file (@rest)
+ {
+ if (($file =~ /^(.*)\.in$/) && -f "$1.am")
+ {
+ $input = $file;
+ last;
+ }
+ }
+ return $input;
+}
my %make_list;
@@ -4184,27 +4201,18 @@
sub scan_autoconf_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 '';
- # 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;
- }
- else
- {
- # FIXME: should be error if .in is missing.
- $input =~ s/\.in$//;
- }
-
- if (-f $input . '.am')
+ # Handle $local:$input syntax.
+ my ($local, @rest) = split (/:/);
+ @rest = ("$local.in",) unless @rest;
+ my $input = locate_am @rest;
+ if ($input)
{
# We have a file that automake should generate.
$make_list{$input} = join (':', ($local, @rest));
@@ -4424,14 +4432,14 @@
scan_autoconf_traces ($configure_ac);
+ @configure_input_files = sort keys %make_list;
# Set input and output files if not specified by user.
if (! @input_files)
{
- @input_files = sort keys %make_list;
+ @input_files = @configure_input_files;
%output_files = %make_list;
}
- @configure_input_files = sort keys %make_list;
if (! $seen_init_automake)
{
@@ -6501,13 +6509,13 @@
################################################################
-# generate_makefile ($OUTPUT, $MAKEFILE)
-# --------------------------------------
+# generate_makefile ($MAKEFILE_AM, $MAKEFILE_IN)
+# ----------------------------------------------
# Generate a Makefile.in given the name of the corresponding Makefile and
# the name of the file output by config.status.
sub generate_makefile ($$)
{
- my ($output, $makefile) = @_;
+ my ($makefile_am, $makefile_in) = @_;
# Reset all the Makefile.am related variables.
initialize_per_input;
@@ -6519,21 +6527,20 @@
# Name of input file ("Makefile.am") and output file
# ("Makefile.in"). These have no directory components.
- $am_file_name = basename ($makefile) . '.am';
- $in_file_name = basename ($makefile) . '.in';
+ $am_file_name = basename ($makefile_am);
+ $in_file_name = basename ($makefile_in);
# $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 files,
# other than to mark them as dependencies. See
# &scan_autoconf_files for details.
- my (@secondary_inputs);
- ($output, @secondary_inputs) = split (/:/, $output);
+ my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in});
- $relative_dir = dirname ($output);
- $am_relative_dir = dirname ($makefile);
+ $relative_dir = dirname ($makefile);
+ $am_relative_dir = dirname ($makefile_am);
- read_main_am_file ($makefile . '.am');
+ read_main_am_file ($makefile_am);
if (handle_options)
{
# Process buffered warnings.
@@ -6582,7 +6589,7 @@
check_gnu_standards;
check_gnits_standards;
- handle_configure ($output, $makefile, @secondary_inputs);
+ handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
handle_gettext;
handle_libraries;
handle_ltlibraries;
@@ -6618,11 +6625,11 @@
handle_tests;
# This must come after most other rules.
- handle_dist ($makefile);
+ handle_dist;
handle_footer;
do_check_merge_target;
- handle_all ($output);
+ handle_all ($makefile);
# FIXME: Gross!
if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
@@ -6645,10 +6652,10 @@
mkdir ($output_directory . '/' . $am_relative_dir, 0755);
}
- my ($out_file) = $output_directory . '/' . $makefile . ".in";
+ my ($out_file) = $output_directory . '/' . $makefile_in;
# We make sure that `all:' is the first target.
- $output =
+ my $output =
"$output_vars$output_all$output_header$output_rules$output_trailer";
# Decide whether we must update the output file or not.
@@ -6871,25 +6878,19 @@
. "Try `$0 --help' for more information.");
}
- # 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.
- my ($local, $input, @rest) = split (/:/, $arg);
- if (! $input)
+ # Handle $local:$input syntax.
+ my ($local, @rest) = split (/:/, $arg);
+ @rest = ("$local.in",) unless @rest;
+ my $input = locate_am @rest;
+ if ($input)
{
- $input = $local;
+ push @input_files, $input;
+ $output_files{$input} = join (':', ($local, @rest));
}
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.
- $input =~ s/\.in$//
- or fatal "invalid input file name `$arg'\n.";
+ error "no Automake input file found in `$arg'";
}
- push (@input_files, $input);
- $output_files{$input} = join (':', ($local, @rest));
}
}
@@ -6924,7 +6925,7 @@
# Now do all the work on each file.
foreach my $file (@input_files)
{
- $am_file = $file;
+ ($am_file = $file) =~ s/\.in$//;
if (! -f ($am_file . '.am'))
{
error "`$am_file.am' does not exist";
@@ -6934,7 +6935,7 @@
# Any warning setting now local to this Makefile.am.
dup_channel_setup;
- generate_makefile ($output_files{$am_file}, $am_file);
+ generate_makefile ($am_file . '.am', $file);
# Back out any warning setting.
drop_channel_setup;
Index: automake.texi
===================================================================
RCS file: /cvs/automake/automake/automake.texi,v
retrieving revision 1.352
diff -u -r1.352 automake.texi
--- automake.texi 6 Sep 2003 05:36:56 -0000 1.352
+++ automake.texi 23 Sep 2003 07:49:50 -0000
@@ -1120,7 +1120,13 @@
Typically, @code{AC_CONFIG_FILES([foo/Makefile])} will cause Automake to
generate @file{foo/Makefile.in} if @file{foo/Makefile.am} exists.
-These files are all removed by @code{make distclean}.
+When using @code{AC_CONFIG_FILES} with multiple input files, as in
address@hidden([Makefile:top.in:Makefile.in:bot.in])}, Automake
+will generate the first @file{.in} input file for which a @file{.am}
+file exists. If no such file exists the output file is not considered
+to be Automake generated.
+
+Files created by @code{AC_CONFIG_FILES} are removed by @code{make distclean}.
@cvindex AC_CONFIG_FILES
@cvindex AC_OUTPUT
@end table
Index: lib/am/configure.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/configure.am,v
retrieving revision 1.24
diff -u -r1.24 configure.am
--- lib/am/configure.am 24 Jul 2003 21:26:55 -0000 1.24
+++ lib/am/configure.am 23 Sep 2003 07:49:52 -0000
@@ -54,7 +54,7 @@
$(AUTOMAKE) --%STRICTNESS% %USE-DEPS% %MAKEFILE-AM-SOURCES%
## This rule remakes the Makefile.
-%MAKEFILE%: %MAINTAINER-MODE% %MAKEFILE-IN% %MAKEFILE-DEPS%
$(top_builddir)/config.status
+%MAKEFILE%: %MAINTAINER-MODE% %MAKEFILE-DEPS% $(top_builddir)/config.status
## If Makefile is to be updated because of config.status, then run
## config.status without argument in order to (i) rerun all the
## AC_CONFIG_COMMANDS including those that are not visible to
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.516
diff -u -r1.516 Makefile.am
--- tests/Makefile.am 7 Sep 2003 13:26:44 -0000 1.516
+++ tests/Makefile.am 23 Sep 2003 07:49:53 -0000
@@ -328,6 +328,8 @@
output3.test \
output4.test \
output5.test \
+output6.test \
+output7.test \
overrid.test \
parse.test \
percent.test \
Index: tests/output6.test
===================================================================
RCS file: tests/output6.test
diff -N tests/output6.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/output6.test 23 Sep 2003 07:49:53 -0000
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check for support for colon separated input files in AC_CONFIG_FILES
+
+required=GNUmake
+. ./defs || exit 1
+
+set -e
+
+cat > configure.in << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES(foo:a.in:b.in:c.in:d.in)
+AC_OUTPUT
+END
+
+cat >a.in <<'EOF'
+a = A
+b = A
+c = A
+d = A
+EOF
+
+cat >b.in <<'EOF'
+b = B
+c = B
+d = B
+EOF
+
+cat >c.am <<'EOF'
+c = C
+d = C
+
+print:
+ @echo $a$b$c$d
+EOF
+
+echo 'd = D' > d.in
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE -f foo print | grep 'ABCD'
+
+$sleep
+cat >b.in <<'EOF'
+a = G
+b = F
+c = F
+d = F
+EOF
+
+# This involves the rebuild rule, hence it requires GNUmake
+$MAKE -f foo print | grep 'GFCD'
Index: tests/output7.test
===================================================================
RCS file: tests/output7.test
diff -N tests/output7.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/output7.test 23 Sep 2003 07:49:53 -0000
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2003 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check for support for colon separated input files in AC_CONFIG_FILES,
+# with sources in sub directories.
+
+. ./defs || exit 1
+
+set -e
+
+cat > configure.in << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([
+ Makefile:mk/toplevel.in
+ sub/Makefile:mk/sub.in
+ mk/Makefile
+])
+AC_OUTPUT
+END
+
+mkdir mk sub
+cat >mk/Makefile.am <<'EOF'
+all-local:
+ @echo in--mk
+EOF
+
+cat >mk/sub.am <<'EOF'
+all-local:
+ @echo in--sub
+EOF
+
+cat >mk/toplevel.am <<'EOF'
+all-local:
+ @echo at--toplevel
+SUBDIRS = mk sub
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE >output
+cat output
+grep in--mk output
+grep in--sub output
+grep at--toplevel output
+
+$MAKE distcheck
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: AC_CONFIG_FILES and multiple input files.,
Alexandre Duret-Lutz <=