From 6d8fbae077c5bc611fc666b45bf1a102c6a30621 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Sun, 6 Apr 2025 08:41:20 -0700
Subject: [PATCH] build: avoid test failure on systems lacking "more"

On such systems, treat "more" as optional, just as we treat "less".
If the primary program is not available, do not install zmore.
Reported by Bruno Haible in http://debbugs.gnu.org/77563 and noticed
on a 2025 x86_64 GNU/Hurd system.
* configure.ac: Check for more/MORE just like we do for less/LESS.
* tests/Makefile.am: Use the new variables.
* NEWS: Mention it.
---
 NEWS              | 2 ++
 configure.ac      | 2 ++
 tests/Makefile.am | 8 +++++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index c5fbfb4..4d1c5dc 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ GNU gzip NEWS                                    -*- outline -*-
   performance issues.  You can continue to use scripts to specify
   whatever gzip options you like.

+  'zmore' is no longer installed on platforms lacking 'more'.
+
 ** Performance improvements

   gzip now decompresses significantly faster by computing CRCs via a
diff --git a/configure.ac b/configure.ac
index 310ed2b..1a74266 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,8 @@ AC_PROG_CPP
 AC_PROG_GREP
 AC_CHECK_PROG([LESS], [less], [less])
 AM_CONDITIONAL([LESS], [test "$LESS"])
+AC_CHECK_PROG([MORE], [more], [more])
+AM_CONDITIONAL([MORE], [test "$MORE"])
 AC_CHECK_TOOL([NM], [nm], [nm])
 AC_PROG_LN_S
 AC_PROG_RANLIB
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d86cfb0..419e311 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,12 @@ else
 ZLESS_PROG =
 endif

+if MORE
+ZMORE_PROG = zless
+else
+ZMORE_PROG =
+endif
+
 built_programs = \
   gzip		\
   gunzip	\
@@ -70,7 +76,7 @@ built_programs = \
   zforce	\
   zgrep		\
   $(ZLESS_PROG)	\
-  zmore		\
+  $(ZMORE_PROG)	\
   znew

 TESTS_ENVIRONMENT =					\
-- 
2.48.1.268.g9520f7d998

