]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
dist: auxiliary files can be distributed from subdir Makefiles
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 30 Sep 2011 10:12:43 +0000 (12:12 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 8 Oct 2011 19:07:42 +0000 (21:07 +0200)
With this change, we make it possible for a subdir Makefile.am
to distribute files in the config auxdir; while this means that
some files might be copied multiple times, it simplify some logic
in the automake script, and fix at least one important bug.  In
fact, before this change, the auxiliary script `test-driver' was
not being distributed as expected when TESTS was defined only in
a subdir Makefile (which is a pretty common setup indeed).  Now
this does not happen anymore: so the present change fixes automake
bug#9546.

Another welcome collateral effect is that `dist-auxfile-2.test'
now passes.

OTOH, the present changes *breaks threaded automake*.  The reason
is that automake needs to serialize file installations spawned
by `--add-missing' (this isn't for cosmetic reasons, but is
really needed to avoid possible race conditions and botched output
files).  Currently the code that installs required files is
intertwined with the code that declares the DIST_COMMON variables;
so, upon de-serialization, the definition of DIST_COMMON might get
emitted in the wrong Makefile.in.

Some follow-up refactoring in automake will soon take care of
remedying this situation.  For the moment, we just declare some
"parallel-am" tests as xfailing.

* automake.in (maybe_push_required_file): Add ad-hoc handling for
the case where the directory part of the required file is different
from the subdir where the current Makefile.am resides, but is equal
to the "config-aux directory" ($config_auxdir).  This is needed to
allow a construct in a non-top-level Makefile.am to require a file
in the config-aux directory.
* tests/test-driver-is-distributed.test: Extend and adjust.  This
test now passes.
* tests/java-compile-run-nested.test: Call automake with the `-a'
option to ensure that the `test-driver' auxiliary script gets
correctly installed.  This test now passes.
* tests/distcom-subdir.test: New test.
* tests/dist-readonly.test: Likewise.
* tests/dist-repeated.test: Likewise.
* tests/dist-auxdir-many-subdirs.test: Likewise.
* tests/distcom7.test: Removed, it's obsolete now.
* tests/Makefile.am (TESTS, XFAIL_TESTS): Update.

17 files changed:
ChangeLog
Makefile.in
automake.in
doc/Makefile.in
lib/Automake/Makefile.in
lib/Automake/tests/Makefile.in
lib/am/Makefile.in
lib/am/distdir.am
m4/Makefile.in
tests/Makefile.am
tests/Makefile.in
tests/dist-auxdir-many-subdirs.test [new file with mode: 0755]
tests/dist-readonly.test [new file with mode: 0755]
tests/dist-repeated.test [new file with mode: 0755]
tests/distcom-subdir.test [moved from tests/distcom7.test with 58% similarity]
tests/java-compile-run-nested.test
tests/test-driver-is-distributed.test

index b298f85e21650586356fabb7e6cddb884533617a..4526648135aef99da8c7c2d3e2f367c0ce62b78d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2011-10-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       dist: auxiliary files can be distributed from subdir Makefiles
+       With this change, we make it possible for a subdir Makefile.am
+       to distribute files in the config auxdir; while this means that
+       some files might be copied multiple times, it simplify some logic
+       in the automake script, and fix at least one important bug.  In
+       fact, before this change, the auxiliary script `test-driver' was
+       not being distributed as expected when TESTS was defined only in
+       a subdir Makefile (which is a pretty common setup indeed).  Now
+       this does not happen anymore: so the present change fixes automake
+       bug#9546.
+       Another welcome collateral effect is that `dist-auxfile-2.test'
+       now passes.
+       OTOH, the present changes *breaks threaded automake*.  The reason
+       is that automake needs to serialize file installations spawned
+       by `--add-missing' (this isn't for cosmetic reasons, but is
+       really needed to avoid possible race conditions and botched output
+       files).  Currently the code that installs required files is
+       intertwined with the code that declares the DIST_COMMON variables;
+       so, upon de-serialization, the definition of DIST_COMMON might get
+       emitted in the wrong Makefile.in.
+       Some follow-up refactoring in automake will soon take care of
+       remedying this situation.  For the moment, we just declare some
+       "parallel-am" tests as xfailing.
+       * automake.in (maybe_push_required_file): Add ad-hoc handling for
+       the case where the directory part of the required file is different
+       from the subdir where the current Makefile.am resides, but is equal
+       to the "config-aux directory" ($config_auxdir).  This is needed to
+       allow a construct in a non-top-level Makefile.am to require a file
+       in the config-aux directory.
+       * tests/test-driver-is-distributed.test: Extend and adjust.  This
+       test now passes.
+       * tests/java-compile-run-nested.test: Call automake with the `-a'
+       option to ensure that the `test-driver' auxiliary script gets
+       correctly installed.  This test now passes.
+       * tests/distcom-subdir.test: New test.
+       * tests/dist-readonly.test: Likewise.
+       * tests/dist-repeated.test: Likewise.
+       * tests/dist-auxdir-many-subdirs.test: Likewise.
+       * tests/distcom7.test: Removed, it's obsolete now.
+       * tests/Makefile.am (TESTS, XFAIL_TESTS): Update.
+
 2011-10-07  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        parallel-tests: warn on conditional TEST_EXTENSIONS definition
index 24a6c7fe1acf21ea654d51c6cd5ef4745f109c50..5104e295393de414ab820913275e7e82a85291a5 100644 (file)
@@ -52,8 +52,11 @@ POST_UNINSTALL = :
 build_triplet = @build@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
-       $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
-       ChangeLog INSTALL NEWS THANKS TODO
+       $(srcdir)/Makefile.in $(top_srcdir)/configure \
+       $(top_srcdir)/lib/config.guess $(top_srcdir)/lib/config.sub \
+       $(top_srcdir)/lib/install-sh $(top_srcdir)/lib/missing \
+       $(top_srcdir)/lib/mkinstalldirs AUTHORS COPYING ChangeLog \
+       INSTALL NEWS THANKS TODO
 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 \
index 9d6acc0ac11444d11037641fcee369efb41212f7..d5b39b741e438fa6536e2f0a5eb36b073e9c9c99 100644 (file)
@@ -7619,6 +7619,17 @@ sub maybe_push_required_file
       push_dist_common ($file);
       return 1;
     }
+  # This is needed to allow a construct in a non-top-level Makefile.am
+  # to require a file in the build-aux directory (see at least the test
+  # script `test-driver-is-distributed.test').  This is related to the
+  # automake bug#9546.  Note that the use of $config_aux_dir instead
+  # of $am_config_aux_dir here is deliberate and necessary.
+  elsif ($dir eq $config_aux_dir)
+    {
+      # FIXME: this breaks serialization of threaded automake :-(
+      push_dist_common ("$am_config_aux_dir/$file");
+      return 1;
+    }
   elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
     {
       # If we are doing the topmost directory, and the file is in a
index b0d06f2d21b5fa4afad97cfcdfbcd58fd2d5d889..ab3e552f1724909cfd01399cabd917aa10ff38c9 100644 (file)
@@ -52,7 +52,8 @@ subdir = doc
 DIST_COMMON = $(automake_TEXINFOS) $(dist_doc_DATA) $(dist_man1_MANS) \
        $(dist_noinst_DATA) $(srcdir)/Makefile.am \
        $(srcdir)/Makefile.in $(srcdir)/stamp-vti \
-       $(srcdir)/version.texi
+       $(srcdir)/version.texi $(top_srcdir)/lib/mdate-sh \
+       $(top_srcdir)/lib/mkinstalldirs $(top_srcdir)/lib/texinfo.tex
 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 \
index 2ea1a18fe14caade3f003cf43dab1c968fa432c9..b83778bf223f568daa5097bab0ddb11a8d7d0f09 100644 (file)
@@ -51,7 +51,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 subdir = lib/Automake
 DIST_COMMON = $(dist_perllib_DATA) $(srcdir)/Makefile.am \
-       $(srcdir)/Makefile.in
+       $(srcdir)/Makefile.in $(top_srcdir)/lib/mkinstalldirs
 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 \
index 3e5def591d2f9c3acf6f995cfcf3d532ac3a3f1c..ead6233a92c7ff8d385c8f4aa33ae3bdee614eb0 100644 (file)
@@ -48,7 +48,8 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 subdir = lib/Automake/tests
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(top_srcdir)/lib/mkinstalldirs $(top_srcdir)/lib/test-driver
 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 \
index 53ce53d411b0f8fbc773780dc26b9e4f6e36db35..050806aaf20978fb6b59eca335a16804c45c6f5a 100644 (file)
@@ -51,7 +51,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 subdir = lib/am
 DIST_COMMON = $(dist_am_DATA) $(srcdir)/Makefile.am \
-       $(srcdir)/Makefile.in
+       $(srcdir)/Makefile.in $(top_srcdir)/lib/mkinstalldirs
 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 \
index 7e31f2c8b69f16ea560370568f7d2687c9f4ee40..0eed2480ce4c94e77fa5e333ad9e2f8f2e365b02 100644 (file)
@@ -216,6 +216,7 @@ endif %?TOPDIR_P%
 ## Test for file existence because sometimes a file gets included in
 ## DISTFILES twice.  For example this happens when a single source
 ## file is used in building more than one program.
+## See also test `dist-repeated.test'.
            test -f "$(distdir)/$$file" \
            || cp -p $$d/$$file "$(distdir)/$$file" \
            || exit 1; \
index 8bc9b701c2c2eb0d3b39f6f5e4b10e6f57d78890..66ca13846ce35e450d0d84440e327aed60c66f50 100644 (file)
@@ -51,7 +51,8 @@ POST_UNINSTALL = :
 build_triplet = @build@
 subdir = m4
 DIST_COMMON = $(dist_automake_ac_DATA) $(dist_system_ac_DATA) \
-       $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(top_srcdir)/lib/mkinstalldirs
 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 \
index 35baf9eee1de6d473867c533446fb23691f35da0..8fdec80f5347675d9f3be80b2d2dd641d42d9c29 100644 (file)
@@ -28,14 +28,13 @@ all.test \
 auxdir2.test \
 cond17.test \
 dist-auxfile.test \
-dist-auxfile-2.test \
 gcj6.test \
 override-conditional-2.test \
+parallel-am.test \
 java-nobase.test \
 pr8365-remake-timing.test \
 yacc-dist-nobuild-subdir.test \
 vala-vpath.test \
-test-driver-is-distributed.test \
 txinfo5.test
 
 
@@ -405,13 +404,16 @@ discover.test \
 dist-auxfile.test \
 dist-auxfile-2.test \
 dist-included-parent-dir.test \
+dist-readonly.test \
+dist-repeated.test \
+dist-auxdir-many-subdirs.test \
 distcleancheck.test \
 distcom2.test \
 distcom3.test \
 distcom4.test \
 distcom5.test \
 distcom6.test \
-distcom7.test \
+distcom-subdir.test \
 distdir.test \
 distlinks.test \
 distlinksbrk.test \
index 3d7fe7c9ea1c4adf15661061aaa89c3532d5c018..dbe4621bb088cbf93680e7449b47ea2030adc607 100644 (file)
@@ -51,7 +51,8 @@ build_triplet = @build@
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
        $(srcdir)/aclocal.in $(srcdir)/automake.in $(srcdir)/defs \
        $(srcdir)/defs-static.in $(srcdir)/instspc-tests.am \
-       $(srcdir)/parallel-tests.am
+       $(srcdir)/parallel-tests.am $(top_srcdir)/lib/mkinstalldirs \
+       $(top_srcdir)/lib/test-driver
 subdir = tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/amversion.m4 \
@@ -294,10 +295,9 @@ EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
        extract-testsuite-summary tap-setup.sh tap-summary-aux.sh \
        distcheck-hook-m4.am
 XFAIL_TESTS = all.test auxdir2.test cond17.test dist-auxfile.test \
-       dist-auxfile-2.test gcj6.test override-conditional-2.test \
+       gcj6.test override-conditional-2.test parallel-am.test \
        java-nobase.test pr8365-remake-timing.test \
-       yacc-dist-nobuild-subdir.test vala-vpath.test \
-       test-driver-is-distributed.test txinfo5.test \
+       yacc-dist-nobuild-subdir.test vala-vpath.test txinfo5.test \
        $(instspc_xfail_tests)
 parallel_tests = check-concurrency-bug9245-p.test \
        check-exported-srcdir-p.test check-fd-redirect-p.test \
@@ -668,13 +668,16 @@ discover.test \
 dist-auxfile.test \
 dist-auxfile-2.test \
 dist-included-parent-dir.test \
+dist-readonly.test \
+dist-repeated.test \
+dist-auxdir-many-subdirs.test \
 distcleancheck.test \
 distcom2.test \
 distcom3.test \
 distcom4.test \
 distcom5.test \
 distcom6.test \
-distcom7.test \
+distcom-subdir.test \
 distdir.test \
 distlinks.test \
 distlinksbrk.test \
diff --git a/tests/dist-auxdir-many-subdirs.test b/tests/dist-auxdir-many-subdirs.test
new file mode 100755 (executable)
index 0000000..4f32f64
--- /dev/null
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# It should be legitimate for many subdir Makefiles to require the
+# same config-aux files.
+
+am_create_testdir=empty
+parallel_tests=yes
+required=cc
+. ./defs || Exit 1
+
+count=0
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Usage: do_check [--add-missing] [CONFIG-AUXDIR-PATH=.]
+do_check ()
+{
+  case $1 in
+    -a|--add-missing) add_missing=yes; shift;;
+    *) add_missing=no;;
+  esac
+  auxdir=${1-.}
+
+  count=`expr $count + 1`
+  mkdir T$count.d
+  cd T$count.d
+
+  distdir=$me-$count
+  unindent > configure.in << END
+    AC_INIT([$me], [$count])
+    AC_CONFIG_AUX_DIR([$auxdir])
+    AM_INIT_AUTOMAKE([parallel-tests])
+    AC_PROG_CC
+    # We don't want to require python or emcas in this test, so
+    # the tricks below.
+    AM_PATH_PYTHON([2.2], [], [:])
+    EMACS=no; AM_PATH_LISPDIR
+    AC_CONFIG_FILES([Makefile])
+END
+
+  unindent > Makefile.stub <<'END'
+    ## For depcomp.
+    bin_PROGRAMS = foo
+    foo_SOURCES = foo.c
+    ## For py-compile.
+    python_PYTHON = bar.py
+    ## For elisp-comp.
+    lisp_LISP = baz.el
+    ## For test-driver.
+    TESTS =
+END
+
+  required_files='
+    install-sh
+    missing
+    depcomp
+    py-compile
+    elisp-comp
+    test-driver
+  '
+
+  echo "SUBDIRS =" > Makefile.am
+
+  suffixes='0 1 2 3 4 5 6 7 8 9'
+
+  for x in $suffixes; do
+    mkdir sub$x
+    echo "SUBDIRS += sub$x" >> Makefile.am
+    echo "AC_CONFIG_FILES([sub$x/Makefile])" >> configure.in
+    cp Makefile.stub sub$x/Makefile.am
+    echo 'int main (void) { return 0; }' > sub$x/foo.c
+    touch sub$x/bar.py sub$x/baz.el
+  done
+  echo AC_OUTPUT >> configure.in
+
+  $ACLOCAL
+  $AUTOCONF
+
+  # FIXME: this is not good for installcheck; fix after merging
+  # into testsuite-work.
+  "$top_testsrcdir"/lib/install-sh -d $auxdir
+  if test $add_missing = yes; then
+    $AUTOMAKE -a --copy
+    for f in $required_files; do
+      test -f $auxdir/$f
+      # To ensure that if a auxiliary file is required and distributed
+      # by many Makefiles, the "dist" rule won't try to copy it multiple
+      # times in $(distdir).
+      chmod a-w $auxdir/$f
+    done
+  else
+    for f in $required_files; do
+      # FIXME: this is not good for installcheck; fix after merging
+      # into testsuite-work.
+      cp "$top_testsrcdir"/lib/$f $auxdir/$f
+      # See comments above.
+      chmod a-w $auxdir/$f
+    done
+    $AUTOMAKE
+  fi
+
+  for vpath in : false; do
+    if $vpath; then
+      mkdir build
+      cd build
+      srcdir=..
+    else
+      srcdir=.
+    fi
+    $srcdir/configure
+    $MAKE distdir
+    find $distdir # For debugging.
+    for f in $required_files; do
+      test -f $distdir/$auxdir/$f
+    done
+    cd $srcdir
+  done
+
+  cd "$ocwd" || fatal_ "cannot chdir back to '$ocwd'"
+}
+
+do_check .
+do_check --add-missing .
+do_check build-aux
+do_check --add-missing build-aux
+do_check a/b/c
+do_check --add-missing a/b/c
+
+:
diff --git a/tests/dist-readonly.test b/tests/dist-readonly.test
new file mode 100755 (executable)
index 0000000..3b558c9
--- /dev/null
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that a readonly files are distributed as such, and not make
+# writable while being copied in the $(distdir).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+EXTRA_DIST = bar.txt
+check-local: test
+.PHONY: test
+test:
+       test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
+       if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
+       grep 'main (void)' $(srcdir)/foo.c
+       test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
+       if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
+       grep 'To be, or not to be' $(srcdir)/bar.txt
+END
+
+echo 'int main (void) { return 0; }' > foo.c
+echo To be, or not to be ... > bar.txt
+chmod a-w foo.c bar.txt
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distdir
+ls -l $distdir # For debugging.
+test -f foo.c && test ! -w foo.c || Exit 1
+(echo x > foo.c) && Exit 1
+test -f bar.txt && test ! -w bar.txt || Exit 1
+(echo x > bar.txt) && Exit 1
+$MAKE distcheck
+
+:
diff --git a/tests/dist-repeated.test b/tests/dist-repeated.test
new file mode 100755 (executable)
index 0000000..7dd8bdd
--- /dev/null
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program 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.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that we can distribute the same file as many times as we want.
+# The distdir target should take care of not copying it more than one
+# time anyway.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.c
+bar_SOURCES = foo.c
+python_PYTHON = bar.py
+EXTRA_DIST = foo.c bar.py
+
+.PHONY: sanity-check
+sanity-check:
+       for f in $(DISTFILES); do echo " $$f "; done > dist.txt
+       cat dist.txt
+       test `grep ' foo\.c '  dist.txt | wc -l` -eq 3
+       test `grep ' bar\.py ' dist.txt | wc -l` -eq 2
+
+# So that we don't have to require a C compiler.
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+
+# So that we don't have to require a Python interpreter.
+pythondir = ${prefix}/py
+PYTHON = false
+END
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Help to ensure cp won't see the same file twice.
+mkdir bin
+cat > bin/cp <<END
+#!/bin/sh
+PATH='$PATH'; export PATH
+
+case " \$* " in
+  *foo.c\ *)
+    if test -f '$ocwd'/foo-c-copied; then
+      echo "\$0: we tried to copy foo.c twice" >&2
+      exit 1
+    else
+      # For a sanity check later.
+      echo ok > '$ocwd'/cp-wrapper-has-seen-foo-c
+    fi
+    ;;
+esac
+
+case " \$* " in
+  *bar.py\ *)
+    if test -f '$ocwd'/bar-py-copied; then
+      echo "\$0: we tried to copy bar.py twice" >&2
+      exit 1
+    else
+      # For a sanity check later.
+      echo ok > '$ocwd'/cp-wrapper-has-seen-bar-py
+    fi
+    ;;
+esac
+
+exec cp "\$@"
+END
+chmod a+x bin/cp
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH;
+
+: > foo.c
+: > bar.py
+: > py-compile
+
+# Help to ensure cp won't try to copy the same file twice.
+chmod a-w foo.c bar.py
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE sanity-check || fatal_ "expected invariants not verified"
+$MAKE distdir
+test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \
+  || fatal_ "our cp wrapper hasn't run correctly"
+
+:
similarity index 58%
rename from tests/distcom7.test
rename to tests/distcom-subdir.test
index 129bb57636a9896895d7c9eba978bac9eb600c4b..f873682f9f05b32329d64c5194029409b91c7a92 100755 (executable)
@@ -14,8 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# Test to make sure that Automake complains when an auxfile (here depcomp)
-# is installed, but the Makefile that distributes it is not processed.
+# Test to make sure that if an auxfile (here depcomp) is required
+# by a subdir Makefile.am, it is distributed by that Makefile.am.
 
 . ./defs || Exit 1
 
@@ -32,14 +32,44 @@ END
 rm -f depcomp
 mkdir subdir
 
+: > subdir/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+test ! -f depcomp
+
 cat > subdir/Makefile.am << 'END'
 bin_PROGRAMS = foo
 END
 
 : > subdir/foo.c
 
-$ACLOCAL
-AUTOMAKE_fails --add-missing subdir/Makefile
-grep 'without.*Makefile.*arguments' stderr
+$AUTOMAKE -a subdir/Makefile
+test -f depcomp
+
+# FIXME: the logic of this check and other similar ones in other
+# FIXME: `distcom*.test' files should be factored out in a common
+# FIXME: subroutine in `defs'...
+sed -n -e "
+  /^DIST_COMMON =.*\\\\$/ {
+    :loop
+    p
+    n
+    t clear
+    :clear
+    s/\\\\$/\\\\/
+    t loop
+    s/$/ /
+    s/[$tab ][$tab ]*/ /g
+    p
+    n
+  }" subdir/Makefile.in > dc.txt
+cat dc.txt
+$FGREP ' $(top_srcdir)/depcomp ' dc.txt
+
+./configure
+$MAKE distdir
+test -f $distdir/depcomp
 
 :
index ec75c92ce0f7e039b1f7493c646d49bb8d87c4e2..2019208fae4c738ce2b0ccb8baa3179115d7272c 100755 (executable)
@@ -238,7 +238,7 @@ chmod a+x tests/*.test
 
 $ACLOCAL
 $AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
 
 # To have the parallel testsuite more verbose.
 VERBOSE=yes; export VERBOSE
index 09ea45a86e8a3e3fd66ef5c252d0f6c0763f8133..e9a3f146d80ce830ef0243e385fde737723c346c 100755 (executable)
@@ -26,19 +26,23 @@ AC_CONFIG_FILES([tests/Makefile])
 AC_OUTPUT
 END
 
+rm -f depcomp # It's unneeded.
+
 mkdir tests
 
 cat > Makefile.am << 'END'
 SUBDIRS = tests
-test0:
-       echo ' ' $(DIST_COMMON) ' ' | grep '[ /]test-driver '
-test1: distdir
+check-local: test-top
+test-top: distdir
        ls -l $(distdir) $(distdir)/* ;: For debugging.
        test -f $(distdir)/test-driver
-.PHONY: test0 test1
+.PHONY: test-top
 END
 
 cat > tests/Makefile.am << 'END'
+check-local: test-sub
+test-sub:
+       echo ' ' $(DIST_COMMON) ' ' | grep '[ /]test-driver '
 TESTS = foo.test
 EXTRA_DIST = $(TESTS)
 END
@@ -53,7 +57,37 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 ./configure
-$MAKE test0 test1
+$MAKE test-top
+cd tests; $MAKE test-sub; cd ..;
+$MAKE distcheck
+
+# Try again, with a `config_auxdir' != `.' this time.
+
+$MAKE distclean
+
+mkdir build-aux
+mv missing install-sh test-driver build-aux
+
+for d in . tests; do
+  sed 's|test-driver|build-aux/test-driver|' $d/Makefile.am > $d/t
+  mv -f $d/t $d/Makefile.am
+  cat $d/Makefile.am # For debugging.
+done
+
+# Extra newline possibly required by OpenBSD 3.9 sed, see the autoconf
+# manual for details.
+sed '/^AC_INIT/i\
+AC_CONFIG_AUX_DIR([build-aux])
+' configure.in > t
+mv -f t configure.in
+cat configure.in # For debugging.
+
+touch aclocal.m4 # To avoid useless remakes.
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE test-top
+cd tests; $MAKE test-sub; cd ..;
 $MAKE distcheck
 
 :