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

From: Gavin Smith <[email-masked]>
Date: Sun, 19 Mar 2023 10:17:31 +0000

On Sat, Mar 18, 2023 at 10:10:05PM +0100, Bogdan wrote:
>  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".

It may fix the bug for <= texinfo 4.8 but can I suggest that having
lengthy comments in code explaining why it is done one way and not
another is pretty distracting for anybody trying to understand or
modify the code in the future.  Also note that texinfo 4.8 was released
in 2004, nearly 20 years ago, so I question whether it is worth fixing
this in a complicated way for the benefit of the proprietary macOS
operating system (I believe they use old versions of GNU programs to
avoid using GPLv3-licensed code).

> 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
>