[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: cleanup rewrite_inputs_into_dependencies and fix PR/411
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: cleanup rewrite_inputs_into_dependencies and fix PR/411 |
Date: |
Sat, 22 Nov 2003 19:04:11 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
This simplifies rewrite_inputs_into_dependencies. The old
implementation was very clumsy because it tried to do too much.
Sometimes it was used just to prepend $(srcdir) or
$(top_srcdir), sometimes it was used just to compute relative
filenames, and sometimes we wanted to add $(srcdir) to one files
and not to the others.
The current implementation is simpler:
- prepend_srcdir is a separate function
- rewrite_inputs_into_dependencies know whether to add $(srcdir) or not
by itself: if the input is also an output, it lies in the build
directory, otherwise we always want $(srcdir) (and we want to
distribute the file too).
Using this new rewrite_inputs_into_dependencies to compute
Makefile dependencies fixes PR/411.
I'm installing this. (Checked with GNU Make and BSD Make.)
2003-11-22 Alexandre Duret-Lutz <address@hidden>
Fix for PR automake/411:
* automake.in (rewrite_inputs_into_dependencies): Simplify, and rename
into ...
(prepend_srcdir): ... this.
(rewrite_inputs_into_dependencies): New function, extracted from ...
(handle_configure): ... here. Adjust to use prepend_srcdir
or rewrite_inputs_into_dependencies where needed. Especially,
using (the new) rewrite_inputs_into_dependencies to compute
Makefile dependencies will fix PR/411.
* lib/am/configure.am (DIST_COMMON): Remove %MAKEFILE-IN%, it's
already distributed by rewrite_inputs_into_dependencies.
* tests/Makefile.am (TESTS): Add output10.test, remove distcom.test.
* tests/colon3.test: Use set -e. Don't allow any AUTOMAKE
invocation refer to zardoz. Make sure two.in and three.in
appear as $(srcdir)/two.in and $(srcdir)/three.in dependencies.
* tests/distcom.test: Delete. This is covered by tests/output9.test.
* tests/output10.test: New file, for PR/411.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1517
diff -u -r1.1517 automake.in
--- automake.in 21 Nov 2003 19:16:11 -0000 1.1517
+++ automake.in 22 Nov 2003 17:48:15 -0000
@@ -3441,45 +3441,72 @@
}
-# @DEPENDENCY
-# &rewrite_inputs_into_dependencies ($ADD_SRCDIR, @INPUTS)
-# --------------------------------------------------------
-# 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)
-# 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 ($@)
+# @DEPENDENCIES
+# &prepend_srcdir (@INPUTS)
+# -------------------------
+# Prepend $(srcdir) or $(top_srcdir) to all @INPUTS. The idea is that
+# if an input file has a directory part the same as the current
+# directory, then the directory part is simply replaced by $(srcdir).
+# But if the directory part is different, then $(top_srcdir) is
+# prepended.
+sub prepend_srcdir (@)
{
- my ($add_srcdir, @inputs) = @_;
+ my @inputs = @_;
my @newinputs;
foreach my $single (@inputs)
{
if (dirname ($single) eq $relative_dir)
{
- push (@newinputs,
- ($add_srcdir eq $single ? '$(srcdir)/' : '')
- . basename ($single));
+ push (@newinputs, '$(srcdir)/' . basename ($single));
}
else
{
- push (@newinputs,
- ($add_srcdir ? '$(top_srcdir)/' : '') . $single);
+ push (@newinputs, '$(top_srcdir)/' . $single);
}
}
return @newinputs;
}
+# @DEPENDENCIES
+# rewrite_inputs_into_dependencies ($OUTPUT, @INPUTS)
+# ---------------------------------------------------
+# Compute a list of dependencies appropriate for the rebuild
+# rule of
+# AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...)
+# Also distribute $INPUTs which are not build by another AC_CONFIG_FILES.
+sub rewrite_inputs_into_dependencies ($@)
+{
+ my ($file, @inputs) = @_;
+ my @res = ();
+
+ for my $i (@inputs)
+ {
+ if (exists $ac_config_files_location{$i})
+ {
+ if (dirname ($i) eq $relative_dir)
+ {
+ $i = basename $i;
+ }
+ else
+ {
+ $i = '$(top_builddir)/' . $i;
+ }
+ }
+ else
+ {
+ msg ('error', $ac_config_files_location{$file},
+ "required file `$i' not found")
+ unless exists $output_files{$i} || -f $i;
+ ($i) = prepend_srcdir ($i);
+ push_dist_common ($i);
+ }
+ push @res, $i;
+ }
+ return @res;
+}
+
+
# &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
# ------------------------------------------------------------------
@@ -3492,14 +3519,13 @@
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,
+ my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am,
$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 @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs);
my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL,
@configure_deps, @aclocal_m4_deps,
@@ -3572,9 +3598,9 @@
{
error $config_header_location, "required file `$in' not found"
unless -f $in;
- push_dist_common (rewrite_inputs_into_dependencies (1, $in));
+ push_dist_common (prepend_srcdir ($in));
}
- @ins = rewrite_inputs_into_dependencies (1, @ins);
+ @ins = prepend_srcdir (@ins);
# Header defined and in this directory.
my @files;
@@ -3711,33 +3737,7 @@
}
}
- # An input file is either output by some other AC_CONFIG_FILES,
- # or it must exist and be relative to $(top_srcdir). In the
- # latter case, we distribute it; in the former, we should not.
- my @rewritten_inputs = ();
- for my $i (@inputs)
- {
- if (exists $ac_config_files_location{$i})
- {
- if (dirname ($i) eq $relative_dir)
- {
- $i = basename $i;
- }
- else
- {
- $i = '$(top_builddir)/' . $i;
- }
- }
- else
- {
- msg ('error', $ac_config_files_location{$file},
- "required file `$i' not found")
- unless -f $i;
- ($i) = rewrite_inputs_into_dependencies (1, $i);
- push_dist_common ($i);
- }
- push @rewritten_inputs, $i;
- }
+ my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs);
$output_rules .= ($local . ': '
. '$(top_builddir)/config.status '
Index: lib/am/configure.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/configure.am,v
retrieving revision 1.28
diff -u -r1.28 configure.am
--- lib/am/configure.am 19 Nov 2003 20:09:45 -0000 1.28
+++ lib/am/configure.am 22 Nov 2003 17:48:16 -0000
@@ -79,7 +79,7 @@
cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE%
$(am__depfiles_maybe);; \
esac;
-DIST_COMMON += %MAKEFILE-AM% %MAKEFILE-IN%
+DIST_COMMON += %MAKEFILE-AM%
## --------------------------- ##
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.532
diff -u -r1.532 Makefile.am
--- tests/Makefile.am 21 Nov 2003 19:16:12 -0000 1.532
+++ tests/Makefile.am 22 Nov 2003 17:48:16 -0000
@@ -172,7 +172,6 @@
dirforbid.test \
dirlist.test \
discover.test \
-distcom.test \
distcom2.test \
distcom3.test \
distcom4.test \
@@ -337,6 +336,7 @@
output7.test \
output8.test \
output9.test \
+output10.test \
overrid.test \
parse.test \
percent.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.686
diff -u -r1.686 Makefile.in
--- tests/Makefile.in 21 Nov 2003 19:16:12 -0000 1.686
+++ tests/Makefile.in 22 Nov 2003 17:48:17 -0000
@@ -34,6 +34,8 @@
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = tests
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(srcdir)/aclocal.in $(srcdir)/automake.in $(srcdir)/defs.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/amversion.m4 \
$(top_srcdir)/m4/auxdir.m4 $(top_srcdir)/m4/init.m4 \
@@ -44,8 +46,6 @@
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-DIST_COMMON = README $(srcdir)/Makefile.in Makefile.am aclocal.in \
- automake.in defs.in
mkinstalldirs = $(SHELL) $(top_srcdir)/lib/mkinstalldirs
CONFIG_CLEAN_FILES = defs aclocal-${APIVERSION} automake-${APIVERSION}
SOURCES =
@@ -286,7 +286,6 @@
dirforbid.test \
dirlist.test \
discover.test \
-distcom.test \
distcom2.test \
distcom3.test \
distcom4.test \
@@ -451,6 +450,7 @@
output7.test \
output8.test \
output9.test \
+output10.test \
overrid.test \
parse.test \
percent.test \
@@ -637,7 +637,7 @@
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -666,11 +666,11 @@
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-defs: $(top_builddir)/config.status defs.in
+defs: $(top_builddir)/config.status $(srcdir)/defs.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-aclocal-${APIVERSION}: $(top_builddir)/config.status aclocal.in
+aclocal-${APIVERSION}: $(top_builddir)/config.status $(srcdir)/aclocal.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-automake-${APIVERSION}: $(top_builddir)/config.status automake.in
+automake-${APIVERSION}: $(top_builddir)/config.status $(srcdir)/automake.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
uninstall-info-am:
tags: TAGS
Index: tests/colon3.test
===================================================================
RCS file: /cvs/automake/automake/tests/colon3.test,v
retrieving revision 1.12
diff -u -r1.12 colon3.test
--- tests/colon3.test 14 Nov 2003 21:25:58 -0000 1.12
+++ tests/colon3.test 22 Nov 2003 17:48:17 -0000
@@ -1,5 +1,6 @@
#! /bin/sh
-# Copyright (C) 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -23,6 +24,8 @@
. ./defs || exit 1
+set -e
+
cat > configure.in << 'END'
AC_INIT
AM_INIT_AUTOMAKE(nonesuch, nonesuch)
@@ -33,26 +36,24 @@
: > two.in
: > three.in
-$ACLOCAL || exit 1
-$AUTOMAKE || exit 1
+$ACLOCAL
+$AUTOMAKE
# We actually check several things here.
# Automake should have created zardoz.in.
-test -f zardoz.in || exit 1
+test -f zardoz.in
# The generated file should refer to zardoz.in and zardoz.am, but
-# never just "zardoz" -- except the actual automake invocation can
-# refer to it (don't ask).
+# never just "zardoz".
echo Grep1
-grep zardoz zardoz.in | $FGREP -v 'zardoz.in' | $FGREP -v 'zardoz.am' \
- | $FGREP -v AUTOMAKE > O
+grep zardoz zardoz.in | $EGREP -v 'zardoz.in' | $FGREP -v 'zardoz.am' > O || :
# We cat the output file so we see in when verbose.
cat O
-test -z "`cat O`" || exit 1
+test -z "`cat O`"
# Makefile should depend on two.in.
echo Grep2
-grep '^Makefile:.* two.in' zardoz.in || exit 1
+grep '^Makefile:.* \$(srcdir)/two.in' zardoz.in
# Likewise three.in.
echo Grep3
-grep '^Makefile:.* three.in' zardoz.in
+grep '^Makefile:.* \$(srcdir)/three.in' zardoz.in
Index: tests/distcom.test
===================================================================
RCS file: tests/distcom.test
diff -N tests/distcom.test
--- tests/distcom.test 14 Nov 2003 21:25:58 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,47 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2001, 2002 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.
-
-# A test for failure to include files provided in AC_OUTPUT into
-# DIST_COMMON
-# From Derek R. Price.
-
-. ./defs || exit 1
-
-cat > configure.in << EOF
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AC_OUTPUT(subdir/bar \
- Makefile \
- subdir/Makefile)
-EOF
-
-: > Makefile.am
-
-mkdir subdir
-: > subdir/Makefile.am
-: > subdir/bar.in
-
-$ACLOCAL || exit 1
-$AUTOMAKE || exit 1
-
-# verify bar.in
-grep 'DIST_COMMON.*bar.in' subdir/Makefile.in || exit 1
-
-exit 0
Index: tests/output10.test
===================================================================
RCS file: tests/output10.test
diff -N tests/output10.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/output10.test 22 Nov 2003 17:48:17 -0000
@@ -0,0 +1,67 @@
+#! /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.
+
+# Make sure an AC_CONFIG_FILES can have an AC_CONFIG_FILES output as input.
+# This is comparable to output9.test, but testing Makefile rules.
+# PR/411
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << END
+AC_SUBST([FOO], [top])
+AC_SUBST([BAR], [bot])
+AC_CONFIG_FILES([a/top])
+AC_CONFIG_FILES([a/bot])
+AC_CONFIG_FILES([b/Makefile:a/top:b/Makefile.in:a/bot])
+AC_OUTPUT
+END
+
+mkdir a
+mkdir b
+
+cat >Makefile.am <<\EOF
+SUBDIRS = b
+dist-hook:
+ test ! -f $(distdir)/a/top
+ test ! -f $(distdir)/a/bot
+EOF
+
+cat >b/Makefile.am <<\EOF
+output:
+ echo $(TOP)$(BOT) > ok
+EOF
+
+echo address@hidden@ >a/top.in
+echo address@hidden@ >a/bot.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure
+cd b
+$MAKE output
+grep topbot ok
+cd ..
+$MAKE distcheck
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: cleanup rewrite_inputs_into_dependencies and fix PR/411,
Alexandre Duret-Lutz <=