Ok, here's the patch I sent a month ago together with new testcases. I also found a little opportunity for refactoring.
Paolo 2007-03-12 Paolo Bonzini <[EMAIL PROTECTED]> * automake.in (output_texinfo_build_rules): Add COND parameter. Emit INFO_DEPS and TEXINFOS. (handle_texinfo_helper): Remove references to dead variable info_deps_list. Collect conditions for info_texinfos files and pass it to output_texinfo_build_rules. Don't emit TEXINFOS. (append_pretty_variable): New. (push_dist_common): Use it. * automake.in (output_texinfo_build_rules): Add COND parameter. * lib/am/texibuild.am (INFODEPS): Don't emit it. * tests/Makefile.am (TESTS): Add condinfo.test. * tests/condinfo.test: New test. Index: NEWS =================================================================== RCS file: /sources/automake/automake/NEWS,v retrieving revision 1.323 diff -u -p -r1.323 NEWS --- NEWS 10 Jan 2007 17:57:24 -0000 1.323 +++ NEWS 12 Mar 2007 17:35:09 -0000 @@ -16,6 +16,11 @@ New in 1.10a: (and its time stamps) if the contents did not change. +Bugs fixed in 1.10.1: + +* Automake is now able to handle conditional info_TEXINFOS. + + New in 1.10: * Version requirements: Index: automake.in =================================================================== RCS file: /sources/automake/automake/automake.in,v retrieving revision 1.1641 diff -u -p -r1.1641 automake.in --- automake.in 16 Oct 2006 05:24:17 -0000 1.1641 +++ automake.in 12 Mar 2007 17:35:10 -0000 @@ -7,7 +7,7 @@ eval 'case $# in 0) exec @PERL@ -S "$0"; # automake - create Makefile.in from Makefile.am # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -2960,15 +2960,16 @@ sub scan_texinfo_file ($) # ($DIRSTAMP, @CLEAN_FILES) -# output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, @DEPENDENCIES) -# ------------------------------------------------------------------ +# output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, $COND, @DEPENDENCIES) +# ------------------------------------------------------------------------- # SOURCE - the source Texinfo file # DEST - the destination Info file -# INSRC - wether DEST should be built in the source tree +# INSRC - whether DEST should be built in the source tree +# COND - the condition under which DEST should be built # DEPENDENCIES - known dependencies -sub output_texinfo_build_rules ($$$@) +sub output_texinfo_build_rules ($$$$@) { - my ($source, $dest, $insrc, @deps) = @_; + my ($source, $dest, $insrc, $cond, @deps) = @_; # Split `a.texi' into `a' and `.texi'. my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/); @@ -3029,6 +3030,13 @@ sub output_texinfo_build_rules ($$$@) my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx; + append_pretty_variable ('INFO_DEPS', $cond, INTERNAL, "$dipfx$dsfx"); + + # This next line isn't strictly needed now -- the places that look here + # could easily be changed to look in info_TEXINFOS. But this is + # probably better, in case html_TEXINFOS is ever supported. + append_pretty_variable ('TEXINFOS', $cond, INTERNAL, $source); + $output_rules .= file_contents ('texibuild', new Automake::Location, DEPS => "@deps", @@ -3058,7 +3066,7 @@ sub output_texinfo_build_rules ($$$@) sub handle_texinfo_helper ($) { my ($info_texinfos) = @_; - my (@infobase, @info_deps_list, @texi_deps); + my (@infobase, @texi_deps); my %versions; my $done = 0; my @texi_cleans; @@ -3072,6 +3080,19 @@ sub handle_texinfo_helper ($) @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f; my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$'; + my %info_texinfos_conds; + + append_pretty_variable ('INFO_DEPS', TRUE, INTERNAL, ''); + append_pretty_variable ('TEXINFOS', TRUE, INTERNAL, ''); + + $info_texinfos->traverse_recursively + (sub { + my ($var, $val, $cond, $full_cond) = @_; + $info_texinfos_conds{$val} = $full_cond; + }, + undef, + inner_expand => 1); + foreach my $texi ($info_texinfos->value_as_list_recursive (inner_expand => 1)) { @@ -3219,11 +3240,10 @@ sub handle_texinfo_helper ($) } my ($dirstamp, @cfiles) = - output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps); + output_texinfo_build_rules ($texi, $out_file, $insrc, + $info_texinfos_conds{$texi}, @texi_deps); push (@texi_cleans, @cfiles); - push (@info_deps_list, $out_file); - # If a vers*.texi file is needed, emit the rule. if ($vtexi) { @@ -3241,8 +3261,8 @@ sub handle_texinfo_helper ($) # This is ugly, but it is our historical practice. if ($config_aux_dir_set_in_configure_ac) { - require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, - 'mdate-sh'); + require_conf_file_with_macro (TRUE, 'info_TEXINFOS', + FOREIGN, 'mdate-sh'); } else { @@ -3313,11 +3333,6 @@ sub handle_texinfo_helper ($) define_files_variable ("PSS", @infobase, 'ps', INTERNAL); define_files_variable ("HTMLS", @infobase, 'html', INTERNAL); - # This next isn't strictly needed now -- the places that look here - # could easily be changed to look in info_TEXINFOS. But this is - # probably better, in case noinst_TEXINFOS is ever supported. - define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL); - # Do some error checking. Note that this file is not required # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly # up above. @@ -3325,13 +3340,13 @@ sub handle_texinfo_helper ($) { if ($need_texi_file > 1) { - require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, - 'texinfo.tex'); + require_conf_file_with_macro (TRUE, 'info_TEXINFOS', + FOREIGN, 'texinfo.tex'); } else { - require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, - 'texinfo.tex'); + require_file_with_macro (TRUE, 'info_TEXINFOS', + FOREIGN, 'texinfo.tex'); } } @@ -5859,6 +5874,21 @@ sub cond_stack_endif ($$$) ## ------------------------ ## +# &append_pretty_variable ($VAR, $COND, $WHERE, @VALUE) +# ----------------------------------------------------- +# Like define_variable, but the value is a list, and the variable may +# be defined conditionally. The second argument is the Condition +# under which the value should be defined; this should be the empty +# string to define the variable unconditionally. The third argument +# is a list holding the values to use for the variable. The value is +# pretty printed in the output file. Can be invoked multiple times. +sub append_pretty_variable ($$$@) +{ + my ($var, $cond, $where, @value) = @_; + Automake::Variable::define ($var, VAR_AUTOMAKE, '+', $cond, "@value", + '', $where, VAR_PRETTY); +} + # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE) # ----------------------------------------------------- # Like define_variable, but the value is a list, and the variable may @@ -5879,7 +5909,6 @@ sub define_pretty_variable ($$$@) } } - # define_variable ($VAR, $VALUE, $WHERE) # -------------------------------------- # Define a new Automake Makefile variable VAR to VALUE, but only if @@ -7388,8 +7417,7 @@ sub push_dist_common { prog_error "push_dist_common run after handle_dist" if $handle_dist_run; - Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_", - '', INTERNAL, VAR_PRETTY); + append_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @_); } Index: doc/Makefile.in =================================================================== RCS file: /sources/automake/automake/doc/Makefile.in,v retrieving revision 1.65 diff -u -p -r1.65 Makefile.in --- doc/Makefile.in 12 Nov 2006 18:02:41 -0000 1.65 +++ doc/Makefile.in 12 Mar 2007 17:35:10 -0000 @@ -53,13 +53,13 @@ CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = INFO_DEPS = $(srcdir)/automake.info +TEXINFOS = automake.texi TEXINFO_TEX = $(top_srcdir)/lib/texinfo.tex am__TEXINFO_TEX_DIR = $(top_srcdir)/lib DVIS = automake.dvi PDFS = automake.pdf PSS = automake.ps HTMLS = automake.html -TEXINFOS = automake.texi TEXI2DVI = texi2dvi TEXI2PDF = $(TEXI2DVI) --pdf --batch MAKEINFOHTML = $(MAKEINFO) --html Index: lib/am/texibuild.am =================================================================== RCS file: /sources/automake/automake/lib/am/texibuild.am,v retrieving revision 1.27 diff -u -p -r1.27 texibuild.am --- lib/am/texibuild.am 7 Aug 2005 08:30:30 -0000 1.27 +++ lib/am/texibuild.am 12 Mar 2007 17:35:10 -0000 @@ -60,8 +60,6 @@ fi; \ rm -rf $$backupdir; exit $$rc -INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX% - ?GENERIC?%SOURCE_SUFFIX%.dvi: ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP% TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ Index: tests/Makefile.am =================================================================== RCS file: /sources/automake/automake/tests/Makefile.am,v retrieving revision 1.617 diff -u -p -r1.617 Makefile.am --- tests/Makefile.am 16 Oct 2006 05:24:17 -0000 1.617 +++ tests/Makefile.am 12 Mar 2007 17:35:10 -0000 @@ -152,6 +152,7 @@ condd.test \ condhook.test \ condinc.test \ condinc2.test \ +condinfo.test \ condlib.test \ condman.test \ condman2.test \ Index: tests/Makefile.in =================================================================== RCS file: /sources/automake/automake/tests/Makefile.in,v retrieving revision 1.805 diff -u -p -r1.805 Makefile.in --- tests/Makefile.in 16 Oct 2006 05:24:17 -0000 1.805 +++ tests/Makefile.in 12 Mar 2007 17:35:10 -0000 @@ -285,6 +285,7 @@ condd.test \ condhook.test \ condinc.test \ condinc2.test \ +condinfo.test \ condlib.test \ condman.test \ condman2.test \ Index: tests/condinfo.test =================================================================== RCS file: tests/condinfo.test diff -N tests/condinfo.test --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/condinfo.test 12 Mar 2007 17:35:10 -0000 @@ -0,0 +1,79 @@ +#! /bin/sh +# Copyright (C) 2007 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. + +# Test conditional info_TEXINFOS. +. ./defs || exit 1 + +cat > configure.in << 'END' +AC_INIT(Makefile.am) +AM_INIT_AUTOMAKE(foo,0.0) +AC_PROG_CC +AM_CONDITIONAL(NO,[test x = y]) +AM_CONDITIONAL(YES,[test x = x]) +MAKEINFO=makeinfo +AC_SUBST(MAKEINFO) +AC_OUTPUT(Makefile) +END + +cat > Makefile.am << 'END' +info_TEXINFOS = +if YES +info_TEXINFOS += baz.texi +endif +if NO +info_TEXINFOS += foo.texi +endif +if YES +info_TEXINFOS += bar.texi +endif +if NO +info_TEXINFOS += absent.texi +endif +END + +echo @setfilename foo.info > foo.texi +echo This should not be generated. >> foo.texi + +echo @setfilename bar.info > bar.texi +echo This should be generated. >> bar.texi + +echo @setfilename baz.info > baz.texi +echo This should also be generated. >> baz.texi + +echo @setfilename absent.info > absent.texi +echo This will be removed. >> absent.texi + +: > texinfo.tex + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure +$MAKE + +rm absent.texi + +$MAKE info +if test -f foo.info; then exit 1; else :; fi +test -f bar.info && rm -f bar.info +test -f baz.info && rm -f baz.info + +$MAKE bar.info +$MAKE baz.info