automake-patches
[Top][All Lists]
Advanced

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

[PATCH] init.m4: add probe to check "rm -f" without args work


From: Stefano Lattarini
Subject: [PATCH] init.m4: add probe to check "rm -f" without args work
Date: Wed, 16 Jan 2013 13:13:18 +0100

On 01/09/2013 08:14 PM, Stefano Lattarini wrote:
> See automake bug#10828.
> 
> * PLANS/rm-f-without-args.txt: New.
> 
> Signed-off-by: Stefano Lattarini <address@hidden>
> ---
>  PLANS/rm-f-without-args.txt | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 PLANS/rm-f-without-args.txt
> 
> diff --git a/PLANS/rm-f-without-args.txt b/PLANS/rm-f-without-args.txt
> new file mode 100644
> index 0000000..d5f96eb
> --- /dev/null
> +++ b/PLANS/rm-f-without-args.txt
> @@ -0,0 +1,40 @@
> +Summary
> +-------
> +
> +POSIX will say in a future version that calling "rm -f" with no argument
> +is OK; and this sensible behaviour seem to be already very widespread in
> +"the wild" (and possibly lacking only on those systems that are well on
> +their way to obsolescence).
> +
> +Se we'd like to simplify several automake-generated "cleaning" rules
> +accordingly, to get rid of the awful idiom:
> +
> +  test -z "$(VAR)" || rm -f $(VAR)
> +
> +See automake bug#10828.
> +
> +For Automake 1.13.2 (or 1.13.3)
> +-------------------------------
> +
> +Add a temporary "probe check" in AM_INIT_AUTOMAKE that verifies that
> +the no-args "rm -f" usage is supported on the system configure is
> +being run on; complain loudly (but not with a fatal error) if this is
> +not the case, and tell the user to report the situation to us.
> +
Here is a patch implementing this first part of the plan.  Note that, in
order to improve the visibility of the loud warning, I have made it fatal
by default; the user will still be able to instruct configure to continue
anyway by setting the ACCEPT_INFERIOR_RM_PROGRAM environment variable to
"yes" (that knob is mentioned in the fatal error message).

I will push in a couple of days if there is no objection.

Regards,
  Stefano

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----

>From f78b0f0b2741fcdd4e21151758a8a75ddaa8aa17 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Sat, 12 Jan 2013 19:20:54 +0100
Subject: [PATCH] init.m4: add probe to check "rm -f" without args work

See automake bug#10828.

POSIX will say in a future version that running "rm -f" with no argument
is OK: <http://austingroupbugs.net/view.php?id=542>).

We want to be able to make that assumption in our Makefile recipes.
So we introduce an aggressive probe to check that the usage we want is
actually supported "in the wild" to an acceptable degree.

* m4/init.m4 (AM_INIT_AUTOMAKE): Implement the probe.  To make any issue
more visible, cause the running configure to be aborted by default if
the 'rm' program in use doesn't match our expectations; the user can
still override this though, by setting the ACCEPT_INFERIOR_RM_PROGRAM
environment variable to "yes".

* t/spy-rm.tap: Update heading comments.
* t/rm-f-probe.sh: New test.
* t/list-of-tests.mk: Add it.
* PLANS/rm-f-without-args.txt: Adjust.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 PLANS/rm-f-without-args.txt |  8 ++---
 m4/init.m4                  | 43 +++++++++++++++++++++++++-
 t/list-of-tests.mk          |  1 +
 t/rm-f-probe.sh             | 74 +++++++++++++++++++++++++++++++++++++++++++++
 t/spy-rm.tap                |  8 ++---
 5 files changed, 125 insertions(+), 9 deletions(-)
 create mode 100755 t/rm-f-probe.sh

diff --git a/PLANS/rm-f-without-args.txt b/PLANS/rm-f-without-args.txt
index 5d39e22..5362f98 100644
--- a/PLANS/rm-f-without-args.txt
+++ b/PLANS/rm-f-without-args.txt
@@ -13,13 +13,13 @@ accordingly, to get rid of the awful idiom:

 See automake bug#10828.

-For Automake 1.13.2 (or 1.13.3)
--------------------------------
+For Automake 1.13.2 (DONE)
+--------------------------

 Add a temporary "probe check" in AM_INIT_AUTOMAKE that verifies that
 the no-args "rm -f" usage is supported on the system configure is
-being run on; complain loudly (but not with a fatal error) if this is
-not the case, and tell the user to report the situation to us.
+being run on; complain loudly if this is not the case, and tell the
+user to report the situation to us.

 For Automake 1.14
 -----------------
diff --git a/m4/init.m4 b/m4/init.m4
index c5af65c..ce64a6c 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -117,7 +117,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see 
below.
 AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
-])
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes.  So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+  cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present.  This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell address@hidden about your system, including the value
+of your $PATH and any error possibly output before this message.  This
+can help us improve future automake versions.
+
+END
+  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+    echo 'Configuration will proceed anyway, since you have set the' >&2
+    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+    echo >&2
+  else
+    cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+  fi
+fi])

 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 44f598e..0f5dbee 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -953,6 +953,7 @@ t/remake-macrodir.sh \
 t/remake-timing-bug-pr8365.sh \
 t/reqd2.sh \
 t/repeated-options.sh \
+t/rm-f-probe.sh \
 t/rulepat.sh \
 t/self-check-cc-no-c-o.sh \
 t/self-check-configure-help.sh \
diff --git a/t/rm-f-probe.sh b/t/rm-f-probe.sh
new file mode 100755
index 0000000..1cb220a
--- /dev/null
+++ b/t/rm-f-probe.sh
@@ -0,0 +1,74 @@
+#! /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/>.
+
+# Verify our probe that checks that "rm -f" doesn't complain if called
+# without file operands works as expected.  See automake bug#10828.
+
+. test-init.sh
+
+echo AC_OUTPUT >> configure.ac
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir bin
+cat > bin/rm <<'END'
+#!/bin/sh
+set -e; set -u;
+PATH=$original_PATH; export PATH
+rm_opts=
+while test $# -gt 0; do
+  case $1 in
+    -*) rm_opts="$rm_opts $1";;
+     *) break;;
+  esac
+  shift
+done
+if test $# -eq 0; then
+  echo "Oops, fake rm called without arguments" >&2
+  exit 1
+else
+  exec rm $rm_opts "$@"
+fi
+END
+chmod a+x bin/rm
+
+original_PATH=$PATH
+PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
+export PATH original_PATH
+
+rm -f && exit 99 # Sanity check.
+
+./configure 2>stderr && { cat stderr >&2; exit 1; }
+cat stderr >&2
+
+grep "'rm' program.* unable to run without file operands" stderr
+$FGREP "tell address@hidden about your system" stderr
+$FGREP "install GNU coreutils" stderr
+$EGREP "(^| |')ACCEPT_INFERIOR_RM_PROGRAM($| |')" stderr
+
+ACCEPT_INFERIOR_RM_PROGRAM=yes; export ACCEPT_INFERIOR_RM_PROGRAM
+
+./configure
+$MAKE
+$MAKE distcheck
+
+# For the sake of our exit trap.
+PATH=$original_PATH; export PATH
+
+:
diff --git a/t/spy-rm.tap b/t/spy-rm.tap
index 29840ab..3b8dd2d 100755
--- a/t/spy-rm.tap
+++ b/t/spy-rm.tap
@@ -19,10 +19,10 @@
 # to hold on all non-museum systems, and will soon be mandated
 # by POSIX as well) in future version of automake, to simplify
 # automake-provided cleanup rules.
-# References:
-#  <http://lists.gnu.org/archive/html/bug-autoconf/2012-02/msg00002.html>
-#  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10819>
-#  <http://austingroupbugs.net/view.php?id=542>
+# See automake bug#10828.
+# Other references:
+# <http://lists.gnu.org/archive/html/bug-autoconf/2012-02/msg00002.html>
+# <http://austingroupbugs.net/view.php?id=542>

 am_create_testdir=empty
 . test-init.sh
-- 
1.8.1.rc3.192.g2d0029e



reply via email to

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