diff -ru nethack-3.4.3-orig/include/config.h nethack-3.4.3/include/config.h
--- nethack-3.4.3-orig/include/config.h	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/include/config.h	2005-12-19 15:34:30.000000000 -0800
@@ -103,6 +103,12 @@
 # endif
 #endif
 
+#ifdef X11_GRAPHICS
+# ifndef DEFAULT_WINDOW_SYS
+#  define DEFAULT_WINDOW_SYS "x11"
+# endif
+#endif
+
 #ifdef MSWIN_GRAPHICS
 # ifdef TTY_GRAPHICS
 # undef TTY_GRAPHICS
diff -ru nethack-3.4.3-orig/include/system.h nethack-3.4.3/include/system.h
--- nethack-3.4.3-orig/include/system.h	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/include/system.h	2005-12-19 15:34:30.000000000 -0800
@@ -72,7 +72,7 @@
 
 #if !defined(__cplusplus) && !defined(__GO32__)
 
-#if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
+#if (defined(BSD) && !defined(__APPLE__)) || defined(ULTRIX) || defined(RANDOM)
 # ifdef random
 # undef random
 # endif
diff -ru nethack-3.4.3-orig/include/unixconf.h nethack-3.4.3/include/unixconf.h
--- nethack-3.4.3-orig/include/unixconf.h	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/include/unixconf.h	2005-12-19 15:34:31.000000000 -0800
@@ -19,20 +19,20 @@
  */
 
 /* define exactly one of the following four choices */
-/* #define BSD 1 */	/* define for 4.n/Free/Open/Net BSD  */
+#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 */
 /* #define ULTRIX */	/* define for Ultrix v3.0 or higher (but not lower) */
 			/* Use BSD for < v3.0 */
 			/* "ULTRIX" not to be confused with "ultrix" */
-#define SYSV		/* define for System V, Solaris 2.x, newer versions */
+/* #define SYSV	*/	/* define for System V, Solaris 2.x, newer versions */
 			/* of Linux */
 /* #define HPUX */	/* Hewlett-Packard's Unix, version 6.5 or higher */
 			/* use SYSV for < v6.5 */
 
 
 /* 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 */
@@ -284,7 +284,7 @@
 #endif
 
 #if defined(BSD) || defined(ULTRIX)
-# if !defined(DGUX) && !defined(SUNOS4)
+# if !defined(DGUX) && !defined(SUNOS4) && !defined(__APPLE__)
 #define memcpy(d, s, n)		bcopy(s, d, n)
 #define memcmp(s1, s2, n)	bcmp(s2, s1, n)
 # endif
@@ -331,7 +331,7 @@
 #  define GETRES_SUPPORT
 # endif
 #else
-# if defined(BSD) || defined(SVR4)
+# if (defined(BSD) && !defined(__APPLE__)) || defined(SVR4)
 /*
  * [ALI] We assume that SVR4 means we can safely include syscall.h
  * (although it's really a BSDism). This is certainly true for Solaris 2.5,
diff -ru nethack-3.4.3-orig/src/files.c nethack-3.4.3/src/files.c
--- nethack-3.4.3-orig/src/files.c	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/src/files.c	2005-12-19 15:34:31.000000000 -0800
@@ -1341,7 +1341,7 @@
 		nesting--;
 		return FALSE;
 	    case EACCES:
-		HUP raw_printf("No write permission to lock %s!", filename);
+		HUP raw_printf("No write permission to lock %s [%s]!", filename, lockname);
 		nesting--;
 		return FALSE;
 # ifdef VMS			/* c__translate(vmsfiles.c) */
@@ -1556,17 +1556,6 @@
 		Sprintf(tmp_config, "%s/%s", envp, configfile);
 	if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
 		return(fp);
-# if defined(__APPLE__)
-	/* try an alternative */
-	if (envp) {
-		Sprintf(tmp_config, "%s/%s", envp, "Library/Preferences/NetHack Defaults");
-		if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
-			return(fp);
-		Sprintf(tmp_config, "%s/%s", envp, "Library/Preferences/NetHack Defaults.txt");
-		if ((fp = fopenp(tmp_config, "r")) != (FILE *)0)
-			return(fp);
-	}
-# endif
 	if (errno != ENOENT) {
 	    char *details;
 
diff -ru nethack-3.4.3-orig/sys/unix/Makefile.src nethack-3.4.3/sys/unix/Makefile.src
--- nethack-3.4.3-orig/sys/unix/Makefile.src	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/sys/unix/Makefile.src	2005-12-19 15:34:31.000000000 -0800
@@ -146,13 +146,13 @@
 # directories.  The ones given below is the usual spot for linux systems.
 # The paths are for glibconfig.h and gnomesupport.h respectively.
 #
-GNOMEINC=-I/usr/lib/glib/include -I/usr/lib/gnome-libs/include -I../win/gnome
+GNOMEINC=`gnome-config --cflags gnome` -I../win/gnome
 
 # flags for debugging:
 # CFLAGS = -g -I../include
 
-CFLAGS = -O -I../include
-LFLAGS = 
+CFLAGS = -O -I../include -DHACKDIR=\"$(HACKDIR)\" -I@PREFIX@/include -I/usr/X11R6/include -no-cpp-precomp
+LFLAGS = -L@PREFIX@/lib -L/usr/X11R6/lib
 
 # 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
@@ -230,24 +230,24 @@
 # 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 -lXpm -lX11
 # 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
 #
 # libraries for Qt
-WINQTLIB = -L$(QTDIR)/lib -lqt
+WINQTLIB = -L$(QTDIR)/lib -lqt-mt
 #
 # libraries for KDE (with Qt)
 WINKDELIB = -lkdecore -lkdeui -lXext
 #
 # libraries for Gnome
-WINGNOMELIB = -lgnomeui -lgnome -lart_lgpl -lgtk -lgdk -lpopt
+WINGNOMELIB = `gnome-config --libs gnome gnomeui`
 #
 # libraries for Gem port
 WINGEMLIB = -le_gem -lgem
diff -ru nethack-3.4.3-orig/sys/unix/Makefile.top nethack-3.4.3/sys/unix/Makefile.top
--- nethack-3.4.3-orig/sys/unix/Makefile.top	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/sys/unix/Makefile.top	2005-12-19 15:34:31.000000000 -0800
@@ -40,7 +40,7 @@
 SHELLDIR = $(PREFIX)/games
 
 # per discussion in Install.X11 and Install.Qt
-VARDATND = 
+# VARDATND = 
 # VARDATND = x11tiles NetHack.ad pet_mark.xbm
 # VARDATND = x11tiles NetHack.ad pet_mark.xbm rip.xpm
 # for Atari/Gem
@@ -48,7 +48,7 @@
 # for BeOS
 # VARDATND = beostiles
 # for Gnome
-# VARDATND = x11tiles pet_mark.xbm rip.xpm mapbg.xpm
+VARDATND = x11tiles NetHack.ad pet_mark.xbm rip.xpm mapbg.xpm
 
 VARDATD = data oracles options quest.dat rumors
 VARDAT = $(VARDATD) $(VARDATND)
@@ -186,7 +186,7 @@
 	cp src/$(GAME) $(GAMEDIR)
 	cp util/recover $(GAMEDIR)
 	-rm -f $(SHELLDIR)/$(GAME)
-	sed -e 's;/usr/games/lib/nethackdir;$(GAMEDIR);' \
+	sed -e 's;/usr/games/lib/nethackdir;$(HACKDIR);' \
 		-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
 		< sys/unix/nethack.sh \
 		> $(SHELLDIR)/$(GAME)
diff -ru nethack-3.4.3-orig/sys/unix/unixmain.c nethack-3.4.3/sys/unix/unixmain.c
--- nethack-3.4.3-orig/sys/unix/unixmain.c	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/sys/unix/unixmain.c	2005-12-19 15:34:31.000000000 -0800
@@ -88,7 +88,7 @@
 	hackpid = getpid();
 	(void) umask(0777 & ~FCMASK);
 
-	choose_windows(DEFAULT_WINDOW_SYS);
+	choose_windows(getenv("DISPLAY") ? DEFAULT_WINDOW_SYS : "tty");
 
 #ifdef CHDIR			/* otherwise no chdir() */
 	/*
diff -ru nethack-3.4.3-orig/sys/unix/unixres.c nethack-3.4.3/sys/unix/unixres.c
--- nethack-3.4.3-orig/sys/unix/unixres.c	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/sys/unix/unixres.c	2005-12-19 15:34:31.000000000 -0800
@@ -18,6 +18,10 @@
 
 #ifdef GETRES_SUPPORT
 
+# if defined(__APPLE__)
+#include <sys/stat.h>
+# endif
+
 # if defined(LINUX)
 
 /* requires dynamic linking with libc */
diff -ru nethack-3.4.3-orig/win/Qt/qt_win.cpp nethack-3.4.3/win/Qt/qt_win.cpp
--- nethack-3.4.3-orig/win/Qt/qt_win.cpp	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/win/Qt/qt_win.cpp	2005-12-19 15:34:31.000000000 -0800
@@ -102,7 +102,7 @@
 #include "qt_xpms.h"
 
 #include <dirent.h>
-#ifdef Q_WS_MACX
+#ifdef __APPLE__
 #  include <sys/malloc.h>
 #else
 #  include <malloc.h>
diff -ru nethack-3.4.3-orig/win/gnome/gnmain.c nethack-3.4.3/win/gnome/gnmain.c
--- nethack-3.4.3-orig/win/gnome/gnmain.c	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/win/gnome/gnmain.c	2005-12-19 15:34:31.000000000 -0800
@@ -725,7 +725,7 @@
     uid = getuid();
     euid = geteuid();
     if (uid != euid)
-      setuid(uid);
+      seteuid(uid);
     hide_privileges(TRUE);
     /* XXX gnome_init must print nethack options for --help, but does not */
     gnome_init ("nethack", VERSION_STRING, argc, argv);
@@ -768,7 +768,7 @@
      * to not refresh the window when adding widgets after the window 
      * has already been shown */
     if (uid != euid)
-      setuid(euid);
+      seteuid(euid);
     for(i = 0; i < SIZE(ghack_chain); i++)
 	ghack_chain[i].handler =
 	  signal(ghack_chain[i].signum, ghack_sig_handler);
diff -ru nethack-3.4.3-orig/win/tty/termcap.c nethack-3.4.3/win/tty/termcap.c
--- nethack-3.4.3-orig/win/tty/termcap.c	2005-12-19 15:34:20.000000000 -0800
+++ nethack-3.4.3/win/tty/termcap.c	2005-12-19 15:34:51.000000000 -0800
@@ -835,10 +835,6 @@
 
 #include <curses.h>
 
-#ifndef LINUX
-extern char *tparm();
-#endif
-
 #  ifdef COLOR_BLACK	/* trust include file */
 #undef COLOR_BLACK
 #  else
