[PATCH 87/94] games-roguelike/nethack: GNU Hurd fixes; lex dependency

Sam James <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Message-ID <ec03a0b16b4125e52ed20f30e00a56106650c7a3.1774994369.git.sam@gentoo.org>
From: Swagtoy <[email protected]>

This is a series of patches (and one little workaround) for GNU Hurd to
get the game to build. Everything works well, except for the guidebook.

It also adds a lex dependency, which was presumably missing from the
ebuild originally.

Signed-off-by: Swagtoy <[email protected]>
Part-of: https://github.com/gentoo/gentoo/pull/46000
Closes: https://github.com/gentoo/gentoo/pull/46000
Signed-off-by: Sam James <[email protected]>
---
 .../files/nethack-3.6.7-hurd-tparm.patch        | 15 +++++++++++++++
 ...ack-3.6.7-no-define-warn-unused-result.patch | 17 +++++++++++++++++
 .../nethack/files/nethack-3.6.7-path-max.patch  | 15 +++++++++++++++
 ...ack-3.6.7.ebuild => nethack-3.6.7-r1.ebuild} |  8 +++++++-
 4 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 games-roguelike/nethack/files/nethack-3.6.7-hurd-tparm.patch
 create mode 100644 games-roguelike/nethack/files/nethack-3.6.7-no-define-warn-unused-result.patch
 create mode 100644 games-roguelike/nethack/files/nethack-3.6.7-path-max.patch
 copy games-roguelike/nethack/{nethack-3.6.7.ebuild => nethack-3.6.7-r1.ebuild} (92%)

diff --git a/games-roguelike/nethack/files/nethack-3.6.7-hurd-tparm.patch b/games-roguelike/nethack/files/nethack-3.6.7-hurd-tparm.patch
new file mode 100644
index 0000000000000..08766e30eaf62
--- /dev/null
+++ b/games-roguelike/nethack/files/nethack-3.6.7-hurd-tparm.patch
@@ -0,0 +1,15 @@
+Not a favorable solution, since this is probably some outdated quirk to begin
+with. But in life, shall we leave the unknown to itself...
+
+diff '--color=auto' -ru NetHack-3.6.7/win/tty/termcap.c NetHack-3.6.7-fix/win/tty/termcap.c
+--- NetHack-3.6.7/win/tty/termcap.c	2026-03-29 17:22:57.252478012 -0400
++++ NetHack-3.6.7-fix/win/tty/termcap.c	2026-03-29 18:36:03.070723420 -0400
+@@ -838,7 +838,7 @@
+ 
+ #include <curses.h>
+ 
+-#if !defined(LINUX) && !defined(__FreeBSD__) && !defined(NOTPARMDECL)
++#if !defined(__gnu_hurd__) && !defined(LINUX) && !defined(__FreeBSD__) && !defined(NOTPARMDECL)
+ extern char *tparm();
+ #endif
+ 
diff --git a/games-roguelike/nethack/files/nethack-3.6.7-no-define-warn-unused-result.patch b/games-roguelike/nethack/files/nethack-3.6.7-no-define-warn-unused-result.patch
new file mode 100644
index 0000000000000..378c55687c74f
--- /dev/null
+++ b/games-roguelike/nethack/files/nethack-3.6.7-no-define-warn-unused-result.patch
@@ -0,0 +1,17 @@
+GCC (as of 15.2.1_p20260214) seems to fail, specifically for GNU Hurd (as seen
+by the !defined (__linux__) bit), as gcc's __attribute__ expects an argument
+there. It seems rather old (and quite undesirable), so for now, we will just
+disable the snippet of code.
+
+diff '--color=auto' -ru NetHack-3.6.7/include/tradstdc.h NetHack-3.6.7-fix/include/tradstdc.h
+--- NetHack-3.6.7/include/tradstdc.h	2023-02-15 16:52:57.000000000 -0500
++++ NetHack-3.6.7-fix/include/tradstdc.h	2026-03-24 00:48:35.740547092 -0400
+@@ -429,7 +429,7 @@
+ #if __GNUC__ >= 3
+ #define UNUSED __attribute__((unused))
+ #define NORETURN __attribute__((noreturn))
+-#if !defined(__linux__) || defined(GCC_URWARN)
++#if 0
+ /* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
+    discarding the result by casting to (void) is not accepted as a 'use' */
+ #define __warn_unused_result__ /*empty*/
diff --git a/games-roguelike/nethack/files/nethack-3.6.7-path-max.patch b/games-roguelike/nethack/files/nethack-3.6.7-path-max.patch
new file mode 100644
index 0000000000000..3d1f6bfb618aa
--- /dev/null
+++ b/games-roguelike/nethack/files/nethack-3.6.7-path-max.patch
@@ -0,0 +1,15 @@
+diff '--color=auto' -ru NetHack-3.6.7/src/files.c NetHack-3.6.7-fix/src/files.c
+--- NetHack-3.6.7/src/files.c	2023-02-15 16:52:57.000000000 -0500
++++ NetHack-3.6.7-fix/src/files.c	2026-03-29 17:25:31.135961712 -0400
+@@ -4020,6 +4020,11 @@
+ #ifndef PATH_MAX
+ #include <limits.h>
+ #endif
++
++/* the Hurd still doesn't define PATH_MAX */
++#ifndef PATH_MAX
++#define PATH_MAX 2048
++#endif
+ #endif
+ 
+ void
diff --git a/games-roguelike/nethack/nethack-3.6.7.ebuild b/games-roguelike/nethack/nethack-3.6.7-r1.ebuild
similarity index 92%
copy from games-roguelike/nethack/nethack-3.6.7.ebuild
copy to games-roguelike/nethack/nethack-3.6.7-r1.ebuild
index 08b526369699d..64c4e9f31f109 100644
--- a/games-roguelike/nethack/nethack-3.6.7.ebuild
+++ b/games-roguelike/nethack/nethack-3.6.7-r1.ebuild
@@ -31,6 +31,7 @@ DEPEND="
 "
 BDEPEND="
 	virtual/pkgconfig
+	app-alternatives/lex
 	app-alternatives/yacc
 	X? (
 		x11-apps/bdftopcf
@@ -41,6 +42,9 @@ BDEPEND="
 PATCHES=(
 	"${FILESDIR}/${PN}-3.6.3-recover.patch"
 	"${FILESDIR}/${PN}-3.6.6-clang16.patch"
+	"${FILESDIR}/${PN}-3.6.7-no-define-warn-unused-result.patch"
+	"${FILESDIR}/${PN}-3.6.7-path-max.patch"
+	"${FILESDIR}/${PN}-3.6.7-hurd-tparm.patch"
 )
 
 src_prepare() {
@@ -74,7 +78,9 @@ src_compile() {
 		HACKDIR="${EPREFIX}/usr/$(get_libdir)/nethack"
 	)
 
-	emake "${LOCAL_MAKEOPTS[@]}" nethack recover Guidebook spec_levs
+	emake "${LOCAL_MAKEOPTS[@]}" nethack recover spec_levs
+	# XXX: Lots of troff errors on Hurd, so don't build the Guidebook there for now.
+	! use kernel_Hurd && emake "${LOCAL_MAKEOPTS[@]}" Guidebook
 
 	# Upstream still has some parallel compilation bugs
 	emake -j1 "${LOCAL_MAKEOPTS[@]}" all
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.