From: Stefano Lattarini Date: Sat, 16 Jun 2012 08:30:07 +0000 (+0200) Subject: [ng] texi: reduce code duplication in output Makefile X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f351807567c390b0fe42631a92c809a4da5cfa01;p=thirdparty%2Fautomake.git [ng] texi: reduce code duplication in output Makefile No semantic change is intended. * lib/am/texibuild.am: Use a make-runtime $(foreach) loop to define the conversion rules for all the accepted Texinfo suffixes ('.txi', '.texi', '.texinfo'), with the help of ... (am__texi_rules_for_suffix): ... this new internal make function. * automake.in (handle_texinfo): Adjust. * t/txinfo6.sh: Adjust and extend. * t/txinfo-rules-once.sh: Remove as obsolete. Signed-off-by: Stefano Lattarini --- diff --git a/automake.in b/automake.in index 4ce80b170..244c12bcd 100644 --- a/automake.in +++ b/automake.in @@ -3179,18 +3179,16 @@ sub handle_texinfo () define_verbose_texinfo; # Keep this list in sync with the $infobase transform done # in &handle_texinfo_helper. - foreach my $valid_texinfo_suf (qw/texi texinfo txi/) - { - $output_verbatim .= preprocess_file ( - "$libdir/am/texibuild.am", - AM_V_MAKEINFO => verbose_flag('MAKEINFO'), - AM_V_TEXI2DVI => verbose_flag('TEXI2DVI'), - AM_V_TEXI2PDF => verbose_flag('TEXI2PDF'), - TEXIQUIET => verbose_flag('texinfo'), - TEXIDEVNULL => verbose_flag('texidevnull'), - 'TEXI-SUFFIX' => $valid_texinfo_suf - ); - } + my @valid_texinfo_suffixes = qw/texi texinfo txi/; + $output_verbatim .= preprocess_file ( + "$libdir/am/texibuild.am", + AM_V_MAKEINFO => verbose_flag('MAKEINFO'), + AM_V_TEXI2DVI => verbose_flag('TEXI2DVI'), + AM_V_TEXI2PDF => verbose_flag('TEXI2PDF'), + TEXIQUIET => verbose_flag('texinfo'), + TEXIDEVNULL => verbose_flag('texidevnull'), + 'TEXI-SUFFIXES' => "@valid_texinfo_suffixes", + ); ($mostlyclean, $clean, $maintclean) = handle_texinfo_helper ($info_texinfos); chomp $mostlyclean; chomp $clean; diff --git a/lib/am/texibuild.am b/lib/am/texibuild.am index a81bcf2ac..09905d5a2 100644 --- a/lib/am/texibuild.am +++ b/lib/am/texibuild.am @@ -89,14 +89,15 @@ define am__texibuild_html fi endef -%.info: %.%TEXI-SUFFIX% - $(call am__texibuild_info,$(am__info_insrc)) - -%.dvi: %.%TEXI-SUFFIX% - $(call am__texibuild_dvi_or_pdf,%AM_V_TEXI2DVI%,$(TEXI2DVI)) - -%.pdf: %.%TEXI-SUFFIX% - $(call am__texibuild_dvi_or_pdf,%AM_V_TEXI2PDF%,$(TEXI2PDF)) +define am__texi_rules_for_suffix +%.info: %.$1 + $$(call am__texibuild_info,$$(am__info_insrc)) +%.dvi: %.$1 + $$(call am__texibuild_dvi_or_pdf,$$(AM_V_TEXI2DVI),$$(TEXI2DVI)) +%.pdf: %.$1 + $$(call am__texibuild_dvi_or_pdf,$$(AM_V_TEXI2PDF),$$(TEXI2PDF)) +%.html: %.$1 + $$(am__texibuild_html) +endef -%.html: %.%TEXI-SUFFIX% - $(am__texibuild_html) +$(foreach s,%TEXI-SUFFIXES%,$(eval $(call am__texi_rules_for_suffix,$s))) diff --git a/t/txinfo-rules-once.sh b/t/txinfo-rules-once.sh deleted file mode 100755 index d15ecbcb6..000000000 --- a/t/txinfo-rules-once.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/sh -# Copyright (C) 2003-2012 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 -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program 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 this program. If not, see . - -# Some grepping checks on Texinfo support. - -. ./defs || Exit 1 - -echo AC_OUTPUT >> configure.ac - -$ACLOCAL - -: > texinfo.tex - -echo info_TEXINFOS = main.texi other.texi sub/x.texi > Makefile.am -mkdir sub -echo @setfilename main.info > main.texi -echo @setfilename other.info > other.texi -echo @setfilename sub/x.info > sub/x.texi -$AUTOMAKE -$EGREP '\.(info|texi)' Makefile.in # For debugging. -test $(grep -c '^%\.info: %\.texi$' Makefile.in) -eq 1 - -: diff --git a/t/txinfo6.sh b/t/txinfo6.sh index b13c51f86..05997b156 100755 --- a/t/txinfo6.sh +++ b/t/txinfo6.sh @@ -14,20 +14,30 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test to make sure '.txi' extension works. +# Make sure '.txi' and '.texinfo' are accepted Texinfo extensions. . ./defs || Exit 1 -cat > Makefile.am << 'END' -info_TEXINFOS = foo.txi -END +echo AC_OUTPUT >> configure.ac +echo info_TEXINFOS = foo.txi doc/bar.texinfo > Makefile.am +mkdir doc echo '@setfilename foo.info' > foo.txi +echo '@setfilename bar.info' > doc/bar.texinfo : > texinfo.tex $ACLOCAL +$AUTOCONF $AUTOMAKE -grep '^%\.info: %\.txi$' Makefile.in +./configure + +for fmt in info pdf dvi html; do + $MAKE -n "$fmt" > stdout || { cat stdout; Exit 1; } + cat stdout + for basename in foo doc/bar; do + grep "[/ $tab]$basename\\.$fmt[; $tab]" stdout + done +done :