From 371ac5dca3b7d724d36ea40511c3a0f3f59106da Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Fri, 16 Dec 2022 17:48:53 +0000
Subject: Cope with groff 1.17's macro file name changes

Forwarded: no
Last-Update: 2022-12-16

Patch-Name: groff-1.17-macro-naming.patch
---
 config/Imake.p-params | 14 ++++++++++++--
 troffcvt/Imakefile    |  3 ++-
 troffcvt/main.c       |  2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/config/Imake.p-params b/config/Imake.p-params
index d0f9960..3dcf87d 100644
--- a/config/Imake.p-params
+++ b/config/Imake.p-params
@@ -48,7 +48,7 @@
  */
 
 #ifndef	MacroLibDir
-#define	MacroLibDir	$(USRLIBDIR)/tmac
+#define	MacroLibDir	/usr/share/groff/current/tmac
 #endif
 
 /*
@@ -58,7 +58,16 @@
  */
 
 #ifndef MacroFilePrefix
-#define MacroFilePrefix tmac.
+#define MacroFilePrefix
+#endif
+
+/*
+ * Suffix for constructing a system macro filename.  Some systems (e.g.
+ * groff >= 1.17) use names like e.tmac or s.tmac.
+ */
+
+#ifndef MacroFileSuffix
+#define MacroFileSuffix .tmac
 #endif
 
 #ifndef TcGenLib
@@ -86,6 +95,7 @@
        PROJLIBDIR = ProjLibDir
       MACROLIBDIR = MacroLibDir
   MACROFILEPREFIX = MacroFilePrefix
+  MACROFILESUFFIX = MacroFileSuffix
 
          STRING_H = StringH
  STRING_H_DEFINES = StringHDefines
diff --git a/troffcvt/Imakefile b/troffcvt/Imakefile
index 956d9a1..883d78b 100644
--- a/troffcvt/Imakefile
+++ b/troffcvt/Imakefile
@@ -4,7 +4,8 @@ XCOMM any special -D's or other flags for compiling
 DEFINES = \
 	-D'PROJLIBDIR="$(PROJLIBDIR)"' \
 	-D'MACROLIBDIR="$(MACROLIBDIR)"' \
-	-D'MACROFILEPREFIX="$(MACROFILEPREFIX)"'
+	-D'MACROFILEPREFIX="$(MACROFILEPREFIX)"' \
+	-D'MACROFILESUFFIX="$(MACROFILESUFFIX)"'
 
 XCOMM any special -I's for compiling
 INCLUDES =
diff --git a/troffcvt/main.c b/troffcvt/main.c
index fd689df..c1a899d 100644
--- a/troffcvt/main.c
+++ b/troffcvt/main.c
@@ -623,7 +623,7 @@ short	out;
 		}
 		else					/* macro file */
 		{
-			sprintf (buf, "%s%s", MACROFILEPREFIX, name);
+			sprintf (buf, "%s%s%s", MACROFILEPREFIX, name, MACROFILESUFFIX);
 			if (!ReadMacroFile (buf))
 				ETMPanic ("cannot read macro file for -m%s",
 									name);
