diff -r -c vnc-3.3.7-unixsrc/Xvnc/config/cf/Imake.cf vnc-3.3.7-unixsrc/Xvnc/config/cf/Imake.cf
*** vnc-3.3.7-unixsrc/Xvnc/config/cf/Imake.cf	Sat May 11 03:57:05 2002
--- vnc-3.3.7-unixsrc/Xvnc/config/cf/Imake.cf	Fri Nov  8 10:03:24 2002
***************
*** 19,24 ****
--- 19,39 ----
   *     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 -r -c vnc-3.3.7-unixsrc/Xvnc/config/cf/darwin.cf vnc-3.3.7-unixsrc/Xvnc/config/cf/darwin.cf
*** vnc-3.3.7-unixsrc/Xvnc/config/cf/darwin.cf	Fri Nov  8 10:26:32 2002
--- vnc-3.3.7-unixsrc/Xvnc/config/cf/darwin.cf	Fri Nov  8 10:02:22 2002
***************
*** 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                  /usr/bin/cpp
+ #define RawCppCmd               CppCmd
+ 
+ /* we have a gcc compatible compiler, but its not called gcc */
+ #define CcCmd                   /usr/bin/cc
+ #define CplusplusCmd            /usr/bin/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 -r -c vnc-3.3.7-unixsrc/Xvnc/config/imake/imakemdep.h vnc-3.3.7-unixsrc/Xvnc/config/imake/imakemdep.h
*** vnc-3.3.7-unixsrc/Xvnc/config/imake/imakemdep.h	Sat May 11 03:57:05 2002
--- vnc-3.3.7-unixsrc/Xvnc/config/imake/imakemdep.h	Fri Nov  8 09:29:24 2002
***************
*** 269,274 ****
--- 269,277 ----
  /* expects cpp in PATH */
  #define DEFAULT_CPP "cpp"
  #endif
+ #if defined(__APPLE__)
+ #define DEFAULT_CPP "/usr/bin/cpp"
+ #endif
  
  /*
   * Step 5:  cpp_argv
***************
*** 537,542 ****
--- 540,548 ----
  	"-traditional",
  	"-Demxos2",
  #endif
+ #if defined(__APPLE__)
+         "-D__APPLE__",
+ #endif
  
  };
  
***************
*** 596,601 ****
--- 602,613 ----
  # 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,909 ****
--- 916,927 ----
  #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 -r -c vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/include/servermd.h vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/include/servermd.h
*** vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/include/servermd.h	Sat May 11 03:57:06 2002
--- vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/include/servermd.h	Fri Nov  8 09:31:22 2002
***************
*** 132,137 ****
--- 132,154 ----
  
  #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 */
*** vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/os/access.c	Sat May 11 03:57:06 2002
--- vnc-3.3.7-unixsrc/Xvnc/programs/Xserver/os/access.c	Mon Dec 23 14:48:55 2002
***************
*** 103,109 ****
  #endif
  
  #if !defined(AMOEBA)
! #ifdef hpux
  # include <sys/utsname.h>
  # ifdef HAS_IFREQ
  #  include <net/if.h>
--- 103,109 ----
  #endif
  
  #if !defined(AMOEBA)
! #if defined(hpux) || defined(__DARWIN__)
  # include <sys/utsname.h>
  # ifdef HAS_IFREQ
  #  include <net/if.h>
***************
*** 480,486 ****
  
  #else /* WINTCP */
  
! #if !defined(SIOCGIFCONF) || (defined (hpux) && ! defined (HAS_IFREQ))
  void
  DefineSelf (fd)
      int fd;
--- 480,487 ----
  
  #else /* WINTCP */
  
! #if !defined(SIOCGIFCONF) || (defined (hpux) && ! defined (HAS_IFREQ)) || defined(__DARWIN__)
  void
  DefineSelf (fd)
      int fd;
 diff -r -c vnc-3.3.7-unixsrc/vncserver vnc-3.3.7-unixsrc/vncserver
*** vnc-3.3.7-unixsrc/vncserver	Fri Nov  1 07:53:29 2002
--- vnc-3.3.7-unixsrc/vncserver	Fri Nov  8 09:32:57 2002
***************
*** 37,45 ****
  $depth = 16;
  $desktopName = "X";
  $vncClasses = (((-d "/usr/share/vnc/classes") && "/usr/share/vnc/classes") ||
!                ((-d "/usr/local/vnc/classes") && "/usr/local/vnc/classes"));
  $vncUserDir = "$ENV{HOME}/.vnc";
! $xauthorityFile = "$ENV{XAUTHORITY}" || "$ENV{HOME}/.Xauthority";
  
  $defaultXStartup
      = ("#!/bin/sh\n\n".
--- 37,46 ----
  $depth = 16;
  $desktopName = "X";
  $vncClasses = (((-d "/usr/share/vnc/classes") && "/usr/share/vnc/classes") ||
!                ((-d "/usr/local/vnc/classes") && "/usr/local/vnc/classes") ||
!                ((-d "<PREFIX>/share/vnc/classes") && "<PREFIX>/share/vnc/classes"));
  $vncUserDir = "$ENV{HOME}/.vnc";
! $xauthorityFile = "$ENV{XAUTHORITY}" || "$ENV{HOME}/.Xauthority" || "$vncUserDir/.XAuthority";
  
  $defaultXStartup
      = ("#!/bin/sh\n\n".
