Description: Debian-specific patchset for slashem
 This is a collection of patches against slashem specifically for Debian.
 (TODO: Separate this gigantic patch into several smaller quilt-style patches)
Forwarded: not-needed
Last-Update: 05-13-2012

--- a/include/config.h
+++ b/include/config.h
@@ -7,6 +7,8 @@
 
 #undef SHORT_FILENAMES
 
+/* Include Debian specific magic */
+#include "debian.h"
 
 /*#define DEBUG*/
 /*#define DDEBUG*/
@@ -50,8 +52,8 @@
  * Define all of those you want supported in your binary.
  * Some combinations make no sense.  See the installation document.
  */
-#define TTY_GRAPHICS		/* good old tty based graphics */
-/* #define X11_GRAPHICS */	/* X11 interface */
+/* #define TTY_GRAPHICS	*/	/* good old tty based graphics */
+/* #define X11_GRAPHICS */      /* X11 interface */
 /* #define QT_GRAPHICS */	/* Qt Interface */
 /* #define KDE */		/* KDE Interface */
 /* #define GTK_GRAPHICS */	/* GTK Interface */
@@ -111,7 +113,7 @@
 # define USE_XPM		/* Use XPM format for images (required) */
 # define GRAPHIC_TOMBSTONE	/* Use graphical tombstone (rip.xpm) */
 # ifndef DEFAULT_WINDOW_SYS
-#  define DEFAULT_WINDOW_SYS "Qt"
+/* #  define DEFAULT_WINDOW_SYS "Qt"  /* Evil Qt windowing port */
 # endif
 #endif
 
@@ -179,7 +181,7 @@
  *  xpmtoppm <x11tiles.xpm | pnmscale 1.25 | pnmdepth 255 |
  *     ppmquant 90 | ppmtoxpm >x11tiles_big.xpm
  */
-/* # define USE_XPM */		/* Disable if you do not have the XPM library */
+# define USE_XPM		/* Disable if you do not have the XPM library */
 # ifdef USE_XPM
 #  define GRAPHIC_TOMBSTONE	/* Use graphical tombstone (rip.xpm) */
 # endif
@@ -202,7 +204,7 @@
 
 #ifndef WIZARD		/* allow for compile-time or Makefile changes */
 # ifndef KR1ED
-#  define WIZARD  "wizard" /* the person allowed to use the -D option */
+#  define WIZARD  "root" /* the person allowed to use the -D option */
 # else
 #  define WIZARD
 #  define WIZARD_NAME "wizard"
@@ -230,12 +232,12 @@
 
 #ifdef UNIX
 /* path and file name extension for compression program */
-# define COMPRESS "/usr/bin/compress" /* Lempel-Ziv compression */
-# define COMPRESS_EXTENSION ".Z"	     /* compress's extension */
+/* # define COMPRESS "/usr/bin/compress" */  /* Lempel-Ziv compression */
+/* # define COMPRESS_EXTENSION ".Z" */	     /* compress's extension */
 
 /* An example of one alternative you might want to use: */
-/* # define COMPRESS "/usr/local/bin/gzip" */   /* FSF gzip compression */
-/* # define COMPRESS_EXTENSION ".gz" */	     /* normal gzip extension */
+# define COMPRESS "/bin/gzip"    /* FSF gzip compression */
+# define COMPRESS_EXTENSION ".gz" 	/* normal gzip extension */
 
 /* # define COMPRESS "/usr/bin/bzip2"	*//* bzip2 compression */
 /* # define COMPRESS_EXTENSION ".bz2"	*//* bzip2 extension */
@@ -249,7 +251,7 @@
  *	a tar-like file, thus making a neater installation.  See *conf.h
  *	for detailed configuration.
  */
-/* #define DLB */             /* not supported on all platforms */
+#define DLB             /* not supported on all platforms */
 
 /*
  *	Defining INSURANCE slows down level changes, but allows games that
@@ -282,7 +284,7 @@
  * since the user might create files in a directory of his choice.
  * Of course SECURE is meaningful only if HACKDIR is defined.
  */
-/* #define SECURE */	/* do setuid(getuid()) after chdir() */
+#define SECURE	/* do setuid(getuid()) after chdir() */
 
 /*
  * If it is desirable to limit the number of people that can play Hack
--- /dev/null
+++ b/include/debian.h
@@ -0,0 +1,38 @@
+/* Configuration of Slash'em for Debian:
+ *
+ * This file includes a bit of magic to make it posible to build several
+ * window interfaces in seperate binaries without patching config.h.
+ */
+
+#if defined DEBIAN_TTY
+# define TTY_GRAPHICS
+# define NH_CONFIG_FILE     ".slashemrc"
+#endif
+
+#if defined DEBIAN_X11
+# define X11_GRAPHICS
+# define DEFAULT_WC_TILED_MAP
+# define DEFAULT_WINDOW_SYS "X11"
+# define NH_CONFIG_FILE     ".slashemrc-x11"
+#endif
+
+#if defined DEBIAN_SDL
+# define SDL_GRAPHICS
+# define DEFAULT_WC_TILED_MAP
+# define NH_CONFIG_FILE	    ".slashemrc-sdl"
+#endif
+
+#if defined DEBIAN_GTK
+# define PROXY_GRAPHICS
+# define GTK_GRAPHICS
+# define GTK_PROXY
+# define DEFAULT_WC_TILED_MAP
+# define NH_CONFIG_FILE     ".slashemrc-gtk"
+#endif
+
+#if defined DEBIAN_QT
+# define QT_GRAPHICS
+# define NH_CONFIG_FILE     ".slashemrc-qt"
+#endif
+
+#define USE_XPM
--- a/include/file.h
+++ b/include/file.h
@@ -41,3 +41,7 @@
 
 /* Environment Options Name */
 #define NETHACK_ENV_OPTIONS "@UPPER@OPTIONS"
+
+/* Include Debian configuration to overrule NH_CONFIG_FILE */
+#include "debian.h"
+
--- a/include/global.h
+++ b/include/global.h
@@ -35,7 +35,7 @@
 #define NH_CMDHELPAREA	FILE_AREA_SHARE
 #define NH_HISTORY		"history"	/* a file giving nethack's history */
 #define NH_HISTORY_AREA	FILE_AREA_SHARE
-#define NH_LICENSE		"license"	/* file with license information */
+#define NH_LICENSE		"copyright"	/* file with license information */
 #define NH_LICENSE_AREA	FILE_AREA_DOC
 #define NH_OPTIONFILE	"opthelp"	/* a file explaining runtime options */
 #define NH_OPTIONAREA	FILE_AREA_SHARE
--- a/include/unixconf.h
+++ b/include/unixconf.h
@@ -20,9 +20,11 @@
  */
 
 /* define exactly one of the following four choices */
-/* #define BSD 1 */	/* define for 4.n/Free/Open/Net BSD  */
+#if defined(__FreeBSD_kernel__)
+#define BSD 1	/* define for 4.n/Free/Open/Net BSD  */
 			/* also for relatives like SunOS 4.x, DG/UX, and */
 			/* older versions of Linux */
+#endif
 /* #define ULTRIX */	/* define for Ultrix v3.0 or higher (but not lower) */
 			/* Use BSD for < v3.0 */
 			/* "ULTRIX" not to be confused with "ultrix" */
@@ -33,12 +35,14 @@
 
 
 /* define any of the following that are appropriate */
-#define SVR4		/* use in addition to SYSV for System V Release 4 */
+/* #define SVR4	*/	/* use in addition to SYSV for System V Release 4 */
 			/* including Solaris 2+ */
 #define NETWORK		/* if running on a networked system */
 			/* e.g. Suns sharing a playground through NFS */
 /* #define SUNOS4 */	/* SunOS 4.x */
-/* #define LINUX */	/* Another Unix clone */
+#if defined(LINUX)
+#define LINUX   	/* Another Unix clone */
+#endif
 /* #define CYGWIN32 */	/* Unix on Win32 -- use with case sensitive defines */
 /* #define GENIX */	/* Yet Another Unix Clone */
 /* #define HISX */	/* Bull Unix for XPS Machines */
@@ -113,7 +117,7 @@
  * FILE_AREA_DOC	For human-readable documentation
  */
 
-/* #define FILE_AREAS */		/* Use file areas */
+#define FILE_AREAS		/* Use file areas */
 
 #ifdef FILE_AREAS
 
--- a/src/options.c
+++ b/src/options.c
@@ -169,7 +169,7 @@
 #else
 	{"news", (boolean *)0, FALSE, SET_IN_FILE},
 #endif
-	{"null", &flags.null, TRUE, SET_IN_GAME},
+	{"null", &flags.null, FALSE, SET_IN_GAME},
 #ifdef MAC
 	{"page_wait", &flags.page_wait, TRUE, SET_IN_GAME},
 #else
--- a/src/topten.c
+++ b/src/topten.c
@@ -33,7 +33,7 @@
 #define NAMSZ	10
 #define DTHSZ	100
 #define ROLESZ   3
-#define PERSMAX	 3		/* entries per name/uid per char. allowed */
+#define PERSMAX	 10		/* entries per name/uid per char. allowed */
 #define POINTSMIN	1	/* must be > 0 */
 #define ENTRYMAX	100	/* must be >= 10 */
 
--- a/sys/unix/Makefile.src
+++ b/sys/unix/Makefile.src
@@ -1,3 +1,6 @@
+# Determine kernel name
+UNAME := $(shell uname -s)
+
 #	NetHack Makefile.
 #	SCCS Id: @(#)Makefile.src	3.4	2002/03/02
 
@@ -122,13 +125,18 @@
 # CFLAGS = -O -I../include -I/usr/X11/include
 # LFLAGS = -L/usr/X11/lib
 
-# flags for Linux
+# flags for Linux and kFreeBSD
 #   compile normally
-# CFLAGS = -O2 -fomit-frame-pointer -I../include
-# LFLAGS = -L/usr/X11R6/lib
+#   disable optimization on non-Linux archs due to FTBFS
+ifeq ($(UNAME),Linux)
+CFLAGS = -DDEBIAN_$(GUI) -O2 -fomit-frame-pointer -fstack-protector --param=ssp-buffer-size=4 -I../include -I/usr/X11R6/include
+else
+CFLAGS = -DDEBIAN_$(GUI) -fstack-protector --param=ssp-buffer-size=4 -I../include -I/usr/X11R6/include
+endif
+LFLAGS = -L/usr/X11R6/lib -Wl,-z,relro
 #   OR compile backwards compatible a.out format
-# CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include
-# LFLAGS = -b i486-linuxaout -L/usr/X11R6/lib
+# CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include -I/usr/X11/include
+# LFLAGS = -b i486-linuxaout -L/usr/X11/lib
 
 # flags for BeOS
 #   on a Mac/BeBox:
@@ -144,8 +152,8 @@
 # flags for debugging:
 # CFLAGS = -g -I../include
 
-CFLAGS = -O -I../include
-LFLAGS =
+# CFLAGS = -O -I../include
+# LFLAGS =
 
 # Only used for the Gnome interface.
 # When including the Gnome interface, you need to include gnome specific
@@ -163,6 +171,7 @@
 # RedHat 6.1
 # QTDIR = /usr/lib/qt-2.0.1
 #
+QTDIR= /usr
 QTLIBDIR=$(QTDIR)/lib
 QTINCDIR=$(QTDIR)/include
 QTBINDIR=$(QTDIR)/bin
@@ -178,10 +187,12 @@
 # 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
 # the C++ libraries linked in.
-CXXFLAGS = $(CFLAGS) -I. -I$(QTINCDIR)
-# Qt is C++, so define the compiler and linker thus required:
-CXX=g++
-#LINK=g++
+ifeq ($(GUI), "QT")
+  CXXFLAGS = $(CFLAGS) -I. -I$(QTINCDIR)
+  # Qt is C++, so define the compiler and linker thus required:
+  CXX=g++
+  LINK=g++
+endif
 #	For cross-compiling, eg. with gcc on Linux (see also CC further up):
 #CXX=arm-linux-g++
 #LINK=arm-linux-gcc
@@ -291,27 +302,37 @@
 SDLGL_CFLAGS = `sdl-config --cflags`
 
 # Use these declarations if you only want to support the TTY windowing system
-WINSRC = $(WINTTYSRC)
-WINOBJ = $(WINTTYOBJ)
+ifeq ($(GUI),TTY)
+  WINSRC = $(WINTTYSRC)
+  WINOBJ = $(WINTTYOBJ)
+endif
 # Use these declarations if you want to support the X11 windowing system
-# WINSRC = $(WINTTYSRC) $(WINX11SRC)
-# WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
+ifeq ($(GUI),X11)
+  WINSRC = $(WINTTYSRC) $(WINX11SRC)
+  WINOBJ = $(WINTTYOBJ) $(WINX11OBJ)
+endif
 # Use these declarations if you want to support the Qt windowing system
-# WINSRC = $(WINTTYSRC) $(WINQTSRC)
-# WINOBJ = $(WINTTYOBJ) $(WINQTOBJ)
+ifeq ($(GUI),QT)
+  WINSRC = $(WINTTYSRC) $(WINQTSRC)
+  WINOBJ = $(WINTTYOBJ) $(WINQTOBJ)
+endif
 # Use these declarations if you want to support a conventional
 # GTK windowing system (only useful if not installing setuid or setgid)
 # WINSRC = $(WINTTYSRC) $(WINGTKSRC) $(PROXYUTLSRC)
-# WINOBJ = $(WINTTYOBJ) $(WINGTKOBJ) $(PROXYUTLOBJ)
+###INOBJ = $(WINTTYOBJ) $(WINGTKOBJ) $(PROXYUTLOBJ)
 # Use these declarations if you want to support external windowing systems
 # and a proxified GTK windowing system (see Install.GTK)
-# WINSRC = $(WINTTYSRC) $(WINGTKSRC) \
-#	$(WINPROXYSRC) $(PROXYUTLSRC) $(PROXYCOMSRC) $(PROXYCLNTSRC)
-# WINOBJ = $(WINTTYOBJ) $(WINGTKOBJ) \
-#	$(WINPROXYOBJ) $(PROXYUTLOBJ) $(PROXYCOMOBJ) $(PROXYCLNTOBJ)
+ifeq ($(GUI),GTK)
+  WINSRC = $(WINTTYSRC) $(WINGTKSRC) \
+ 	$(WINPROXYSRC) $(PROXYUTLSRC) $(PROXYCOMSRC) $(PROXYCLNTSRC)
+  WINOBJ = $(WINTTYOBJ) $(WINGTKOBJ) \
+ 	$(WINPROXYOBJ) $(PROXYUTLOBJ) $(PROXYCOMOBJ) $(PROXYCLNTOBJ)
+endif
 # Use these declarations to only support the SDL/GL windowing systems
-# WINSRC = $(WINGLSRC)
-# WINOBJ = $(WINGLOBJ)
+ifeq ($(GUI),SDL)
+  WINSRC = $(WINGLSRC)
+  WINOBJ = $(WINGLOBJ)
+endif
 # Use these declarations if you want to support external windowing systems
 # WINSRC = $(WINTTYSRC) $(WINPROXYSRC) $(PROXYUTLSRC) $(PROXYCOMSRC)
 # WINOBJ = $(WINTTYOBJ) $(WINPROXYOBJ) $(PROXYUTLOBJ) $(PROXYCOMOBJ)
@@ -336,12 +357,12 @@
 # WINTTYLIB = -ltermcap
 # WINTTYLIB = -lcurses
 # WINTTYLIB = -lcurses16
-# WINTTYLIB = -lncurses
-WINTTYLIB = -ltermlib
+WINTTYLIB = -lncurses
+# WINTTYLIB = -ltermlib
 #
 # libraries for X11
 # If USE_XPM is defined in config.h, you will also need -lXpm here.
-WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
+WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11 -lXpm
 # 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
@@ -366,24 +387,35 @@
 #
 # libraries for SDL/GL window port
 WINSDLLIB = `sdl-config --libs` -lz -lpng
-WINGLLIB = -lGL
+WINGLLIB = 
 #
 # libraries for proxy
 WINPROXYLIB = -lpthread
 
 # Use this declaration if you only want to support the TTY windowing system
-WINLIB = $(WINTTYLIB)
+ifeq ($(GUI),TTY)
+  WINLIB = $(WINTTYLIB)
+endif
 # Use this declaration if you want to support the X11 windowing system
-# WINLIB = $(WINTTYLIB) $(WINX11LIB)
+ifeq ($(GUI),X11)
+  WINLIB = $(WINTTYLIB) $(WINX11LIB)
+endif
 # Use this declaration if you want to support the Qt windowing system
-# WINLIB = $(WINTTYLIB) $(WINQTLIB)
+ifeq ($(GUI),QT)
+  WINLIB = $(WINTTYLIB) $(WINQTLIB)
+endif
 # Use this declaration if you want to support a conventional
 # GTK windowing system (only useful if not installing setuid or setgid)
 # WINLIB = $(WINTTYLIB) $(WINGTKLIB)
 # Use this declaration if you want to support external windowing systems
 # and a proxified GTK windowing system (see Install.GTK)
-# WINLIB = $(WINTTYLIB) $(WINGTKLIB) $(WINPROXYLIB)
+ifeq ($(GUI),GTK)
+  WINLIB = $(WINTTYLIB) $(WINGTKLIB) $(WINPROXYLIB)
+endif
 # Use this declaration to only support the SDL/GL windowing system
+ifeq ($(GUI),SDL)
+  WINLIB = $(WINSDLLIB)
+endif
 # WINLIB = $(WINGLLIB)
 # Use this declaration if you want to support external windowing systems
 # WINLIB = $(WINTTYLIB) $(WINPROXYLIB)
@@ -530,7 +562,7 @@
 
 Sysunix:	$(HOBJ) Makefile
 	@echo "Loading ..."
-	@$(LINK) $(LFLAGS) -o $(GAME) $(HOBJ) $(WINLIB) $(LIBS)
+	$(LINK) $(LFLAGS) -o $(GAME) $(HOBJ) $(WINLIB) $(LIBS) -lm
 	@touch Sysunix
 
 Sys3B2:	$(HOBJ) Makefile
--- a/sys/unix/Makefile.top
+++ b/sys/unix/Makefile.top
@@ -17,12 +17,12 @@
 PREFIX   = /usr
 GAME     = slashem
 # GAME     = slashem.prg
-GAMEUID  = games
-GAMEGRP  = bin
+GAMEUID  = root
+GAMEGRP  = games
 
 # Permissions - some places use setgid instead of setuid, for instance
 # See also the option "SECURE" in include/config.h
-GAMEPERM = 04755
+GAMEPERM = 02755
 FILEPERM = 0644
 EXEPERM  = 0755
 DIRPERM  = 0755
@@ -40,16 +40,16 @@
 # These must agree with the definitions in unixconf.h
 
 # Defs. for non file areas support.
-GAMEDIR  = $(PREFIX)/local/slashemdir
-VARDIR = $(GAMEDIR)
-FILE_AREA_VAR = $(VARDIR)
-FILE_AREA_SAVE = $(VARDIR)/save
-FILE_AREA_SHARE = $(GAMEDIR)
-FILE_AREA_UNSHARE = $(GAMEDIR)
-FILE_AREA_DOC = $(GAMEDIR)
-FILE_AREA_BONES = $(FILE_AREA_VAR)
-FILE_AREA_LEVL = $(FILE_AREA_VAR)
-SHELLDIR = $(PREFIX)/local/bin
+# GAMEDIR  = $(PREFIX)/local/slashemdir
+# VARDIR = $(GAMEDIR)
+# FILE_AREA_VAR = $(VARDIR)
+# FILE_AREA_SAVE = $(VARDIR)/save
+# FILE_AREA_SHARE = $(GAMEDIR)
+# FILE_AREA_UNSHARE = $(GAMEDIR)
+# FILE_AREA_DOC = $(GAMEDIR)
+# FILE_AREA_BONES = $(FILE_AREA_VAR)
+# FILE_AREA_LEVL = $(FILE_AREA_VAR)
+# SHELLDIR = $(PREFIX)/local/bin
 
 # Defs. compatible with Linux's FSSTND 1.2
 # FILE_AREA_VAR = /var/lib/games/slashem
@@ -62,14 +62,15 @@
 # SHELLDIR = /usr/games
 
 # Defs. compatible with FHS 2.0
-# FILE_AREA_VAR = /var/games/slashem
-# FILE_AREA_SAVE = /var/games/slashem/save
-# FILE_AREA_SHARE = /usr/share/games/slashem
-# FILE_AREA_UNSHARE = /usr/lib/games/slashem
-# FILE_AREA_DOC = /usr/share/doc/slashem
-# FILE_AREA_BONES = $(FILE_AREA_VAR)
-# FILE_AREA_LEVL = $(FILE_AREA_VAR)
-# SHELLDIR = /usr/games
+FILE_AREA_VAR = $(PREFIX)/var/games/slashem
+FILE_AREA_SAVE = $(PREFIX)/var/games/slashem/save
+FILE_AREA_SHARE = $(PREFIX)/usr/share/games/slashem
+FILE_AREA_UNSHARE = $(PREFIX)/usr/lib/games/slashem
+FILE_AREA_DOC = $(PREFIX)/usr/share/doc/slashem-common
+FILE_AREA_BONES = $(FILE_AREA_VAR)
+FILE_AREA_LEVL = $(FILE_AREA_VAR)
+SHELLDIR = $(PREFIX)/usr/games
+GAMEDIR = /usr/lib/games/slashem
 
 # KDEDIR = /opt/kde
 # SHELLDIR = $(KDEDIR)/bin
@@ -78,8 +79,8 @@
 # for inclusion in DLB libraries (ND) and which are (D). Port specific files
 # per discussions in Install.X11, Install.Qt and Install.GTK
 CNF_SHARE_QTND = x11tiles rip.xpm nhsplash.xpm
-CNF_SHARE_X11ND = x11bigtiles x11tiles SlashEM.ad pet_mark.xbm
-# CNF_SHARE_X11ND = x11bigtiles x11tiles SlashEM.ad pet_mark.xbm rip.xpm
+# CNF_SHARE_X11ND = x11bigtiles x11tiles SlashEM.ad pet_mark.xbm
+CNF_SHARE_X11ND = x11bigtiles x11tiles SlashEM.ad pet_mark.xbm rip.xpm
 CNF_SHARE_GTKND = x11big3dtiles x11bigtiles x11tiles rip.xpm credit.xpm gtkrc
 CNF_SHARE_GTKPROXYND = x11big3dtiles.map x11bigtiles.map x11tiles.map
 # for Atari/Gem
@@ -101,7 +102,7 @@
 # CNF_SHARE_DATND = $(CNF_SHARE_GTKND) $(CNF_SHARE_GTKPROXYND)
 # CNF_SHARE_DATND = $(CNF_SHARE_GLND)
 # CNF_SHARE_DATND = $(CNF_SHARE_PROXYND)
-CNF_SHARE_DATND =
+CNF_SHARE_DATND = $(CNF_SHARE_X11ND) $(CNF_SHARE_GLND) $(CNF_SHARE_GTKND) $(CNF_SHARE_GTKPROXYND)
 
 CNF_SHARE_DATD = data oracles options quest.dat rumors
 CNF_SHARE_DAT = $(CNF_SHARE_DATD) $(CNF_SHARE_DATND)
@@ -290,10 +291,10 @@
 	$(MAKE) dofiles-$${target-nodlb}
 	cp src/$(GAME) $(FILE_AREA_UNSHARE)
 	cp util/recover $(FILE_AREA_UNSHARE)
-	cp dat/license doc/Guidebook.txt $(FILE_AREA_DOC)
+	cp doc/Guidebook.txt $(FILE_AREA_DOC)
 #	cp win/Qt/KDE/kslashem.kdelnk $(KDEDIR)/share/applnk/Games
 	-rm -f $(SHELLDIR)/$(GAME)
-	sed -e 's;/usr/games/lib/nethackdir;$(FILE_AREA_UNSHARE);' \
+	sed -e 's;/usr/games/lib/nethackdir;$(GAMEDIR);' \
 		-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
 		< sys/unix/nethack.sh \
 		> $(SHELLDIR)/$(GAME)
@@ -303,9 +304,9 @@
 	chmod $(GAMEPERM) $(FILE_AREA_UNSHARE)/$(GAME)
 	chmod $(EXEPERM) $(FILE_AREA_UNSHARE)/recover
 	-( cd $(FILE_AREA_DOC) ; \
-			$(CHOWN) $(GAMEUID) license Guidebook.txt ; \
-			$(CHGRP) $(GAMEGRP) license Guidebook.txt ; \
-			chmod $(FILEPERM) license Guidebook.txt )
+			$(CHOWN) $(GAMEUID) Guidebook.txt ; \
+			$(CHGRP) $(GAMEGRP) Guidebook.txt ; \
+			chmod $(FILEPERM) Guidebook.txt )
 	-$(CHOWN) $(GAMEUID) $(SHELLDIR)/$(GAME)
 	$(CHGRP) $(GAMEGRP) $(SHELLDIR)/$(GAME)
 	chmod $(EXEPERM) $(SHELLDIR)/$(GAME)
--- a/sys/unix/Makefile.utl
+++ b/sys/unix/Makefile.utl
@@ -1,3 +1,6 @@
+# Determine kernel name
+UNAME := $(shell uname -s)
+
 #	Makefile for NetHack's utility programs.
 #	SCCS Id: @(#)Makefile.utl	3.4	1997/04/19
 
@@ -70,10 +73,15 @@
 # SGI cc 3.10 will fail to compile makedefs with -O
 # CFLAGS = -I../include -D__STDC__ -woff 100,293
 
-# flags for Linux
+# flags for Linux and kFreeBSD
 #   compile normally
-# CFLAGS = -O2 -fomit-frame-pointer -I../include
-# LFLAGS = -L/usr/X11R6/lib
+#   disable optimization on non-Linux archs due to FTBFS
+ifeq ($(UNAME),Linux)
+CFLAGS = -DDEBIAN_$(GUI) -O2 -fomit-frame-pointer -fstack-protector --param=ssp-buffer-size=4 -I../include -I/usr/X11R6/include
+else
+CFLAGS = -DDEBIAN_$(GUI) -fstack-protector --param=ssp-buffer-size=4 -I../include -I/usr/X11R6/include
+endif
+LFLAGS = -L/usr/X11R6/lib -Wl,-z,relro
 #   OR compile backwards compatible a.out format
 # CFLAGS = -O2 -b i486-linuxaout -fomit-frame-pointer -I../include
 # LFLAGS = -b i486-linuxaout -L/usr/X11R6/lib
@@ -89,8 +97,8 @@
 # flags for debugging:
 # CFLAGS = -g -I../include
 
-CFLAGS = -O -I../include
-LFLAGS =
+# CFLAGS = -O -I../include
+# LFLAGS =
 
 LIBS =
  
@@ -101,11 +109,11 @@
 
 # yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
 # if, instead of yacc/lex you have bison/flex, comment/uncomment the following.
-YACC     = yacc
-LEX      = lex
-# YACC     = bison -y
+# YACC     = yacc
+# LEX      = lex
+YACC     = bison -y
 # YACC     = byacc
-# LEX      = flex
+LEX      = flex
  
 # these are the names of the output files from YACC/LEX. Under MS-DOS
 # and similar systems, they may differ
--- a/sys/unix/nethack.sh
+++ b/sys/unix/nethack.sh
@@ -1,10 +1,8 @@
 #!/bin/sh
 #	SCCS Id: @(#)nethack.sh	3.4	1990/02/26
 
-HACKDIR=/usr/games/lib/nethackdir
-export HACKDIR
-HACK=$HACKDIR/nethack
-MAXNROFPLAYERS=4
+HACK=/usr/lib/games/slashem/slashem
+MAXNROFPLAYERS=0
 
 # Since Nethack.ad is installed in HACKDIR, add it to XUSERFILESEARCHPATH
 case "x$XUSERFILESEARCHPATH" in
@@ -57,7 +55,6 @@
 fi
 
 
-cd $HACKDIR
 case $1 in
 	-s*)
 		exec $HACK "$@"
--- a/win/tty/termcap.c
+++ b/win/tty/termcap.c
@@ -960,10 +960,6 @@
 
 #include <curses.h>
 
-#if !defined(LINUX) && !defined(__FreeBSD__)
-extern char *tparm();
-#endif
-
 #  ifdef COLOR_BLACK	/* trust include file */
 #ifndef VIDEOSHADES
 #undef COLOR_BLACK
--- a/include/system.h
+++ b/include/system.h
@@ -530,7 +530,11 @@
 E time_t FDECL(time, (time_t *));
 #  endif
 # else
+#  if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+E time_t FDECL(time, (time_t *));
+#  else
 E long FDECL(time, (time_t *));
+#  endif
 # endif /* ULTRIX */
 
 #ifdef VMS
--- a/src/hacklib.c
+++ b/src/hacklib.c
@@ -4,6 +4,9 @@
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* We could include only config.h, except for the overlay definitions... */
+#if defined(__FreeBSD_kernel__)
+    #include <time.h>
+#endif
 #include "hack.h"
 /*=
     Assorted 'small' utility routines.	They're virtually independent of
--- a/util/makedefs.c
+++ b/util/makedefs.c
@@ -4,6 +4,10 @@
 /* Copyright (c) Dean Luick, 1990.				  */
 /* NetHack may be freely redistributed.  See license for details. */
 
+#if defined(__FreeBSD_kernel__)
+    #include <time.h>
+#endif
+
 #define MAKEDEFS_C	/* use to conditionally include file sections */
 /* #define DEBUG */	/* uncomment for debugging info */
 
