[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/6] use documented m4sh interfaces
From: |
Paolo Bonzini |
Subject: |
[PATCH 3/6] use documented m4sh interfaces |
Date: |
Fri, 7 Nov 2008 09:40:42 +0100 |
Here we start with the meat. This patch ends Libtool's indiscriminate
usage of undocumented (and in some cases deprecated) M4sh interfaces.
AS_SHELL_SANITIZE is replaced with either AS_INIT or AS_INIT_GENERATED
(the latter also subsumes _AS_PREPARE), and the standard M4sh diversions
are used. AS_INIT_GENERATED is a new macro in Autoconf's latest git,
whose source we include in libtool.m4 if needed. (Actually we copy it
to _LT_INIT_GENERATED, with some hacks, to avoid problems with aclocal
pull libtool.m4 into every file).
* clcommit.m4sh: Do not unset CDPATH, use AS_INIT and M4sh diversions.
* libltdl/config/mailnotify.m4sh: Likewise.
* libtoolize.m4sh: Likewise.
* tests/defs.m4sh: Likewise.
* tests/testsuite.at: Move AT_INIT invocation at the top.
* libltdl/m4/libtool.m4 (_LT_INIT_GENERATED): New.
(LT_OUTPUT): Use it.
* libltdl/config/general.m4sh (M4SH_IN_HEADER): New.
(progpath): Move setting before $0 could be clobbered.
* libltdl/config/ltmain.m4sh (M4SH_IN_HEADER): New.
---
clcommit.m4sh | 7 +----
libltdl/config/general.m4sh | 20 ++++++++++++------
libltdl/config/ltmain.m4sh | 4 +++
libltdl/config/mailnotify.m4sh | 7 +----
libltdl/m4/libtool.m4 | 43 ++++++++++++++++++++++++++++-----------
libtoolize.m4sh | 8 +-----
tests/defs.m4sh | 8 ++----
tests/testsuite.at | 5 ++-
8 files changed, 60 insertions(+), 42 deletions(-)
diff --git a/clcommit.m4sh b/clcommit.m4sh
index 0d3ba42..73719cc 100644
--- a/clcommit.m4sh
+++ b/clcommit.m4sh
@@ -1,5 +1,4 @@
-m4_define([_m4_divert(SCRIPT)], 100)
-m4_divert_push([SCRIPT])#!/bin/sh
+AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])dnl
# @configure_input@
# clcommit (GNU @PACKAGE@) version 2.0
@@ -80,9 +79,7 @@ test -f "libltdl/config/$MKSTAMP" &&
MKSTAMP="libltdl/config/$MKSTAMP"
PROGRAM=clcommit
-AS_SHELL_SANITIZE
-$as_unset CDPATH
-
+m4_divert_pop
m4_include([getopt.m4sh])
M4SH_VERBATIM([[
diff --git a/libltdl/config/general.m4sh b/libltdl/config/general.m4sh
index 53ff5ea..cde7354 100644
--- a/libltdl/config/general.m4sh
+++ b/libltdl/config/general.m4sh
@@ -30,6 +30,19 @@ or obtained by writing to the Free Software Foundation, Inc.,
m4_define([M4SH_VERBATIM], [$1])dnl
+m4_ifndef([M4SH_IN_HEADER],
+[m4_define([M4SH_IN_HEADER],
+[m4_divert_text([HEADER-COPYRIGHT], [$1])])])
+
+M4SH_IN_HEADER([dnl
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+])
+
M4SH_VERBATIM([[
: ${CP="cp -f"}
: ${ECHO="echo"}
@@ -87,13 +100,6 @@ func_dirname_and_basename ()
# Generated shell functions inserted here.
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
# The name of this program:
# In the unlikely event $progname began with a '-', it would play havoc with
# func_echo (imagine progname=-n), so we prepend ./ in that case:
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 696b6ab..5c7dd96 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -111,6 +111,10 @@ done
$lt_unset CDPATH
+dnl This script is generated by config.status, so we cannot put things
+dnl in the header.
+m4_define([M4SH_IN_HEADER], [$1])dnl
+
m4_include([getopt.m4sh])
M4SH_VERBATIM([[
diff --git a/libltdl/config/mailnotify.m4sh b/libltdl/config/mailnotify.m4sh
index 20d6b83..a95f201 100644
--- a/libltdl/config/mailnotify.m4sh
+++ b/libltdl/config/mailnotify.m4sh
@@ -1,5 +1,4 @@
-m4_define([_m4_divert(SCRIPT)], 100)
-m4_divert_push([SCRIPT])#!/bin/sh
+AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])dnl
# @configure_input@
# mailnotify (GNU @PACKAGE@) version 0.6
@@ -63,9 +62,7 @@ m4_divert_push([SCRIPT])#!/bin/sh
PROGRAM=mailnotify
-AS_SHELL_SANITIZE
-$as_unset CDPATH
-
+m4_divert_pop
m4_include([getopt.m4sh])
M4SH_VERBATIM([[
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index caf88b1..34fa517 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -553,6 +553,34 @@ esac
_LT_OUTPUT_LIBTOOL_INIT
])
+# AS_INIT_GENERATED(FILE, [COMMENT])
+# ----------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable. If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins. After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script. The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],[m4_define([_LT_INIT_GENERATED],[AS_INIT_GENERATED(@$)])],
+[m4_defun([_LT_INIT_GENERATED],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[as_write_fail=0
+cat >$1 <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || as_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $as_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_INIT_GENERATED
# LT_OUTPUT
# ---------
@@ -562,20 +590,11 @@ _LT_OUTPUT_LIBTOOL_INIT
AC_DEFUN([LT_OUTPUT],
[: ${CONFIG_LT=./config.lt}
AC_MSG_NOTICE([creating $CONFIG_LT])
-cat >"$CONFIG_LT" <<_LTEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate a libtool stub with the current configuration.
-
-lt_cl_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_LTEOF
+_LT_INIT_GENERATED(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
cat >>"$CONFIG_LT" <<\_LTEOF
-AS_SHELL_SANITIZE
-_AS_PREPARE
-
-exec AS_MESSAGE_FD>&1
+lt_cl_silent=false
exec AS_MESSAGE_LOG_FD>>config.log
{
echo
diff --git a/libtoolize.m4sh b/libtoolize.m4sh
index 5e7487e..15b4b94 100644
--- a/libtoolize.m4sh
+++ b/libtoolize.m4sh
@@ -1,7 +1,5 @@
m4_pattern_allow([dnl])
-m4_define([_m4_divert(SCRIPT)], 100)
-m4_divert_push([SCRIPT])dnl
-#! /bin/sh
+AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])dnl
# @configure_input@
# libtoolize (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
@@ -72,9 +70,7 @@ m4_divert_push([SCRIPT])dnl
PROGRAM=libtoolize
-AS_SHELL_SANITIZE
-$as_unset CDPATH
-
+m4_divert_pop
m4_include([getopt.m4sh])
M4SH_VERBATIM([[
diff --git a/tests/defs.m4sh b/tests/defs.m4sh
index c467818..48d1d37 100644
--- a/tests/defs.m4sh
+++ b/tests/defs.m4sh
@@ -1,5 +1,5 @@
-m4_define([_m4_divert(SCRIPT)], 100)
-m4_divert_push([SCRIPT])# @configure_input@
+AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])dnl
+# @configure_input@
# defs -- Defines for Libtool testing environment.
#
# Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software
@@ -26,9 +26,7 @@ m4_divert_push([SCRIPT])# @configure_input@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
####
-AS_SHELL_SANITIZE
-$as_unset CDPATH
-
+m4_divert_pop
m4_include([general.m4sh])
M4SH_VERBATIM([[
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 5037d14..d03b67d 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -23,6 +23,8 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
####
+AT_INIT
+
m4_divert_push([PREPARE_TESTS])dnl
: ${tst_dist=dist}
: ${ACLOCAL=aclocal}
@@ -369,5 +371,4 @@ dnl AT_TESTED([grep autoreconf autom4te automake])
## The suite. ##
## ----------- ##
-AT_INIT
-# The other tests will be appended here by the Makefile rule.
+# Tests will be appended here by the Makefile rule.
--
1.5.5
- [PATCH 3/6] use documented m4sh interfaces,
Paolo Bonzini <=