Cope with parallel BSD make -jN semantics.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 17 May 2009 10:03:47 +0000 (12:03 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 17 May 2009 10:16:11 +0000 (12:16 +0200)
When BSD `make -jN' is used without `-B' which enables backwards
compatible semantics, it may reuse the same shell for several
commands within a rule; so ensure we do not leave it in a
different directory, nor `exit 0' early in a multi-command rule.

* lib/am/distdir.am (distcheck): After running `distcleancheck',
change back to original working directory.
* lib/am/remake-hdr.am (%CONFIG_HIN%): Run autoheader in a
subshell.
* lib/am/mans.am (uninstall-man%SECTION%): Do not `exit 0' early
in a rule that consists of several shell invocations.  Parallel
NetBSD `make -jN' without `-B' will use only one shell for all
commands, but won't respawn one after `exit 0'.  Fixes
notrans.test failure.
* tests/makej2.test: New test.
* tests/Makefile.am: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
Makefile.in
doc/Makefile.in
lib/am/distdir.am
lib/am/mans.am
lib/am/remake-hdr.am
tests/Makefile.am
tests/Makefile.in
tests/makej2.test [new file with mode: 0755]

index 901d872fedf54779889981c7412b668fff955afb..f03fff52ce6720fa7821a3d5ac182b60f0d53224 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2009-05-17  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Cope with parallel BSD make -jN semantics.
+       When BSD `make -jN' is used without `-B' which enables backwards
+       compatible semantics, it may reuse the same shell for several
+       commands within a rule; so ensure we do not leave it in a
+       different directory, nor `exit 0' early in a multi-command rule.
+       * lib/am/distdir.am (distcheck): After running `distcleancheck',
+       change back to original working directory.
+       * lib/am/remake-hdr.am (%CONFIG_HIN%): Run autoheader in a
+       subshell.
+       * lib/am/mans.am (uninstall-man%SECTION%): Do not `exit 0' early
+       in a rule that consists of several shell invocations.  Parallel
+       NetBSD `make -jN' without `-B' will use only one shell for all
+       commands, but won't respawn one after `exit 0'.  Fixes
+       notrans.test failure.
+       * tests/makej2.test: New test.
+       * tests/Makefile.am: Update.
+
        Fix typo in comment.
        * lib/am/install.am: Fix typo.
 
index 56a3126717a8f38e2e5d36d69ffe1140c399b7b5..575d95e40e1c21ace42decf11aea748f0185fc80 100644 (file)
@@ -638,6 +638,7 @@ distcheck: dist
        test -d $(distdir)/_build || exit 0; \
        dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
          && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
          && $(am__cd) $(distdir)/_build \
          && ../configure --srcdir=.. --prefix="$$dc_install_base" \
            $(DISTCHECK_CONFIGURE_FLAGS) \
@@ -660,7 +661,9 @@ distcheck: dist
          && rm -rf "$$dc_destdir" \
          && $(MAKE) $(AM_MAKEFLAGS) dist \
          && rm -rf $(DIST_ARCHIVES) \
-         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
        $(am__remove_distdir)
        @(echo "$(distdir) archives ready for distribution: "; \
          list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
index 6433ad82f6c2fd79b8728312f6d20d0db8ed480d..11511189e7e57c73b4f5c37d2929cfd98f635797 100644 (file)
@@ -459,9 +459,9 @@ uninstall-man1:
        files=`{ for i in $$list; do echo "$$i"; done; \
        } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
              -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
-       test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(man1dir)" && rm -f $$files
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
 install-dist_docDATA: $(dist_doc_DATA)
        @$(NORMAL_INSTALL)
        test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)"
index 43af3611a2947efc03493a295e4045742fdc0393..a3c91b39bf291273b3b5160bbe90f960801c9cf0 100644 (file)
@@ -464,6 +464,9 @@ distcheck: dist
 ## create very long directory names.
          && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 ?DISTCHECK-HOOK?         && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
+## Parallel BSD make may not start a new shell for each command in a recipe,
+## so be sure to `cd' back to the original directory after this.
+         && am__cwd=`pwd` \
          && $(am__cd) $(distdir)/_build \
          && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 ?GETTEXT?          --with-included-gettext \
@@ -501,7 +504,10 @@ distcheck: dist
          && $(MAKE) $(AM_MAKEFLAGS) dist \
 ## Make sure to remove the dists we created in the test build directory.
          && rm -rf $(DIST_ARCHIVES) \
-         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+## Cater to parallel BSD make (see above).
+         && cd "$$am__cwd" \
+         || exit 1
        $(am__remove_distdir)
        @(echo "$(distdir) archives ready for distribution: "; \
          list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
index 1828c5da943921edae936b196a52519facd5cb39..cf66e4f134f99c594636105085021da2992a83f1 100644 (file)
@@ -119,9 +119,9 @@ if %?NOTRANS_MANS%
 ?HAVE_NOTRANS?   sed -n '/\.%SECTION%[a-z]*$$/p'; \
 ## Extract basename of manpage, change the extension if needed.
        } | sed 's,.*/,,;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,'`; \
-       test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files; }
 endif %?NOTRANS_MANS%
 if %?TRANS_MANS%
 ## Handle MANS without notrans_ prefix
@@ -136,7 +136,7 @@ if %?TRANS_MANS%
 ## transform, and change the extension if needed.
        } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
              -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
-       test -n "$$files" || exit 0; \
-       echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
-       cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man%SECTION%dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man%SECTION%dir)" && rm -f $$files; }
 endif %?TRANS_MANS%
index c1bc42f0aad349f90d8697229920baf73e39aca7..c87572bffd4d213e27c683ae4e1e3566fe7f4461 100644 (file)
@@ -1,6 +1,6 @@
 ## automake - create Makefile.in from Makefile.am
 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2005,
-## 2008 Free Software Foundation, Inc.
+## 2008, 2009 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
@@ -35,7 +35,8 @@
 ## by autoheader.
 if %?FIRST%
 %CONFIG_HIN%: %MAINTAINER-MODE% $(am__configure_deps) %FILES%
-       $(am__cd) $(top_srcdir) && $(AUTOHEADER)
+## Cater to parallel BSD make.
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
 ## Whenever $(AUTOHEADER) has run, we must make sure that
 ## ./config.status will rebuild config.h.  The dependency from %STAMP%
 ## on %CONFIG_H_DEPS% (which contains config.hin) is not enough to
index d70060846f02c19935501423efcb173606bd0dfe..5d5a2905108c24847a55a7c7643e7ab79f3804c7 100644 (file)
@@ -422,6 +422,7 @@ lzma.test \
 maintclean.test \
 make.test \
 makej.test \
+makej2.test \
 maken.test \
 maken2.test \
 maken3.test \
index bc77d2341303cd94ac9721d73cb3117f65c73ef9..abce1cd9578abcb6e34b6c2699f575d4267fdb3f 100644 (file)
@@ -655,6 +655,7 @@ lzma.test \
 maintclean.test \
 make.test \
 makej.test \
+makej2.test \
 maken.test \
 maken2.test \
 maken3.test \
diff --git a/tests/makej2.test b/tests/makej2.test
new file mode 100755 (executable)
index 0000000..e89afec
--- /dev/null
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2009  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 3, 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 to make sure known BSD `make -jN' issues are fixed:
+# without -B, it may reuse the same shell for separate commands in a
+# rule, which can lead to interesting results.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+test-distdir-removed:
+       test ! -d $(distdir)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure "--prefix=`pwd`/inst"
+
+$MAKE -j2 || Exit 77
+$MAKE -j2 distcheck
+$MAKE test-distdir-removed
+
+Exit 0