Re: DELETE_ON_ERROR test-suite.log and .PRECIOUS

Stefano Lattarini <[email protected]>
Newsgroups gmane.comp.sysutils.automake.general,gmane.comp.sysutils.automake.patches
Message-ID <[email protected]>
On 07/20/2013 08:35 AM, Holger Hans Peter Freyther wrote:
> Good Morning,
> 
> systemd is using .DELETE_ON_ERROR to simplify some rules[1] but the
> side-effect is that during make check and a failing test the result
> of 'test-suite.log' will be deleted as well. I 'fixed' this by adding
> .PRECIOUS: $(TEST_SUITE_LOG) to the file but that is triggering the
> following warning:
> 
> Makefile.am:35: warning: user target '.PRECIOUS' defined here ...
> /usr/share/automake-1.13/am/configure.am: ... overrides Automake target
> '.PRECIOUS' defined here
> 
> Is there a better way to ask automake/make to keep the test-suite.log
> around? Is there a way to make the warning go away?
> 
> kind regards
> 	holger
> 
> 
> [1] http://cgit.freedesktop.org/systemd/systemd/commit/?id=96bd03d5b8d5d04fc8037c03a43bb5b148cc1e29
> 
Thanks for the suggestion, and sorry for the shameful delay.
I implemented the required improvement with the trivial patch
attached.  It should appear in Automake 1.15.

Thanks,
  Stefano
0001-Allow-user-to-extend-.PRECIOUS-target.patch (text/x-patch, 4.9 KB)
From f0a7083afefe98aa7aecf4ece592915395947631 Mon Sep 17 00:00:00 2001
Message-Id: <f0a7083afefe98aa7aecf4ece592915395947631.1388086590.git.stefano.lattarini@gmail.com>
From: Stefano Lattarini <[email protected]>
Date: Thu, 26 Dec 2013 19:31:15 +0100
Subject: [PATCH] Allow user to extend .PRECIOUS target

References:
<http://lists.freedesktop.org/archives/systemd-devel/2013-July/012155.html>
<http://lists.gnu.org/archive/html/automake/2013-07/msg00011.html>

* bin/automake.in: Adjust to ensure we handle '.PRECIOUS' the same way
we do for '.PHONY' and '.MAKE'.
* lib/Automake/Rule.pm: Likewise.
* t/precious.sh: New test.
* t/list-of-tests.mk: Add it.
* t/phony.sh: Enhance a little while at it.
* NEWS: Update.
* THANKS: Likewise.

Reported-by: Holger Hans Peter Freyther <[email protected]>
Signed-off-by: Stefano Lattarini <[email protected]>
---
 NEWS                 |  5 +++++
 THANKS               |  1 +
 bin/automake.in      |  4 ++--
 lib/Automake/Rule.pm |  2 +-
 t/list-of-tests.mk   |  1 +
 t/phony.sh           |  1 +
 t/precious.sh        | 32 ++++++++++++++++++++++++++++++++
 7 files changed, 43 insertions(+), 3 deletions(-)
 create mode 100644 t/precious.sh

diff --git a/NEWS b/NEWS
index 8d902c0..dd2812a 100644
--- a/NEWS
+++ b/NEWS
@@ -93,6 +93,11 @@ New in 1.15:
     implementation of the TAP driver (that is documented in the manual)
     is more portable and has feature parity with the perl implementation.
 
+* Bug fixes:
+
+  - The user can now extend the special .PRECIOUS target, the same way
+    he could already do with the .MAKE .and .PHONY targets.
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.14.1:
diff --git a/THANKS b/THANKS
index 2b4f8ee..58dac98 100644
--- a/THANKS
+++ b/THANKS
@@ -152,6 +152,7 @@ Harlan Stenn                    [email protected]
 He Li                           [email protected]
 Henrik Frystyk Nielsen          [email protected]
 Hib Eris                        [email protected]
+Holger Hans Peter Freyther      [email protected]
 Ian Lance Taylor                [email protected]
 Ignacy Gawedzki                 [email protected]
 Илья Н. Голубев                 [email protected]
diff --git a/bin/automake.in b/bin/automake.in
index 283d1bb..8808300 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -4645,9 +4645,9 @@ sub handle_factored_dependencies ()
       # to append dependencies.  This would not work if Automake
       # refrained from defining its own .PHONY target as it does
       # with other overridden targets.
-      # Likewise for '.MAKE'.
+      # Likewise for '.MAKE' and '.PRECIOUS'.
       my @undefined_conds = (TRUE,);
-      if ($_ ne '.PHONY' && $_ ne '.MAKE')
+      if ($_ ne '.PHONY' && $_ ne '.MAKE' && $_ ne '.PRECIOUS')
 	{
 	  @undefined_conds =
 	    Automake::Rule::define ($_, 'internal',
diff --git a/lib/Automake/Rule.pm b/lib/Automake/Rule.pm
index a28a78d..5227009 100644
--- a/lib/Automake/Rule.pm
+++ b/lib/Automake/Rule.pm
@@ -340,8 +340,8 @@ sub reset()
      # Tarballing.
      'dist-all'             => [],
 
-     # Phonying.
      '.PHONY'               => [],
+     '.PRECIOUS'            => [],
      # Recursive install targets (so "make -n install" works for BSD Make).
      '.MAKE'		    => [],
      );
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 54afd8f..a9694d8 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -838,6 +838,7 @@ t/percent.sh \
 t/percent2.sh \
 t/per-target-flags.sh \
 t/phony.sh \
+t/precious.sh \
 t/pluseq.sh \
 t/pluseq2.sh \
 t/pluseq3.sh \
diff --git a/t/phony.sh b/t/phony.sh
index dd0c54a..a632776 100644
--- a/t/phony.sh
+++ b/t/phony.sh
@@ -26,6 +26,7 @@ EOF
 
 $ACLOCAL
 $AUTOMAKE
+$FGREP '.PHONY:' Makefile.in  # For debugging.
 test $($FGREP -c '.PHONY:' Makefile.in) -eq 3
 
 :
diff --git a/t/precious.sh b/t/precious.sh
new file mode 100644
index 0000000..8750305
--- /dev/null
+++ b/t/precious.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (C) 2013 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 2, 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/>.
+
+# Make sure .PRECIOUS can be extended by the user, and can be given
+# dependencies several times.
+
+. test-init.sh
+
+cat >Makefile.am << 'EOF'
+.PRECIOUS: foo
+.PRECIOUS: bar
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '.PRECIOUS:' Makefile.in  # For debugging.
+test $($FGREP -c '.PRECIOUS:' Makefile.in) -eq 3
+
+:
-- 
1.8.5.rc0.335.g7794a68
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.