git: fa2a8dd2b9bd - main - games/xnethack: update to 7.0

From: Neel Chauhan <nc_at_FreeBSD.org>
Date: Fri, 11 Mar 2022 17:30:44 UTC
The branch main has been updated by nc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fa2a8dd2b9bd292bfd97c1539fefbbc3c3cde3d5

commit fa2a8dd2b9bd292bfd97c1539fefbbc3c3cde3d5
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2022-03-11 00:40:22 +0000
Commit:     Neel Chauhan <nc@FreeBSD.org>
CommitDate: 2022-03-11 17:30:36 +0000

    games/xnethack: update to 7.0
    
    While we are add it, add another flavour for the Qt frontend.
    
    Changelog:      https://github.com/copperwater/xNetHack/blob/master/doc/xnh-changelog-7.0.md
    
    PR:     262483
---
 games/xnethack/Makefile                          |  21 +++-
 games/xnethack/distinfo                          |   6 +-
 games/xnethack/files/patch-doc_dlb.6             |   4 +-
 games/xnethack/files/patch-doc_nethack.6         |  17 +--
 games/xnethack/files/patch-doc_recover.6         |   6 +-
 games/xnethack/files/patch-include-config.h      |   8 +-
 games/xnethack/files/patch-include-unixconf.h    |   4 +-
 games/xnethack/files/patch-sys-unix-Makefile.doc |  13 ++-
 games/xnethack/files/patch-sys-unix-Makefile.src |  72 +++++++------
 games/xnethack/files/patch-sys-unix-Makefile.top | 127 ++++++++++-------------
 games/xnethack/files/patch-sys-unix-Makefile.utl |   4 +-
 games/xnethack/files/patch-sys-unix-sysconf      |   4 +-
 games/xnethack/files/patch-util-makedefs.c       |  18 ++--
 games/xnethack/files/patch-win-tty-termcap.c     |   4 +-
 games/xnethack/files/patch-win_Qt_qt__pre.h      |  11 ++
 games/xnethack/pkg-plist                         |   8 ++
 16 files changed, 171 insertions(+), 156 deletions(-)

diff --git a/games/xnethack/Makefile b/games/xnethack/Makefile
index ca1993103cf3..b342ec0f71d5 100644
--- a/games/xnethack/Makefile
+++ b/games/xnethack/Makefile
@@ -1,7 +1,6 @@
 PORTNAME=	xNetHack
 DISTVERSIONPREFIX=	xnh
-DISTVERSION=	6.1
-PORTREVISION=	1
+DISTVERSION=	7.0
 CATEGORIES=	games
 
 MAINTAINER=	fuz@fuz.su
@@ -12,9 +11,10 @@ LICENSE_NAME=	NETHACK GENERAL PUBLIC LICENSE
 LICENSE_FILE=	${WRKSRC}/dat/license
 LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
 
-FLAVORS=	x11 nox11
+FLAVORS=	x11 nox11 qt
 FLAVOR?=	${FLAVORS:[1]}
 nox11_PKGNAMESUFFIX=	-nox11
+qt_PKGNAMESUFFIX=	-qt
 
 USES=		alias compiler:c11 gmake ncurses tar:tgz lua:54
 USE_GITHUB=	yes
@@ -33,11 +33,20 @@ DOCSDIR=	${PREFIX}/share/doc/${HACKNAME}
 .if ${FLAVOR} == "x11"
 USES+=		xorg
 USE_XORG=	xaw xpm xmu xext xt x11 sm ice
-CFLAGS+=	-DX11_GRAPHICS -DUSE_TILES
+CFLAGS+=	-DUSE_TILES
 GRAPHICS=	X11_GRAPHICS
 .elif ${FLAVOR} == "nox11"
 GRAPHICS=	# none
+.elif ${FLAVOR} == "qt"
+USES+=		localbase pkgconfig qt:5
+USE_QT=		buildtools_build core gui multimedia network widgets
+MAKE_ENV+=	MOCPATH=${MOC} LINK="${CXX} -pie"
+# Qt wants PIC for some reason.  For C code, PIE should be enough.
+CFLAGS+=	-I${QT_INCDIR} -fpie
+CXXFLAGS+=	-I${QT_INCDIR} -fpic
+GRAPHICS=	QT_GRAPHICS
 .endif
+
 CFLAGS+=	-DNOMAIL -DCURSES_GRAPHICS
 
 OPTIONS_DEFINE=	DOCS
@@ -63,7 +72,10 @@ post-patch:
 .endif
 
 do-configure:
+	${TOUCH} ${WRKSRC}/dat/gitinfo.txt
 	@cd ${WRKSRC}/sys/unix; ${SH} setup.sh
+	# work around a race condition
+	cd ${WRKSRC}/util; ${MAKE_CMD} tiletxt.c
 
 post-install:
 	${STRIP_CMD} ${STAGEDIR}${DATADIR}/recover
@@ -75,6 +87,7 @@ post-install:
 	@${CP} ${STAGEDIR}/${DATADIR}/sysconf ${STAGEDIR}/${DATADIR}/sysconf.sample
 	# Make "sample" files from records to prevent them being removed
 	# if they have been altered
+	@${CP} ${STAGEDIR}/${DATADIR}/logfile ${STAGEDIR}/${DATADIR}/livelog.sample
 	@${CP} ${STAGEDIR}/${DATADIR}/logfile ${STAGEDIR}/${DATADIR}/logfile.sample
 	@${CP} ${STAGEDIR}/${DATADIR}/record ${STAGEDIR}/${DATADIR}/record.sample
 	@${CP} ${STAGEDIR}/${DATADIR}/xlogfile ${STAGEDIR}/${DATADIR}/xlogfile.sample
diff --git a/games/xnethack/distinfo b/games/xnethack/distinfo
index b414821b5fcf..311196d7ea1d 100644
--- a/games/xnethack/distinfo
+++ b/games/xnethack/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1620650405
-SHA256 (copperwater-xNetHack-xnh6.1_GH0.tar.gz) = 48cdb14a0b30cd439e04ccc3daa21d4db8b2abe9090dd7dcb2fdfa839a9572d8
-SIZE (copperwater-xNetHack-xnh6.1_GH0.tar.gz) = 5850953
+TIMESTAMP = 1646737487
+SHA256 (copperwater-xNetHack-xnh7.0_GH0.tar.gz) = d2f9ed47a2dde9d1dfeba073f4f2cbb6c226f8d98457a860b56ec00551429725
+SIZE (copperwater-xNetHack-xnh7.0_GH0.tar.gz) = 5985717
diff --git a/games/xnethack/files/patch-doc_dlb.6 b/games/xnethack/files/patch-doc_dlb.6
index ee45582bb8a7..a6884527a5e2 100644
--- a/games/xnethack/files/patch-doc_dlb.6
+++ b/games/xnethack/files/patch-doc_dlb.6
@@ -1,6 +1,6 @@
---- doc/dlb.6.orig	2021-03-22 22:28:14 UTC
+--- doc/dlb.6.orig	2022-03-07 23:57:15 UTC
 +++ doc/dlb.6
-@@ -96,7 +96,7 @@ List the contents of the archive 'foo':
+@@ -95,7 +95,7 @@ List the contents of the archive 'foo':
  Kenneth Lorber
  .SH "SEE ALSO"
  .PP
diff --git a/games/xnethack/files/patch-doc_nethack.6 b/games/xnethack/files/patch-doc_nethack.6
index 179b1c2e1bce..e25ec372830c 100644
--- a/games/xnethack/files/patch-doc_nethack.6
+++ b/games/xnethack/files/patch-doc_nethack.6
@@ -1,6 +1,6 @@
---- doc/nethack.6.orig	2021-03-22 22:28:14 UTC
+--- doc/nethack.6.orig	2022-03-07 23:57:15 UTC
 +++ doc/nethack.6
-@@ -17,7 +17,7 @@ nethack \- Exploring The Mazes of Menace
+@@ -16,7 +16,7 @@ nethack \- Exploring The Mazes of Menace
  .SH SYNOPSIS
  .na
  .hy 0
@@ -9,7 +9,7 @@
  [
  .B \-d
  .I directory
-@@ -219,7 +219,7 @@ option, which must be the first argument if it appears
+@@ -218,7 +218,7 @@ option, which must be the first argument if it appears
  supplies a directory which is to serve as the playground.
  It overrides the value from NETHACKDIR, HACKDIR,
  or the directory specified by the game administrator during compilation
@@ -18,7 +18,7 @@
  This option is usually only useful to the game administrator.
  The playground must contain several auxiliary files such as help files,
  the list of top scorers, and a subdirectory
-@@ -265,7 +265,7 @@ name is '.xnethackrc' in the user's home directory.
+@@ -264,7 +264,7 @@ name is '.xnethackrc' in the user's home directory.
  
  .br
  All other files are in the playground directory,
@@ -27,12 +27,3 @@
  If DLB was defined during the compile, the data files and special levels
  will be inside a larger file, normally nhdat, instead of being separate
  files.
-@@ -392,7 +392,7 @@ SHOPTYPE and SPLEVTYPE can be used in debugging (wizar
- DEBUGFILES can be used if the program was built with 'DEBUG' enabled.
- .SH "SEE ALSO"
- .PP
--recover(6)
-+recover(6)
- .SH BUGS
- .PP
- Probably infinite.
diff --git a/games/xnethack/files/patch-doc_recover.6 b/games/xnethack/files/patch-doc_recover.6
index 06d36363e29a..9273032901e3 100644
--- a/games/xnethack/files/patch-doc_recover.6
+++ b/games/xnethack/files/patch-doc_recover.6
@@ -1,6 +1,6 @@
---- doc/recover.6.orig	2021-03-22 22:28:14 UTC
+--- doc/recover.6.orig	2022-03-07 23:57:15 UTC
 +++ doc/recover.6
-@@ -43,7 +43,7 @@ option, which must be the first argument if it appears
+@@ -42,7 +42,7 @@ option, which must be the first argument if it appears
  supplies a directory which is the NetHack playground.
  It overrides the value from NETHACKDIR, HACKDIR, or the directory
  specified by the game administrator during compilation
@@ -9,7 +9,7 @@
  .PP
  ^?ALLDOCS
  For recovery to be possible,
-@@ -130,7 +130,7 @@ but even a compression-using
+@@ -129,7 +129,7 @@ but even a compression-using
  .I nethack
  will find them in the uncompressed form.
  .SH "SEE ALSO"
diff --git a/games/xnethack/files/patch-include-config.h b/games/xnethack/files/patch-include-config.h
index 09e486a83591..cd282cbf1737 100644
--- a/games/xnethack/files/patch-include-config.h
+++ b/games/xnethack/files/patch-include-config.h
@@ -1,6 +1,6 @@
---- include/config.h.orig	2021-03-22 22:28:14 UTC
+--- include/config.h.orig	2022-03-07 23:57:15 UTC
 +++ include/config.h
-@@ -294,11 +294,11 @@
+@@ -303,11 +303,11 @@
  
  #if defined(UNIX) && !defined(ZLIB_COMP) && !defined(COMPRESS)
  /* path and file name extension for compression program */
@@ -16,7 +16,7 @@
  #endif
  
  #ifndef COMPRESS
-@@ -383,7 +383,7 @@
+@@ -392,7 +392,7 @@
   * otherwise it will be the current directory.
   */
  #ifndef HACKDIR
@@ -25,7 +25,7 @@
  #endif
  
  /*
-@@ -646,7 +646,7 @@ typedef unsigned char uchar;
+@@ -653,7 +653,7 @@ typedef unsigned char uchar;
  #ifdef DUMPLOG
  
  #ifndef DUMPLOG_FILE
diff --git a/games/xnethack/files/patch-include-unixconf.h b/games/xnethack/files/patch-include-unixconf.h
index 790f7ccdbedd..f845b24a7169 100644
--- a/games/xnethack/files/patch-include-unixconf.h
+++ b/games/xnethack/files/patch-include-unixconf.h
@@ -1,4 +1,4 @@
---- include/unixconf.h.orig	2021-03-22 22:28:14 UTC
+--- include/unixconf.h.orig	2022-03-07 23:57:15 UTC
 +++ include/unixconf.h
 @@ -20,13 +20,13 @@
   */
@@ -16,7 +16,7 @@
                       /* of Linux */
  /* #define HPUX */   /* Hewlett-Packard's Unix, version 6.5 or higher */
                       /* use SYSV for < v6.5 */
-@@ -315,7 +315,7 @@
+@@ -317,7 +317,7 @@
  #endif
  
  #if defined(BSD) || defined(ULTRIX)
diff --git a/games/xnethack/files/patch-sys-unix-Makefile.doc b/games/xnethack/files/patch-sys-unix-Makefile.doc
index d9d793b86507..3e70c98d130d 100644
--- a/games/xnethack/files/patch-sys-unix-Makefile.doc
+++ b/games/xnethack/files/patch-sys-unix-Makefile.doc
@@ -1,8 +1,11 @@
---- sys/unix/Makefile.doc.orig	2021-03-22 22:28:14 UTC
+--- sys/unix/Makefile.doc.orig	2022-03-07 23:57:15 UTC
 +++ sys/unix/Makefile.doc
-@@ -66,15 +66,15 @@ Guidebook.dvi:	Guidebook.tex
- 	latex Guidebook.tex
- 
+@@ -73,17 +73,17 @@ Guidebook.dvi	: Guidebook.tex
+ # (note: 'make makedefs', not 'make $(MAKEDEFS)')
+ $(MAKEDEFS)	: ../util/makedefs.c ../include/config.h ../src/mdlib.c \
+ 		  ../util/mdgrep.h
+-	( cd ../util ; make makedefs )
++	( cd ../util ; ${MAKE} makedefs )
  
 -GAME	= nethack
 -MANDIR	= /usr/man/man6
@@ -22,7 +25,7 @@
  # manual installation for most SYSV-style systems
  # GAMEMANCREATE = cat nethack.6 | $(NHGREP) | nroff -man - >
  # RCVRMANCREATE = cat recover.6 | $(NHGREP) | nroff -man - >
-@@ -82,10 +82,10 @@ MDMANCREATE = cat makedefs.6 | $(NHGREP) >
+@@ -91,10 +91,10 @@ MDMANCREATE = cat makedefs.6 | $(NHGREP) >
  # MDMANCREATE = cat makedefs.6 | $(NHGREP) | nroff -man - >
  
  manpages:
diff --git a/games/xnethack/files/patch-sys-unix-Makefile.src b/games/xnethack/files/patch-sys-unix-Makefile.src
index 306cfd00fab6..d9073ce22b96 100644
--- a/games/xnethack/files/patch-sys-unix-Makefile.src
+++ b/games/xnethack/files/patch-sys-unix-Makefile.src
@@ -1,6 +1,6 @@
---- sys/unix/Makefile.src.orig	2021-03-22 22:28:14 UTC
+--- sys/unix/Makefile.src.orig	2022-03-07 23:57:15 UTC
 +++ sys/unix/Makefile.src
-@@ -169,9 +169,17 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(
+@@ -169,14 +169,22 @@ SYSOBJ = $(TARGETPFX)ioctl.o $(TARGETPFX)unixmain.o $(
  
  # flags for debugging:
  # CFLAGS = -g -I../include
@@ -15,11 +15,17 @@
  #CFLAGS = -O -I../include
 -#LFLAGS =
 +LFLAGS += -L${LUA_LIBDIR}
-+LINK = $(CC)
++LINK ?= $(CC)
  
  # The Qt and Be window systems are written in C++, while the rest of
  # NetHack is standard C.  If using Qt, uncomment the LINK line here to get
-@@ -297,6 +305,29 @@ WINBEOBJ =
+ # the C++ libraries linked in.
+-CXXFLAGS = $(CCXXFLAGS) -I. -I$(QTDIR)/include $(QTCXXFLAGS)
++CXXFLAGS += -I. -I../include -I${LUA_INCDIR}
+ CXX ?= g++
+ MOC ?= moc
+ MOCPATH ?= $(QTDIR)/bin/$(MOC)
+@@ -305,6 +313,29 @@ WINBEOBJ =
  # Curses - Karl Garrison, Tangles
  #WINSRC = $(WINCURSESSRC)
  #WINOBJ = $(WINCURSESOBJ)
@@ -49,7 +55,7 @@
  #
  # on some systems the termcap library is in -ltermcap or -lcurses
  # on 386 Xenix, the -ltermlib tputs() seems not to work; use -lcurses instead
-@@ -313,6 +344,7 @@ WINBEOBJ =
+@@ -321,6 +352,7 @@ WINBEOBJ =
  # WINTTYLIB = -lcurses16
  # WINTTYLIB = -lncurses
  #WINTTYLIB = -ltermlib
@@ -57,7 +63,7 @@
  #
  # libraries for X11
  # If USE_XPM is defined in config.h, you will also need -lXpm here.
-@@ -320,10 +352,13 @@ WINBEOBJ =
+@@ -328,16 +360,19 @@ WINBEOBJ =
  # WINX11LIB = -lXaw -lXmu -lXt -lX11
  # WINX11LIB = -lXaw -lXmu -lXext -lXt -lXpm -lX11 -lm
  # WINX11LIB = -lXaw -lXmu -lXpm -lXext -lXt -lX11 -lSM -lICE -lm # BSD/OS 2.0
@@ -67,12 +73,19 @@
  # libraries for Qt 3
 -WINQT3LIB = -L$(QTDIR)/lib -lqt
 +#WINQTLIB = -L$(QTDIR)/lib -lqt
-+WINQT3LIB = ${QTCFGLIBS} ${LIBQT}
-+WINQTLIB = ${QTCFGLIBS} ${LIBQT}
++#WINQT3LIB = ${QTCFGLIBS} ${LIBQT}
++#WINQTLIB = ${QTCFGLIBS} ${LIBQT}
  #
  # libraries for Qt 4
  WINQT4LIB = `pkg-config QtGui --libs`
-@@ -339,7 +374,7 @@ WINBELIB = -lbe
+ #
+ # libraries for Qt 5 (use with WINQTSRC and WINQTOBJ)
+-WINQT5LIB = `pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs`
++WINQTLIB = `pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs`
+ #
+ # libraries for KDE (with Qt)
+ WINKDELIB = -lkdecore -lkdeui -lXext
+@@ -347,7 +382,7 @@ WINBELIB = -lbe
  #
  # libraries for curses port
  # link with ncurses
@@ -81,7 +94,7 @@
  # link with pdcurses for SDL, installed in a separate directory
  #WINCURSESLIB = -L/usr/local/lib/pdcurses -lpdcurses -lSDL
  # same as above, for XCurses
-@@ -349,6 +384,18 @@ WINCURSESLIB = -lncurses
+@@ -357,6 +392,18 @@ WINCURSESLIB = -lncurses
  #
  # For Curses
  #WINLIB = $(WINCURSESLIB)
@@ -100,16 +113,16 @@
  #
  # some platforms need to build the support libraries
  # BUILDMORE = $(TARGETPFX)pdcurses.a
-@@ -384,7 +431,7 @@ WINCURSESLIB = -lncurses
- # LIBS =
- 
- # make NetHack
--GAME     = xnethack
-+GAME     = xnethack
- # GAME     = nethack.prg
- GAMEBIN = $(GAME)
+@@ -412,7 +459,7 @@ AWK	= awk
+ # skip it--if nethack's sources don't reside in a git repository than
+ # the script which creates that file will fail benignly and 'makedefs -v'
+ # will proceed without it
+-GITINFO=1
++GITINFO=0
  
-@@ -412,7 +459,7 @@ GITINFO=1
+ # if you change this to 1, feedback while building will omit -Dthis -Wthat
+ # -Isomewhere so that each file being compiled is listed on one short line;
+@@ -420,7 +467,7 @@ GITINFO=1
  # (rather than just in suffix default rule), such as is implemented by
  # gnu make and others which have picked up its extensions;
  # allowed values are 0, 1, and empty (which behaves like 0)
@@ -118,17 +131,16 @@
  
  # ----------------------------------------
  #
-@@ -465,7 +512,8 @@ PACKAGE=@true
+@@ -473,7 +520,7 @@ PACKAGE=@true
  MAKEDEFS = ../util/makedefs
  
  # -lm required by lua
--LUALIB = ../lib/lua/liblua.a -lm
-+#LUALIB = ../lib/lua/liblua.a -lm
-+LUALIB = -llua-${LUA_VER} -lm
+-LUALIB = ../lib/lua/liblua.a -lm $(DLLIB)
++LUALIB = -llua-${LUA_VER} -lm $(DLLIB)
  
  # timestamp files to reduce `make' overhead and shorten .o dependency lists
  CONFIG_H = ../src/config.h-t
-@@ -654,7 +702,7 @@ DUMB.Setup:	../include/extern.h
+@@ -668,7 +715,7 @@ DUMB.Setup:	../include/extern.h
  	cp ../include/extern.DUMB ../include/extern.h
  	@touch DUMB.Setup
  
@@ -137,9 +149,9 @@
  	@( cd .. ; $(MAKE) lua_support )
  
  #	dependencies for makedefs and its outputs, which the util
-@@ -673,11 +721,11 @@ objects.o:
+@@ -687,11 +734,11 @@ objects.o:
  
- # Qt 3 windowport meta-object-compiler output
+ # outdated Qt 3 windowport meta-object-compiler output
  qt3_kde0.moc: ../win/Qt3/qt3_kde0.h
 -	$(QTDIR)/bin/moc -o qt3kde0.moc ../win/Qt3/qt3_kde0.h
 +	${MOC} -o qt3kde0.moc ../win/Qt3/qt3_kde0.h
@@ -147,8 +159,8 @@
 -	$(QTDIR)/bin/moc -o qt3win.moc ../win/Qt3/qt3_win.h
 +	${MOC} -o qt3win.moc ../win/Qt3/qt3_win.h
  qt3tableview.moc: ../win/Qt3/qt3tableview.h
--	$(QTDIR)/bin/moc -o qt3tableview.moc ../win/Qt/qt3tableview.h
-+	${MOC} -o qt3tableview.moc ../win/Qt/qt3tableview.h
+-	$(QTDIR)/bin/moc -o qt3tableview.moc ../win/Qt3/qt3tableview.h
++	${MOC} -o qt3tableview.moc ../win/Qt3/qt3tableview.h
  
- # Qt 4 windowport meta-object-compiler output
- qt_kde0.moc : ../win/Qt/qt_kde0.h
+ #	build monst.o and objects.o before executing '$(MAKE) makedefs'
+ $(MAKEDEFS): $(FIRSTOBJ) \
diff --git a/games/xnethack/files/patch-sys-unix-Makefile.top b/games/xnethack/files/patch-sys-unix-Makefile.top
index 7dd119a0717f..feff1aaed068 100644
--- a/games/xnethack/files/patch-sys-unix-Makefile.top
+++ b/games/xnethack/files/patch-sys-unix-Makefile.top
@@ -1,96 +1,87 @@
---- sys/unix/Makefile.top.orig	2021-03-22 22:28:14 UTC
+--- sys/unix/Makefile.top.orig	2022-03-07 23:57:15 UTC
 +++ sys/unix/Makefile.top
-@@ -20,18 +20,18 @@ NHSROOT=.
- 
- # make NetHack
- #PREFIX	 = /usr
--GAME     = xnethack
-+GAME     = xnethack
+@@ -25,15 +25,15 @@ NHSROOT=.
+ GAME     = xnethack
  # GAME     = nethack.prg
  #GAMEUID  = games
 -#GAMEGRP  = bin
 +GAMEGRP  = games
  
- # Permissions - some places use setgid instead of setuid, for instance
- # See also the option "SECURE" in include/config.h
+ #	Permissions - some places use setgid instead of setuid, for instance.
+ #	See also the option "SECURE" in include/config.h.
 -#GAMEPERM = 04755
--FILEPERM = 0644
 +GAMEPERM = 02755
-+FILEPERM = 0664
+ FILEPERM = 0644
  # VARFILEPERM = 0644
  EXEPERM  = 0755
 -DIRPERM  = 0755
 +DIRPERM  = 0775
  # VARDIRPERM = 0755
  
- # VARDIR may also appear in unixconf.h as "VAR_PLAYGROUND" else HACKDIR
-@@ -41,14 +41,15 @@ DIRPERM  = 0755
- # therefore there should not be anything in HACKDIR that you want to keep
- # (if there is, you'll have to do the installation by hand or modify the
- # instructions)
--#HACKDIR  = $(PREFIX)/games/lib/$(GAME)dir
+ #	VARDIR may also appear in unixconf.h as "VAR_PLAYGROUND" else HACKDIR
+@@ -44,10 +44,12 @@ DIRPERM  = 0755
+ #	keep (if there is, you'll have to do the installation by hand or
+ #	modify the install commands below).
+ #HACKDIR  = $(PREFIX)/games/lib/$(GAME)dir
 -#VARDIR  = $(HACKDIR)
-+HACKDIR  = %%HACKDIR%%
++HACKDIR = %%HACKDIR%%
++INSTDIR = ${HACKDIR}
 +VARDIR  = $(HACKDIR)
-+INSTDIR = $(HACKDIR)
- # Where nethack.sh in installed.  If this is not defined, the wrapper is not used.
+ #	Where nethack.sh is installed (as 'nethack').
+ #	If this is not defined, the shell wrapper script is not used.
 -#SHELLDIR = $(PREFIX)/games
-+SHELLDIR = ${PREFIX}/bin
++SHELLDIR = $(PREFIX)/bin
  
+ #	Extra data files depending upon the interface(s) built into nethack.
  # per discussion in Install.X11 and Install.Qt
- #VARDATND =
- # VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
--# VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
-+VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
- # for Atari/Gem
- # VARDATND = nh16.img title.img GEM_RSC.RSC rip.img
-@@ -75,7 +76,7 @@ VARDAT = $(VARDATD) $(VARDATND)
- #CHGRP = chgrp
- 
- # Lua version
--LUA_VERSION = 5.4.2
-+LUA_VERSION = ${LUA_VER}
+@@ -62,7 +64,7 @@ DIRPERM  = 0755
+ #	X11 with GRAPHIC_TOMBSTONE (requires 'xpm'):
+ # VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
+ #	both X11 and Qt:
+-# VARDATND = x11tiles nhtiles.bmp NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
++VARDATND = x11tiles nhtiles.bmp NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
+ #	Qt without X11; assumes GRAPHIC_TOMBSTONE:
+ # VARDATND = nhtiles.bmp pet_mark.xbm pilemark.xbm rip.xpm
  
- #
- # end of configuration
-@@ -108,7 +109,7 @@ all:    $(ALLDEP)
+@@ -123,7 +125,7 @@ all:    $(ALLDEP)
  $(GAME): lua_support
  	( cd src ; $(MAKE) $(GAME) )
  
 -lua_support: $(TOPLUALIB) include/nhlua.h
 +lua_support: include/nhlua.h
  	@true
- lib/lua-$(LUA_VERSION)/src/liblua.a: lib/lua-$(LUA_VERSION)/src/lua.h
- 	( cd lib/lua-$(LUA_VERSION)/src \
-@@ -116,13 +117,11 @@ lib/lua-$(LUA_VERSION)/src/liblua.a: lib/lua-$(LUA_VER
- lib/lua/liblua.a: lib/lua-$(LUA_VERSION)/src/liblua.a
- 	@( if [ ! -d lib/lua ] ; then mkdir -p lib/lua ; fi )
- 	cp lib/lua-$(LUA_VERSION)/src/liblua.a $@
+ $(LUATOP)/liblua.a: $(LUAHEADERS)/lua.h
+ 	( cd $(LUATOP) \
+@@ -131,13 +133,11 @@ $(LUATOP)/liblua.a: $(LUAHEADERS)/lua.h
+ lib/lua/liblua.a: $(LUATOP)/liblua.a
+ 	@( if test -d lib/lua ; then true ; else mkdir -p lib/lua ; fi )
+ 	cp $(LUATOP)/liblua.a $@
 -include/nhlua.h: $(TOPLUALIB)
 +include/nhlua.h:
  	echo '/* nhlua.h - generated by top Makefile */' > $@
--	@echo '#include "../lib/lua-$(LUA_VERSION)/src/lua.h"' >> $@
+-	@echo '#include "../$(LUAHEADERS)/lua.h"' >> $@
 -	@sed -e '/(lua_error)/!d' -e '/(lua_error)/s/;/ NORETURN;/1' \
--		< lib/lua-$(LUA_VERSION)/src/lua.h >> $@
--	@echo '#include "../lib/lua-$(LUA_VERSION)/src/lualib.h"' >> $@
--	@echo '#include "../lib/lua-$(LUA_VERSION)/src/lauxlib.h"' >> $@
+-		< $(LUAHEADERS)/lua.h >> $@
+-	@echo '#include "../$(LUAHEADERS)/lualib.h"' >> $@
+-	@echo '#include "../$(LUAHEADERS)/lauxlib.h"' >> $@
 +	@echo '#include <lua.h>' >> $@
 +	@echo '#include <lualib.h>' >> $@
 +	@echo '#include <lauxlib.h>' >> $@
  	@echo '/*nhlua.h*/' >> $@
- 
- # Note: many of the dependencies below are here to allow parallel make
-@@ -234,39 +233,22 @@ dofiles:
+ # LUATESTTARGET is this by default
+ lib/lua-$(LUA_VERSION)/src/lua.h:
+@@ -258,39 +258,22 @@ dofiles:
  		-e '}' 					\
  	  	-e '$$s/.*/nodlb/p' < dat/options` ;	\
  	$(MAKE) dofiles-$${target-nodlb}
 -	cp src/$(GAME) $(INSTDIR)
 -	cp util/recover $(INSTDIR)
 -	-if test -n '$(SHELLDIR)'; then rm -f $(SHELLDIR)/$(GAME); fi
+-	if test -n '$(SHELLDIR)'; then \
 +	cp src/$(GAME) ${DESTDIR}$(INSTDIR)/$(GAME)
 +	cp util/recover ${DESTDIR}$(INSTDIR)
 +	-if test -n '${DESTDIR}$(SHELLDIR)'; then rm -f ${DESTDIR}$(SHELLDIR)/$(GAME); fi
- 	if test -n '$(SHELLDIR)'; then \
++	if test -n '${DESTDIR}$(SHELLDIR)'; then \
  		sed -e 's;/usr/games/lib/nethackdir;$(HACKDIR);' \
  		-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
  		< sys/unix/nethack.sh \
@@ -127,22 +118,7 @@
  #
  # This is not part of the dependency build hierarchy.
  # It requires an explicit "make fetch-Lua".
-@@ -283,13 +265,9 @@ fetch-Lua:
- update: $(GAME) recover $(VARDAT) spec_levs
- #	(don't yank the old version out from under people who're playing it)
- 	-mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old
--	-mv $(INSTDIR)/nhdat $(INSTDIR)/nhdat.old
-+	-mv ${DESTDIR}$(INSTDIR)/nhdat ${DESTDIR}$(INSTDIR)/nhdat.old
- # set up new versions of the game files
- 	( $(MAKE) dofiles )
--# touch time-sensitive files
--	-touch -c $(VARDIR)/bones* $(VARDIR)/?lock* $(VARDIR)/wizard*
--	-touch -c $(VARDIR)/save/* $(VARDIR)/whereis/*
--	touch $(VARDIR)/perm $(VARDIR)/record
- # and a reminder
- 	@echo You may also want to install the man pages via the doc Makefile.
- 
-@@ -300,25 +278,16 @@ install: rootcheck $(GAME) recover $(VARDAT) spec_levs
+@@ -327,25 +310,17 @@ install: rootcheck $(GAME) recover $(VARDAT) spec_levs
  	true; $(PREINSTALL)
  # set up the directories
  # not all mkdirs have -p; those that don't will create a -p directory
@@ -153,7 +129,7 @@
 +	-if test -n '${DESTDIR}$(SHELLDIR)'; then \
 +		mkdir -p ${DESTDIR}$(SHELLDIR); fi
 +	rm -rf ${DESTDIR}$(INSTDIR) ${DESTDIR}$(VARDIR)
-+	-mkdir -p ${DESTDIR}$(INSTDIR) ${DESTDIR}$(VARDIR) ${DESTDIR}$(VARDIR)/save ${DESTDIR}$(VARDIR)/whereis
++	-mkdir -p ${DESTDIR}$(INSTDIR) ${DESTDIR}$(VARDIR)/save ${DESTDIR}$(VARDIR)/whereis
  	if test -d ./-p; then rmdir ./-p; fi
 -	-$(CHOWN) $(GAMEUID) $(INSTDIR) $(VARDIR) $(VARDIR)/save $(VARDIR)/whereis
 -	$(CHGRP) $(GAMEGRP) $(INSTDIR) $(VARDIR) $(VARDIR)/save $(VARDIR)/whereis
@@ -163,13 +139,14 @@
  # set up the game files
  	( $(MAKE) dofiles )
  # set up some additional files
--	touch $(VARDIR)/perm $(VARDIR)/record $(VARDIR)/logfile \
--		$(VARDIR)/xlogfile $(VARDIR)/livelog
--	-( cd $(VARDIR) ; \
--		$(CHOWN) $(GAMEUID) perm record logfile xlogfile livelog ; \
--		$(CHGRP) $(GAMEGRP) perm record logfile xlogfile livelog ; \
--		chmod $(VARFILEPERM) perm record logfile xlogfile livelog )
-+	touch ${DESTDIR}$(VARDIR)/perm ${DESTDIR}$(VARDIR)/record ${DESTDIR}$(VARDIR)/logfile ${DESTDIR}$(VARDIR)/xlogfile
- 	true; $(POSTINSTALL)
+-	touch $(VARDIR)/perm $(VARDIR)/record $(VARDIR)/logfile $(VARDIR)/xlogfile \
+-         $(VARDIR)/livelog
+-	-( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm record logfile xlogfile livelog ; \
+-			$(CHGRP) $(GAMEGRP) perm record logfile xlogfile livelog ; \
+-			chmod $(VARFILEPERM) perm record logfile xlogfile livelog )
+-	true; $(POSTINSTALL)
++	touch ${DESTDIR}$(VARDIR)/perm ${DESTDIR}$(VARDIR)/record \
++            ${DESTDIR}$(VARDIR)/logfile ${DESTDIR}$(VARDIR)/xlogfile ${DESTDIR}$(VARDIR)/livelog
  # and a reminder
  	@echo You may also want to reinstall the man pages via the doc Makefile.
+ 
diff --git a/games/xnethack/files/patch-sys-unix-Makefile.utl b/games/xnethack/files/patch-sys-unix-Makefile.utl
index 10fd6bc5aa42..35c331bd7b72 100644
--- a/games/xnethack/files/patch-sys-unix-Makefile.utl
+++ b/games/xnethack/files/patch-sys-unix-Makefile.utl
@@ -1,6 +1,6 @@
---- sys/unix/Makefile.utl.orig	2021-03-22 22:28:14 UTC
+--- sys/unix/Makefile.utl.orig	2022-03-07 23:57:15 UTC
 +++ sys/unix/Makefile.utl
-@@ -93,18 +93,25 @@ NHSROOT=..
+@@ -98,18 +98,25 @@ NHSROOT=..
  # flags for debugging:
  # CFLAGS = -g -I../include
  
diff --git a/games/xnethack/files/patch-sys-unix-sysconf b/games/xnethack/files/patch-sys-unix-sysconf
index 4629279cc86d..1647d57bd4ea 100644
--- a/games/xnethack/files/patch-sys-unix-sysconf
+++ b/games/xnethack/files/patch-sys-unix-sysconf
@@ -1,6 +1,6 @@
---- sys/unix/sysconf.orig	2021-03-22 22:28:14 UTC
+--- sys/unix/sysconf.orig	2022-03-07 23:57:15 UTC
 +++ sys/unix/sysconf
-@@ -136,7 +136,7 @@ LLC_TURNS=3000
+@@ -134,7 +134,7 @@ LIVELOG=0x1FFF
  #   %D current time, YYYYMMDDhhmmss format
  #   %n player name
  #   %N first character of player name
diff --git a/games/xnethack/files/patch-util-makedefs.c b/games/xnethack/files/patch-util-makedefs.c
index 13d38f3bfba0..e6770b1f0cd3 100644
--- a/games/xnethack/files/patch-util-makedefs.c
+++ b/games/xnethack/files/patch-util-makedefs.c
@@ -1,4 +1,4 @@
---- util/makedefs.c.orig	2021-03-22 22:28:14 UTC
+--- util/makedefs.c.orig	2022-03-07 23:57:15 UTC
 +++ util/makedefs.c
 @@ -116,6 +116,7 @@ static struct version_info version;
  #define MAXFNAMELEN 600
@@ -8,7 +8,7 @@
  
  #ifdef FILE_PREFIX
  /* if defined, a first argument not starting with - is
-@@ -229,6 +230,12 @@ main(int argc, char *argv[])
+@@ -230,6 +231,12 @@ main(int argc, char *argv[])
          return 1;
      }
  
@@ -21,9 +21,9 @@
  #ifdef FILE_PREFIX
      if (argc >= 2 && argv[1][0] != '-') {
          file_prefix = argv[1];
-@@ -964,12 +971,12 @@ do_rnd_access_file(const char* fname, const char* defl
-        more likely to be picked than normal but it's nothing to worry about */
-     (void) fputs(xcrypt(deflt_content), ofp);
+@@ -989,12 +996,12 @@ do_rnd_access_file(
+         Strcat(buf, "\n"); /* so make sure that the default one does too    */
+     (void) fputs(xcrypt(padline(buf, padlength)), ofp);
  
 -    tfp = getfp(DATA_TEMPLATE, "grep.tmp", WRTMODE, FLG_TEMPFILE);
 +    tfp = getfp(DATA_TEMPLATE, tempfilename, WRTMODE, FLG_TEMPFILE);
@@ -35,8 +35,8 @@
 +    ifp = getfp(DATA_TEMPLATE, tempfilename, RDTMODE, 0);
  #endif
      while ((line = fgetline(ifp)) != 0) {
-         if (line[0] != '#' && line[0] != '\n')
-@@ -980,7 +987,7 @@ do_rnd_access_file(const char* fname, const char* defl
+         if (line[0] != '#' && line[0] != '\n') {
+@@ -1007,7 +1014,7 @@ do_rnd_access_file(
      Fclose(ofp);
  
  #ifdef HAS_NO_MKSTEMP
@@ -45,7 +45,7 @@
  #endif
      return;
  }
-@@ -1758,12 +1765,12 @@ do_dungeon(void)
+@@ -1791,12 +1798,12 @@ do_dungeon(void)
      }
      Fprintf(ofp, "%s", Dont_Edit_Data);
  
@@ -60,7 +60,7 @@
  #endif
      while ((line = fgetline(ifp)) != 0) {
          SpinCursor(3);
-@@ -1779,7 +1786,7 @@ do_dungeon(void)
+@@ -1812,7 +1819,7 @@ do_dungeon(void)
      Fclose(ofp);
  
  #ifdef HAS_NO_MKSTEMP
diff --git a/games/xnethack/files/patch-win-tty-termcap.c b/games/xnethack/files/patch-win-tty-termcap.c
index 9338a9c87743..4569b7e54fcd 100644
--- a/games/xnethack/files/patch-win-tty-termcap.c
+++ b/games/xnethack/files/patch-win-tty-termcap.c
@@ -1,6 +1,6 @@
---- win/tty/termcap.c.orig	2021-03-22 22:28:14 UTC
+--- win/tty/termcap.c.orig	2022-03-07 23:57:15 UTC
 +++ win/tty/termcap.c
-@@ -185,10 +185,6 @@ tty_startup(int *wid, int *hgt)
+@@ -188,10 +188,6 @@ tty_startup(int *wid, int *hgt)
          error("Terminal must backspace.");
  #else
          if (!(BC = Tgetstr("bc"))) { /* termcap also uses bc/bs */
diff --git a/games/xnethack/files/patch-win_Qt_qt__pre.h b/games/xnethack/files/patch-win_Qt_qt__pre.h
new file mode 100644
index 000000000000..5c32ef0f8dc0
--- /dev/null
+++ b/games/xnethack/files/patch-win_Qt_qt__pre.h
@@ -0,0 +1,11 @@
+--- win/Qt/qt_pre.h.orig	2022-03-11 00:02:45 UTC
++++ win/Qt/qt_pre.h
+@@ -28,7 +28,7 @@
+ #pragma GCC diagnostic ignored "-Wshadow"
+ #endif
+ 
+-#include <QtGlobal>
++#include <QtCore/QtGlobal>
+ 
+ /* QFontMetrics::width was deprecated in Qt 5.11 */
+ #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
diff --git a/games/xnethack/pkg-plist b/games/xnethack/pkg-plist
index 4cc6d9988bd1..28cdcc50fcee 100644
--- a/games/xnethack/pkg-plist
+++ b/games/xnethack/pkg-plist
@@ -79,6 +79,7 @@ bin/%%HACKNAME%%
 %%DATADIR%%/bigrm-1.lua
 %%DATADIR%%/bigrm-10.lua
 %%DATADIR%%/bigrm-11.lua
+%%DATADIR%%/bigrm-12.lua
 %%DATADIR%%/bigrm-2.lua
 %%DATADIR%%/bigrm-3.lua
 %%DATADIR%%/bigrm-4.lua
@@ -101,10 +102,12 @@ bin/%%HACKNAME%%
 %%DATADIR%%/help
 %%DATADIR%%/hh
 %%DATADIR%%/history
+%%DATADIR%%/invocation.lua
 %%DATADIR%%/juiblex.lua
 %%DATADIR%%/keyhelp
 %%DATADIR%%/knox.lua
 %%DATADIR%%/license
+@sample(games,games,664) %%DATADIR%%/livelog.sample
 @sample(games,games,664) %%DATADIR%%/logfile.sample
 %%DATADIR%%/medusa-1.lua
 %%DATADIR%%/medusa-2.lua
@@ -123,9 +126,12 @@ bin/%%HACKNAME%%
 %%DATADIR%%/minetn-6.lua
 %%DATADIR%%/minetn-7.lua
 %%DATADIR%%/minetn-8.lua
+%%DATADIR%%/nhcore.lua
 %%DATADIR%%/nhlib.lua
+%%DATADIR%%/nhtiles.bmp
 %%DATADIR%%/opthelp
 %%DATADIR%%/options
+%%DATADIR%%/optmenu
 %%DATADIR%%/oracle-1.lua
 %%DATADIR%%/oracle-2.lua
 %%DATADIR%%/oracle-3.lua
@@ -141,6 +147,7 @@ bin/%%HACKNAME%%
 @mode 02755
 %%DATADIR%%/recover
 @mode
+%%DATADIR%%/rip.xpm
 %%DATADIR%%/rumors
 %%DATADIR%%/sanctum.lua
 %%DATADIR%%/shirts
@@ -158,6 +165,7 @@ bin/%%HACKNAME%%
 %%DATADIR%%/tower1.lua
 %%DATADIR%%/tower2.lua
 %%DATADIR%%/tower3.lua
+%%DATADIR%%/tower4.lua
 %%DATADIR%%/tribute
 %%DATADIR%%/valley.lua
 %%DATADIR%%/water.lua