bsd build support

Originating from https://github.com/NetHack/NetHack/pull/1519,
there was an issue with the pull request's back-end fork or with
the pull request itself.

The code changes were applied manually instead, with credit to the
pull request's author, instead of being directly merged in via the
pull request.

Contributed by @SirWumpus on GitHub.

Also,
- fixed a bit of conditional code in include/unixconf.h, where the
  #else clause remained out of reach for non-bsd systems, but was
  needed..
- added a disclaimer to the contributed sys/unix/hints/netbsd.500.
This commit is contained in:
Anthony C Howe
2026-05-13 12:49:45 -04:00
committed by nhmall
parent 46ab1ae213
commit afeb2f55c9
3 changed files with 98 additions and 11 deletions
+7 -2
View File
@@ -170,7 +170,7 @@
#ifdef AMS
#define AMS_MAILBOX "/Mailbox"
#else
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define DEF_MAILREADER "/usr/bin/mail"
#else
#define DEF_MAILREADER "/usr/ucb/Mail"
@@ -331,9 +331,14 @@
#include <sys/wait.h>
#endif
#if defined(__NetBSD__)
#define tparm2(s, x) tparm(s,x,0,0,0,0,0,0,0,0)
#else
#define tparm2(s, x) tparm(s,x)
#endif
#if defined(BSD) || defined(ULTRIX)
#if !defined(DGUX) && !defined(SUNOS4)
#if !defined(DGUX) && !defined(SUNOS4) && !defined(__NetBSD__)
#define memcpy(d, s, n) bcopy(s, d, n)
#define memcmp(s1, s2, n) bcmp(s2, s1, n)
#endif
+78
View File
@@ -0,0 +1,78 @@
#
# NetHack 5.0 unix $NHDT-Date: 1596498428 2020/08/03 23:47:08 $ $NHDT-Branch: NetHack-5.0 $:$NHDT-Revision: 1.14 $
# Copyright 2026 by Anthony C Howe.
# NetHack may be freely redistributed. See license for details.
#
# This is a contributed file. The NetHack Development Team makes this
# file available so that others may benefit, but may not be able to
# support or maintain it. Use at your own risk.
#
#-PRE
# unix hints file
# This hints file provides the legacy configuration that NetHack has shipped
# with historically - this means you will most likely need to hand edit .h
# and Makefiles.
PREFIX=/usr/local
# Binaries and supporting data.
HACKDIR=$(PREFIX)/libexec/nethackdir
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# Careful, this directory is deleted on install.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
INSTDIR=$(HACKDIR)
# Save games
VARDIR=/var/games/nethackdir
# Home for nethask.sh wrapper. If undefined, no wrapper installed.
# Suggest leaving /usr/games as-is from bsdgames.tgz.
SHELLDIR=$(PREFIX)/bin
CFLAGS=-O -I../include -USYSV -DBSD -DHACKDIR='"$(HACKDIR)"' -DVAR_PLAYGROUND='"$(VARDIR)"'
LINK=$(CC)
WINSRC = $(WINTTYSRC)
WINOBJ = $(WINTTYOBJ)
WINLIB = $(WINTTYLIB)
WINTTYLIB=-ltermcap
CHOWN=chown
CHGRP=chgrp
GAMEUID = games
GAMEGRP = games
GAMEPERM = 04755
VARFILEPERM = 0644
VARDIRPERM = 0755
.ifdef MAKEFILE_DOC
MAKEDEFS = ../util/makedefs
NEEDMAKEDEFS = $(MAKEDEFS)
.if exists (/usr/pkg/bin/groff)
NROFF = /usr/pkg/bin/groff
.else
NROFF = groff
.endif
# NROFF_FLAGS comes from a hints file
GUIDEBOOK = Guidebook # regular ASCII file
COLCMD = col -bx
PSCMD = $(NROFF)
NHGREP = $(MAKEDEFS) --grep --input - --output -
GUIDEBOOK_MN_SRC = Guidebook.mn
GUIDEBOOK_MN = $(GUIDEBOOK_MN_SRC)
GUIDE_PREFORMAT = cat $(GUIDEBOOK_MN) | $(NHGREP) | tbl tmac.n -
ONEPAGE_PREFORMAT = cat Gbk-1pg-pfx.mn $(GUIDEBOOK_MN) Gbk-1pg-sfx.mn \
| $(NHGREP) | tbl tmac.n -
ONEPAGECMD = $(ONEPAGE_PREFORMAT) | $(NROFF) -c -Tascii $(NROFF_FLAGS) \
| $(COLCMD)
GUIDECMD = export GROFF_NO_SGR=1; \
$(GUIDE_PREFORMAT) | $(NROFF) -c -Tascii $(NROFF_FLAGS) \
| $(COLCMD)
GUIDEBOOK_TEX_SRC = Guidebook.tex
GUIDEBOOK_TEX = $(GUIDEBOOK_TEX_SRC)
.endif # MAKEFILE_DOC
+13 -9
View File
@@ -41,7 +41,12 @@ static char *nh_VE = (char *) 0; /* cursor_normal */
/*static char *nh_VS = (char *) 0;*/ /* cursor_visible (highlighted cursor) */
static char *nh_Ic = (char *) 0; /* initialize_color */
static char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE;
#if !defined(__NetBSD__)
static char *UP, *BC;
static char PC = '\0';
#endif
static char *HO, *CL, *CE, *XD, *SO, *SE, *TI, *TE;
static char *VS, *VE;
static char *ME, *MR, *MB, *MH, *MD;
static char *ZH, *ZR;
@@ -49,7 +54,6 @@ static char *ZH, *ZR;
#ifdef TERMLIB
boolean dynamic_HIHE = FALSE;
static int SG;
static char PC = '\0';
static char tbuf[512];
#endif /*TERMLIB*/
@@ -973,10 +977,10 @@ init_hilite(void)
if (colors >= 16) {
for (c = 0; c < SIZE(ti_map); c++) {
/* system colors */
scratch = tparm(setf, ti_map[c].nh_color);
scratch = tparm2(setf, ti_map[c].nh_color);
hilites[ti_map[c].nh_color] = dupstr(scratch);
/* bright colors */
scratch = tparm(setf, ti_map[c].nh_bright_color);
scratch = tparm2(setf, ti_map[c].nh_bright_color);
hilites[ti_map[c].nh_bright_color] = dupstr(scratch);
}
} else {
@@ -987,7 +991,7 @@ init_hilite(void)
while (c--) {
char *work;
scratch = tparm(setf, ti_map[c].ti_color);
scratch = tparm2(setf, ti_map[c].ti_color);
work = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(work, MD);
hilites[ti_map[c].nh_bright_color] = work;
@@ -998,10 +1002,10 @@ init_hilite(void)
}
if (colors >= 16) {
scratch = tparm(setf, COLOR_WHITE | BRIGHT);
scratch = tparm2(setf, COLOR_WHITE | BRIGHT);
hilites[CLR_WHITE] = dupstr(scratch);
} else {
scratch = tparm(setf, COLOR_WHITE);
scratch = tparm2(setf, COLOR_WHITE);
hilites[CLR_WHITE] = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(hilites[CLR_WHITE], MD);
Strcat(hilites[CLR_WHITE], scratch);
@@ -1012,7 +1016,7 @@ init_hilite(void)
if (iflags.wc2_darkgray) {
if (colors >= 16) {
scratch = tparm(setf, COLOR_BLACK|BRIGHT);
scratch = tparm2(setf, COLOR_BLACK|BRIGHT);
hilites[CLR_BLACK] = dupstr(scratch);
} else {
/* On many terminals, esp. those using classic PC CGA/EGA/VGA
@@ -1020,7 +1024,7 @@ init_hilite(void)
* produces a dark shade of gray that is visible against a
* black background. We can use it to represent black objects.
*/
scratch = tparm(setf, COLOR_BLACK);
scratch = tparm2(setf, COLOR_BLACK);
hilites[CLR_BLACK] = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(hilites[CLR_BLACK], MD);
Strcat(hilites[CLR_BLACK], scratch);