From 0e411a0410d6461dd85941bf1121921475426275 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sun, 17 May 2009 12:03:47 +0200 Subject: [PATCH] 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. Signed-off-by: Ralf Wildenhues --- ChangeLog | 17 ++++++++++++++++ Makefile.in | 5 ++++- doc/Makefile.in | 6 +++--- lib/am/distdir.am | 8 +++++++- lib/am/mans.am | 12 ++++++------ lib/am/remake-hdr.am | 5 +++-- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/makej2.test | 46 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 88 insertions(+), 13 deletions(-) create mode 100755 tests/makej2.test diff --git a/ChangeLog b/ChangeLog index 901d872fe..f03fff52c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,22 @@ 2009-05-17 Ralf Wildenhues + 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. diff --git a/Makefile.in b/Makefile.in index 56a312671..575d95e40 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) | \ diff --git a/doc/Makefile.in b/doc/Makefile.in index 6433ad82f..11511189e 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -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)" diff --git a/lib/am/distdir.am b/lib/am/distdir.am index 43af3611a..a3c91b39b 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -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) | \ diff --git a/lib/am/mans.am b/lib/am/mans.am index 1828c5da9..cf66e4f13 100644 --- a/lib/am/mans.am +++ b/lib/am/mans.am @@ -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% diff --git a/lib/am/remake-hdr.am b/lib/am/remake-hdr.am index c1bc42f0a..c87572bff 100644 --- a/lib/am/remake-hdr.am +++ b/lib/am/remake-hdr.am @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index d70060846..5d5a29051 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -422,6 +422,7 @@ lzma.test \ maintclean.test \ make.test \ makej.test \ +makej2.test \ maken.test \ maken2.test \ maken3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index bc77d2341..abce1cd95 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 000000000..e89afec3e --- /dev/null +++ b/tests/makej2.test @@ -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 . + +# 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 -- 2.34.1