This is a patch to build X11R6.4 libraries and clients binaries with
gnu-win32 beta 19. Most of X libraries are built as DLLs.

What You have to do:
1. Take original X11R6.4 distribution from ftp.x.org (You need file
tog-1.tar.gz). Also, You can take contrib.tar.gz - it contains
a lot of useful programs (xman, for example) and documentation.
2. Unpack this file to some (current) directory with "tar xvfz tog-1.tar.gz".
You will have xc subdirectory.
Note: this directory should be on binary-mounted volume!
3. Apply this patch with "patch -p0 -s <X11R6.4-b19.diff" command
4. Cd to CYWINROOT/H-i386-cygwin32/bin directory and run "ln -s gcc.exe cc".
5. Rename xc/config/cf/site.sample to site.def
6. Cd to xc directory and run "make -i World". Full build takes about 2 hrs
on P-166 machine.
7. Run "make install". All X11R6.4 libraries and clients binaries are now
installed in /usr/X11R6.4 directory.

diff -urN -X xexclude xc.orig/config/cf/Imake.cf xc/config/cf/Imake.cf
--- xc.orig/config/cf/Imake.cf	Wed Jun 25 16:31:34 1997
+++ xc/config/cf/Imake.cf	Wed Apr 01 21:58:43 1998
@@ -414,6 +414,13 @@
 # endif /* __alpha */
 #endif /* linux */
 
+#ifdef __CYGWIN32__
+# define MacroIncludeFile <cygwin32.cf>
+# define MacroFile cygwin32.cf
+# define LinuxArchitecture
+# define i386Architecture
+#endif /* __CYGWIN32__ */
+
 #ifdef __uxp__
 # define MacroIncludeFile <fujitsu.cf>
 # define MacroFile fujitsu.cf
diff -urN -X xexclude xc.orig/config/cf/Imakefile xc/config/cf/Imakefile
--- xc.orig/config/cf/Imakefile	Thu Nov 07 22:48:15 1996
+++ xc/config/cf/Imakefile	Wed Apr 01 21:58:43 1998
@@ -14,6 +14,7 @@
 
 RULEFILES = \
 Imake.rules \
+cygwin32.rules \
 Motif.rules \
 Win32.rules \
 X11.rules \
@@ -36,6 +37,7 @@
 
 TMPLFILES = \
 Imake.tmpl \
+cygwin32.tmpl \
 Library.tmpl \
 Motif.tmpl \
 Server.tmpl \
@@ -58,6 +60,7 @@
 
 CFFILES = \
 Imake.cf \
+cygwin32.cf \
 Amoeba.cf \
 DGUX.cf \
 FreeBSD.cf \
diff -urN -X xexclude xc.orig/config/cf/cygwin32.cf xc/config/cf/cygwin32.cf
--- xc.orig/config/cf/cygwin32.cf	Thu Jan 01 03:00:00 1970
+++ xc/config/cf/cygwin32.cf	Wed Apr 01 21:58:43 1998
@@ -0,0 +1,116 @@
+XCOMM platform:  $XConsortium: cygwin32.cf sos 1996/02/08 18:59:31 gildea $
+XCOMM
+XCOMM changes since b18 cygwin32 release
+XCOMM	- avoided tons of "not in XXX directory" messages;
+XCOMM	- dlls are built stripped;
+XCOMM	- search for cpp in a default location;
+XCOMM	- fixed problem with missed netinet/tcp.h;
+XCOMM	- xterm compiles and works;
+XCOMM	- more libs are built as a dlls;
+XCOMM	- all dlls have different base addresses;
+
+#ifndef OSName
+#define OSName                  Cygwin32
+#endif
+#ifndef OSVendor
+#define OSVendor                Cygnus Solutions
+#endif
+#ifndef OSMajorVersion
+#define OSMajorVersion          19
+#endif
+#ifndef OSMinorVersion
+#define OSMinorVersion          0
+#endif
+#ifndef OSTeenyVersion
+#define OSTeenyVersion
+#endif
+
+#define BuildFonts		NO
+#define BuildServer		NO
+
+#ifndef UnixCpp
+#define UnixCpp
+#endif
+
+#define HasGcc                  YES
+#define HasGcc2                 YES
+#define HasGcc2ForCplusplus     YES
+#define GccUsesGas              YES
+#define UseGas                  YES
+#define GnuCpp                  YES
+#define HasShadowPasswd         NO
+#define HasLibCrypt             NO
+#define HasPutenv               YES
+#define HasShm                  NO
+#define HasSockets              YES
+#define GzipFontCompression	YES
+
+#define AvoidNullMakeCommand    NO
+#define StripInstalledPrograms  YES
+#define CompressAllFonts        YES
+#define Malloc0ReturnsNull      NO
+#define NeedConstPrototypes     YES
+#define NeedFunctionPrototypes  YES
+#define NeedNestedPrototypes    YES
+#define NeedVarargsPrototypes   YES
+#define NeedWidePrototypes      NO
+#define SetTtyGroup             YES
+#define ExpandManNames          NO
+
+#define ThreadedX		NO
+#define HasThreadSafeAPI	NO
+#define LnCmd                   ln -s
+#define CcCmd                   gcc
+#define AsCmd                   as
+#define LdCmd                   ld
+#define MkdirHierCmd            mkdir -p
+#define CppCmd                  `CcCmd --print-prog-name=cpp | sed 's@\\\\@/@g'`
+#define YaccCmd                 byacc
+#define LexCmd                  flex -l
+#define LexLib                  -lfl
+#define PreProcessCmd           CcCmd -E
+#define StdIncDir               `CcCmd --print-libgcc-file-name | sed 's:libgcc.a:../../../../i386-cygwin32/include:'|sed 's@\\\\@/@g'`
+#define PostIncDir              `CcCmd --print-libgcc-file-name | sed 's:libgcc.a:/include:'|sed 's@\\\\@/@g'`
+#define LdCombineFlags          -r
+#define OptimizedCDebugFlags    -O2 -s -mpentium
+#define StandardDefines         -D__i386__ -DX_LOCALE -D_MT -DNO_TCP_H
+#define XawI18nDefines          -DUSE_XWCHAR_STRING -DUSE_XMBTOWC
+#define HasWChar32              YES
+#define StandardCppDefines      -traditional StandardDefines
+#define ServerOSDefines         -DDDXTIME -DFD_SETSIZE=256
+#define ExtensionOSDefines      -DXTESTEXT1
+#define ServerExtraDefines      -DGCCUSESGAS
+#define ConnectionFlags         -DTCPCONN
+#define InstUidFlags            -s -m 4711
+#define UseRgbTxt		YES
+
+/* Some of these man page defaults are overriden in the above OS sections */
+#ifndef ManSuffix
+# define ManSuffix      1x
+#endif
+#ifndef ManDir
+# define ManDir         $(MANSOURCEPATH)1
+#endif
+#ifndef LibManSuffix
+# define LibManSuffix   3x
+#endif
+#ifndef LibmanDir
+# define LibmanDir      $(MANSOURCEPATH)3
+#endif
+#ifndef FileManSuffix
+# define FileManSuffix  5x
+#endif
+#ifndef FileManDir
+# define FileManDir     $(MANSOURCEPATH)5
+#endif
+
+#define TermcapLibrary -ltermcap
+
+/* --unix option of cygwin make fools the standard MakeFlagsToShellFlags macro */
+#define MakeFlagsToShellFlags(makeflags,shellcmd)\
+	for flag in ${MAKEFLAGS} ''; do \				@@\
+	  case "$$flag" in *=*) ;;--*) ;; *[makeflags]*) shellcmd;; esac; done
+
+#include <cygwin32.rules>
+/*#include <xfree86.cf>*/
+
diff -urN -X xexclude xc.orig/config/cf/cygwin32.rules xc/config/cf/cygwin32.rules
--- xc.orig/config/cf/cygwin32.rules	Thu Jan 01 03:00:00 1970
+++ xc/config/cf/cygwin32.rules	Wed Apr 01 21:58:43 1998
@@ -0,0 +1,181 @@
+XCOMM $XConsortium: cygwin32.rules /main/12 1996/01/03 14:51:18 kaleb $
+
+/*
+ * Cygwin32 shared library rules (DLL versions)
+ */
+#define HasSharedLibraries YES
+#define NeedLibInsideFlag YES
+#define ForceNormalLib NO
+#define SharedLibXaw NO
+#define SharedLibXmu NO
+#define SharedLibXt NO
+#define SharedLibSM YES
+#define SharedLibICE YES
+#define SharedLibXext YES
+#define SharedLibXie YES
+#define SharedLibXi YES
+#define SharedLibPex YES
+#define SharedLibXtst YES
+#define SharedOldX YES
+#define SharedLibXp YES
+
+
+#ifndef SharedDataSeparation
+#define SharedDataSeparation NO
+#endif
+#ifndef SharedCodeDef
+#define SharedCodeDef /**/
+#endif
+#ifndef SharedLibraryDef
+#define SharedLibraryDef /**/
+#endif
+#ifndef ShLibIncludeFile
+#define ShLibIncludeFile <cygwin32.tmpl>
+#endif
+#ifndef SharedLibraryLoadFlags
+#define SharedLibraryLoadFlags /**/
+#endif
+/*
+ * SharedLibraryDataTarget - generate rules to create shared data file
+ */
+#ifndef SharedLibraryDataTarget
+#define SharedLibraryDataTarget(libname,rev,salist)
+#endif
+/*
+ * InstallSharedLibraryData - generate rules to install the shared library data
+ */
+#ifndef InstallSharedLibraryData
+#define InstallSharedLibraryData(libname,rev,dest)
+#endif /* InstallSharedLibraryData */
+
+GCCLIB = $(shell echo							        \
+	-L`dirname \`gcc -print-file-name=libgcc.a|sed 's@\\\\\\\\@/@g'\``	\
+	-L`dirname \`gcc -print-file-name=libcygwin.a|sed 's@\\\\\\\\@/@g'\``   \
+	-L`dirname \`gcc -print-file-name=libkernel32.a|sed 's@\\\\\\\\@/@g'\`` \
+	-lgcc -lcygwin -lkernel32 -lgcc)
+DLLTOOL= dlltool
+BASE_COUNTER=/tmp/DLL_BASE_COUNTER
+
+#define MakeDLL(libname,solist)					@@\
+	if [ -f $(BASE_COUNTER) ]; then true; \			@@\
+	else echo 0x67000000 > $(BASE_COUNTER); fi		@@\
+	$(DLLTOOL) --dllname Concat3(lib,libname,.dll) --def libname.def --output-lib Concat3(lib,libname,.a) @@\
+	$(LD) --base-file=dll.base $(LD_STUFF)			@@\
+	$(DLLTOOL) $(DLL_STUFF)					@@\
+	$(LD) --base-file=dll.base win.exp $(LD_STUFF)		@@\
+	$(DLLTOOL) $(DLL_STUFF)					@@\
+	$(LD) win.exp $(LD_STUFF)				@@\
+	rm -f win.exp dll.base					@@\
+	IMAGE_LENGTH=`objdump -x Concat3(lib,libname,.dll) |awk '/SizeOfImage/ {print "0x"$$2}'`; \ @@\
+	export IMAGE_LENGTH=`expr '(' \`printf %d $$IMAGE_LENGTH\` / 65536 + 1 ')' '*' 65536` ; \ @@\
+	export IMAGE_BASE=`cat $(BASE_COUNTER)`; \			@@\
+	printf 0x%x `expr \`printf %d $$IMAGE_BASE\` + $$IMAGE_LENGTH` > $(BASE_COUNTER)
+
+
+#define SharedLibraryTarget(libname,rev,solist,down,up)                 @@\
+AllTarget(Concat3(lib,libname,.dll))                                    @@\
+									@@\
+CppFileTarget(libname.def,libname-def.cpp,-DLIBRARY_VERSION=rev,$(ICONFIGFILES)) @@\
+									@@\
+LD_STUFF=--dll -s -o Concat3(lib,libname,.dll) solist junk.o $(REQUIREDLIBS) -e __cygwin32_dll_entry@12 $(GCCLIB) --image-base `cat $(BASE_COUNTER)` @@\
+DLL_STUFF=--dllname Concat3(lib,libname,.dll) --def libname.def --base-file dll.base --output-exp win.exp @@\
+                                                                        @@\
+junk.c:                                                                                 @@\
+	echo "#include <cygwin32/cygwin_dll.h>"		>junk.c		@@\
+	echo "DECLARE_CYGWIN_DLL(dll_main);"		>>junk.c	@@\
+	echo "int WINAPI dll_main(HANDLE a, DWORD reason, void *q)" >>junk.c  @@\
+	echo "{ return 1; }"				>>junk.c	@@\
+Concat3(lib,libname,.dll): solist junk.o libname.def			@@\
+	RemoveFile(LibraryTargetName(libname))				@@\
+	RemoveFile(Concat3(lib,libname,.dll))				@@\
+	MakeDLL(libname,solist)						@@\
+	LinkBuildLibrary(Concat3(lib,libname,.a))			@@\
+clean::									@@\
+	RemoveFile(LibraryTargetName(libname))				@@\
+	RemoveFile(Concat3(lib,libname,.dll))				@@\
+	RemoveFile(junk.o)						@@\
+	RemoveFile(junk.c)						@@\
+	RemoveFile($(BASE_COUNTER))
+
+#define InstallSharedLibrary(libname,rev,dest)                          @@\
+InstallTarget(install,LibraryTargetName(libname),$(INSTLIBFLAGS),$(USRLIBDIR)) @@\
+InstallTarget(install,Concat3(lib,libname,.dll),$(INSTLIBFLAGS),$(BINDIR))
+
+#define ProgramTargetName(target)target.exe
+
+#define NormalProgramTarget(program,objects,deplibs,locallibs,syslibs)  @@\
+AllTarget(ProgramTargetName(program))					@@\
+ProgramTargetName(program): objects deplibs				@@\
+	RemoveTargetProgram($@)						@@\
+	LinkRule($@,$(LDOPTIONS),objects,locallibs $(LDLIBS) syslibs)	@@\
+									@@\
+clean::									@@\
+	RemoveFile(ProgramTargetName(program))
+
+#define ProgramTargetHelper(program,srcs,objs,deplib,locallib,syslib)	@@\
+ProgramTargetName(program): $(objs) $(deplib)				@@\
+	RemoveTargetProgram($@)						@@\
+	LinkRule($@,$(LDOPTIONS),$(objs),locallib $(LDLIBS) syslib)	@@\
+									@@\
+InstallProgram(program,$(BINDIR))					@@\
+InstallManPage(program,$(MANDIR))
+
+#define ComplexProgramTarget(program)					@@\
+AllTarget(ProgramTargetName(program))					@@\
+									@@\
+ProgramTargetHelper(program,SRCS,OBJS,DEPLIBS,$(LOCAL_LIBRARIES),NullParameter) @@\
+									@@\
+DependTarget()								@@\
+LintTarget()								@@\
+									@@\
+clean::									@@\
+	RemoveFile(ProgramTargetName(program))
+
+#define ComplexProgramTarget_1(program,locallib,syslib)			@@\
+        OBJS = $(OBJS1) $(OBJS2) $(OBJS3)				@@\
+        SRCS = $(SRCS1) $(SRCS2) $(SRCS3)				@@\
+        PROGRAM1 = ProgramTargetName(program)				@@\
+									@@\
+AllTarget($(PROGRAM1) $(PROGRAM2) $(PROGRAM3))				@@\
+									@@\
+ProgramTargetHelper(program,SRCS1,OBJS1,DEPLIBS1,locallib,syslib)	@@\
+									@@\
+DependTarget()								@@\
+LintTarget()								@@\
+									@@\
+clean::									@@\
+	for i in $(PROGRAMS); do $(RM) ProgramTargetName($$i); done
+
+#define ComplexProgramTarget_2(program,locallib,syslib)			@@\
+        PROGRAM2 = ProgramTargetName(program)				@@\
+									@@\
+ProgramTargetHelper(program,SRCS2,OBJS2,DEPLIBS2,locallib,syslib)
+
+#define ComplexProgramTarget_3(program,locallib,syslib)			@@\
+        PROGRAM3 = ProgramTargetName(program)				@@\
+									@@\
+ProgramTargetHelper(program,SRCS3,OBJS3,DEPLIBS3,locallib,syslib)
+
+#define ServerTargetWithFlags(server,subdirs,objects,libs,syslibs,flags) @@\
+AllTarget(ProgramTargetName(server))					@@\
+ProgramTargetName(server): subdirs objects libs				@@\
+	MoveToBakFile($@)						@@\
+	LinkRule($@,$(LDOPTIONS),objects,libs $(LDLIBS) syslibs)	@@\
+									@@\
+Concat(load,server):							@@\
+	MoveToBakFile(ProgramTargetName(server))			@@\
+	LinkRule(ProgramTargetName(server),$(LDOPTIONS),objects,libs $(LDLIBS) syslibs) @@\
+									@@\
+loadX:: Concat(load,server)						@@\
+									@@\
+SentinelProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
+SentinelLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
+PurifyProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
+PurifyLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
+ProofProgramTarget(server,subdirs objects libs,objects libs $(LDLIBS) syslibs) @@\
+ProofLinkTarget(Concat(load,server),server,objects libs $(LDLIBS) syslibs) @@\
+									@@\
+InstallProgramWithFlags(server,$(BINDIR),flags)				@@\
+									@@\
+clean::									@@\
+	RemoveFile(ProgramTargetName(server))
diff -urN -X xexclude xc.orig/config/cf/cygwin32.tmpl xc/config/cf/cygwin32.tmpl
--- xc.orig/config/cf/cygwin32.tmpl	Thu Jan 01 03:00:00 1970
+++ xc/config/cf/cygwin32.tmpl	Wed Apr 01 21:58:43 1998
@@ -0,0 +1,23 @@
+XCOMM $XConsortium: WinLib.tmpl,v 1.1 94/01/08 18:32:51 rws Exp $
+
+#define SharedOldXReqs $(LDPRELIB) $(XLIBONLY)
+#define SharedXtReqs $(LDPRELIB) $(SMLIB) $(ICELIB) $(XLIBONLY)
+#define SharedXawReqs $(LDPRELIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
+#define SharedXmuReqs $(LDPRELIB) $(XTOOLLIB) $(XLIB)
+#define SharedXextReqs $(LDPRELIB) $(XLIBONLY)
+#define SharedXiReqs $(LDPRELIB) $(XLIB)
+#define SharedPexReqs $(LDPRELIB) $(XLIBONLY) MathLibrary
+#define SharedXtstReqs $(LDPRELIB) $(XLIB)
+#define SharedXieReqs $(LDPRELIB) $(XLIBONLY)
+#define SharedSMReqs $(LDPRELIB) $(ICELIB)
+#define SharedXpReqs $(LDPRELIBS) $(XAUTHLIB) $(EXTENSIONLIB) $(XLIBONLY)
+#ifndef FixupLibReferences
+#define FixupLibReferences()						@@\
+XMULIBONLY = -lXmu							@@\
+XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+#endif
+
+#ifndef XawClientLibs
+#define XawClientLibs $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+#endif
+
diff -urN -X xexclude xc.orig/config/imake/imake.c xc/config/imake/imake.c
--- xc.orig/config/imake/imake.c	Fri Feb 06 19:02:29 1998
+++ xc/config/imake/imake.c	Wed Apr 01 21:58:44 1998
@@ -363,7 +363,11 @@
 	sprintf(makefileMacro, "MAKEFILE=%s", Imakefile);
 	AddMakeArg( makefileMacro );
 
+#ifdef __CYGWIN32__
+	if ((tmpfd = fopen(tmpMakefile, "wb+")) == NULL)
+#else
 	if ((tmpfd = fopen(tmpMakefile, "w+")) == NULL)
+#endif
 		LogFatal("Cannot create temporary file %s.", tmpMakefile);
 
 	cleanedImakefile = CleanCppInput(Imakefile);
diff -urN -X xexclude xc.orig/config/imake/imakemdep.h xc/config/imake/imakemdep.h
--- xc.orig/config/imake/imakemdep.h	Fri Feb 06 19:02:22 1998
+++ xc/config/imake/imakemdep.h	Wed Apr 01 21:58:44 1998
@@ -253,6 +253,10 @@
 /* expects cpp in PATH */
 #define DEFAULT_CPP "cpp"
 #endif
+#ifdef __CYGWIN32__
+#define USE_CC_E
+#define DEFAULT_CC "gcc"
+#endif
 
 /*
  * Step 5:  cpp_argv
@@ -477,6 +481,9 @@
 #ifdef linux
         "-traditional",
         "-Dlinux",
+#endif
+#ifdef __CYGWIN32__
+        "-traditional",
 #endif
 #ifdef __uxp__
 	"-D__uxp__",
diff -urN -X xexclude xc.orig/config/makedepend/main.c xc/config/makedepend/main.c
--- xc.orig/config/makedepend/main.c	Fri Feb 06 19:10:07 1998
+++ xc/config/makedepend/main.c	Wed Apr 01 21:58:44 1998
@@ -610,12 +610,12 @@
 		fatalerr("cannot open \"%s\"\n", makefile);
 	sprintf(backup, "%s.bak", makefile);
 	unlink(backup);
-#ifdef WIN32
+#if defined (WIN32) || defined (__CYGWIN32__)
 	fclose(fdin);
 #endif
 	if (rename(makefile, backup) < 0)
 		fatalerr("cannot rename %s to %s\n", makefile, backup);
-#ifdef WIN32
+#if defined (WIN32) || defined (__CYGWIN32__)
 	if ((fdin = fopen(backup, "r")) == NULL)
 		fatalerr("cannot open \"%s\"\n", backup);
 #endif
@@ -638,7 +638,7 @@
 	    }
 	}
 	fflush(fdout);
-#if defined(USGISH) || defined(_SEQUENT_)
+#if defined(USGISH) || defined(_SEQUENT_) || defined (__CYGWIN32__)
 	chmod(makefile, st.st_mode);
 #else
         fchmod(fileno(fdout), st.st_mode);
diff -urN -X xexclude xc.orig/lib/ICE/ICE-def.cpp xc/lib/ICE/ICE-def.cpp
--- xc.orig/lib/ICE/ICE-def.cpp	Sun Jan 04 20:25:33 1998
+++ xc/lib/ICE/ICE-def.cpp	Wed Apr 01 21:58:44 1998
@@ -27,6 +27,7 @@
  IceLastReceivedSequenceNumber
  IceLastSentSequenceNumber
  IceListenForConnections
+ IceListenForWellKnownConnections
  IceLockAuthFile
  IceOpenConnection
  IcePing
@@ -49,6 +50,7 @@
  IceUnlockAuthFile
  IceVendor
  IceWriteAuthFileEntry
+ _IceTransGetHostname
  _IceTransGetPeerAddr
  _IceTransGetPeerNetworkId
  _IceErrorBadMinor
diff -urN -X xexclude xc.orig/lib/X11/X11-def.cpp xc/lib/X11/X11-def.cpp
--- xc.orig/lib/X11/X11-def.cpp	Sun Jan 04 20:24:19 1998
+++ xc/lib/X11/X11-def.cpp	Wed Apr 01 22:10:00 1998
@@ -1,12 +1,18 @@
+#ifndef __CYGWIN32__
 LIBRARY X11
+#else
+LIBRARY libX11
+#endif
 VERSION LIBRARY_VERSION
 EXPORTS
+#ifndef __CYGWIN32__
  _Xdebug_p=_Xdebug CONSTANT
  _XCreateMutex_fn_p=_XCreateMutex_fn CONSTANT
  _XFreeMutex_fn_p=_XFreeMutex_fn CONSTANT
  _XLockMutex_fn_p=_XLockMutex_fn CONSTANT
  _XUnlockMutex_fn_p=_XUnlockMutex_fn CONSTANT
  _Xglobal_lock_p=_Xglobal_lock CONSTANT
+#endif
  XActivateScreenSaver
  XAddConnectionWatch
  XAddExtension
@@ -599,14 +605,18 @@
  _XDeqAsyncHandler
  _XEatData
  _XError
+#ifndef __CYGWIN32__
  _XFlushIt
+#endif
  _XFlushGCCache
  _XFreeTemp
  _XGetAsyncData
  _XGetAsyncReply
  _XIOError
  _XInitImageFuncPtrs
+#ifndef __CYGWIN32__
  _XLockDisplay
+#endif
  _XRead
  _XReadEvents
  _XReadPad
@@ -620,8 +630,10 @@
  _XUnregisterFilter
  _XUnregisterInternalConnection
  _XVIDtoVisual
+#ifndef __CYGWIN32__
  _Xthread_init
  _Xthread_waiter
+#endif
  XkbIgnoreExtension
  XkbOpenDisplay
  XkbQueryExtension
@@ -806,4 +818,23 @@
  XkbUpdateKeyTypeVirtualMods
  XkbUpdateMapFromCore
  XkbXlibControlsImplemented
+#ifdef __CYGWIN32__
+ _Xsetlocale
+ _XFlush
+ _Xlcmbtowc
+ _Xlcwctomb
+ _Xlcmbstowcs
+ _Xlcwcstombs
+ _Xmbtowc
+ _Xmblen
+ _Xwctomb
+ _Xmbstowcs
+ _Xwcstombs
+ _Xwcscpy
+ _Xwcsncpy
+ _Xwcslen
+ _Xwcscmp
+ _Xwcsncmp
+#endif
+
 /* $TOG: X11-def.cpp /main/18 1998/01/04 12:31:30 kaleb $ */
diff -urN -X xexclude xc.orig/lib/Xext/Xext-def.cpp xc/lib/Xext/Xext-def.cpp
--- xc.orig/lib/Xext/Xext-def.cpp	Sun Jan 04 20:25:22 1998
+++ xc/lib/Xext/Xext-def.cpp	Wed Apr 01 22:02:11 1998
@@ -89,6 +89,8 @@
  XSecurityFreeXauth
  XSecurityGenerateAuthorization
  XSecurityRevokeAuthorization
+ XLbxQueryExtension
+ XLbxQueryVersion
  XagQueryVersion
  XagCreateAssociation
  XagCreateEmbeddedApplicationGroup
diff -urN -X xexclude xc.orig/lib/Xmu/Xmu-def.cpp xc/lib/Xmu/Xmu-def.cpp
--- xc.orig/lib/Xmu/Xmu-def.cpp	Thu Jan 01 03:00:00 1970
+++ xc/lib/Xmu/Xmu-def.cpp	Wed Apr 01 22:02:11 1998
@@ -0,0 +1,98 @@
+LIBRARY libXmu
+VERSION LIBRARY_VERSION
+EXPORTS
+XmuAllStandardColormaps
+XmuGetAtomName
+XmuInternAtom
+XmuInternStrings
+XmuMakeAtom
+XmuNameOfAtom
+XmuClientWindow
+XmuAddCloseDisplayHook
+XmuLookupCloseDisplayHook
+XmuRemoveCloseDisplayHook
+XmuGetColormapAllocation
+XmuCreateColormap
+XmuCreatePixmapFromBitmap
+XmuCursorNameToIndex
+_XmuCCLookupDisplay
+XmuConvertStandardSelection
+XmuPrintDefaultErrorMessage
+XmuSimpleErrorHandler
+XmuDeleteStandardColormap
+XmuDQAddDisplay
+XmuDQCreate
+XmuDQDestroy
+XmuDQLookupDisplay
+XmuDQRemoveDisplay
+XmuDistinguishableColors
+XmuDistinguishablePixels
+XmuDrawLogo
+XmuDrawRoundedRectangle
+XmuFillRoundedRectangle
+_XEditResCheckMessages
+_XEditResGet16
+_XEditResGet32
+_XEditResGet8
+_XEditResGetSigned16
+_XEditResGetString8
+_XEditResGetWidgetInfo
+_XEditResPut16
+_XEditResPut32
+_XEditResPut8
+_XEditResPutString8
+_XEditResPutWidgetInfo
+_XEditResResetStream
+XmuRegisterExternalAgent
+XmuCvtFunctionToCallback
+XmuGetHostname
+XmuCreateStippledPixmap
+XmuReleaseStippledPixmap
+XmuAddInitializer
+XmuCallInitializers
+XmuLocateBitmapFile
+XmuLocatePixmapFile
+_XmuStringToBitmapFreeCache
+_XmuStringToBitmapInitCache
+XmuLookupAPL
+XmuLookupArabic
+XmuLookupCyrillic
+XmuLookupGreek
+XmuLookupHebrew
+XmuLookupJISX0201
+XmuLookupKana
+XmuLookupLatin1
+XmuLookupLatin2
+XmuLookupLatin3
+XmuLookupLatin4
+XmuLookupString
+XmuLookupStandardColormap
+XmuCompareISOLatin1
+XmuCopyISOLatin1Lowered
+XmuCopyISOLatin1Uppered
+XmuReadBitmapData
+XmuReadBitmapDataFromFile
+XmuScreenOfWindow
+XmuReshapeWidget
+XmuStandardColormap
+XmuCvtStringToBackingStore
+XmuCvtStringToBitmap
+XmuCvtStringToColorCursor
+XmuCvtStringToCursor
+XmuCvtStringToGravity
+XmuCvtStringToJustify
+XmuCvtStringToLong
+XmuCvtStringToOrientation
+XmuCvtStringToShapeStyle
+XmuCvtStringToWidget
+XmuNewCvtStringToWidget
+XmuUpdateMapHints
+XmuVisualStandardColormaps
+XmuWnCountOwnedResources
+XmuWnFetchResources
+XmuWnInitializeNodes
+XmuWnNameToNode
+XctCreate
+XctFree
+XctNextItem
+XctReset
diff -urN -X xexclude xc.orig/lib/font/fontfile/filewr.c xc/lib/font/fontfile/filewr.c
--- xc.orig/lib/font/fontfile/filewr.c	Mon Feb 09 18:48:06 1998
+++ xc/lib/font/fontfile/filewr.c	Wed Apr 01 22:03:24 1998
@@ -35,7 +35,7 @@
 {
     int	fd;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN32__)
     fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
 #else
     fd = creat (name, 0666);
diff -urN -X xexclude xc.orig/lib/zlib/zconf.h xc/lib/zlib/zconf.h
--- xc.orig/lib/zlib/zconf.h	Wed Feb 04 22:51:22 1998
+++ xc/lib/zlib/zconf.h	Wed Apr 01 22:03:25 1998
@@ -47,7 +47,7 @@
 #  define voidp		z_voidp
 #endif
 
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
+#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__CYGWIN32__)
 #  define WIN32
 #endif
 #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
diff -urN -X xexclude xc.orig/programs/Xserver/Xprint/attributes.c xc/programs/Xserver/Xprint/attributes.c
--- xc.orig/programs/Xserver/Xprint/attributes.c	Mon Dec 30 23:01:24 1996
+++ xc/programs/Xserver/Xprint/attributes.c	Wed Apr 01 22:03:25 1998
@@ -1233,7 +1233,7 @@
     return command;
 }
 
-#if defined(CSRG_BASED) || defined(linux) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL))
+#if defined(CSRG_BASED) || defined(linux) || (defined(sun) && !defined(SVR4)) || (defined(SVR4) && !defined(sun) && !defined(USL)) || defined(__CYGWIN32__)
 #define iswspace(c) (isascii(c) && isspace(toascii(c)))
 #endif
 
diff -urN -X xexclude xc.orig/programs/Xserver/include/servermd.h xc/programs/Xserver/include/servermd.h
--- xc.orig/programs/Xserver/include/servermd.h	Mon Feb 09 22:29:54 1998
+++ xc/programs/Xserver/include/servermd.h	Wed Apr 01 22:03:25 1998
@@ -314,7 +314,7 @@
      defined(linux) || \
      (defined(AMOEBA) && defined(i80386)) || \
      defined(MINIX) || \
-     defined(WIN32))
+     defined(WIN32)) || defined(__CYGWIN32__)
 
 #ifndef IMAGE_BYTE_ORDER
 #define IMAGE_BYTE_ORDER	LSBFirst
diff -urN -X xexclude xc.orig/programs/Xserver/os/connection.c xc/programs/Xserver/os/connection.c
--- xc.orig/programs/Xserver/os/connection.c	Mon Feb 09 23:11:40 1998
+++ xc/programs/Xserver/os/connection.c	Wed Apr 01 22:03:25 1998
@@ -86,7 +86,7 @@
 
 #if defined(TCPCONN) || defined(STREAMSCONN)
 # include <netinet/in.h>
-# ifndef hpux
+# if !defined(hpux) && !defined(__CYGWIN32__)
 #  ifdef apollo
 #   ifndef NO_TCP_H
 #    include <netinet/tcp.h>
diff -urN -X xexclude xc.orig/programs/Xserver/os/osinit.c xc/programs/Xserver/os/osinit.c
--- xc.orig/programs/Xserver/os/osinit.c	Mon Feb 09 23:12:33 1998
+++ xc/programs/Xserver/os/osinit.c	Wed Apr 01 22:03:25 1998
@@ -118,7 +118,7 @@
 		dup2 (fileno (err), 2);
 		fclose (err);
 	    }
-#if defined(SYSV) || defined(SVR4) || defined(WIN32)
+#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN32__)
 	    {
 	    static char buf[BUFSIZ];
 	    setvbuf (stderr, buf, _IOLBF, BUFSIZ);
diff -urN -X xexclude xc.orig/programs/lbxproxy/os/connection.c xc/programs/lbxproxy/os/connection.c
--- xc.orig/programs/lbxproxy/os/connection.c	Wed Feb 11 17:53:54 1998
+++ xc/programs/lbxproxy/os/connection.c	Wed Apr 01 22:03:26 1998
@@ -83,7 +83,7 @@
 
 #if defined (TCPCONN) || defined(STREAMSCONN)
 # include <netinet/in.h>
-# ifndef hpux
+# if !defined(hpux) && !defined(__CYGWIN32__)
 #  ifdef apollo
 #   ifndef NO_TCP_H
 #    include <netinet/tcp.h>
diff -urN -X xexclude xc.orig/programs/xdm/choose.c xc/programs/xdm/choose.c
--- xc.orig/programs/xdm/choose.c	Mon Feb 09 21:54:23 1998
+++ xc/programs/xdm/choose.c	Wed Apr 01 22:03:26 1998
@@ -36,7 +36,9 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#ifndef __CYGWIN32__
 #include <sys/un.h>
+#endif
 #include <ctype.h>
 #include <errno.h>
 #if defined(STREAMSCONN)
diff -urN -X xexclude xc.orig/programs/xdm/daemon.c xc/programs/xdm/daemon.c
--- xc.orig/programs/xdm/daemon.c	Mon Feb 09 21:54:30 1998
+++ xc/programs/xdm/daemon.c	Wed Apr 01 22:03:26 1998
@@ -116,7 +116,7 @@
     close (1);
     close (2);
 
-#if !((defined(SYSV) || defined(SVR4)) && defined(i386))
+#if !((defined(SYSV) || defined(SVR4)) && defined(i386)) && !defined(__CYGWIN32__)
     if ((i = open ("/dev/tty", O_RDWR)) >= 0) {	/* did open succeed? */
 #if defined(USG) && defined(TCCLRCTTY)
 	int zero = 0;
diff -urN -X xexclude xc.orig/programs/xdm/socket.c xc/programs/xdm/socket.c
--- xc.orig/programs/xdm/socket.c	Mon Feb 09 21:56:17 1998
+++ xc/programs/xdm/socket.c	Wed Apr 01 22:03:26 1998
@@ -38,7 +38,9 @@
 #include <errno.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#ifndef __CYGWIN32__
 #include <sys/un.h>
+#endif
 #include <netdb.h>
 
 #ifdef X_NOT_STDC_ENV
diff -urN -X xexclude xc.orig/programs/xdm/util.c xc/programs/xdm/util.c
--- xc.orig/programs/xdm/util.c	Mon Feb 09 21:56:26 1998
+++ xc/programs/xdm/util.c	Wed Apr 01 22:03:26 1998
@@ -212,7 +212,7 @@
 
 CleanUpChild ()
 {
-#if defined(SYSV) || defined(SVR4)
+#if defined(SYSV) || defined(SVR4) || defined(__CYGWIN32__)
 	setpgrp ();
 #else
 	setpgrp (0, getpid ());
diff -urN -X xexclude xc.orig/programs/xdm/xdmcp.c xc/programs/xdm/xdmcp.c
--- xc.orig/programs/xdm/xdmcp.c	Mon Feb 09 21:56:34 1998
+++ xc/programs/xdm/xdmcp.c	Wed Apr 01 22:03:27 1998
@@ -41,7 +41,9 @@
 
 #include	<sys/socket.h>
 #include	<netinet/in.h>
+#ifndef __CYGWIN32__
 #include	<sys/un.h>
+#endif
 #include	<netdb.h>
 
 #ifdef X_NOT_STDC_ENV
@@ -529,7 +531,7 @@
 		}
 		break;
 #endif
-#ifdef AF_UNIX
+#if defined(AF_UNIX) && !defined(__CYGWIN32__)
 	    case AF_UNIX:
 		{
 		    struct sockaddr_un	un_addr;
diff -urN -X xexclude xc.orig/programs/xhost/xhost.c xc/programs/xhost/xhost.c
--- xc.orig/programs/xhost/xhost.c	Mon Feb 09 21:58:46 1998
+++ xc/programs/xhost/xhost.c	Wed Apr 01 22:03:27 1998
@@ -651,3 +651,12 @@
     XmuPrintDefaultErrorMessage (dpy, rep, stderr);
     return 0;
 }
+
+#ifdef __CYGWIN32__
+void sethostent(int x)
+{}
+
+void endhostent()
+{}
+#endif
+
diff -urN -X xexclude xc.orig/programs/xterm/Imakefile xc/programs/xterm/Imakefile
--- xc.orig/programs/xterm/Imakefile	Thu Aug 28 16:09:06 1997
+++ xc/programs/xterm/Imakefile	Wed Apr 01 22:03:27 1998
@@ -39,10 +39,9 @@
           OBJS2 = resize.o
            SRCS = $(SRCS1) $(SRCS2)
            OBJS = $(OBJS1) $(OBJS2)
-       PROGRAMS = resize xterm
        DEPLIBS1 = XkbClientDepLibs XawClientDepLibs
        DEPLIBS2 = 
-       PROGRAMS = xterm resize
+       PROGRAMS = ProgramTargetName(xterm) ProgramTargetName(resize)
 
 #ifndef TermcapLibrary
 #if SystemV && !defined(MacIIArchitecture)
@@ -83,7 +82,7 @@
 #endif
 #endif
 #endif
-install:: xterm
+install:: ProgramTargetName(xterm)
 	MakeDir($(DESTDIR)$(BINDIR))
 	RemoveFile(xterm.inst)
 	LinkRule(xterm.inst,$(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS),$(OBJS1),$(LDOVERRIDE) XawClientLibs $(LDRESUME) $(LDLIBS) $(TERMCAPLIB) $(PTYLIB))
diff -urN -X xexclude xc.orig/programs/xterm/main.c xc/programs/xterm/main.c
--- xc.orig/programs/xterm/main.c	Mon Feb 09 22:16:58 1998
+++ xc/programs/xterm/main.c	Wed Apr 01 22:03:27 1998
@@ -129,6 +129,14 @@
 #define WTMP
 #endif
 
+#ifdef __CYGWIN32__
+#define SYSV
+#define SVR4
+#define LASTLOG
+#define WTMP
+#define ATT
+#endif
+
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 
@@ -260,7 +268,7 @@
 #define ttyslot() 1
 #endif /* apollo */
 
-#ifdef SVR4
+#if defined(SVR4) && !defined(__CYGWIN32__)
 #include <utmpx.h>
 #define setutent setutxent
 #define getutent getutxent
@@ -983,7 +991,9 @@
     	d_tio.c_cc[VEOF] = CEOF;
 	d_tio.c_cc[VEOL] = CNUL;
 	d_tio.c_cc[VEOL2] = CNUL;
+#ifdef VSWTCH
 	d_tio.c_cc[VSWTCH] = CNUL;
+#endif
 
 #ifdef USE_TERMIOS /* { */
 	d_tio.c_cc[VSUSP] = CSUSP;
@@ -1835,7 +1845,7 @@
 #endif	/* sun */
 	struct passwd *pw = NULL;
 #ifdef UTMP
-#ifdef SVR4
+#if defined(SVR4) && !defined(__CYGWIN32__)
 	struct utmpx utmp;
 #else
 	struct utmp utmp;
@@ -2991,7 +3001,7 @@
 	/* hung sh problem? */
 	signal (SIGHUP, SIG_DFL);
 #else
-	signal (SIGHUP,SIG_IGN);
+	signal (SIGHUP, SIG_IGN);
 #endif
 
 /*
@@ -3351,6 +3361,16 @@
     static long arg;
     ioctl (fd, FIONREAD, (char *) &arg);
     return (int) arg;
+#elif defined(__CYGWIN32__)
+    fd_set set;
+    struct timeval timeout = {0, 0};
+
+    FD_ZERO (&set);
+    FD_SET (fd, &set);
+    if (select (fd+1, &set, NULL, NULL, &timeout) > 0)
+      return 1;
+    else
+      return 0;
 #else
     struct pollfd pollfds[1];
 
diff -urN -X xexclude xc.orig/programs/xterm/resize.c xc/programs/xterm/resize.c
--- xc.orig/programs/xterm/resize.c	Thu May 25 06:12:04 1995
+++ xc/programs/xterm/resize.c	Wed Apr 01 22:03:27 1998
@@ -59,7 +59,7 @@
 #undef SYSV				/* pretend to be bsd */
 #endif /* macII */
 
-#if defined(SYSV) || defined(linux)
+#if defined(SYSV) || defined(linux) || defined(__CYGWIN32__)
 #define USE_SYSV_TERMIO
 #define USE_SYSV_UTMP
 #else /* else not SYSV */
