Improve NetBSD 'make -n' output for many standard targets.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 09:42:34 +0000 (10:42 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 14:32:07 +0000 (15:32 +0100)
* automake.in (handle_tags): Let .MAKE depend on
`tags-recursive' and `ctags-recursive' if appropriate.
(handle_all): Likewise for `all'.
(do_check_merge_target): Likewise for `check-am' and `check'.
* lib/am/ansi2knr.am (.MAKE): Depend on %ANSI2KNR-DIR%/ansi2knr.
* lib/am/install.am [%?maybe_BUILT_SOURCES%] (.MAKE): Depend on
`install'.
* tests/maken3.test, tests/maken4.test: New tests.
* tests/Makefile.am: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
12 files changed:
ChangeLog
Makefile.in
automake.in
lib/Automake/Makefile.in
lib/Automake/tests/Makefile.in
lib/Makefile.in
lib/am/ansi2knr.am
lib/am/install.am
tests/Makefile.am
tests/Makefile.in
tests/maken3.test [new file with mode: 0755]
tests/maken4.test [new file with mode: 0755]

index c37f9e9..bc8ad4d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-03-07  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Improve NetBSD 'make -n' output for many standard targets.
+       * automake.in (handle_tags): Let .MAKE depend on
+       `tags-recursive' and `ctags-recursive' if appropriate.
+       (handle_all): Likewise for `all'.
+       (do_check_merge_target): Likewise for `check-am' and `check'.
+       * lib/am/ansi2knr.am (.MAKE): Depend on %ANSI2KNR-DIR%/ansi2knr.
+       * lib/am/install.am [%?maybe_BUILT_SOURCES%] (.MAKE): Depend on
+       `install'.
+       * tests/maken3.test, tests/maken4.test: New tests.
+       * tests/Makefile.am: Update.
+
        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)'.
index d1c4615..49f70c2 100644 (file)
@@ -739,8 +739,9 @@ ps-am:
 uninstall-am: uninstall-binSCRIPTS
        @$(NORMAL_INSTALL)
        $(MAKE) $(AM_MAKEFLAGS) uninstall-hook
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-       install-exec-am install-strip uninstall-am
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-exec-am install-strip tags-recursive \
+       uninstall-am
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
        all all-am am--refresh check check-am clean clean-generic \
index 67ee0d2..9367a08 100755 (executable)
@@ -3571,6 +3571,7 @@ sub handle_tags
                          . "\tdone\n");
        push (@tag_deps, 'tags-recursive');
        &depend ('.PHONY', 'tags-recursive');
+       &depend ('.MAKE', 'tags-recursive');
 
        $output_rules .= ("ctags-recursive:\n"
                          . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
@@ -3581,6 +3582,7 @@ sub handle_tags
                          . "\tdone\n");
        push (@ctag_deps, 'ctags-recursive');
        &depend ('.PHONY', 'ctags-recursive');
+       &depend ('.MAKE', 'ctags-recursive');
     }
 
     if (&saw_sources_p (1)
@@ -4503,6 +4505,7 @@ sub handle_all ($)
                        . '$(MAKE) $(AM_MAKEFLAGS) '
                        . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
                        . "\n\n");
+        depend ('.MAKE', 'all');
       }
     else
       {
@@ -4533,13 +4536,19 @@ sub do_check_merge_target ()
       # `all', to ensure all the primary targets are built.  Then it
       # must build the local check rules.
       $output_rules .= "check-am: all-am\n";
+      if (@check)
+        {
+         pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ",
+                            @check);
+         depend ('.MAKE', 'check-am');
+       }
+    }
+  if (@check_tests)
+    {
       pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ",
-                        @check)
-       if @check;
+                        @check_tests);
+      depend ('.MAKE', 'check-am');
     }
-  pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t  ",
-                    @check_tests)
-    if @check_tests;
 
   depend '.PHONY', 'check', 'check-am';
   # Handle recursion.  We have to honor BUILT_SOURCES like for `all:'.
@@ -4549,6 +4558,8 @@ sub do_check_merge_target ()
                       : '')
                    . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
                    . "\n");
+  depend ('.MAKE', 'check')
+    if var ('BUILT_SOURCES');
 }
 
 # handle_clean ($MAKEFILE)
index d5cb888..aa647c5 100644 (file)
@@ -599,8 +599,8 @@ ps-am:
 
 uninstall-am: uninstall-dist_perllibDATA uninstall-nodist_perllibDATA
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-       install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
        all all-am check check-am clean clean-generic ctags \
index 520048a..b663fc4 100644 (file)
@@ -418,7 +418,7 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
 
 .PHONY: all all-am check check-TESTS check-am clean clean-generic \
        distclean distclean-generic distdir dvi dvi-am html html-am \
index 8a74896..b6f9f1d 100644 (file)
@@ -574,8 +574,8 @@ ps-am:
 
 uninstall-am: uninstall-dist_pkgvdataDATA uninstall-dist_scriptDATA
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
-       install-data-am install-strip
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-data-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
        all all-am check check-am clean clean-generic ctags \
index ee106c5..e81f116 100644 (file)
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2008
+## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2008, 2009
 ## Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@ if %?ANSI2KNR-DIR%
 ANSI2KNR = %ANSI2KNR-DIR%/ansi2knr
 %ANSI2KNR-DIR%/ansi2knr:
        $(am__cd) %ANSI2KNR-DIR% && $(MAKE) $(AM_MAKEFLAGS) ./ansi2knr
+.MAKE: %ANSI2KNR-DIR%/ansi2knr
 
 else !%?ANSI2KNR-DIR%
 
index c114fa5..8380fd3 100644 (file)
@@ -1,5 +1,6 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008  Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004, 2006, 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
@@ -62,6 +63,10 @@ install-data: install-data-am
 uninstall: uninstall-am
 endif !%?SUBDIRS%
 
+if %?maybe_BUILT_SOURCES%
+.MAKE: install
+endif %?maybe_BUILT_SOURCES%
+
 .MAKE .PHONY: install-am
 install-am: all-am
        @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
index 15e8e61..8a65684 100644 (file)
@@ -395,6 +395,8 @@ make.test \
 makej.test \
 maken.test \
 maken2.test \
+maken3.test \
+maken4.test \
 makevars.test \
 man.test \
 man2.test \
index 5cece90..a491055 100644 (file)
@@ -550,6 +550,8 @@ make.test \
 makej.test \
 maken.test \
 maken2.test \
+maken3.test \
+maken4.test \
 makevars.test \
 man.test \
 man2.test \
@@ -1095,7 +1097,7 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: install-am install-strip
+.MAKE: check-am install-am install-strip
 
 .PHONY: all all-am check check-TESTS check-am clean clean-generic \
        distclean distclean-generic distclean-local distdir dvi dvi-am \
diff --git a/tests/maken3.test b/tests/maken3.test
new file mode 100755 (executable)
index 0000000..7810649
--- /dev/null
@@ -0,0 +1,167 @@
+#! /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 `make -n' for various targets, to ensure that no files or
+# directories are created.
+#
+# This test exercises the GCS-mandated targets (except for dist)
+# as well as tags, TAGS.
+
+# Please keep this test in sync with sister test maken4.test.
+
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub sub2
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+SUBDIRS = sub sub2
+##BUILT_SOURCES = foo
+foo:
+foo.test:
+all-local:
+       @: > stamp-all
+install-data-local:
+       @: > stamp-install
+uninstall-local:
+       @: > stamp-uninstall
+clean-local:
+       @: > stamp-clean
+distclean-local:
+       @: > stamp-distclean
+info-local:
+       @: > stamp-info
+html-local:
+       @: > stamp-html
+dvi-local:
+       @: > stamp-dvi
+ps-local:
+       @: > stamp-ps
+pdf-local:
+       @: > stamp-pdf
+check-local:
+       @: > stamp-check
+installcheck-local:
+       @: > stamp-installcheck
+mostlyclean-local:
+       @: > stamp-mostlyclean
+maintainer-clean-local:
+       @: > stamp-maintainer-clean
+END
+cat >sub/Makefile.am <<'END'
+all-local:
+       @: > stamp-all-sub
+install-data-local:
+       @: > stamp-install-sub
+uninstall-local:
+       @: > stamp-uninstall-sub
+clean-local:
+       @: > stamp-clean-sub
+distclean-local:
+       @: > stamp-distclean-sub
+info-local:
+       @: > stamp-info-sub
+html-local:
+       @: > stamp-html-sub
+dvi-local:
+       @: > stamp-dvi-sub
+ps-local:
+       @: > stamp-ps-sub
+pdf-local:
+       @: > stamp-pdf-sub
+check-local:
+       @: > stamp-check-sub
+installcheck-local:
+       @: > stamp-installcheck-sub
+tags:
+       @: > stamp-tags-sub
+TAGS:
+       @: > stamp-TAGS-sub
+mostlyclean-local:
+       @: > stamp-mostlyclean-sub
+maintainer-clean-local:
+       @: > stamp-maintainer-clean-sub
+END
+cat >sub2/Makefile.am <<'END'
+all install uninstall clean check:
+       @: > sub2-$@-should-not-be-executed
+info dvi pdf ps:
+       @: > sub2-$@-should-not-be-executed
+html:
+       @: > sub2-$@-should-not-be-executed
+install-info install-html install-dvi install-pdf install-ps:
+       @: > sub2-$@-should-not-be-executed
+installcheck installdirs tags TAGS mostlyclean:
+       @: > sub2-$@-should-not-be-executed
+## These targets cannot be overridden like this:
+## install-strip distclean maintainer-clean
+END
+
+$ACLOCAL
+$AUTOCONF
+
+check_targets ()
+{
+  set -e
+  for target in \
+    all install install-strip uninstall clean distclean check \
+    info html dvi pdf ps \
+    install-info install-html install-dvi install-pdf install-ps \
+    installcheck installdirs tags TAGS mostlyclean maintainer-clean
+  do
+    $MAKE -n $target >stdout || { cat stdout; Exit 1; }
+    cat stdout
+    case $target in
+    install-* | installdirs | tags | TAGS ) ;;
+    *)
+      test ! -f "stamp-$target$" || Exit 1
+      ;;
+    esac
+    case $target in
+    install-* | installdirs ) ;;
+    *)
+      test ! -f "sub/stamp-$target-sub" || Exit 1
+      ;;
+    esac
+    case $target in
+    distclean | maintainer-clean ) ;;
+    *)
+      test ! -f "sub2/sub2-$target-should-not-be-executed" || Exit 1
+      ;;
+    esac
+  done
+}
+
+$AUTOMAKE -Wno-override
+./configure
+check_targets || Exit 1
+
+# Now, introduce BUILT_SOURCES into the toplevel Makefile
+# TODO: add BUILT_SOURCES to sub2, fix fallout.
+sed 's/##//' < Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE -Wno-override --force Makefile
+./configure
+check_targets || Exit 1
+
+Exit 0
diff --git a/tests/maken4.test b/tests/maken4.test
new file mode 100755 (executable)
index 0000000..689a3a9
--- /dev/null
@@ -0,0 +1,172 @@
+#! /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 `make -n' for various targets, to ensure that stdout output is
+# sufficiently complete.  This currently only works for GNU make and
+# BSD make implementations that support the `.MAKE' special target.
+#
+# This test exercises the GCS-mandated targets (except for dist)
+# as well as tags, TAGS.
+
+# Please keep this test in sync with sister test maken3.test.
+
+required=GNUmake
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub sub2
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+SUBDIRS = sub sub2
+##BUILT_SOURCES = foo
+foo:
+foo.test:
+all-local:
+       @: > stamp-all
+install-data-local:
+       @: > stamp-install
+uninstall-local:
+       @: > stamp-uninstall
+clean-local:
+       @: > stamp-clean
+distclean-local:
+       @: > stamp-distclean
+info-local:
+       @: > stamp-info
+html-local:
+       @: > stamp-html
+dvi-local:
+       @: > stamp-dvi
+ps-local:
+       @: > stamp-ps
+pdf-local:
+       @: > stamp-pdf
+check-local:
+       @: > stamp-check
+installcheck-local:
+       @: > stamp-installcheck
+mostlyclean-local:
+       @: > stamp-mostlyclean
+maintainer-clean-local:
+       @: > stamp-maintainer-clean
+END
+cat >sub/Makefile.am <<'END'
+all-local:
+       @: > stamp-all-sub
+install-data-local:
+       @: > stamp-install-sub
+uninstall-local:
+       @: > stamp-uninstall-sub
+clean-local:
+       @: > stamp-clean-sub
+distclean-local:
+       @: > stamp-distclean-sub
+info-local:
+       @: > stamp-info-sub
+html-local:
+       @: > stamp-html-sub
+dvi-local:
+       @: > stamp-dvi-sub
+ps-local:
+       @: > stamp-ps-sub
+pdf-local:
+       @: > stamp-pdf-sub
+check-local:
+       @: > stamp-check-sub
+installcheck-local:
+       @: > stamp-installcheck-sub
+tags:
+       @: > stamp-tags-sub
+TAGS:
+       @: > stamp-TAGS-sub
+mostlyclean-local:
+       @: > stamp-mostlyclean-sub
+maintainer-clean-local:
+       @: > stamp-maintainer-clean-sub
+END
+cat >sub2/Makefile.am <<'END'
+all install uninstall clean check:
+       @: > sub2-$@-should-not-be-executed
+info dvi pdf ps:
+       @: > sub2-$@-should-not-be-executed
+html:
+       @: > sub2-$@-should-not-be-executed
+install-info install-html install-dvi install-pdf install-ps:
+       @: > sub2-$@-should-not-be-executed
+installcheck installdirs tags TAGS mostlyclean:
+       @: > sub2-$@-should-not-be-executed
+## These targets cannot be overridden like this:
+## install-strip distclean maintainer-clean
+END
+
+$ACLOCAL
+$AUTOCONF
+
+check_targets ()
+{
+  set -e
+  for target in \
+    all install install-strip uninstall clean distclean check \
+    info html dvi pdf ps \
+    install-info install-html install-dvi install-pdf install-ps \
+    installcheck installdirs tags TAGS mostlyclean maintainer-clean
+  do
+    $MAKE -n $target >stdout || { cat stdout; Exit 1; }
+    cat stdout
+    case $target in
+    install-* | installdirs | tags | TAGS ) ;;
+    *)
+      grep "stamp-$target$" stdout || Exit 1
+      test ! -f "stamp-$target$" || Exit 1
+      ;;
+    esac
+    case $target in
+    install-* | installdirs ) ;;
+    *)
+      grep "stamp-$target-sub" stdout || Exit 1
+      test ! -f "sub/stamp-$target-sub" || Exit 1
+      ;;
+    esac
+    case $target in
+    distclean | maintainer-clean ) ;;
+    *)
+      grep "should-not-be-executed" stdout || Exit 1
+      test ! -f "sub2/sub2-$target-should-not-be-executed" || Exit 1
+      ;;
+    esac
+  done
+}
+
+$AUTOMAKE -Wno-override
+./configure
+check_targets || Exit 1
+
+# Now, introduce BUILT_SOURCES into the toplevel Makefile
+# TODO: add BUILT_SOURCES to sub2, fix fallout.
+sed 's/##//' < Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE -Wno-override --force Makefile
+./configure
+check_targets || Exit 1
+
+Exit 0