bug-gnulib
[Top][All Lists]
Advanced

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

Remove influence of Automake conditionals on conditional dependencies


From: Bruno Haible
Subject: Remove influence of Automake conditionals on conditional dependencies
Date: Sun, 09 Jan 2022 15:39:34 +0100

gnulib-tool has a long-standing limitation: it disables conditional
dependencies processing when the module contains a reference to an
Automake conditional. This is due to an Automake problem: Automake
errs out at 'configure' time when it sees something that resembles
a nested Automake conditional.

This patch lifts the limitation. It makes proper use of nested
Automake conditionals.


2022-01-09  Bruno Haible  <bruno@clisp.org>

        Remove influence of Automake conditionals on conditional dependencies.
        * m4/gnulib-common.m4 (gl_CONDITIONAL): New macro.
        (gl_CONDITIONAL_HEADER): Use it instead of AM_CONDITIONAL.
        * m4/libgmp.m4 (gl_LIBGMP): Likewise.
        * modules/posix_spawn_file_actions_addfchdir-tests (configure.ac):
        Likewise.
        * modules/uchar-c++-tests (configure.ac): Likewise.
        * gnulib-tool (func_modules_transitive_closure): Don't inhibit
        conditional dependencies processing on a module that uses an Automake
        conditional.

diff --git a/gnulib-tool b/gnulib-tool
index 455d97d9e6..99854415ba 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -3114,17 +3114,6 @@ func_modules_transitive_closure ()
         if func_acceptable $module; then
           func_append outmodules " $module"
           if test "$cond_dependencies" = true; then
-            if ! $gnu_make \
-               && func_get_automake_snippet_conditional $module \
-                  | grep '^if ' > /dev/null; then
-              # A module whose Makefile.am snippet contains a reference to an
-              # automake conditional. If we were to use it conditionally, we
-              # would get an error
-              #   configure: error: conditional "..." was never defined.
-              # because automake 1.11.1 does not handle nested conditionals
-              # correctly. As a workaround, make the module unconditional.
-              func_uncond_add_module $module
-            fi
             if func_cond_module_p $module; then
               conditional=true
             else
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index afe0836083..bd7318aead 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -813,6 +813,24 @@ AC_DEFUN([gl_CACHE_VAL_SILENT],
   ])
 ])
 
+# gl_CONDITIONAL(conditional, condition)
+# is like AM_CONDITIONAL(conditional, condition), except that it does not
+# produce an error
+#   configure: error: conditional "..." was never defined.
+#   Usually this means the macro was only invoked conditionally.
+# when only invoked conditionally. Instead, in that case, both the _TRUE
+# and the _FALSE case are disabled.
+AC_DEFUN([gl_CONDITIONAL],
+[
+  pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
+  AM_CONDITIONAL([$1], [$2])
+  popdef([AC_CONFIG_COMMANDS_PRE])dnl
+  if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
+    [$1]_TRUE='#'
+    [$1]_FALSE='#'
+  fi
+])
+
 # gl_CC_ALLOW_WARNINGS
 # sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
 # that reverts a preceding '-Werror' option, if available.
@@ -969,7 +987,7 @@ AC_DEFUN([gl_CONDITIONAL_HEADER],
     *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
   esac
   AC_SUBST(gl_header_name)
-  AM_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
+  gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
   m4_popdef([gl_generate_cond])
   m4_popdef([gl_generate_var])
   m4_popdef([gl_header_name])
diff --git a/m4/libgmp.m4 b/m4/libgmp.m4
index a2dee93382..d69dcc7237 100644
--- a/m4/libgmp.m4
+++ b/m4/libgmp.m4
@@ -1,4 +1,4 @@
-# libgmp.m4 serial 6
+# libgmp.m4 serial 7
 # Configure the GMP library or a replacement.
 dnl Copyright 2020-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -63,8 +63,8 @@ AC_DEFUN([gl_LIBGMP],
   else
     GL_GENERATE_GMP_H=true
   fi
-  AM_CONDITIONAL([GL_GENERATE_MINI_GMP_H],
+  gl_CONDITIONAL([GL_GENERATE_MINI_GMP_H],
     [test $HAVE_LIBGMP != yes])
-  AM_CONDITIONAL([GL_GENERATE_GMP_GMP_H],
+  gl_CONDITIONAL([GL_GENERATE_GMP_GMP_H],
     [test $HAVE_LIBGMP = yes && test "$ac_cv_header_gmp_h" != yes])
 ])
diff --git a/modules/posix_spawn_file_actions_addfchdir-tests 
b/modules/posix_spawn_file_actions_addfchdir-tests
index 903a30f859..d32dbba2ae 100644
--- a/modules/posix_spawn_file_actions_addfchdir-tests
+++ b/modules/posix_spawn_file_actions_addfchdir-tests
@@ -20,7 +20,7 @@ AC_EGREP_CPP([notposix], [[
   ]],
   [posix_spawn_ported=no],
   [posix_spawn_ported=yes])
-AM_CONDITIONAL([POSIX_SPAWN_PORTED], [test $posix_spawn_ported = yes])
+gl_CONDITIONAL([POSIX_SPAWN_PORTED], [test $posix_spawn_ported = yes])
 
 Makefile.am:
 TESTS += test-posix_spawn_file_actions_addfchdir
diff --git a/modules/uchar-c++-tests b/modules/uchar-c++-tests
index 7ff4e1bf23..7e63bb9fce 100644
--- a/modules/uchar-c++-tests
+++ b/modules/uchar-c++-tests
@@ -29,7 +29,7 @@ if test "$CXX" != no; then
 else
   gl_cv_cxxheader_cuchar=no
 fi
-AM_CONDITIONAL([CXX_HAVE_CUCHAR], [test $gl_cv_cxxheader_cuchar != no])
+gl_CONDITIONAL([CXX_HAVE_CUCHAR], [test $gl_cv_cxxheader_cuchar != no])
 
 Makefile.am:
 if ANSICXX






reply via email to

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