Subject: bug#13351: [IMPORTANT] Dropping support for split '.info' files in mainline Automake

From: Stefano Lattarini <[email-masked]>
Date: Tue, 08 Jan 2013 14:36:58 +0100

On 01/07/2013 08:30 PM, Stefano Lattarini wrote:
> Reference:
> <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13351>
> 
> On 01/04/2013 05:43 PM, Stefano Lattarini wrote:
>> Hi Thien-Thi, thanks for the feedback.
>>
>> On 01/04/2013 03:07 PM, Thien-Thi Nguyen wrote:
>>> () Stefano Lattarini <[email-masked]>
>>> () Thu, 03 Jan 2013 21:53:21 +0100
>>>
>>>    Thoughts, opinions, objections?
>>>
>>> I support making ‘--no-split’ the default.  But if the package end-user
>>> can override that, how can Automake drop support for it?
>>>
>> By adding it unconditionally in the makeinfo invocation, after all the
>> other options.
>>
> Here is a a patch.  I will wait four of five days for feedback before
> pushing it to master.
>
Oops, I had sent the patch to the Automake-NG list rather than the
Automake one.  Sorry for the confusion.

Stefano

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----

>From cdba479fe5739555ad9ec30e0224f24b2facf548 Mon Sep 17 00:00:00 2001
Message-Id: <cdba479fe[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Fri, 4 Jan 2013 18:12:29 +0100
Subject: [PATCH] texi: no longer support split info files

See automake bug#13351 and bug#12320.

Automake-generated recipes have for a long time supported "split"
info files:

  http://www.gnu.org/software/texinfo/manual/texinfo/texinfo.html#Tag-and-Split-Files

When I asked the rationale for this feature:

  http://lists.gnu.org/archive/html/texinfo-devel/2012-08/msg00015.html

Karl Berry confirmed that the reason for its existence was indeed
"efficiency, especially memory size":

  http://lists.gnu.org/archive/html/texinfo-devel/2012-08/msg00024.html

He also added that "The Elisp manual is one of the largest ones around.
Looks like it would be maybe 3.5mb as one file."  Not in any way big by
modern standards.

OTOH, it appears that the use of split info files (at least in the way
they have been handled by Automake-generated rules for a long time) can
cause real problems in some (admittedly quite corner-case) situations:

  http://thread.gmane.org/gmane.comp.parsers.bison.bugs/3963
  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12320

So we now follow suit with Automake-NG (see commit v1.12.2-901-gdd603e2,
<http://lists.gnu.org/archive/html/automake-ng/2012-08/msg00147.html>)
and have Automake-generated makefiles pass the '--no-split' option
unconditionally to makeinfo invocations.

This allow some nice simplifications in our Texinfo recipes, and offer
an automatic fix for bug#12320.

Another *very* good aspect of such a change is that it should be 100%
transparent to the Automake users.

* lib/am/texinfos.am: Simplify moderately.
* lib/am/texibuild.am: Simplify greatly the recipe for the creation
of info files.
* t/txinfo-makeinfo-error-no-clobber.sh: Adjust.
* t/txinfo-no-split.sh: New test.
* t/list-of-tests.mk: Add it.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 lib/am/texibuild.am                   |   41 +++-----------
 lib/am/texinfos.am                    |   37 ++++++-------
 t/list-of-tests.mk                    |    1 +
 t/txinfo-makeinfo-error-no-clobber.sh |    7 ---
 t/txinfo-no-split.sh                  |   94 +++++++++++++++++++++++++++++++++
 5 files changed, 119 insertions(+), 61 deletions(-)
 create mode 100755 t/txinfo-no-split.sh

diff --git a/lib/am/texibuild.am b/lib/am/texibuild.am
index 2e2a6e1..9f568fb 100644
--- a/lib/am/texibuild.am
+++ b/lib/am/texibuild.am
@@ -22,39 +22,14 @@
 ## should never be dependent upon a non-distributed built file.
 ## Therefore we ensure that %DIRSTAMP% exists in the rule.
 ?!INSRC??DIRSTAMP?	@test -f %DIRSTAMP% || $(MAKE) $(AM_MAKEFLAGS) %DIRSTAMP%
-## Back up the info files before running makeinfo. This is the cheapest
-## way to ensure that
-## 1) If the texinfo file shrinks (or if you start using --no-split),
-##    you'll not be left with some dead info files lying around -- dead
-##    files which would end up in the distribution.
-## 2) If the texinfo file has some minor mistakes which cause makeinfo
-##    to fail, the info files are not removed.  (They are needed by the
-##    developer while he writes documentation.)
-	%AM_V_MAKEINFO%restore=: && backupdir=.am$$$$ && \
-?INSRC?	am__cwd=`pwd` && $(am__cd) $(srcdir) && \
-	rm -rf $$backupdir && mkdir $$backupdir && \
-## If makeinfo is not installed we must not backup the files so
-## 'missing' can do its job and touch $@ if it exists.
-	if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
-	  for f in $@ $@-[0-9] $@-[0-9][0-9]; do \
-	    if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
-	  done; \
-	else :; fi && \
-?INSRC?	cd "$$am__cwd"; \
-	if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
-?!INSRC?	 -o $@ `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%; \
-?INSRC??!GENERIC_INFO?	 -o $@ $(srcdir)/%SOURCE_INFO%; \
-?INSRC??GENERIC_INFO?	 -o $@ $<; \
-	then \
-	  rc=0; \
-?INSRC?	  $(am__cd) $(srcdir); \
-	else \
-	  rc=$$?; \
-## Beware that backup info files might come from a subdirectory.
-?INSRC?	  $(am__cd) $(srcdir) && \
-	  $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
-	fi; \
-	rm -rf $$backupdir; exit $$rc
+## If the texinfo file has some minor mistakes which cause makeinfo
+## to fail, the info files are not removed.
+	$(AM_V_MAKEINFO)$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) \
+	                %MAKEINFOFLAGS% --no-split -o $@-t \
+?!INSRC?	        `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%
+?INSRC??!GENERIC_INFO?	$(srcdir)/%SOURCE_INFO%
+?INSRC??GENERIC_INFO?	$<
+	$(AM_V_at)mv -f $@-t $@

 INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%

diff --git a/lib/am/texinfos.am b/lib/am/texinfos.am
index 9b92920..a57bb03 100644
--- a/lib/am/texinfos.am
+++ b/lib/am/texinfos.am
@@ -191,12 +191,11 @@ install-info-am: $(INFO_DEPS)
 	  case $$file in \
 	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
 	  esac; \
-	  if test -f $$file; then d=.; else d=$(srcdir); fi; \
-	  for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9]; do \
-	    if test -f $$ifile; then \
-	      echo "$$ifile"; \
-	    else : ; fi; \
-	  done; \
+	  if test -f $$file; then \
+	    echo ./$$file; \
+	  else \
+	    echo $(srcdir)/$$file; \
+	  fi; \
 	done | $(am__base_list) | \
 	while read files; do \
 	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \
@@ -311,8 +310,8 @@ uninstall-info-am:
 	for file in $$list; do \
 	  relfile=`echo "$$file" | sed 's|^.*/||'`; \
 	  (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
-	     echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9]"; \
-	     rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9]; \
+	     echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile"; \
+	     rm -f $$relfile; \
 	   else :; fi); \
 	done

@@ -345,15 +344,14 @@ dist-info: $(INFO_DEPS)
 	  case $$base in \
 	    $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
 	  esac; \
-	  if test -f $$base; then d=.; else d=$(srcdir); fi; \
-	  for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9]; do \
-	    if test -f $$file; then \
-## Strip leading '$$d/'.
-	      relfile=`expr "$$file" : "$$d/\(.*\)"`; \
-	      test -f "$(distdir)/$$relfile" || \
-		cp -p $$file "$(distdir)/$$relfile"; \
-	    else :; fi; \
-	  done; \
+	  if test -f $$base; then \
+	    file=./$$base; \
+	  else \
+	    file=$(srcdir)/$$base; \
+	  fi; \
+	  if test -f $$file && test ! -f "$(distdir)/$$base"; then \
+	    cp -p $$file "$(distdir)/$$base"; \
+	  fi; \
 	done
 endif %?LOCAL-TEXIS%

@@ -383,10 +381,7 @@ clean-aminfo:

 .PHONY maintainer-clean-am: maintainer-clean-aminfo
 maintainer-clean-aminfo:
-	@list='$(INFO_DEPS)'; for i in $$list; do \
-	  echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9]"; \
-	  rm -f $$i $$i-[0-9] $$i-[0-9][0-9]; \
-	done
+	-test -z "$(INFO_DEPS)" || rm -f $(INFO_DEPS)
 ## Use '-rf', not just '-f'; see comments in 'mostlyclean-aminfo'
 ## above for details.
 ?MAINTCLEAN?	-test -z "%MAINTCLEAN%" \
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index e8efe45..a6b379c 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -1170,6 +1170,7 @@ t/txinfo-no-clutter.sh \
 t/txinfo-no-extra-dist.sh \
 t/txinfo-no-installinfo.sh \
 t/txinfo-no-repeated-targets.sh \
+t/txinfo-no-split.sh \
 t/txinfo-other-suffixes.sh \
 t/txinfo-override-infodeps.sh \
 t/txinfo-override-texinfo-tex.sh \
diff --git a/t/txinfo-makeinfo-error-no-clobber.sh b/t/txinfo-makeinfo-error-no-clobber.sh
index f4b7d01..c567e89 100755
--- a/t/txinfo-makeinfo-error-no-clobber.sh
+++ b/t/txinfo-makeinfo-error-no-clobber.sh
@@ -45,10 +45,6 @@ $AUTOCONF
 ./configure
 $MAKE

-# Feign more info files.
-: > main.info-1
-: > sub/main.info-1
-
 # Break main.texi.
 $sleep
 cp main.texi main.old
@@ -64,15 +60,12 @@ END
 # makeinfo will bail out, but we should conserve the old info files.
 $MAKE && exit 1
 test -f main.info
-test -f main.info-1

 # Restore main.texi, and break sub/main.texi.
 cp main.texi sub/main.texi
 mv main.old main.texi
 $MAKE && exit 1
 test -f main.info
-test ! -e main.info-1
 test -f sub/main.info
-test -f sub/main.info-1

 :
diff --git a/t/txinfo-no-split.sh b/t/txinfo-no-split.sh
new file mode 100755
index 0000000..aecf7e7
--- /dev/null
+++ b/t/txinfo-no-split.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2013 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/>.
+
+# Info split files should not be produced (automake bug#13351).
+
+required=makeinfo
+. test-init.sh
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+MAKEINFO = makeinfo --split-size 10
+info_TEXINFOS = foo.texi
+
+test-split: # A sanity check.
+	$(MAKEINFO) -o split.info foo.texi
+
+check-local:
+	test -f $(srcdir)/foo.info
+	test ! -f $(srcdir)/foo.info-1
+	test "`find $(srcdir) . | grep '\.info'`" = "$(srcdir)/foo.info"
+END
+
+cat > foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@settitle foo
+@dircategory Dummy utilities
+@direntry
+* Foo: (foo).  Does nothing at all.
+@end direntry
+
+@node Top
+@top Foo
+
+@menu
+* Intro::    Introduction
+* Planets::  List of Planets
+@end menu
+
+@node Intro
+@chapter Introduction
+Will list planets.
+
+@node Planets
+@chapter List of planets
+Hello Mercury.
+Hello Venus
+Hello Earth
+Hello Mars.
+Hello Jupiter.
+Hello Saturn.
+Hello Uran.
+Hello Neptune.
+Hello Pluto.
+@bye
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE test-split
+ls -l # For debugging.
+test -f split.info
+test -f split.info-1
+test -f split.info-2
+rm -f split*
+
+$MAKE
+
+ls -l # For debugging.
+test -f foo.info
+test ! -f foo.info-1
+test "$(find . | $FGREP '.info' | sed 's|^\./||')" = foo.info
+
+$MAKE distcheck
+
+:
-- 
1.7.10.4