bug#29188: [PATCH] texi2dvi usage doesn't work with <texinfo-4.9

Bogdan <[email protected]> Sat, 18 Mar 2023 22:10:05 +0100
Newsgroups gmane.comp.sysutils.automake.bugs,gmane.comp.sysutils.automake.patches
Message-ID <[email protected]>
Hello.

  The attached patch fixes bug#29188.

  The problem was with "--build-dir=": the old texi2dvi (which is a 
shell script) splits "--build-dir=xxx" into "--build-dir" and "xxx", 
interprets the "--build-dir" switch as "--batch" (checks just the 
first letter, great) and the "xxx" stays on the command line and is 
being treated as another input file, causing the error.

  Fortunately, since texinfo-4.9, one can set the build directory with 
an environment variable "TEXI2DVI_BUILD_DIRECTORY". Unfortunately, 
texinfo has a bug there, too. When setting "--build-dir=" on the 
command line, the build mode is set to "tidy" (which cleans some log 
files, etc.). Fine. The problem is that if you set the build directory 
using an environment variable, the mode is NOT set to "tidy", leaving 
the logs files and failing tests. Luckily, you can also set the build 
mode from an environment variable, "TEXI2DVI_BUILD_MODE".

  That's why the new invocation of $(TEXI2DVI) and $(TEXI2PDF) has 2 
additional environment variables prepended.

  Testing:
- verified - the failing test doesn't work with old texinfo
- verified - the failing test works after the fix with old texinfo
- verified - the failing test works after the fix with new texinfo
- verified - all 84 texi+txi+info tests work after the fix with new 
texinfo (make check TESTS="`ls t/*texi*.sh t/*txi*.sh t/*info*.sh`")
- verified - all 84 texi+txi+info tests work after the fix with old 
texinfo

  Yes, I downloaded texinfo 4.8 just for this purpose.

  So, the old texinfo, which doesn't support "--build-dir=" or the 
environment variables, should work without change, and the new texinfo 
got switched from command-line switches to environment variables and 
should work as well, the same way it used to be.

-- 
Regards - Bogdan ('bogdro') D.                 (GNU/Linux & FreeDOS)
X86 assembly (DOS, GNU/Linux):    http://bogdro.evai.pl/index-en.php
Soft(EN): http://bogdro.evai.pl/soft  http://bogdro.evai.pl/soft4asm
www.Xiph.org  www.TorProject.org  www.LibreOffice.org  www.GnuPG.org
automake-old-texinfo-mail.diff (text/x-patch, 2.7 KB)
From 05cb873bec12638b0218afcb0a42076f571c7836 Mon Sep 17 00:00:00 2001
From: Bogdan Drozdowski <>
Date: Sat, 18 Mar 2023 21:46:36 +0100
Subject: [PATCH] Support for texinfo<4.9

---
 lib/am/texibuild.am | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/am/texibuild.am b/lib/am/texibuild.am
index 6f6099c8d..b83dbfa44 100644
--- a/lib/am/texibuild.am
+++ b/lib/am/texibuild.am
@@ -76,7 +76,17 @@ INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
 ## avoid hitting a Texinfo bug that could cause low-probability racy
 ## failure when doing parallel builds; see:
 ## https://lists.gnu.org/archive/html/automake-patches/2012-06/msg00073.html
-	$(TEXI2DVI) $(AM_TEXI2FLAGS) %MAKEINFOFLAGS% %TEXIQUIET% --build-dir=$(@:.dvi=.t2d) -o $@ %TEXIDEVNULL% \
+## See bug#29188 for why we are not using "--build-dir=": the old texi2dvi
+## splits "--build-dir=xxx" into "--build-dir" and "xxx", interprets the
+## "--build-dir" as "--batch" (checks just 1 letter, great!) and the "xxx"
+## stays on the command line as another input file, causing the error.
+	TEXI2DVI_BUILD_DIRECTORY=$(@:.dvi=.t2d) \
+## We need TEXI2DVI_BUILD_MODE=tidy due to another bug in texi2dvi:
+## when "--build-dir" is passed on the command line, the build mode is
+## automatically set to 'tidy' by default, but when the build directory
+## is set using an environment variable, the build mode stays default.
+	TEXI2DVI_BUILD_MODE=tidy \
+	$(TEXI2DVI) $(AM_TEXI2FLAGS) %MAKEINFOFLAGS% %TEXIQUIET% -o $@ %TEXIDEVNULL% \
 ?GENERIC?	%SOURCE%
 ?!GENERIC?	`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
 
@@ -97,7 +107,17 @@ INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
 ## avoid hitting a Texinfo bug that could cause low-probability racy
 ## failure when doing parallel builds; see:
 ## https://lists.gnu.org/archive/html/automake-patches/2012-06/msg00073.html
-	$(TEXI2PDF) $(AM_TEXI2FLAGS) %MAKEINFOFLAGS% %TEXIQUIET% --build-dir=$(@:.pdf=.t2p) -o $@ %TEXIDEVNULL% \
+## See bug#29188 for why we are not using "--build-dir=": the old texi2dvi
+## splits "--build-dir=xxx" into "--build-dir" and "xxx", interprets the
+## "--build-dir" as "--batch" (checks just 1 letter, great!) and the "xxx"
+## stays on the command line as another input file, causing the error.
+	TEXI2DVI_BUILD_DIRECTORY=$(@:.pdf=.t2p) \
+## We need TEXI2DVI_BUILD_MODE=tidy due to another bug in texi2dvi:
+## when "--build-dir" is passed on the command line, the build mode is
+## automatically set to 'tidy' by default, but when the build directory
+## is set using an environment variable, the build mode stays default.
+	TEXI2DVI_BUILD_MODE=tidy \
+	$(TEXI2PDF) $(AM_TEXI2FLAGS) %MAKEINFOFLAGS% %TEXIQUIET% -o $@ %TEXIDEVNULL% \
 ?GENERIC?	%SOURCE%
 ?!GENERIC?	`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
 
-- 
2.35.1