]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Improve `make -n dist' and `make -n distcheck' for GNU make.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 08:00:19 +0000 (09:00 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 08:00:19 +0000 (09:00 +0100)
Ensure that `make -n dist' and `make -n distcheck' do not change
files, due to GNU make executing rules containing `$(MAKE)'.

* lib/am/distdir.am (distdir): Separate the creation of
`$(distdir)/$$subdir' for `$(DIST_SUBDIRS)' and the recursion
into the `$(DIST_SUBDIRS)' in two separate rule commands.
(distcheck): Exit recursive rule early when run with `make -n',
as detected by a witness file.
* tests/maken.test, tests/maken2.test: New tests.
* tests/Makefile.am: Update.
* NEWS: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
Makefile.in
NEWS
lib/Automake/Makefile.in
lib/Makefile.in
lib/am/distdir.am
tests/Makefile.am
tests/Makefile.in
tests/maken.test [new file with mode: 0755]
tests/maken2.test [new file with mode: 0755]

index 36250205e0ef93eb06d08513d5aabf86b70fe2a6..c37f9e91008fb39d4cbe2f10af718bdf65297030 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-03-07  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Improve `make -n dist' and `make -n distcheck' for GNU make.
+       Ensure that `make -n dist' and `make -n distcheck' do not change
+       files, due to GNU make executing rules containing `$(MAKE)'.
+       * lib/am/distdir.am (distdir): Separate the creation of
+       `$(distdir)/$$subdir' for `$(DIST_SUBDIRS)' and the recursion
+       into the `$(DIST_SUBDIRS)' in two separate rule commands.
+       (distcheck): Exit recursive rule early when run with `make -n',
+       as detected by a witness file.
+       * tests/maken.test, tests/maken2.test: New tests.
+       * tests/Makefile.am: Update.
+       * NEWS: Update.
+
 2009-03-07  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Solaris make testsuite fixes.
index 6dde4e5dfc39dbcc34e8ed75f2150cc79ead2c6d..d1c461554c9bd4acc98932a57a53693bf6d2f376 100644 (file)
@@ -494,6 +494,10 @@ distdir: $(DISTFILES)
            test -d "$(distdir)/$$subdir" \
            || $(MKDIR_P) "$(distdir)/$$subdir" \
            || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
            dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
            $(am__relativize); \
            new_distdir=$$reldir; \
@@ -582,6 +586,7 @@ distcheck: dist
        mkdir $(distdir)/_build
        mkdir $(distdir)/_inst
        chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
        dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
          && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
          && $(am__cd) $(distdir)/_build \
diff --git a/NEWS b/NEWS
index 6fcc1a535b0bbab7333230d780fde8f194836131..d4b59e95084e7defb65125689341b387774bb5b3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -170,6 +170,9 @@ Bugs fixed in 1.10a:
     containing the error message, but exit successfully.  However, `make dist'
     will ensure that no such bogus man pages are packaged into a tarball.
 
+  - Targets provided by automake behave better with `make -n', in that they
+    take care not to create files.
+
 * Bugs introduced by 1.10:
 
   - Fix output of dummy dependency files in presence of post-processed
index 3217731fd47e3144e485f7f15db7627cfd726873..d5cb88889a21d82572050da62a9c6cb3a453d2e0 100644 (file)
@@ -477,6 +477,10 @@ distdir: $(DISTFILES)
            test -d "$(distdir)/$$subdir" \
            || $(MKDIR_P) "$(distdir)/$$subdir" \
            || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
            dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
            $(am__relativize); \
            new_distdir=$$reldir; \
index f45ea0b6907f53ba4f58dcc71876eeefdf6c91e6..8a74896677cc8b713e035d86c92d50f8b6b4ca80 100644 (file)
@@ -452,6 +452,10 @@ distdir: $(DISTFILES)
            test -d "$(distdir)/$$subdir" \
            || $(MKDIR_P) "$(distdir)/$$subdir" \
            || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
            dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
            $(am__relativize); \
            new_distdir=$$reldir; \
index 5acfa493f9b341fd47622e292aaf3dbb472272fe..ad5e7713c47bc2d0695659161b9b4fc576fb4362 100644 (file)
@@ -220,12 +220,18 @@ endif %?TOPDIR_P%
 ## directory, then we use `distdir' instead of `top_distdir'; this lets
 ## us work correctly with an enclosing package.
 ##
+## Split the loop for the directory creation and the one for recursion,
+## so that with GNU make -n, only the latter is executed.
 if %?SUBDIRS%
        @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
          if test "$$subdir" = .; then :; else \
            test -d "$(distdir)/$$subdir" \
            || $(MKDIR_P) "$(distdir)/$$subdir" \
            || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
            dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
            $(am__relativize); \
            new_distdir=$$reldir; \
@@ -418,6 +424,12 @@ distcheck: dist
        mkdir $(distdir)/_inst
 ## Undo the write access.
        chmod a-w $(distdir)
+## With GNU make, the following command will be executed even with `make -n',
+## due to the presence of `$(MAKE)'.  That is normally all well (and `$(MAKE)'
+## is necessary for things like parallel distcheck), but here we don't want
+## execution.  To avoid MAKEFLAGS parsing hassles, use a witness file that a
+## non-`-n' run would have just created.
+       test -d $(distdir)/_build || exit 0; \
 ## Compute the absolute path of `_inst'.  Strip any leading DOS drive
 ## to allow DESTDIR installations.  Otherwise "$(DESTDIR)$(prefix)" would
 ## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
index d4687f47d675a57c1db159d73a500b86c2aec33e..15e8e619770f0d3a52ba239b5640f381740f92e4 100644 (file)
@@ -393,6 +393,8 @@ lzma.test \
 maintclean.test \
 make.test \
 makej.test \
+maken.test \
+maken2.test \
 makevars.test \
 man.test \
 man2.test \
index dc0a339c13fa0f921a68193b2fa360573593370a..5cece9010ae9b7f23975e8a251923db786ea840a 100644 (file)
@@ -548,6 +548,8 @@ lzma.test \
 maintclean.test \
 make.test \
 makej.test \
+maken.test \
+maken2.test \
 makevars.test \
 man.test \
 man2.test \
diff --git a/tests/maken.test b/tests/maken.test
new file mode 100755 (executable)
index 0000000..8219ec6
--- /dev/null
@@ -0,0 +1,61 @@
+#! /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/>.
+
+# Ensure that `make -n dist' and `make -n distcheck' do not change files
+# on disk, due to GNU make executing rules containing `$(MAKE)'.
+
+# Please keep this test in sync with sister test maken2.test.
+
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+distcheck-hook:
+       @: > stamp-distcheck-hook
+test-no-distdir:
+       test ! -d $(distdir)
+       test ! -f stamp-distcheck-hook
+       test ! -f sub/stamp-sub-dist-hook
+END
+cat >sub/Makefile.am <<'END'
+dist-hook:
+       @: > stamp-sub-dist-hook
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$sleep
+echo stamp > stampfile
+$sleep
+for target in dist distcheck; do
+  $MAKE -n $target
+  $MAKE test-no-distdir
+  test `ls -1t | sed 1q` = stampfile
+done
+
+Exit 0
diff --git a/tests/maken2.test b/tests/maken2.test
new file mode 100755 (executable)
index 0000000..4569375
--- /dev/null
@@ -0,0 +1,63 @@
+#! /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/>.
+
+# Ensure that `make -n dist' and `make -n distcheck' show what would happen.
+# This currently works for GNU make only.
+
+# Please keep this test in sync with sister test maken.test.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+distcheck-hook:
+       @: > stamp-distcheck-hook
+test-no-distdir:
+       test ! -d $(distdir)
+       test ! -f stamp-distcheck-hook
+       test ! -f sub/stamp-sub-dist-hook
+END
+cat >sub/Makefile.am <<'END'
+dist-hook:
+       @: > stamp-sub-dist-hook
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$sleep
+echo stamp > stampfile
+$sleep
+for target in dist distcheck; do
+  $MAKE -n $target
+  $MAKE test-no-distdir
+  $MAKE -n $target | grep stamp-sub-dist-hook
+  test `ls -1t | sed 1q` = stampfile
+done
+
+Exit 0