md5, sha1, sha256, sha512: support older autoconf
authorEric Blake <eblake@redhat.com>
Mon, 6 Jan 2014 17:26:37 +0000 (10:26 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 6 Jan 2014 21:48:35 +0000 (14:48 -0700)
commitd18d1b8023822220bb8f0a079c7312a1adffdce0
treede3778ddd79a35167c16795720665e7a638f71ea
parent580240a85bd8ec3e8b2d2379badfc13d7fe1d8e7
md5, sha1, sha256, sha512: support older autoconf

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 diversion stack.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
m4/00gnulib.m4