bug-gnulib
[Top][All Lists]
Advanced

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

[PATCHv2] md5, sha1, sha256, sha512: support older autoconf


From: Eric Blake
Subject: [PATCHv2] md5, sha1, sha256, sha512: support older autoconf
Date: Mon, 6 Jan 2014 14:22:46 -0700

On RHEL 6 (using autoconf 2.63), './gnulib-tool --test crypto/md5'
fails with this, ever since commit 3386f398:

executing aclocal -I glm4
glm4/gl-openssl.m4:11: error: m4_defn: undefined macro: _m4_divert_diversion
glm4/gl-openssl.m4:11: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1

Autoconf 2.63b introduced some bug fixes to m4_divert*, including
the ability to use the diversion stack prior to calling m4_init;
and aclocal happens to be a use of autom4te where m4_init was
not invoked prior to the expansion of gl_CRYPTO_CHECK.  The fix
is to copy the trick used in newer autoconf - wrap the entire
execution of autom4te inside one more layer of diversion stack,
where _m4_divert_diversion being defined serves as a nice witness
of whether we are already wrapped.  This workaround has to live
in 00gnulib.m4 in order to come prior to any other m4 file that
might be included by virtue of gnulib.

Then, with my first attempt applied, I still got failures on
RHEL 5 (using autoconf 2.59); it turns out that without the
guaranteed-FIFO behavior of m4_wrap added in 2.62 and newer,
places that _do_ use m4_init got confused if our wrapper pops
its state in an m4_wrap that happens in LIFO order.  It took
some experimenting to find a formula that guarantees we undo
the wrap at the correct moment before the m4_init warning
message can chew us out about an unabalanced divrsion stack.

* m4/00gnulib.m4 (m4_divert_push): Wrap diversion stack
on older autoconf.
Reported off-list by Pavel Hrdina.

Signed-off-by: Eric Blake <address@hidden>
---

Glad I tested on RHEL 5 before pushing v1; v2 looks even
crazier.  Don't worry if you don't understand the black magic
going on in autoconf diversions (I guess that's what I get
for being the Autoconf maintainer that originally cleaned up
the m4_wrap/divert mess for 2.62 and 2.63; never realizing
it would come back to haunt me several years later :)

 ChangeLog      |  4 ++++
 m4/00gnulib.m4 | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 805dc53..ff71c97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2014-01-06  Eric Blake  <address@hidden>

+       md5, sha1, sha256, sha512: support older autoconf
+       * m4/00gnulib.m4 (m4_divert_push): Wrap diversion stack
+       for autoconf < 2.63b.
+
        include_next: port to autoconf 2.63
        * m4/gnulib-common.m4 (AS_VAR_COPY): Define if missing.

diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
index b494772..8eca551 100644
--- a/m4/00gnulib.m4
+++ b/m4/00gnulib.m4
@@ -1,4 +1,4 @@
-# 00gnulib.m4 serial 2
+# 00gnulib.m4 serial 3
 dnl Copyright (C) 2009-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,7 +6,23 @@ dnl with or without modifications, as long as this notice is 
preserved.

 dnl This file must be named something that sorts before all other
 dnl gnulib-provided .m4 files.  It is needed until such time as we can
-dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics.
+dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE and
+dnl m4_divert semantics.
+
+# Until autoconf 2.63, handling of the diversion stack required m4_init
+# to be called first; but this does not happen with aclocal.  Wrapping
+# the entire execution in another layer of the diversion stack fixes this.
+# Worse, prior to autoconf 2.62, m4_wrap depended on the underlying m4
+# for whether it was FIFO or LIFO; in order to properly balance with
+# m4_init, we need to undo our push just before anything wrapped within
+# the m4_init body.  The way to ensure this is to wrap both sides of
+# m4_init with a one-shot macro that does the pop at the right time.
+m4_ifndef([_m4_divert_diversion],
+[m4_divert_push([KILL])
+m4_define([gl_divert_fixup], [m4_divert_pop()m4_define([$0])])
+m4_define([m4_init],
+  [gl_divert_fixup()]m4_defn([m4_init])[gl_divert_fixup()])])
+

 # AC_DEFUN_ONCE([NAME], VALUE)
 # ----------------------------
-- 
1.8.4.2




reply via email to

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