Subject: bug#54063: - special case] Try .texi.in when .texi missing

From: Bogdan <[email-masked]>
Date: Tue, 27 Dec 2022 22:48:25 +0100

Hello, Automake gurus.

I have a special case for bug#54063. In my case, the .texi file is 
missing during 'automake' time, because it is being created by 
'configure' from a matching .texi.in file. That file exists during 
'automake' time, so it can be scanned for the output filename - no 
need to use /dev/null in such simple case.

The attached patch (with a test) should fix this issue. Hope I've done 
everything the right way.

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

From 80d896457f1ad251f6e6e3bb2310c19127296798 Mon Sep 17 00:00:00 2001
From: Bogdan Drozdowski <>
Date: Mon, 26 Dec 2022 18:22:52 +0100
Subject: [PATCH] Fix error when texi missing and texi.in present (a case of
 bug 54063)

---
 bin/automake.in                 | 16 ++++++++++--
 t/list-of-tests.mk              |  1 +
 t/txinfo-no-texi-but-texi-in.sh | 43 +++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 t/txinfo-no-texi-but-texi-in.sh

diff --git a/bin/automake.in b/bin/automake.in
index c094234bc..b4a4e69a7 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -3063,8 +3063,20 @@ sub scan_texinfo_file
   my ($filename) = @_;
 
   # If the source file doesn't exist, we'll fall back below.
-  my $source = -e $filename ? $filename : "/dev/null";
-  my $texi = new Automake::XFile "< $source";
+  if (! -e $filename)
+    {
+      if (-e ($filename . '.in'))
+        {
+          # $filename.texi.in exists: assume $filename.texi is generated
+          # and parse $filename.texi.in as the real input
+          $filename .= '.in';
+        }
+      else
+        {
+          $filename = '/dev/null';
+        }
+    }
+  my $texi = new Automake::XFile "< $filename";
   verb "reading $filename";
 
   my ($outfile, $vfile);
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index d82cf9c4d..5f1c903eb 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -1232,6 +1232,7 @@ t/txinfo-no-installinfo.sh \
 t/txinfo-no-repeated-targets.sh \
 t/txinfo-no-setfilename.sh \
 t/txinfo-no-setfilename-no-inputs.sh \
+t/txinfo-no-texi-but-texi-in.sh \
 t/txinfo-other-suffixes.sh \
 t/txinfo-override-infodeps.sh \
 t/txinfo-override-texinfo-tex.sh \
diff --git a/t/txinfo-no-texi-but-texi-in.sh b/t/txinfo-no-texi-but-texi-in.sh
new file mode 100644
index 000000000..112a4b34b
--- /dev/null
+++ b/t/txinfo-no-texi-but-texi-in.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2022 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 <https://www.gnu.org/licenses/>.
+
+# Check if Automake doesn't exit with an error for Texinfo output files
+# without a direct input file, but with a matching input file processed
+# by 'configure' (file.texi.IN).
+
+. test-init.sh
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi
+END
+
+cat > main.texi.in << 'END'
+\input texinfo
+@setfilename testmain.info
+@settitle main
+@node Top
+Hello world.
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+grep 'testmain.info:' Makefile.in
+
+:
-- 
2.35.1