automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/8] dist: auxiliary files can be distributed from subdir Makefil


From: Stefano Lattarini
Subject: [PATCH 1/8] dist: auxiliary files can be distributed from subdir Makefiles
Date: Sun, 9 Oct 2011 10:52:57 +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.
---
 ChangeLog                                    |   43 ++++++++
 Makefile.in                                  |    7 +-
 automake.in                                  |   11 ++
 doc/Makefile.in                              |    3 +-
 lib/Automake/Makefile.in                     |    2 +-
 lib/Automake/tests/Makefile.in               |    3 +-
 lib/am/Makefile.in                           |    2 +-
 lib/am/distdir.am                            |    1 +
 m4/Makefile.in                               |    3 +-
 tests/Makefile.am                            |    8 +-
 tests/Makefile.in                            |   13 ++-
 tests/dist-auxdir-many-subdirs.test          |  142 ++++++++++++++++++++++++++
 tests/dist-readonly.test                     |   60 +++++++++++
 tests/dist-repeated.test                     |  102 ++++++++++++++++++
 tests/{distcom7.test => distcom-subdir.test} |   40 +++++++-
 tests/java-compile-run-nested.test           |    2 +-
 tests/test-driver-is-distributed.test        |   44 +++++++-
 17 files changed, 460 insertions(+), 26 deletions(-)
 create mode 100755 tests/dist-auxdir-many-subdirs.test
 create mode 100755 tests/dist-readonly.test
 create mode 100755 tests/dist-repeated.test
 rename tests/{distcom7.test => distcom-subdir.test} (58%)

diff --git a/ChangeLog b/ChangeLog
index b298f85..4526648 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2011-10-08  Stefano Lattarini  <address@hidden>
+
+       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  <address@hidden>
 
        parallel-tests: warn on conditional TEST_EXTENSIONS definition
diff --git a/Makefile.in b/Makefile.in
index 24a6c7f..5104e29 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -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 \
diff --git a/automake.in b/automake.in
index 9d6acc0..d5b39b7 100644
--- a/automake.in
+++ b/automake.in
@@ -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
diff --git a/doc/Makefile.in b/doc/Makefile.in
index b0d06f2..ab3e552 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -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 \
diff --git a/lib/Automake/Makefile.in b/lib/Automake/Makefile.in
index 2ea1a18..b83778b 100644
--- a/lib/Automake/Makefile.in
+++ b/lib/Automake/Makefile.in
@@ -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 \
diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in
index 3e5def5..ead6233 100644
--- a/lib/Automake/tests/Makefile.in
+++ b/lib/Automake/tests/Makefile.in
@@ -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 \
diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in
index 53ce53d..050806a 100644
--- a/lib/am/Makefile.in
+++ b/lib/am/Makefile.in
@@ -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 \
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 7e31f2c..0eed248 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -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; \
diff --git a/m4/Makefile.in b/m4/Makefile.in
index 8bc9b70..66ca138 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -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 \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 35baf9e..8fdec80 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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 \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 3d7fe7c..dbe4621 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -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
index 0000000..4f32f64
--- /dev/null
+++ b/tests/dist-auxdir-many-subdirs.test
@@ -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
index 0000000..3b558c9
--- /dev/null
+++ b/tests/dist-readonly.test
@@ -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
index 0000000..7dd8bdd
--- /dev/null
+++ b/tests/dist-repeated.test
@@ -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"
+
+:
diff --git a/tests/distcom7.test b/tests/distcom-subdir.test
similarity index 58%
rename from tests/distcom7.test
rename to tests/distcom-subdir.test
index 129bb57..f873682 100755
--- a/tests/distcom7.test
+++ b/tests/distcom-subdir.test
@@ -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
 
 :
diff --git a/tests/java-compile-run-nested.test 
b/tests/java-compile-run-nested.test
index ec75c92..2019208 100755
--- a/tests/java-compile-run-nested.test
+++ b/tests/java-compile-run-nested.test
@@ -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
diff --git a/tests/test-driver-is-distributed.test 
b/tests/test-driver-is-distributed.test
index 09ea45a..e9a3f14 100755
--- a/tests/test-driver-is-distributed.test
+++ b/tests/test-driver-is-distributed.test
@@ -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
 
 :
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]