[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix AC_CONFIG_LINKS([X:X]) (was: New module gnu-make)
From: |
Ralf Wildenhues |
Subject: |
fix AC_CONFIG_LINKS([X:X]) (was: New module gnu-make) |
Date: |
Sat, 15 Mar 2008 18:28:40 +0100 |
User-agent: |
Mutt/1.5.17+20080114 (2008-01-14) |
hmm, this was long ago:
* Ralf Wildenhues wrote on Fri, Nov 16, 2007 at 05:52:54PM CET:
>
> Current Autoconf allows you to do this:
> AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])
>
> the only bit that's missing is that automake shouldn't remove
> the original file upon
> make distclean
>
> in a non-VPATH build. Will fix.
Here's a patch for automake, review appreciated. I'll probably apply in
a couple of days, still wondering whether also to branch-1-10.
Does anybody know a better name for CONFIG_CLEAN_VPATH_FILES (files
which are to be removed from the build tree, but only if the build tree
does not coincide with the source tree)?
Thanks,
Ralf
For AC_CONFIG_LINKS, if source and destination are equal, do not
remove the file in a non-VPATH build.
* automake.in (rewrite_inputs_into_dependencies): Do distribute
inputs where input and output name are equal. This relies on
the assumption that it only happens with AC_CONFIG_LINKS.
(handle_configure) <CONFIG_CLEAN_VPATH_FILES>: New variable, for
links where source and dest are equal.
* lib/am/clean.am (distclean-generic): Remove, if build tree not
equal source tree.
* tests/conflnk4.test: New test.
* tests/Makefile.am: Adjust.
diff --git a/automake.in b/automake.in
index 9612204..b939e95 100755
--- a/automake.in
+++ b/automake.in
@@ -3863,7 +3863,7 @@ sub prepend_srcdir (@)
# 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.
+# Also distribute $INPUTs which are not built by another AC_CONFIG_FOOS.
sub rewrite_inputs_into_dependencies ($@)
{
my ($file, @inputs) = @_;
@@ -3874,7 +3874,7 @@ sub rewrite_inputs_into_dependencies ($@)
# We cannot create dependencies on shell variables.
next if (substitute_ac_subst_variables $i) =~ /\$/;
- if (exists $ac_config_files_location{$i})
+ if (exists $ac_config_files_location{$i} && $i ne $file)
{
my $di = dirname $i;
if ($di eq $relative_dir)
@@ -4079,6 +4079,8 @@ sub handle_configure ($$$@)
# Now look for other files in this directory which must be remade
# by config.status, and generate rules for them.
my @actual_other_files = ();
+ # These get cleaned only in a VPATH build.
+ my @actual_other_vpath_files = ();
foreach my $lfile (@other_input_files)
{
my $file;
@@ -4166,7 +4168,14 @@ sub handle_configure ($$$@)
$local = undef;
}
}
- push @actual_other_files, $local if $local;
+ if ($file ne $link)
+ {
+ push @actual_other_files, $local if $local;
+ }
+ else
+ {
+ push @actual_other_vpath_files, $local if $local;
+ }
}
# Do not process sources that contain shell variables.
@@ -4191,6 +4200,8 @@ sub handle_configure ($$$@)
# These files get removed by "make distclean".
define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
@actual_other_files);
+ define_pretty_variable ('CONFIG_CLEAN_VPATH_FILES', TRUE, INTERNAL,
+ @actual_other_vpath_files);
}
# Handle C headers.
diff --git a/lib/am/clean.am b/lib/am/clean.am
index f3dd2c6..90b1175 100644
--- a/lib/am/clean.am
+++ b/lib/am/clean.am
@@ -29,6 +29,8 @@ clean-generic:
distclean-am: distclean-generic clean-am
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test -z "$(CONFIG_CLEAN_VPATH_FILES)" || \
+ test "`pwd`" = "`cd $(srcdir) && pwd`" || rm -f
$(CONFIG_CLEAN_VPATH_FILES)
%DISTCLEAN_RMS%
## Makefiles and their dependencies cannot be cleaned by
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 42a330f..31153dd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -176,6 +176,7 @@ confincl.test \
conflnk.test \
conflnk2.test \
conflnk3.test \
+conflnk4.test \
confsub.test \
confvar.test \
confvar2.test \
--- /dev/null 2007-10-18 18:26:07.000000000 +0200
+++ tests/conflnk4.test 2008-03-11 11:24:58.000000000 +0100
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2003, 2008 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 3, 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., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test to make sure links to _identical files_ created by AC_CONFIG_LINKS get
+# removed with `make distclean' only if doing a VPATH build.
+
+. ./defs || exit 1
+
+set -e
+
+: > src
+mkdir sdir
+: > sdir/Makefile.am
+: > sdir/src2
+
+
+cat >> Makefile.am <<'EOF'
+SUBDIRS = sdir
+test: distdir
+ test -f $(distdir)/src
+ test -f $(distdir)/sdir/src2
+EOF
+
+cat >>configure.in << 'EOF'
+AC_CONFIG_FILES(sdir/Makefile)
+AC_CONFIG_LINKS(src:src)
+AC_CONFIG_LINKS(sdir/src2:sdir/src2)
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+
+# TODO: Make sure links are distributed
+$MAKE test
+
+# Make sure nothing is deleted by `make clean'
+$MAKE clean
+
+test -f ../src
+test -f ../sdir/src2
+
+# Make sure the links are deleted by `make distclean' and the original files
+# are not.
+$MAKE distclean
+
+test -f ../src
+test -f ../sdir/src2
+
+test -r src && exit 1
+test -r sdir/src2 && exit 1
+
+cd ..
+./configure
+
+# TODO: Make sure links are distributed
+$MAKE test
+
+# Make sure nothing is deleted by `make distclean'
+$MAKE distclean
+
+test -f src
+test -f sdir/src2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fix AC_CONFIG_LINKS([X:X]) (was: New module gnu-make),
Ralf Wildenhues <=