automake-patches
[Top][All Lists]
Advanced

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

Improve NetBSD 'make -n' output for many standard targets.


From: Ralf Wildenhues
Subject: Improve NetBSD 'make -n' output for many standard targets.
Date: Sat, 7 Mar 2009 15:38:09 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

For GNU make, `make -n' seems to be basically sane now:
a) the rules provided by automake don't cause any actual changes,
b) output is sufficiently verbose to show all things that would happen.

The new tests below ensure the above for all the interesting targets,
except for dist and distcheck, which have been treated in maken{,2}.test
already.

Now, for non-GNU make, things can still be improved: while (a) holds for
them, (b) doesn't.  The patch below improves upon (b) for NetBSD make
which honors the `.MAKE' special target.

A note is in order here:

None of the BSD manuals I've found document the `.MAKE' special target.
Several document the `.MAKE' special "source" (prerequisite), however,
not all actually implement it.  Since adding a special prerequisite to
rules is a bit more problematic for other make implemenations, let's
refrain from that.  (Still need to investigate the portability of rule
commands marked with `+').

The two tests are again very similar, but the GNU make-specific one
also ensures that certain output does appear with "make -n".

Pushed to master.

Cheers,
Ralf

    Improve BSD '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.

diff --git a/automake.in b/automake.in
index 67ee0d2..9367a08 100755
--- a/automake.in
+++ b/automake.in
@@ -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)
diff --git a/lib/am/ansi2knr.am b/lib/am/ansi2knr.am
index ee106c5..e81f116 100644
--- a/lib/am/ansi2knr.am
+++ b/lib/am/ansi2knr.am
@@ -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%
 
diff --git a/lib/am/install.am b/lib/am/install.am
index c114fa5..8380fd3 100644
--- a/lib/am/install.am
+++ b/lib/am/install.am
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 15e8e61..8a65684 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -395,6 +395,8 @@ make.test \
 makej.test \
 maken.test \
 maken2.test \
+maken3.test \
+maken4.test \
 makevars.test \
 man.test \
 man2.test \
diff --git a/tests/maken3.test b/tests/maken3.test
new file mode 100755
index 0000000..7810649
--- /dev/null
+++ b/tests/maken3.test
@@ -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:
+       @: > address@hidden
+info dvi pdf ps:
+       @: > address@hidden
+html:
+       @: > address@hidden
+install-info install-html install-dvi install-pdf install-ps:
+       @: > address@hidden
+installcheck installdirs tags TAGS mostlyclean:
+       @: > address@hidden
+## 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
index 0000000..689a3a9
--- /dev/null
+++ b/tests/maken4.test
@@ -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:
+       @: > address@hidden
+info dvi pdf ps:
+       @: > address@hidden
+html:
+       @: > address@hidden
+install-info install-html install-dvi install-pdf install-ps:
+       @: > address@hidden
+installcheck installdirs tags TAGS mostlyclean:
+       @: > address@hidden
+## 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




reply via email to

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