# List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
# and their outputs.
my @other_input_files = ();
-# Where the last AC_CONFIG_FILES/AC_OUTPUT appears.
+# Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK appears.
+# The keys are the files created by these macros.
my %ac_config_files_location = ();
# List of directories to search for configure-required files. This
push (@actual_other_files, $local);
}
- foreach my $struct (@config_links)
+ # For links we should clean destinations and distribute sources.
+ foreach my $spec (@config_links)
{
- my ($spec, $where) = @$struct;
my ($link, $file) = split /:/, $spec;
-
- # We skip links that aren't in this directory. However, if
- # the link's directory does not have a Makefile, and we are
- # currently doing `.', then we add the link to CONFIG_CLEAN_FILES
- # in `.'s Makefile.in.
- my $local = basename ($link);
- my $fd = dirname ($link);
- if ($fd ne $relative_dir)
- {
- if ($relative_dir eq '.' && ! &is_make_dir ($fd))
+ my $where = $ac_config_files_location{$link};
+
+ # Skip destinations that contain shell variables.
+ if ($link !~ /\$/)
+ {
+ # We skip links that aren't in this directory. However, if
+ # the link's directory does not have a Makefile, and we are
+ # currently doing `.', then we add the link to CONFIG_CLEAN_FILES
+ # in `.'s Makefile.in.
+ my $local = basename ($link);
+ my $fd = dirname ($link);
+ if ($fd ne $relative_dir)
{
- $local = $link;
- }
- else
- {
- $local = undef;
+ if ($relative_dir eq '.' && ! &is_make_dir ($fd))
+ {
+ $local = $link;
+ }
+ else
+ {
+ $local = undef;
+ }
}
+ push @actual_other_files, $local if $local;
}
- push @actual_other_files, $local if $local;
-
- $local = basename ($file);
- $fd = dirname ($file);
-
- # Make sure the dist directory for each input file is created.
- # We only have to do this at the topmost level though.
- if ($relative_dir eq '.')
+ # Do not process sources that contain shell variables.
+ if ($file !~ /\$/)
{
- $dist_dirs{$fd} = 1;
- }
+ my $fd = dirname ($file);
- # We skip files that aren't in this directory. However, if
- # the files's directory does not have a Makefile, and we are
- # currently doing `.', then we require the file from `.'.
- if ($fd ne $relative_dir)
- {
- if ($relative_dir eq '.' && ! &is_make_dir ($fd))
+ # Make sure the dist directory for each input file is created.
+ # We only have to do this at the topmost level though.
+ if ($relative_dir eq '.')
{
- $local = $file;
+ $dist_dirs{$fd} = 1;
}
- else
+
+ # We distribute files that are in this directory.
+ # At the top-level (`.') we also distribute files whose
+ # directory does not have a Makefile.
+ if (($fd eq $relative_dir)
+ || ($relative_dir eq '.' && ! &is_make_dir ($fd)))
{
- next;
+ # The following will distribute $file as a side-effect when
+ # it is appropriate (i.e., when $file is not already an output).
+ # We do not need the result, just the side-effect.
+ rewrite_inputs_into_dependencies ($link, $file);
}
}
-
- # Require all input files.
- require_file ($where, FOREIGN, $local);
- }
+ }
# These files get removed by "make distclean".
define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
}
elsif ($macro eq 'AC_CONFIG_LINKS')
{
- push @config_links, map { [$_, $where] } split (' ', $args[1]);
+ foreach my $spec (split (' ', $args[1]))
+ {
+ my ($dest, $src) = split (':', $spec);
+ $ac_config_files_location{$dest} = $where;
+ push @config_links, $spec;
+ }
}
elsif ($macro eq 'AC_INIT')
{
--- /dev/null
+#! /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.
+
+# Test to make sure that AC_CONFIG_LINKS using a variable source
+# is not broken.
+
+. ./defs || exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+SUBDIRS = sdir
+test: distdir
+ test ! -e $(distdir)/sdir/dest3
+ test ! -e $(distdir)/sdir/dest2
+ test ! -e $(distdir)/dest3
+ test ! -e $(distdir)/dest2
+ test -f $(distdir)/src2
+## src3 cannot be distributed, Automake knows nothing about it
+ test ! -e $(distdir)/sdir/src3
+ test ! -e $(distdir)/src3
+END
+
+: > src
+: > src2
+mkdir sdir
+: > sdir/Makefile.am
+: > sdir/src3
+
+cat >>configure.in << 'EOF'
+AC_CONFIG_FILES(sdir/Makefile)
+my_src_dir=sdir
+my_dest=dest
+AC_CONFIG_LINKS(sdir/dest2:src2 sdir/dest3:$my_src_dir/src3)
+AC_CONFIG_LINKS($my_dest:src)
+# the following is a link whose source is itself a link
+AC_CONFIG_LINKS(dest4:sdir/dest2)
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# $my_src_dir and $my_dest are variables local to configure, they should
+# not appear in Makefile.
+grep my_src_dir Makefile.in && exit 1
+grep my_dest Makefile.in && exit 1
+
+./configure
+test -e sdir/dest2
+test -e sdir/dest3
+test -e dest
+test -e dest4
+$MAKE test
+
+$MAKE distclean
+test ! -e sdir/dest2
+test ! -e sdir/dest3
+test -e dest # Should still exist, Automake knows nothing about it.
+rm -f dest
+test ! -e dest4
+
+## Cannot do the following, because at the time of writing Autoconf
+## (2.59) does not support AC_CONFIG_LINKS source in the build tree.
+# mkdir build
+# cd build
+# ../configure
+# $MAKE test