From da119eb2417da977932dc8d9df1791343f3c62f3 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 4 Aug 2006 10:23:14 +0000 Subject: [PATCH] * 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. --- ChangeLog | 11 +++++++++++ THANKS | 1 + automake.in | 14 +++++++++----- doc/automake.texi | 44 ++++++++++++++++++++++++++++++++++++++++++++ doc/stamp-vti | 4 ++-- doc/version.texi | 4 ++-- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/amopt.test | 45 +++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 116 insertions(+), 9 deletions(-) create mode 100755 tests/amopt.test diff --git a/ChangeLog b/ChangeLog index 922599ab..a876db0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2006-08-04 Alexandre Duret-Lutz + * 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 diff --git a/THANKS b/THANKS index ced36a0a..ce57ebb4 100644 --- a/THANKS +++ b/THANKS @@ -23,6 +23,7 @@ Arkadiusz Miskiewicz misiek@pld.ORG.PL 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 diff --git a/automake.in b/automake.in index d011d9f9..5e1f967c 100755 --- a/automake.in +++ b/automake.in @@ -1055,12 +1055,16 @@ sub handle_options 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)) } } diff --git a/doc/automake.texi b/doc/automake.texi index 8d68c258..dd741cf6 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -7422,6 +7422,8 @@ they are needed to rebuild @file{Makefile.in}. 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}). @@ -7496,6 +7498,12 @@ endif !DEBUG @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 @@ -7507,6 +7515,42 @@ in the @file{Makefile}. 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} diff --git a/doc/stamp-vti b/doc/stamp-vti index fbc1f742..7e049f89 100644 --- a/doc/stamp-vti +++ b/doc/stamp-vti @@ -1,4 +1,4 @@ -@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 diff --git a/doc/version.texi b/doc/version.texi index fbc1f742..7e049f89 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@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 diff --git a/tests/Makefile.am b/tests/Makefile.am index 586e2379..92591380 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,6 +39,7 @@ alpha.test \ alpha2.test \ amassign.test \ ammissing.test \ +amopt.test \ amsubst.test \ ansi.test \ ansi2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 24de387d..bd43b5fd 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -170,6 +170,7 @@ alpha.test \ alpha2.test \ amassign.test \ ammissing.test \ +amopt.test \ amsubst.test \ ansi.test \ ansi2.test \ diff --git a/tests/amopt.test b/tests/amopt.test new file mode 100755 index 00000000..f7ffb122 --- /dev/null +++ b/tests/amopt.test @@ -0,0 +1,45 @@ +#! /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 <Makefile.am <