2006-08-04 Alexandre Duret-Lutz <adl@gnu.org>
+ * doc/automake.texi (Conditionals): Split in two sections, "Usage"
+ and "Portability", and add a third one, "Limits" to explain how
+ conditional definitions inside multi-lines definitions can be
+ handled.
+ * automake.in (handle_options): Do not assume that
+ AUTOMAKE_OPTIONS is defined in TRUE, but diagnose conditional
+ definitions of AUTOMAKE_OPTIONS.
+ Report from Bas Wijnen.
+ * tests/amopt.test: New test.
+ * tests/Makefile.am (TESTS): Add it.
+
* aclocal.in (install_file): Cannot use /dev/null while diffing
new files, because Tru64's diff do not handle /dev/null. So
create an empty destination file before running diff on a new
Art Haas ahaas@neosoft.com
Assar Westerlund assar@sics.se
Axel Belinfante Axel.Belinfante@cs.utwente.nl
+Bas Wijnen shevek@fmf.nl
Bernard Giroud bernard.giroud@creditlyonnais.ch
Bernard Urban Bernard.Urban@meteo.fr
Bernd Jendrissek berndfoobar@users.sourceforge.net
my $var = var ('AUTOMAKE_OPTIONS');
if ($var)
{
- # FIXME: We should disallow conditional definitions of AUTOMAKE_OPTIONS.
- if (process_option_list ($var->rdef (TRUE)->location,
- $var->value_as_list_recursive (cond_filter =>
- TRUE)))
+ if ($var->has_conditional_contents)
{
- return 1;
+ msg_var ('unsupported', $var,
+ "`AUTOMAKE_OPTIONS' cannot have conditional contents");
+ }
+ foreach my $locvals ($var->value_as_list_recursive (cond_filter => TRUE,
+ location => 1))
+ {
+ my ($loc, $value) = @$locvals;
+ return 1 if (process_option_list ($loc, $value))
}
}
Automake supports a simple type of conditionals.
+@unnumberedsec Usage
+
@acindex AM_CONDITIONAL
Before using a conditional, you must define it by using
@code{AM_CONDITIONAL} in the @file{configure.ac} file (@pxref{Macros}).
@noindent
Unbalanced conditions are errors.
+The @code{else} branch of the above two examples could be omitted,
+since assigning the empty string to an otherwise undefined variable
+makes no difference.
+
+@unnumberedsec Portability
+
Note that conditionals in Automake are not the same as conditionals in
GNU Make. Automake conditionals are checked at configure time by the
@file{configure} script, and affect the translation from
Automake conditionals will work with any make program.
+@unnumberedsec Limits
+
+Conditionals should enclose complete statements like variables or
+rules definitions. Automake cannot deal with conditionals used inside
+a variable definition, for instance, and is not even able to diagnose
+this situation. The following example would not work:
+
+@example
+# This syntax is not understood by Automake
+AM_CPPFLAGS = \
+ -DFEATURE_A \
+if WANT_DEBUG
+ -DDEBUG \
+endif
+ -DFEATURE_B
+@end example
+
+However the intended definition of @code{AM_CPPFLAGS} can be achieved
+with
+
+@example
+if WANT_DEBUG
+ DEBUGFLAGS = -DDEBUG
+endif
+AM_CPPFLAGS = -DFEATURE_A $(DEBUGFLAGS) -DFEATURE_B
+@end example
+
+@noindent or
+
+@example
+AM_CPPFLAGS = -DFEATURE_A
+if WANT_DEBUG
+AM_CPPFLAGS += -DDEBUG
+endif
+AM_CPPFLAGS += -DFEATURE_B
+@end example
@node Gnits
@chapter The effect of @option{--gnu} and @option{--gnits}
-@set UPDATED 6 June 2006
-@set UPDATED-MONTH June 2006
+@set UPDATED 4 August 2006
+@set UPDATED-MONTH August 2006
@set EDITION 1.9a
@set VERSION 1.9a
-@set UPDATED 6 June 2006
-@set UPDATED-MONTH June 2006
+@set UPDATED 4 August 2006
+@set UPDATED-MONTH August 2006
@set EDITION 1.9a
@set VERSION 1.9a
alpha2.test \
amassign.test \
ammissing.test \
+amopt.test \
amsubst.test \
ansi.test \
ansi2.test \
alpha2.test \
amassign.test \
ammissing.test \
+amopt.test \
amsubst.test \
ansi.test \
ansi2.test \
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Make Automake diagnose a conditional AUTOMAKE_OPTIONS.
+# Report from Bas Wijnen.
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<END
+AM_CONDITIONAL([COND], [true])
+END
+
+mkdir sub
+
+# These two Makefile contain the same errors, but have different
+# warnings disabled.
+
+cat >Makefile.am <<END
+if COND
+AUTOMAKE_OPTIONS = -Wall
+endif
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:2.*AUTOMAKE_OPTIONS.*conditional' stderr