From a88a2a277a7b5f835a32c2120ce6afbbeabd4167 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sat, 7 Mar 2009 10:42:34 +0100 Subject: [PATCH] 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. Signed-off-by: Ralf Wildenhues --- ChangeLog | 11 +++ Makefile.in | 5 +- automake.in | 21 +++- lib/Automake/Makefile.in | 4 +- lib/Automake/tests/Makefile.in | 2 +- lib/Makefile.in | 4 +- lib/am/ansi2knr.am | 3 +- lib/am/install.am | 7 +- tests/Makefile.am | 2 + tests/Makefile.in | 4 +- tests/maken3.test | 167 ++++++++++++++++++++++++++++++++ tests/maken4.test | 172 +++++++++++++++++++++++++++++++++ 12 files changed, 387 insertions(+), 15 deletions(-) create mode 100755 tests/maken3.test create mode 100755 tests/maken4.test diff --git a/ChangeLog b/ChangeLog index c37f9e910..bc8ad4d00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2009-03-07 Ralf Wildenhues + 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)'. diff --git a/Makefile.in b/Makefile.in index d1c461554..49f70c2d0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/automake.in b/automake.in index 67ee0d213..9367a089b 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/Automake/Makefile.in b/lib/Automake/Makefile.in index d5cb88889..aa647c5e6 100644 --- a/lib/Automake/Makefile.in +++ b/lib/Automake/Makefile.in @@ -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 \ diff --git a/lib/Automake/tests/Makefile.in b/lib/Automake/tests/Makefile.in index 520048a76..b663fc446 100644 --- a/lib/Automake/tests/Makefile.in +++ b/lib/Automake/tests/Makefile.in @@ -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 \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 8a7489667..b6f9f1d96 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -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 \ diff --git a/lib/am/ansi2knr.am b/lib/am/ansi2knr.am index ee106c59f..e81f116c7 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 c114fa59b..8380fd364 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 15e8e6197..8a6568484 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/Makefile.in b/tests/Makefile.in index 5cece9010..a49105591 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 index 000000000..78106497f --- /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 . + +# 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 index 000000000..689a3a971 --- /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 . + +# 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 -- 2.47.2