autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper


From: Paolo Bonzini
Subject: [PATCH] Turn AS_SHELL_SANITIZE into a for-Libtool-only wrapper
Date: Wed, 15 Oct 2008 13:32:09 +0200

Given the mess that Eric highlighted in his recent messages, I
decided to go on with my original plan of renaming AS_SHELL_SANITIZE
to _AS_SHELL_SANITIZE.  The no-underscore macro, instead, is there
for Libtool only.  As an additional benefit, Libtool gains the
loop that searches for a better shell.  I didn't test Libtool fully
(I will), but I did inspect manually the changes in the libtoolize
script.

With this patch, the better-shell loop is always executed, even if
it is a no-op.  Unfortunately I could not find a better way to
make things go in the appropriate diversion for both "correct"
scripts and Libtool scripts.  However, the next patch will anyway
add a test that is always executed (in order to find a shell with
functions and unset), so this pessimization is only temporary.

Isolating the parts of AS_INIT that should be included in Libtool
required some surgery; the main problem, of course, is that
AS_SHELL_SANITIZE could be called in two different contexts: in
Libtoolize as part of a toplevel script, and in Libtool as part
of the creation of config.lt.  However, overall I like the code
better (with the exception of the new AS_SHELL_SANITIZE macro).

Ok?

Paolo
---
 lib/m4sugar/m4sh.m4 |   50 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 32 insertions(+), 18 deletions(-)

2008-10-15  Paolo Bonzini  <address@hidden>
        * lib/m4sugar/m4sh.m4 (_AS_DETECT_REQUIRED, _AS_DETECT_SUGGESTED):
        Remove m4_require of _AS_DETECT_BETTER_SHELL.
        (_AS_CLEANUP): Add it here.
        (_AS_DETECT_BETTER_SHELL): Just expand the test instead of appending it
        to _AS_CLEANUP.
        (_AS_SHELL_SANITIZE): New name of the old AS_SHELL_SANITIZE macro.
        (AS_SHELL_SANITIZE): New macro hacking around Libtool misuse.
        (AS_PREPARE): Use _AS_SHELL_SANITIZE.
        (AS_INIT): Add m4_provide of itself.

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 20b5772..571a13e 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -138,7 +138,8 @@ m4_define([_AS_BOURNE_COMPATIBLE],
 # -----------
 # Expanded as the last thing before m4sugar cleanup begins.  Macros
 # may append m4sh cleanup hooks to this as appropriate.
-m4_define([_AS_CLEANUP])
+m4_define([_AS_CLEANUP],
+[m4_divert_text([M4SH-SANITIZE], [_AS_DETECT_BETTER_SHELL])])
 
 
 # AS_COPYRIGHT(TEXT)
@@ -155,9 +156,9 @@ $1], [^], address@hidden:@ ])])])
 # _AS_DETECT_REQUIRED(TEST)
 # -------------------------
 # Refuse to execute under a shell that does not pass the given TEST.
+# Does not do AS_REQUIRE for the better-shell detection code.
 m4_defun([_AS_DETECT_REQUIRED],
-[m4_require([_AS_DETECT_BETTER_SHELL])dnl
-m4_set_add([_AS_DETECT_REQUIRED_BODY],
+[m4_set_add([_AS_DETECT_REQUIRED_BODY],
           [($1) || AS_EXIT(1)
 ])])
 
@@ -165,9 +166,9 @@ m4_set_add([_AS_DETECT_REQUIRED_BODY],
 # _AS_DETECT_SUGGESTED(TEST)
 # --------------------------
 # Prefer to execute under a shell that passes the given TEST.
+# Does not do AS_REQUIRE for the better-shell detection code.
 m4_defun([_AS_DETECT_SUGGESTED],
-[m4_require([_AS_DETECT_BETTER_SHELL])dnl
-m4_set_add([_AS_DETECT_SUGGESTED_BODY],
+[m4_set_add([_AS_DETECT_SUGGESTED_BODY],
           [($1) || AS_EXIT(1)
 ])])
 
@@ -186,10 +187,8 @@ m4_set_add([_AS_DETECT_SUGGESTED_BODY],
 # FIXME: The code should test for the OSF bug described in
 # <http://lists.gnu.org/archive/html/autoconf-patches/2006-03/msg00081.html>.
 #
-m4_defun_once([_AS_DETECT_BETTER_SHELL],
-[AS_REQUIRE([_AS_UNSET_PREPARE], , [M4SH-SANITIZE])dnl
-m4_append([_AS_CLEANUP], [m4_divert_text([M4SH-SANITIZE], [
-if test "x$CONFIG_SHELL" = x; then
+m4_defun([_AS_DETECT_BETTER_SHELL],
+[if test "x$CONFIG_SHELL" = x; then
 dnl Remove any tests from suggested that are also required
   m4_set_foreach([_AS_DETECT_SUGGESTED_BODY], [AS_snippet],
                 [m4_set_contains([_AS_DETECT_REQUIRED_BODY],
@@ -239,7 +238,7 @@ dnl Remove any tests from suggested that are also required
       AS_EXIT(1)])
     ])
 fi
-])])])# _AS_DETECT_BETTER_SHELL
+])# _AS_DETECT_BETTER_SHELL
 
 
 # _AS_PREPARE
@@ -316,7 +315,7 @@ m4_if(m4_eval(_m4_divert(_m4_divert_dump) <= 
_m4_divert(_m4_divert_desired)), 1,
 # xx_REQUIRE macros, BODY-TO-EXPAND is mandatory.
 #
 m4_define([AS_REQUIRE_SHELL_FN],
-[_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
+[AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
 AS_REQUIRE([AS_SHELL_FN_$1], [m4_provide([AS_SHELL_FN_$1])$1 ()
 {
 $2
@@ -378,9 +377,10 @@ test $exitcode = 0[]dnl
 ])# _AS_SHELL_FN_WORK
 
 
-# AS_SHELL_SANITIZE
-# -----------------
-m4_defun([AS_SHELL_SANITIZE],
+# _AS_SHELL_SANITIZE
+# ------------------
+# This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED.
+m4_defun([_AS_SHELL_SANITIZE],
 [## --------------------- ##
 ## M4sh Initialization.  ##
 ## --------------------- ##
@@ -433,7 +433,20 @@ export LANGUAGE
 
 # CDPATH.
 $as_unset CDPATH
-])# AS_SHELL_SANITIZE
+])# _AS_SHELL_SANITIZE
+
+
+# AS_SHELL_SANITIZE
+# -----------------
+# This is only needed for the sake of Libtool, which screwed us up royally
+# due to its usage of M4sh internals.
+m4_define([AS_SHELL_SANITIZE],
+[_AS_SHELL_SANITIZE
+m4_provide_if([AS_INIT], [],
+[m4_provide([AS_INIT])
+_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
+_AS_DETECT_BETTER_SHELL
+])])
 
 
 ## ----------------------------- ##
@@ -1683,7 +1696,7 @@ m4_define([AS_VAR_POPDEF],
 # for more detail.
 m4_defun([AS_INIT_GENERATED],
 [m4_require([AS_PREPARE])dnl
-AS_SHELL_SANITIZE
+_AS_SHELL_SANITIZE
 _AS_PREPARE])
 
 # AS_INIT
@@ -1693,6 +1706,7 @@ m4_define([AS_INIT],
 [# Wrap our cleanup prior to m4sugar's cleanup.
 m4_wrap([_AS_CLEANUP])
 m4_init
+m4_provide([AS_INIT])
 
 # Forbidden tokens and exceptions.
 m4_pattern_forbid([^_?AS_])
@@ -1701,10 +1715,11 @@ m4_pattern_forbid([^_?AS_])
 m4_divert_text([BINSH], address@hidden:@! /bin/sh])
 m4_divert_text([HEADER-COMMENT],
               address@hidden:@ Generated from __file__ by m4_PACKAGE_STRING.])
-m4_divert_text([M4SH-SANITIZE], [AS_SHELL_SANITIZE])
+m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
 
 # Let's go!
 m4_divert_pop([KILL])[]dnl
 m4_divert_pop([KILL])[]dnl
 m4_divert_push([BODY])[]dnl
+_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
 ])

-- 
1.5.5





reply via email to

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