bug-automake
[Top][All Lists]
Advanced

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

bug#8718: error when using nested conditionals


From: Bruno Haible
Subject: bug#8718: error when using nested conditionals
Date: Mon, 23 May 2011 00:30:41 +0200
User-agent: KMail/1.9.9

Hi,

When a Makefile.am has nested conditionals, then when an inner conditional is
not defined _and_ not needed (because it's in an unused part of the
Makefile.am), then 'configure' nevertheless emits a fatal error.

This causes major problems for the new 'conditional-dependencies' mode of
gnulib-tool.

How to reproduce:

In an empty directory, create these files and then run the following commands.
================================ configure.ac =================================
AC_INIT([dummy], [0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_PROG_RANLIB
if test 4 = 5; then
  use_foo=true
  gl_FOO
else
  use_foo=false
fi
AM_CONDITIONAL([USE_FOO], [$use_foo])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
=================================== foo.m4 ====================================
AC_DEFUN([gl_FOO],
[
  if test 7 = 7; then
    use_variant_a=true
  else
    use_variant_a=false
  fi
  AM_CONDITIONAL([USE_VARIANT_A], [$use_variant_a])
])
================================= Makefile.am =================================
ACLOCAL_AMFLAGS = -I .
noinst_LIBRARIES = libgnu.a
libgnu_a_SOURCES = bar.c
if USE_FOO
include foo.mk
else
libgnu_a_SOURCES += gazonk.c
endif
=================================== foo.mk ====================================
if USE_VARIANT_A
libgnu_a_SOURCES += foo_a.c
else
libgnu_a_SOURCES += foo_b.c
endif
===============================================================================
$ touch bar.c foo_a.c foo_b.c gazonk.c
$ aclocal -I .
$ automake -a -c
$ autoconf
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for ranlib... ranlib
configure: error: conditional "USE_VARIANT_A" was never defined.
Usually this means the macro was only invoked conditionally.

The value of USE_VARIANT_A is irrelevant, because it occurs in the "if USE_FOO"
part and USE_FOO evaluates to false.

I don't see how this error could be worked around in gnulib, because
  1) it is a fatal error.
  2) What I would need is to extract all AM_CONDITIONALs from foo.m4
     and execute them with 'false' or 'true' values (doesn't matter which)
     before executing the code

       if test 4 = 5; then
         use_foo=true
         gl_FOO
       else
         use_foo=false
       fi

     But because the files { foo.m4, foo.mk, foo_a.c, foo_b.c } should be
     considered as a unit, and there's no way to execute _just_ the
     AM_CONDITIONALs inside gl_FOO and not the other statements, I'm
     blocked.

I do agree that it can be a useful behaviour of Automake to check that
all conditional have values, not only those that are really used. But it
should better a warning, rather than an error, and there should be a way
to turn it off.

Bruno
-- 
In memoriam Richard Friedmann <http://de.wikipedia.org/wiki/Richard_Friedmann>





reply via email to

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