Hi Paul,
> * There seem to be similar issues with modules/fnmatch's
> "gl_CONDITIONAL_HEADER([fnmatch.h])" duplicating fnmatch-h,
> modules/glob's "gl_CONDITIONAL_HEADER([glob.h])" duplicating glob-h, and
> modules/iconv_open's "gl_CONDITIONAL_HEADER([iconv.h])".
Yes, there are in total 4 occurrences (currently) of this idiom:
modules/fnmatch:gl_CONDITIONAL_HEADER([fnmatch.h])
modules/glob:gl_CONDITIONAL_HEADER([glob.h])
modules/iconv_open:gl_CONDITIONAL_HEADER([iconv.h])
modules/stdint:gl_CONDITIONAL_HEADER([limits.h])
> I worked around the problem by installing the attached patch.
The patch is not right. If we have, in this order,
1. an invocation of gl_LIMITS_H that happens to set
GL_GENERATE_LIMITS_H to false,
2. an invocation of gl_CONDITIONAL_HEADER([limits.h]) from the
'limits' module,
3. an invocation of gl_REPLACE_LIMITS_H, from the 'stdint'
module,
the Automake invocation will substitute variables
GL_GENERATE_LIMITS_H_TRUE and GL_GENERATE_LIMITS_H_FALSE that
have been computed from step 1, not from step 3.
> this resulted in 'configure' failing with the diagnostic "***
> GL_GENERATE_LIMITS_H is not set correctly".
Oops; this is unexpected.
> I tried using the latest Gnulib with Emacs and ran into a problem.
Unfortunately, you didn't tell how to reproduce it. In a current emacs git
checkout, I ran
$ admin/merge-gnulib $GNULIB_SRCDIR
$ grep GL_GENERATE_LIMITS_H configure
GL_GENERATE_LIMITS_H
GL_GENERATE_LIMITS_H=false
GL_GENERATE_LIMITS_H=true
GL_GENERATE_LIMITS_H=true
case "$GL_GENERATE_LIMITS_H" in
*) echo "*** GL_GENERATE_LIMITS_H is not set correctly" 1>&2; exit 1 ;;
$GL_GENERATE_LIMITS_H && GL_GENERATE_LIMITS_H=1 || GL_GENERATE_LIMITS_H=
case "$GL_GENERATE_LIMITS_H" in
*) echo "*** GL_GENERATE_LIMITS_H is not set correctly" 1>&2; exit 1 ;;
$GL_GENERATE_LIMITS_H && GL_GENERATE_LIMITS_H=1 || GL_GENERATE_LIMITS_H=
As you can see, there is
- one expansion of gl_LIMITS_H, that sets GL_GENERATE_LIMITS_H to
false or true.
- Then there is an expansion of gl_REPLACE_LIMITS_H, that sets it true always.
- Then come two copies of gl_CONDITIONAL_HEADER([limits.h]).
But what are the
'$GL_GENERATE_LIMITS_H && GL_GENERATE_LIMITS_H=1 || GL_GENERATE_LIMITS_H='
lines??
The macro gl_CONDITIONAL_HEADER is written in such a way that it can be
invoked twice. It is not exactly idemponent, because it needs to handle
the case that the first invocation is for the lib/ directory and the
second invocation is for the tests/ directory.
> The resulting 'configure' script executed two copies of the following code:
>
> case "$GL_GENERATE_STDINT_H" in
> false) STDINT_H='' ;;
> true)
> if test -z "$STDINT_H"; then
> STDINT_H="${gl_source_base_prefix}stdint.h"
> fi
> ;;
> *) echo "*** GL_GENERATE_STDINT_H is not set correctly" 1>&2; exit 1 ;;
> esac
This is harmless.
The error message (which I can't reproduce) occurs when
gl_CONDITIONAL_HEADER([limits.h]) comes before any of gl_LIMITS_H and
gl_REPLACE_LIMITS_H.
> $GL_GENERATE_STDINT_H && GL_GENERATE_STDINT_H=1 || GL_GENERATE_STDINT_H=
> * Should the shell script use a different variable name for the "1" vs
> "" value, than for the "true" vs "false" value? This might help avoid
> similar confusion in the future.
Where do these lines come from? They apparently arise from the
AM_CONDITIONAL invocation. But /usr/share/aclocal-1.16/cond.m4
produces different code for AM_CONDITIONAL than this one.
It comes from emacs' configure.ac !!!
AC_DEFUN([AM_CONDITIONAL],
[$2 && $1=1 || $1=
AC_SUBST([$1])])
The original AM_CONDITIONAL macro supports a condition that has the
same name as a shell variable, e.g.
AM_CONDITIONAL([FOO], [$FOO])
The emacs overridden one does not!
So, that is the problem.
There are two ways to fix this:
(A) Change Emacs AM_CONDITIONAL to support equal names.
(B) Change 27 Gnulib modules to use different names for the
conditional variable.
My preference (by far) is (A). Change emacs/configure.ac to use this:
AC_DEFUN([AM_CONDITIONAL],
[$2 && $1_CONDITION=1 || $1_CONDITION=
AC_SUBST([$1_CONDITION])])
and at the same time, change gnulib-tool through the attached patch.
Bruno
>From 51fd2f6aa67c9402720c683a318dc6ed8ae2daf9 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sat, 18 Dec 2021 14:52:18 +0100
Subject: [PATCH] stdint: Fix handling of limits.h (regression 2021-12-16).
* modules/stdint (configure.ac): Revert last change.
* gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
If --gnu-make is used, assume that AC_SUBSTed variables for conditionals
are constructed by appending the suffix '_CONDITION'.
---
ChangeLog | 8 ++++++++
gnulib-tool | 8 ++++----
modules/stdint | 2 ++
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 07fce5e48..45a4bac3b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-12-18 Bruno Haible <[email protected]>
+
+ stdint: Fix handling of limits.h (regression 2021-12-16).
+ * modules/stdint (configure.ac): Revert last change.
+ * gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
+ If --gnu-make is used, assume that AC_SUBSTed variables for conditionals
+ are constructed by appending the suffix '_CONDITION'.
+
2021-12-18 Bruno Haible <[email protected]>
Fix support for --gnu-make in tests (regression 2021-12-15).
diff --git a/gnulib-tool b/gnulib-tool
index d15c79513..0a0314e3c 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -3775,7 +3775,7 @@ func_emit_lib_Makefile_am ()
echo "## begin gnulib module $module"
if $gnu_make; then
echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
- convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1))/'
+ convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
convert_to_gnu_make_2='s|%reldir%/||g'
convert_to_gnu_make_3='s|%reldir%|.|g'
fi
@@ -3784,7 +3784,7 @@ func_emit_lib_Makefile_am ()
if func_cond_module_p "$module"; then
func_module_conditional_name "$module"
if $gnu_make; then
- echo "ifneq (,\$($conditional))"
+ echo "ifneq (,\$(${conditional}_CONDITION))"
else
echo "if $conditional"
fi
@@ -4156,7 +4156,7 @@ func_emit_tests_Makefile_am ()
{ echo "## begin gnulib module $module"
if $gnu_make; then
echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
- convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1))/'
+ convert_to_gnu_make_1='s/^if \(.*\)/ifneq (,$(\1_CONDITION))/'
convert_to_gnu_make_2='s|%reldir%/||g'
convert_to_gnu_make_3='s|%reldir%|.|g'
fi
@@ -4165,7 +4165,7 @@ func_emit_tests_Makefile_am ()
if func_cond_module_p "$module"; then
func_module_conditional_name "$module"
if $gnu_make; then
- echo "ifneq (,\$($conditional))"
+ echo "ifneq (,\$(${conditional}_CONDITION))"
else
echo "if $conditional"
fi
diff --git a/modules/stdint b/modules/stdint
index 3053a132e..bdec953df 100644
--- a/modules/stdint
+++ b/modules/stdint
@@ -21,6 +21,8 @@ sys_types
configure.ac:
gl_STDINT_H
gl_CONDITIONAL_HEADER([stdint.h])
+dnl Because of gl_REPLACE_LIMITS_H:
+gl_CONDITIONAL_HEADER([limits.h])
AC_PROG_MKDIR_P
Makefile.am:
--
2.25.1