texi: info files can be generated in the builddir
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 3 Apr 2012 20:02:55 +0000 (22:02 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 1 Jan 2013 22:54:36 +0000 (23:54 +0100)
User can now ask info files to be built in the $(builddir), rather than
the $(srcdir), by specifying the Automake option 'info-in-builddir'.
This feature was requested by the developers of GCC, GDB, GNU binutils
and the GNU bfd library.  See the extensive discussion about automake
bug#11034 for more details.

OK, to be honest, having '.info' files built in the builddir was
*already* possible, but only using ugly and undocumented hacks involving
definition of the CLEANFILES and/or DISTCLEANFILES.  For example, the
binutils project did something like this in the relevant 'Makefile.am':

    # Automake 1.9 will only build info files in the objdir if they are
    # mentioned in DISTCLEANFILES.  It doesn't have to be unconditional,
    # though, so we use a bogus condition.
    if GENINSRC_NEVER
    DISTCLEANFILES = binutils.info
    endif

See also the extensive discussion about automake bug#11034; in
particular, the following messages:
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11034#65>
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11034#80>
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11034#86>
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11034#101>

* lib/Automake/Options.pm (_is_valid_easy_option): Recognize the
new 'info-in-builddir' option.
* automake.in (handle_texinfo_helper): If that option is set,
initialize '$insrc' to '0', so that info files will be generated
in the builddir.  Adjust comments to match.
* t/txinfo-builddir.sh: New test.
* t/list-of-tests.mk: Add it.
* NEWS: Update.
* doc/automake.texi: Document the new options.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
NEWS
automake.in
doc/automake.texi
lib/Automake/Options.pm
t/list-of-tests.mk
t/txinfo-builddir.sh [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index c5b6514..804805e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,15 @@ New in 1.13.2:
     should take precedence over the same-named automake-provided macro
     (defined in '/usr/local/share/aclocal-1.14/vala.m4').
 
+* Texinfo support:
+
+  - Automake can now be instructed to place '.info' files generated from
+    Texinfo input in the builddir rather than in the srcdir; this is done
+    specifying the new automake option 'info-in-builddir'.  This feature
+    was requested by the developers of GCC, GDB, GNU binutils and the GNU
+    bfd library.  See the extensive discussion about automake bug#11034
+    for more details.
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.13.1:
index 0764258..e56ea65 100644 (file)
@@ -3269,23 +3269,31 @@ sub handle_texinfo_helper ($)
       # have a single variable ($INSRC) that controls whether
       # the current .info file must be built in the source tree
       # or in the build tree.  Actually this variable is switched
-      # off for .info files that appear to be cleaned; this is
-      # for backward compatibility with package such as Texinfo,
-      # which do things like
-      #   info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
-      #   DISTCLEANFILES = texinfo texinfo-* info*.info*
-      #   # Do not create info files for distribution.
-      #   dist-info:
-      # in order not to distribute .info files.
-      my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1;
-
-      my $soutdir = '$(srcdir)/' . $outdir;
-      $outdir = $soutdir if $insrc;
+      # off in two cases:
+      #  (1) For '.info' files that appear to be cleaned; this is for
+      #      backward compatibility with package such as Texinfo,
+      #      which do things like
+      #        info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
+      #        DISTCLEANFILES = texinfo texinfo-* info*.info*
+      #        # Do not create info files for distribution.
+      #        dist-info:
+      #      in order not to distribute .info files.
+      #  (2) When the undocumented option 'info-in-builddir' is given.
+      #      This is done to allow the developers of GCC, GDB, GNU
+      #      binutils and the GNU bfd library to force the '.info' files
+      #      to be generated in the builddir rather than the srcdir, as
+      #      was once done when the (now removed) 'cygnus' option was
+      #      given.  See automake bug#11034 for more discussion.
+      my $insrc = 1;
+      $insrc = 0 if $out_file =~ $user_cleaned_files;
+      $insrc = 0 if option 'info-in-builddir';
+
+      $outdir = '$(srcdir)/' . $outdir if $insrc;
 
       # If user specified file_TEXINFOS, then use that as explicit
       # dependency list.
       @texi_deps = ();
-      push (@texi_deps, "$soutdir$vtexi") if $vtexi;
+      push (@texi_deps, "$outdir$vtexi") if $vtexi;
 
       my $canonical = canonicalize ($infobase);
       if (var ($canonical . "_TEXINFOS"))
@@ -3339,8 +3347,8 @@ sub handle_texinfo_helper ($)
                                          new Automake::Location,
                                          TEXI     => $texi,
                                          VTI      => $vti,
-                                         STAMPVTI => "${soutdir}stamp-$vti",
-                                         VTEXI    => "$soutdir$vtexi",
+                                         STAMPVTI => "${outdir}stamp-$vti",
+                                         VTEXI    => "$outdir$vtexi",
                                          MDDIR    => $conf_dir,
                                          DIRSTAMP => $dirstamp);
        }
index b4dad5c..443f65a 100644 (file)
@@ -7830,6 +7830,11 @@ install} (unless you use @option{no-installinfo}, see below).
 Furthermore, @file{.info} files are automatically distributed so that
 Texinfo is not a prerequisite for installing your package.
 
+It is worth noting that, contrary to what happens with the other formats,
+the generated @file{.info} files are by default placed in @code{srcdir}
+rather than in the @code{builddir}.  This can be changed with the
+@option{info-in-builddir} option.
+
 @trindex dvi
 @trindex html
 @trindex pdf
@@ -10069,6 +10074,14 @@ options below.  This option should be used in the top-level
 @file{configure.ac}, it will be ignored otherwise.  It will also be
 ignored in sub-packages of nested packages (@pxref{Subpackages}).
 
+@item @option{info-in-builddir}
+@cindex Option, @option{info-in-builddir}
+@opindex info-in-builddir
+Instruct Automake to place the generated @file{.info} files in the
+@code{builddir} rather than in the @code{srcdir}.  Note that this
+might make VPATH builds with some non-GNU make implementations more
+brittle.
+
 @item @option{no-define}
 @cindex Option, @option{no-define}
 @opindex no-define
index 3674920..3932798 100644 (file)
@@ -276,6 +276,7 @@ sub _is_valid_easy_option ($)
     dist-tarZ
     dist-xz
     dist-zip
+    info-in-builddir
     no-define
     no-dependencies
     no-dist
index 591b4f0..71487e9 100644 (file)
@@ -1162,6 +1162,7 @@ t/tests-environment-and-log-compiler.sh \
 t/txinfo-absolute-srcdir-pr408.sh \
 t/txinfo-add-missing-and-dist.sh \
 t/txinfo-bsd-make-recurs.sh \
+t/txinfo-builddir.sh \
 t/txinfo-clean.sh \
 t/txinfo-dvi-recurs.sh \
 t/txinfo-info-in-srcdir.sh \
diff --git a/t/txinfo-builddir.sh b/t/txinfo-builddir.sh
new file mode 100755 (executable)
index 0000000..148a1a6
--- /dev/null
@@ -0,0 +1,127 @@
+#! /bin/sh
+# Copyright (C) 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 <http://www.gnu.org/licenses/>.
+
+# Check that info files are built in builddir when needed.
+# This test that this can be done through the so far undocumented
+# option 'info-in-builddir', as requested by at least GCC, GDB,
+# GNU binutils and the GNU bfd library.  See automake bug#11034.
+
+required='makeinfo tex texi2dvi'
+. test-init.sh
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = info-in-builddir
+info_TEXINFOS = foo.texi subdir/bar.texi mu.texi
+subdir_bar_TEXINFOS = subdir/inc.texi
+CLEANFILES = mu.info
+
+# mu.info should not be rebuilt in the current directory, since
+# it's up-to-date in $(srcdir).
+# This can be caused by a subtle issue related to VPATH handling
+# of version.texi (see also the comment in texi-vers.am): because
+# stamp-vti is newer than version.texi, the 'version.texi: stamp-vti'
+# rule is always triggered.  Still that's not a reason for 'make'
+# to think 'version.texi' has been created...
+check-local:
+       test ! -e mu.info
+       test -f ../mu.info
+END
+
+mkdir subdir
+
+cat > foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@settitle foo
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+cat > mu.texi << 'END'
+\input texinfo
+@setfilename mu.info
+@settitle mu
+@node Top
+Mu mu mu.
+@bye
+END
+
+cat > subdir/bar.texi << 'END'
+\input texinfo
+@setfilename bar.info
+@settitle bar
+@node Top
+Hello walls.
+@include inc.texi
+@bye
+END
+
+echo "I'm included." > subdir/inc.texi
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE info
+test -f foo.info
+test -f subdir/bar.info
+test -f mu.info
+test -f stamp-vti
+test -f version.texi
+test ! -e ../foo.info
+test ! -e ../subdir/bar.info
+test ! -e ../mu.info
+test ! -e ../stamp-vti
+test ! -e ../version.texi
+$MAKE clean
+test -f foo.info
+test -f subdir/bar.info
+test ! -e mu.info
+test -f stamp-vti
+test -f version.texi
+
+# Make sure stamp-vti is older that version.texi.
+# (A common situation in a real tree).
+$sleep
+touch stamp-vti
+
+$MAKE distcheck
+# Being distributed, this file should have been rebuilt.
+test -f mu.info
+
+$MAKE distclean
+test -f stamp-vti
+test -f version.texi
+test -f foo.info
+test -f subdir/bar.info
+test ! -e mu.info
+
+../configure
+$MAKE maintainer-clean
+test ! -e stamp-vti
+test ! -e version.texi
+test ! -e foo.info
+test ! -e subdir/bar.info
+test ! -e mu.info
+
+: