diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/Imake.cf ./Xvnc/config/cf/Imake.cf
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/Imake.cf	Sat May 11 03:57:05 2002
+++ ./Xvnc/config/cf/Imake.cf	Wed Mar  3 08:42:51 2004
@@ -19,6 +19,21 @@
  *     4.  Create a .cf file with the name given by MacroFile.
  */
 
+#if defined(__APPLE__)
+# undef __APPLE__
+# define MacroIncludeFile <darwin.cf>
+# define MacroFile darwin.cf
+# define DarwinArchitecture
+# ifdef __ppc__
+#  define PpcDarwinArchitecture
+#  undef __ppc__
+# endif
+# ifdef __i386__
+#  define i386DarwinArchitecture
+#  undef __i386__
+# endif
+#endif
+
 #if defined(clipper) || defined(__clipper__)
 # undef clipper
 # define MacroIncludeFile <ingr.cf>
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/darwin.cf ./Xvnc/config/cf/darwin.cf
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/darwin.cf	Wed Dec 31 16:00:00 1969
+++ ./Xvnc/config/cf/darwin.cf	Wed Mar  3 09:19:06 2004
@@ -0,0 +1,116 @@
+/* Darwin / Mac OS X configuration by John Carmack <johnc@idsoftware.com> */
+
+/* imake determines the default values by parsing uname */
+#define OSName                  DefaultOSName
+#define OSMajorVersion          DefaultOSMajorVersion
+#define OSMinorVersion          DefaultOSMinorVersion
+#define OSTeenyVersion          DefaultOSTeenyVersion
+
+XCOMM operating system:  OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion)
+
+/*
+ * Define the operating system's capabilities
+ */
+#define HasSnprintf             YES
+#define HasPutenv               YES
+#define HasBSD44Sockets         YES
+#define HasUsableFileMmap       YES
+#define HasZlib                 YES
+#ifndef HasShm
+# define HasShm                 YES
+#endif
+#define HasNdbm                 YES
+
+#ifndef HasGroff
+# define HasGroff               YES
+#endif
+
+/* Libtool on Darwin always uses minor numbers */
+#define LibtoolMinorVersions	YES
+
+/* The most common file system, HFS+, is not case sensitive. */
+#ifndef CaseSensitiveFileSystem
+# define CaseSensitiveFileSystem NO
+#endif
+
+/* we don't need -lm */
+#define MathLibrary             /**/
+
+/* we don't have a termcap library */
+#define TermcapLibrary          /**/
+
+/* we don't have a dbm library */
+#define DBMLibrary              /**/
+
+#define MkdirHierCmd            mkdir -p
+
+/* our cpp isn't in /lib/cpp and it doesn't like -undef */
+#define CppCmd                  cpp
+#define RawCppCmd               CppCmd
+
+/* we have a gcc compatible compiler, but its not called gcc */
+#define CcCmd                   cc
+#define CplusplusCmd            c++
+
+/* default flags to pass to cc */
+# define DefaultCCOptions       -Wpointer-arith -no-cpp-precomp
+
+/* flags to pass to cc when building libraries */
+#ifndef LibraryCCOptions
+# define LibraryCCOptions       DefaultCCOptions -fno-common
+#endif
+
+#ifdef PpcDarwinArchitecture
+# define DarwinMachineDefines   -D__powerpc__
+# define OptimizedCDebugFlags   -O2
+# define ByteOrder              X_BIG_ENDIAN
+#endif /* PpcDarwinArchitecture */
+
+#ifdef i386DarwinArchitecture
+# define DarwinMachineDefines   -D__i386__
+# define OptimizedCDebugFlags   -O2 -fno-strength-reduce
+# define ByteOrder              X_LITTLE_ENDIAN
+#endif /* i386DarwinArchitecture */
+
+/*
+ * __DARWIN__ will be used for platform specific #ifdefs that can't
+ * be handled by existing X defines.
+ *
+ * Darwin's alloca() seg faults (rather than returning NULL) on failed
+ * allocations, so we can't use it.
+ *
+ * Darwin's setlocale() doesn't work properly, so use X11's instead.
+ */
+#define StandardDefines         DarwinMachineDefines -D__DARWIN__ \
+                                -DNO_ALLOCA -DX_LOCALE
+
+/*
+ * Set this to NO to just build the client libs, which should work without
+ * having to write any platform specific code.
+ */
+#define BuildServer             YES
+
+/* our custom X server */
+#define XDarwinServer           YES
+
+#define UsrLibDir		  /usr/X11R6/lib 
+/* Thanks to the IOKit, the X server does not have to be SetUID. */
+#ifndef InstallXserverSetUID
+# define InstallXserverSetUID   NO
+#endif
+
+/* no direct graphics extension */
+#define BuildXF86DGA            NO
+
+/* no server support for extra tablets and weird input devices */
+#define BuildXInputExt          NO
+#define BuildXInputLib          YES
+
+/* no Display Power Management extension */
+#define BuildDPMSExt            NO
+
+#define BuildLibPathVar         DYLD_LIBRARY_PATH
+
+/* include all the XFree86 rules */
+#include <xfree86.cf>
+
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/vnclibs.def.in ./Xvnc/config/cf/vnclibs.def.in
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/config/cf/vnclibs.def.in	Fri Sep 13 02:10:53 2002
+++ ./Xvnc/config/cf/vnclibs.def.in	Wed Mar  3 11:11:46 2004
@@ -19,6 +19,6 @@
 
 VNCLIBS = $(RFB_TOP)/rdr/librdr.a $(RFB_TOP)/rfb/librfb.a @ZLIB_LIB@
 
-VNCSYSLIBS =
+VNCSYSLIBS = @ZLIB_SHLIB@
 
 VNCCPPFLAGS = -I$(RFB_TOP)
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/config/imake/imakemdep.h ./Xvnc/config/imake/imakemdep.h
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/config/imake/imakemdep.h	Sat May 11 03:57:05 2002
+++ ./Xvnc/config/imake/imakemdep.h	Wed Mar  3 08:49:42 2004
@@ -269,6 +269,9 @@
 /* expects cpp in PATH */
 #define DEFAULT_CPP "cpp"
 #endif
+#if defined(__APPLE__)
+#define DEFAULT_CPP "cpp"
+#endif
 
 /*
  * Step 5:  cpp_argv
@@ -537,6 +540,9 @@
 	"-traditional",
 	"-Demxos2",
 #endif
+#if defined(__APPLE__)
+    "-D__APPLE__",
+#endif
 
 };
 
@@ -596,6 +602,12 @@
 # define DEFAULT_OS_MINOR_REV	"r %*d.%[0-9]"
 # define DEFAULT_OS_TEENY_REV	"r %*d.%*d.%[0-9]"
 # define DEFAULT_OS_NAME	"srm %[^\n]"
+#elif defined(__APPLE__)	
+/* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */
+# define DEFAULT_OS_MAJOR_REV	"r %[0-9]"
+# define DEFAULT_OS_MINOR_REV	"r %*d.%[0-9]"
+# define DEFAULT_OS_TEENY_REV	"r %*d.%*d.%[0-9]" /* this will just get 0 */
+# define DEFAULT_OS_NAME	"s %[^\n]"
 #elif defined(ISC)
 /* ISC all Versions ? */
 /* uname -r returns "x.y", e.g. "3.2" ,uname -v returns "x" e.g. "2" */
@@ -904,6 +916,12 @@
 #endif
 #ifdef __EMX__
 	{"__EMX__", "1"},
+#endif
+#if defined(__ppc__)
+    {"__ppc__", "1"},
+#endif
+#if defined(__BIG_ENDIAN__) 
+    {"__BIG_ENDIAN__", "1"},
 #endif
 	/* add any additional symbols before this line */
 	{NULL, NULL}
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/hw/vnc/zrle.cc ./Xvnc/programs/Xserver/hw/vnc/zrle.cc
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/hw/vnc/zrle.cc	Sun Sep  1 08:58:21 2002
+++ ./Xvnc/programs/Xserver/hw/vnc/zrle.cc	Wed Mar  3 09:58:09 2004
@@ -24,6 +24,7 @@
 //
 
 #include <stdio.h>
+#include <assert.h>
 extern "C" {
 #include "rfb.h"
 }
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/include/servermd.h ./Xvnc/programs/Xserver/include/servermd.h
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/include/servermd.h	Sat May 11 03:57:06 2002
+++ ./Xvnc/programs/Xserver/include/servermd.h	Wed Mar  3 08:51:45 2004
@@ -132,6 +132,22 @@
 
 #endif /* vax */
 
+#ifdef __DARWIN__
+
+#define IMAGE_BYTE_ORDER        MSBFirst
+#define BITMAP_BIT_ORDER        MSBFirst
+#define GLYPHPADBYTES           4
+#define GETLEFTBITS_ALIGNMENT   1
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+#define PLENTIFUL_REGISTERS
+#define AVOID_MEMORY_READ
+
+#define FAST_MEMCPY
+
+#endif /* __DARWIN__ */
+
 #if (defined(Lynx) && defined(__powerpc__))
 
 /* For now this is for Xvfb only */
diff -urN ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/os/access.c ./Xvnc/programs/Xserver/os/access.c
--- ../vnc-3.3.7-unixsrc.orig/Xvnc/programs/Xserver/os/access.c	Sat May 11 03:57:06 2002
+++ ./Xvnc/programs/Xserver/os/access.c	Wed Mar  3 08:53:21 2004
@@ -103,7 +103,7 @@
 #endif
 
 #if !defined(AMOEBA)
-#ifdef hpux
+#if defined(hpux) || defined(__DARWIN__)
 # include <sys/utsname.h>
 # ifdef HAS_IFREQ
 #  include <net/if.h>
@@ -480,7 +480,7 @@
 
 #else /* WINTCP */
 
-#if !defined(SIOCGIFCONF) || (defined (hpux) && ! defined (HAS_IFREQ))
+#if !defined(SIOCGIFCONF) || (defined (hpux) && ! defined (HAS_IFREQ)) || defined(__DARWIN__)
 void
 DefineSelf (fd)
     int fd;
