automake-patches
[Top][All Lists]
Advanced

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

FYI: Cleaning up the Texinfo handling


From: Akim Demaille
Subject: FYI: Cleaning up the Texinfo handling
Date: Sun, 6 Jul 2003 09:43:56 +0200 (CEST)

The Texinfo handling is _very_ hairy.  And browsing it revealed several
minors issues that should be decided (where do you put .PHONY for a
target? A std place would help not forgetting some as was the case
currently).  The -recursive/-am handling also needs some factoring.
And also, there are still too many things that ought to be under the
responsibility of a "module" (with texinfo being a "module"), instead
of globally hard coded knowledge (dvi-am, dvi etc. being a %dependencies).

Also, you will see below that some targets are removed from the .PHONY
rules: that's because there are already part of the $(RECURSIVE_TARGETS)
that are already .PHONY.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * automake.in (&define_files_variable): New.
        (&handle_texinfo_helper): Move the handling of user variables from
        here, to...
        (&handle_texinfo): here.
        This is to balance the size of these functions, and to match the
        convention of other _helper functions.
        (&handle_texinfo_helper): Use &define_files_variable.
        Move some code to use less variables.
        Rename $info_cursor as $texi.
        (&handle_texinfo): Do not call handle_texinfo_helper if there are
        no TEXINFOS.
        * lib/am/texinfos.am: Sort the occurrences of dvi, info, pdf, ps
        and html.
        Remove *-recursive targets from .PHONY, they are part of
        $(RECURSIVE_TARGETS) anyway.
        (install-info, mostlyclean-aminfo): Are .PHONY.

Index: Makefile.in
===================================================================
RCS file: /cvs/automake/automake/Makefile.in,v
retrieving revision 1.439
diff -u -u -r1.439 Makefile.in
--- Makefile.in 5 Jul 2003 08:23:17 -0000       1.439
+++ Makefile.in 6 Jul 2003 07:41:25 -0000
@@ -67,8 +67,8 @@
 TEXI2DVI = texi2dvi
 TEXI2PDF = $(TEXI2DVI) --pdf --batch
 DVIPS = dvips
-RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
-       ps-recursive html-recursive install-info-recursive \
+RECURSIVE_TARGETS = dvi-recursive html-recursive info-recursive \
+       pdf-recursive ps-recursive install-info-recursive \
        uninstall-info-recursive all-recursive install-data-recursive \
        install-exec-recursive installdirs-recursive install-recursive \
        uninstall-recursive check-recursive installcheck-recursive
@@ -723,19 +723,17 @@
        ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-info \
        dist-shar dist-tarZ dist-zip distcheck distclean \
        distclean-generic distclean-recursive distclean-tags \
-       distcleancheck distdir distuninstallcheck dvi dvi-am \
-       dvi-recursive html html-am html-recursive info info-am \
-       info-recursive install install-am install-binSCRIPTS \
+       distcleancheck distdir distuninstallcheck dvi dvi-am html \
+       html-am info info-am install install-am install-binSCRIPTS \
        install-data install-data-am install-data-recursive \
        install-exec install-exec-am install-exec-recursive \
-       install-info install-info-am install-info-recursive \
-       install-man install-recursive install-strip installcheck \
-       installcheck-am installdirs installdirs-am \
-       installdirs-recursive maintainer-clean maintainer-clean-aminfo \
-       maintainer-clean-generic maintainer-clean-recursive \
-       maintainer-clean-vti mostlyclean mostlyclean-aminfo \
-       mostlyclean-generic mostlyclean-recursive mostlyclean-vti pdf \
-       pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \
+       install-info install-info-am install-man install-recursive \
+       install-strip installcheck installcheck-am installdirs \
+       installdirs-am installdirs-recursive maintainer-clean \
+       maintainer-clean-aminfo maintainer-clean-generic \
+       maintainer-clean-recursive maintainer-clean-vti mostlyclean \
+       mostlyclean-aminfo mostlyclean-generic mostlyclean-recursive \
+       mostlyclean-vti pdf pdf-am ps ps-am tags tags-recursive \
        uninstall uninstall-am uninstall-binSCRIPTS uninstall-info-am \
        uninstall-info-recursive uninstall-recursive

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1476
diff -u -u -r1.1476 automake.in
--- automake.in 4 Jul 2003 08:36:53 -0000       1.1476
+++ automake.in 6 Jul 2003 07:41:26 -0000
@@ -671,6 +671,7 @@
 ## --------------------------------- ##
 sub register_language (%);
 sub file_contents_internal ($$$%);
+sub define_files_variable (address@hidden);


 # &initialize_per_input ()
@@ -3016,7 +3017,7 @@
   # included files.  We can't scan included files because we don't
   # know the include path.  Therefore we always erase these files, no
   # matter whether they are used or not.
-  #
+  #
   # (tmp is only created if an @macro is used and a certain e-TeX
   # feature is not available.)
   my %clean_suffixes =
@@ -3108,7 +3109,7 @@
   # suffix rules and are appropritate when $source and $dest lie in
   # the current directory; the "specifix" rules is needed in the other
   # case.
-  #
+  #
   # The former are output only once (this is not really apparent here,
   # but just remember that some logic deeper in Automake will not
   # output the same rule twice); while the later need to be output for
@@ -3130,11 +3131,11 @@
   # We cannot use a suffix rule to build info files with an empty
   # extension.  Otherwise we would output a single suffix inference
   # rule, with separate dependencies, as in
-  #
+  #
   #    .texi:
-  #             $(MAKEINFO) ...
+  #             $(MAKEINFO) ...
   #    foo.info: foo.texi
-  #
+  #
   # which confuse Solaris make.  (See the Autoconf manual for
   # details.)  Therefore we use a specific rule in this case.  This
   # applies to info files only (dvi and pdf files always have an
@@ -3163,43 +3164,36 @@
 }


-# ($DO-SOMETHING, $TEXICLEANS)
-# handle_texinfo_helper ()
-# ------------------------
-# Handle all Texinfo source; helper for handle_texinfo
-sub handle_texinfo_helper ()
+# $TEXICLEANS
+# handle_texinfo_helper ($info_texinfos)
+# --------------------------------------
+# Handle all Texinfo source; helper for handle_texinfo.
+sub handle_texinfo_helper ($)
 {
-  reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use
`info_TEXINFOS'";
-  reject_var 'html_TEXINFOS', "HTML generation not yet supported";
-
-  my $info_texinfos = var ('info_TEXINFOS');
-  return (0, '') unless $info_texinfos;
-
-  my @texis = $info_texinfos->value_as_list_recursive ('all');
-
-  my (@info_deps_list, @texi_deps);
-  my (@dvis_list, @pdfs_list, @pss_list, @htmls_list);
+  my ($info_texinfos) = @_;
+  my (@infobase, @info_deps_list, @texi_deps);
   my %versions;
   my $done = 0;
   my @texi_cleans;
-  my $canonical;

-  foreach my $info_cursor (@texis)
+  foreach my $texi ($info_texinfos->value_as_list_recursive ('all'))
     {
-      my $infobase = $info_cursor;
+      my $infobase = $texi;
       $infobase =~ s/\.(txi|texinfo|texi)$//;

-      if ($infobase eq $info_cursor)
+      if ($infobase eq $texi)
        {
          # FIXME: report line number.
-         err_am "texinfo file `$info_cursor' has unrecognized extension";
+         err_am "texinfo file `$texi' has unrecognized extension";
          next;
        }

+      push @infobase, $infobase;
+
       # If 'version.texi' is referenced by input file, then include
       # automatic versioning capability.
       my ($out_file, $vtexi, @clean_files) =
-       scan_texinfo_file ("$relative_dir/$info_cursor")
+       scan_texinfo_file ("$relative_dir/$texi")
        or next;
       push (@texi_cleans, @clean_files);

@@ -3207,7 +3201,7 @@
       # resulting info in this subdirectory.  If it is in the current
       # directory, try hard to not prefix "./" because it breaks the
       # generic rules.
-      my $outdir = dirname ($info_cursor) . '/';
+      my $outdir = dirname ($texi) . '/';
       $outdir = "" if $outdir eq './';
       $out_file =  $outdir . $out_file;

@@ -3224,22 +3218,18 @@
        }

       my ($dirstamp, @cfiles) =
-       output_texinfo_build_rules ($info_cursor, $out_file, @texi_deps);
+       output_texinfo_build_rules ($texi, $out_file, @texi_deps);
       push (@texi_cleans, @cfiles);

       push (@info_deps_list, $out_file);
-      push (@dvis_list, $infobase . '.dvi');
-      push (@pdfs_list, $infobase . '.pdf');
-      push (@pss_list, $infobase . '.ps');
-      push (@htmls_list, $infobase . '.html');

       # If a vers*.texi file is needed, emit the rule.
       if ($vtexi)
        {
-         err_am ("`$vtexi', included in `$info_cursor', "
+         err_am ("`$vtexi', included in `$texi', "
                  . "also included in `$versions{$vtexi}'")
            if defined $versions{$vtexi};
-         $versions{$vtexi} = $info_cursor;
+         $versions{$vtexi} = $texi;

          # We number the stamp-vti files.  This is doable since the
          # actual names don't matter much.  We only number starting
@@ -3271,7 +3261,7 @@
            }
          $output_rules .= file_contents ('texi-vers',
                                          new Automake::Location,
-                                         TEXI     => $info_cursor,
+                                         TEXI     => $texi,
                                          VTI      => $vti,
                                          STAMPVTI => "${outdir}stamp-$vti",
                                          VTEXI    => "$outdir$vtexi",
@@ -3308,9 +3298,6 @@
     }
   define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);

-  # The return value.
-  my $texiclean = makefile_wrap ("", "\t  ", @texi_cleans);
-
   push (@dist_targets, 'dist-info');

   if (! defined $options{'no-installinfo'})
@@ -3322,10 +3309,11 @@
     }

   define_variable ("INFO_DEPS", "@info_deps_list", INTERNAL);
-  define_variable ("DVIS", "@dvis_list", INTERNAL);
-  define_variable ("PDFS", "@pdfs_list", INTERNAL);
-  define_variable ("PSS", "@pss_list", INTERNAL);
-  define_variable ("HTMLS", "@htmls_list", INTERNAL);
+  define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL);
+  define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL);
+  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.
@@ -3348,7 +3336,7 @@
        }
     }

-  return (1, $texiclean);
+  return makefile_wrap ("", "\t  ", @texi_cleans);
 }


@@ -3357,11 +3345,20 @@
 # Handle all Texinfo source.
 sub handle_texinfo ()
 {
-  my ($do_something, $texiclean) = handle_texinfo_helper ();
+  reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use
`info_TEXINFOS'";
+  # FIXME: I think this is an obsolete future feature name.
+  reject_var 'html_TEXINFOS', "HTML generation not yet supported";
+
+  my $info_texinfos = var ('info_TEXINFOS');
+  my $texiclean = "";
+  if ($info_texinfos)
+    {
+      $texiclean = handle_texinfo_helper ($info_texinfos);
+    }
   $output_rules .=  file_contents ('texinfos',
                                   new Automake::Location,
-                                  TEXICLEAN => $texiclean,
-                                  'LOCAL-TEXIS' => $do_something);
+                                  TEXICLEAN     => $texiclean,
+                                  'LOCAL-TEXIS' => !!$info_texinfos);
 }


@@ -5548,6 +5545,19 @@
 {
     my ($var, $value, $where) = @_;
     define_pretty_variable ($var, TRUE, $where, $value);
+}
+
+
+# define_files_variable ($VAR, address@hidden, $EXTENSION, $WHERE)
+# -----------------------------------------------------------
+# Define the $VAR which content is the list of file names composed of
+# a @BASENAME and the $EXTENSION.
+sub define_files_variable (address@hidden)
+{
+  my ($var, $basename, $extension, $where) = @_;
+  define_variable ($var,
+                  join (' ', map { "$_.$extension" } @$basename),
+                  $where);
 }


Index: lib/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/lib/Makefile.in,v
retrieving revision 1.67
diff -u -u -r1.67 Makefile.in
--- lib/Makefile.in     25 Jun 2003 14:01:23 -0000      1.67
+++ lib/Makefile.in     6 Jul 2003 07:41:27 -0000
@@ -52,8 +52,8 @@
 CONFIG_CLEAN_FILES =
 SOURCES =
 DIST_SOURCES =
-RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
-       ps-recursive html-recursive install-info-recursive \
+RECURSIVE_TARGETS = dvi-recursive html-recursive info-recursive \
+       pdf-recursive ps-recursive install-info-recursive \
        uninstall-info-recursive all-recursive install-data-recursive \
        install-exec-recursive installdirs-recursive install-recursive \
        uninstall-recursive check-recursive installcheck-recursive
@@ -446,21 +446,18 @@
 .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
        clean clean-generic clean-recursive ctags ctags-recursive \
        distclean distclean-generic distclean-recursive distclean-tags \
-       distdir dvi dvi-am dvi-recursive html html-am html-recursive \
-       info info-am info-recursive install install-am install-data \
-       install-data-am install-data-recursive \
+       distdir dvi dvi-am html html-am info info-am install \
+       install-am install-data install-data-am install-data-recursive \
        install-dist_pkgvdataDATA install-dist_scriptDATA install-exec \
        install-exec-am install-exec-recursive install-info \
-       install-info-am install-info-recursive install-man \
-       install-recursive install-strip installcheck installcheck-am \
-       installcheck-local installdirs installdirs-am \
-       installdirs-recursive maintainer-clean \
+       install-info-am install-man install-recursive install-strip \
+       installcheck installcheck-am installcheck-local installdirs \
+       installdirs-am installdirs-recursive maintainer-clean \
        maintainer-clean-generic maintainer-clean-recursive \
        mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
-       pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \
-       uninstall uninstall-am uninstall-dist_pkgvdataDATA \
-       uninstall-dist_scriptDATA uninstall-info-am \
-       uninstall-info-recursive uninstall-recursive
+       pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+       uninstall-dist_pkgvdataDATA uninstall-dist_scriptDATA \
+       uninstall-info-am uninstall-info-recursive uninstall-recursive


 install-data-hook:
Index: lib/Automake/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/Makefile.in,v
retrieving revision 1.74
diff -u -u -r1.74 Makefile.in
--- lib/Automake/Makefile.in    25 Jun 2003 14:01:23 -0000      1.74
+++ lib/Automake/Makefile.in    6 Jul 2003 07:41:27 -0000
@@ -49,8 +49,8 @@
 CONFIG_CLEAN_FILES =
 SOURCES =
 DIST_SOURCES =
-RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
-       ps-recursive html-recursive install-info-recursive \
+RECURSIVE_TARGETS = dvi-recursive html-recursive info-recursive \
+       pdf-recursive ps-recursive install-info-recursive \
        uninstall-info-recursive all-recursive install-data-recursive \
        install-exec-recursive installdirs-recursive install-recursive \
        uninstall-recursive check-recursive installcheck-recursive
@@ -433,19 +433,18 @@
 .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
        clean clean-generic clean-recursive ctags ctags-recursive \
        distclean distclean-generic distclean-recursive distclean-tags \
-       distdir dvi dvi-am dvi-recursive html html-am html-recursive \
-       info info-am info-recursive install install-am install-data \
-       install-data-am install-data-recursive \
+       distdir dvi dvi-am html html-am info info-am install \
+       install-am install-data install-data-am install-data-recursive \
        install-dist_perllibDATA install-exec install-exec-am \
        install-exec-recursive install-info install-info-am \
-       install-info-recursive install-man install-recursive \
-       install-strip installcheck installcheck-am installdirs \
-       installdirs-am installdirs-recursive maintainer-clean \
+       install-man install-recursive install-strip installcheck \
+       installcheck-am installdirs installdirs-am \
+       installdirs-recursive maintainer-clean \
        maintainer-clean-generic maintainer-clean-recursive \
        mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
-       pdf-am pdf-recursive ps ps-am ps-recursive tags tags-recursive \
-       uninstall uninstall-am uninstall-dist_perllibDATA \
-       uninstall-info-am uninstall-info-recursive uninstall-recursive
+       pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+       uninstall-dist_perllibDATA uninstall-info-am \
+       uninstall-info-recursive uninstall-recursive

 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
Index: lib/am/texinfos.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/texinfos.am,v
retrieving revision 1.103
diff -u -u -r1.103 texinfos.am
--- lib/am/texinfos.am  14 Apr 2003 19:59:30 -0000      1.103
+++ lib/am/texinfos.am  6 Jul 2003 07:41:27 -0000
@@ -58,35 +58,35 @@
        $(DVIPS) -o $@ $<
 endif %?LOCAL-TEXIS%

-.PHONY: info info-am dvi dvi-am pdf pdf-am html html-am
+.PHONY: dvi dvi-am html html-am info info-am pdf pdf-am ps ps-am
 if %?SUBDIRS%
-RECURSIVE_TARGETS += info-recursive dvi-recursive pdf-recursive ps-recursive
-RECURSIVE_TARGETS += html-recursive
-.PHONY info: info-recursive
-.PHONY dvi: dvi-recursive
-.PHONY pdf: pdf-recursive
-.PHONY ps: ps-recursive
-.PHONY html: html-recursive
+RECURSIVE_TARGETS += dvi-recursive html-recursive info-recursive
+RECURSIVE_TARGETS += pdf-recursive ps-recursive
+dvi: dvi-recursive
+html: html-recursive
+info: info-recursive
+pdf: pdf-recursive
+ps: ps-recursive
 else !%?SUBDIRS%
-info: info-am
 dvi: dvi-am
+html: html-am
+info: info-am
 pdf: pdf-am
 ps: ps-am
-html: html-am
 endif !%?SUBDIRS%

 if %?LOCAL-TEXIS%
-info-am: $(INFO_DEPS)
 dvi-am: $(DVIS)
+html-am: $(HTMLS)
+info-am: $(INFO_DEPS)
 pdf-am: $(PDFS)
 ps-am: $(PSS)
-html-am: $(HTMLS)
 else ! %?LOCAL-TEXIS%
-info-am:
 dvi-am:
+html-am:
+info-am:
 pdf-am:
 ps-am:
-html-am:
 endif ! %?LOCAL-TEXIS%


@@ -108,16 +108,16 @@
 am__installdirs += $(DESTDIR)$(infodir)
 install-data-am: install-info-am
 endif %?LOCAL-TEXIS%
+.PHONY: install-info
 if %?SUBDIRS%
 RECURSIVE_TARGETS += install-info-recursive
-.PHONY install-info: install-info-recursive
+install-info: install-info-recursive
 else !%?SUBDIRS%
 install-info: install-info-am
 endif !%?SUBDIRS%
 endif %?INSTALL-INFO%

 .PHONY: install-info-am
-
 if %?LOCAL-TEXIS%
 install-info-am: $(INFO_DEPS)
        @$(NORMAL_INSTALL)
@@ -243,15 +243,14 @@
 ## `clean-info' is a target that users can use.

 if %?LOCAL-TEXIS%
+.PHONY mostlyclean-am: mostlyclean-aminfo
 .PHONY: mostlyclean-aminfo
-mostlyclean-am: mostlyclean-aminfo
 mostlyclean-aminfo:
 ## Use `-rf', not just `-f', because %TEXICLEAN% also contains
 ## any directory created by `makeinfo --html'.
        -rm -rf %TEXICLEAN%

-.PHONY: maintainer-clean-aminfo
-maintainer-clean-am: maintainer-clean-aminfo
+.PHONY maintainer-clean-am: maintainer-clean-aminfo
 maintainer-clean-aminfo:
        @list='$(INFO_DEPS)'; for i in $$list; do \
 ## .iNN files are DJGPP-style info files.





reply via email to

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