--- vnc_unixsrc/Xvnc/config/imake/imakemdep.h	Tue Sep 26 18:12:33 2000
+++ vnc_unixsrc/Xvnc/config/imake/imakemdep.h	Tue Sep 26 18:14:49 2000
@@ -269,6 +269,9 @@
 /* expects cpp in PATH */
 #define DEFAULT_CPP "cpp"
 #endif
+#if defined(__APPLE__)
+#define DEFAULT_CPP "/usr/bin/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}
--- vnc_unixsrc/Xvnc/config/cf/Imake.cf	Tue Sep 26 16:49:15 2000
+++ vnc_unixsrc/Xvnc/config/cf/Imake.cf	Tue Sep 26 16:49:49 2000
@@ -19,6 +19,13 @@
  *     4.  Create a .cf file with the name given by MacroFile.
  */
 
+#if defined(__APPLE__)                /* JDC */
+# undef __APPLE__
+# define MacroIncludeFile <darwin.cf>
+# define MacroFile darwin.cf
+# define DarwinArchitecture
+#endif
+
 #if defined(clipper) || defined(__clipper__)
 # undef clipper
 # define MacroIncludeFile <ingr.cf>
--- vnc_unixsrc/Xvnc/config/cf/darwin.cf	Tue Sep 26 16:48:55 2000
+++ vnc_unixsrc/Xvnc/config/cf/darwin.cf	Tue Sep 26 16:54:12 2000
@@ -0,0 +1,82 @@
+/* darwin / MacOS-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		0
+
+#define HasSnprintf		YES
+#define	HasPutenv		YES
+#define HasBSD44Sockets         YES
+#define BuildGlxExt		NO
+#ifndef HasShm
+# define HasShm                 YES
+#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		/**/
+
+/* our cpp isn't in /lib/cpp */
+#define	CppCmd			/usr/bin/cpp
+
+/* if -c isn't passed, there are problems with the cfb libs when
+ * they include an object file without any symbols
+ */
+#define RanlibCmd		ranlib -c
+
+/* uncommenting this line will get -g instead of -O, which builds
+ * a lot faster and gets debug info
+ */
+#if 0
+#define DefaultCDebugFlags -g
+#endif
+
+/* a lot of xfree86 code needs __powerpc__ to avoid doing outport asm
+ *
+ * __DARWIN__ will be used for platform specific #ifdefs that can't
+ * be handled by existing X defines
+ *
+ * there is an unfortunate symbol collision with the appkit for TIFFFaxBlackCodes
+ *
+ * We need to define BSD44SOCKETS to get unix domain socket namelen calculated right
+ */
+#define StandardDefines -D__powerpc__ -D__DARWIN__
+
+/* programs/rgb/rgb.h and others needs this */
+#define	HasNdbm			YES
+
+/* set this to NO to just buold the client libs, which should work without
+ * having to write any platform specific code.
+ */
+#define BuildServer		YES
+
+/* our custom X server */
+#define XDarwinServer	YES
+
+/* pex? bah.  I'm not going to bother getting the device
+ * dependent part of this working.  If I get the time, i'll
+ * get glx working instead.
+ */ 
+#define BuildPexExt		NO
+
+/* no direct graphics extension */
+#define	BuildXF86DGA	NO
+
+/* no extra tablets and weird input devices */
+#define BuildXInputExt	NO
+
+/* no Display Power Management extension */
+#define	BuildDPMSExt	NO
+
+# define BuildXvExt     NO
+
+/* include all the xfree rules */
+/* I haven't tracked down why this is needed, but it is... */
+#include <xfree86.cf>
--- vnc_unixsrc/Xvnc/programs/Xserver/include/servermd.h	Tue Sep 26 16:52:25 2000
+++ vnc_unixsrc/Xvnc/programs/Xserver/include/servermd.h	Tue Sep 26 16:52:44 2000
@@ -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 */
--- vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/Imakefile.orig	Wed Apr  4 10:27:39 2001
+++ vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/Imakefile	Wed Apr  4 10:28:45 2001
@@ -12,7 +12,7 @@
 #include <vnclibs.def>
 INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) -I$(XINCLUDESRC) \
 	   -I../../cfb -I../../mfb -I../../mi -I../../include -I../../os \
-	   $(VNCCPPFLAGS)
+	   $(VNCCPPFLAGS) $(EXTRAINCLUDE)
 
 DEFINES = ServerOSDefines
 
--- vnc_unixsrc/vncviewer/Imakefile.orig	Wed Apr  4 09:09:36 2001
+++ vnc_unixsrc/vncviewer/Imakefile	Wed Apr  4 09:37:16 2001
@@ -11,10 +11,10 @@
 DEFINES = -DMITSHM
 #endif
 
-INCLUDES = -I../include -I. -I../lib/zlib -I../lib/jpeg -I/usr/include
+INCLUDES = -I../include -I. -I../lib/zlib -I../lib/jpeg -I/usr/include $(EXTRAINCLUDE)
 VNCAUTH_LIB = ../libvncauth/libvncauth.a
-ZLIB_LIB = -L../lib/zlib -lz
-JPEG_LIB = -L../lib/jpeg -ljpeg
+ZLIB_LIB = -lz
+JPEG_LIB = -ljpeg
 
 DEPLIBS = XawClientDepLibs $(VNCAUTH_LIB)
 LOCAL_LIBRARIES = XawClientLibs $(VNCAUTH_LIB) $(ZLIB_LIB) $(JPEG_LIB)
--- vnc_unixsrc/Xvnc/config/cf/vnclibs.def.orig	Wed Apr  4 11:14:15 2001
+++ vnc_unixsrc/Xvnc/config/cf/vnclibs.def	Wed Apr  4 11:12:41 2001
@@ -7,4 +7,4 @@
 
 VNCLIBS = $(TOP)/../libvncauth/libvncauth.a
 VNCSYSLIBS = -L$(TOP)/../lib/jpeg -ljpeg
-VNCCPPFLAGS = -I$(TOP)/../include -I$(TOP)/../lib/zlib -I$(TOP)/../lib/jpeg
+VNCCPPFLAGS = -I$(TOP)/../include -I$(TOP)/../lib/zlib -I$(TOP)/../lib/jpeg $(EXTRAINCLUDE)
--- vnc_unixsrc/vncserver.orig	Thu Aug 30 06:47:04 2001
+++ vnc_unixsrc/vncserver	Thu Aug 30 06:55:59 2001
@@ -35,23 +35,24 @@
 $geometry = "1024x768";
 $depth = 24;
 $desktopName = "X";
-$vncClasses = "/usr/local/vnc/classes";
+$vncClasses = "<PREFIX>/share/vnc/classes";
 $vncUserDir = "$ENV{HOME}/.vnc";
-$fontPath = "unix/:7100";
+#$fontPath = "unix/:7100";
 
 # Here is another example of setting the font path:
 # $fontPath = "/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/";
+$fontPath = "/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/Type1/";
+
 
 # X colors database path is optional, uncomment and edit to use:
-# $colorPath = "/usr/lib/X11/rgb";
+$colorPath = "/usr/X11R6/lib/X11/rgb";
 
-unless ($xauthorityFile = "$ENV{XAUTHORITY}") {
-  $xauthorityFile = "$ENV{HOME}/.Xauthority";
-}
+$xauthorityFile = "$vncUserDir/.Xauthority";
 
 $defaultXStartup
     = ("#!/bin/sh\n\n".
        "xrdb \$HOME/.Xresources\n".
+       "export XAUTHORITY=$vncUserDir/.Xauthority\n".
        "xsetroot -solid grey\n".
        "xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
        "twm &\n");
@@ -103,7 +104,7 @@
 ($z,$z,$mode) = stat("$vncUserDir/passwd");
 if (!(-e "$vncUserDir/passwd") || ($mode & 077)) {
     warn "\nYou will require a password to access your desktops.\n\n";
-    system("vncpasswd $vncUserDir/passwd"); 
+    system("vncpasswd"); 
     if (($? >> 8) != 0) {
        exit 1;
     }
