diff --git a/configure.ac b/configure.ac
index d7d00e2..cb2586f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -609,9 +609,15 @@ fi
 dnl Handle building documentation
 AM_CONDITIONAL(BUILDDOCS, test "x$BUILDDOCS" = xyes)
 
-dnl Only build sgml docs when linuxdoc is available and
-dnl def.ents has been installed
-XORG_CHECK_LINUXDOC
+AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes])
+
+AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDDOC = xyes])
+
+if test "x$BUILD_LINUXDOC" = xauto; then
+	dnl Only build sgml docs when linuxdoc is available and
+	dnl def.ents has been installed
+	XORG_CHECK_LINUXDOC
+fi
 
 dnl Handle installing libxf86config
 AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
@@ -961,7 +967,6 @@ AC_SUBST([VENDOR_RELEASE])
 AC_SUBST([VENDOR_MAN_VERSION])
 
 AC_DEFINE(DDXOSINIT, 1, [Use OsVendorInit])
-AC_DEFINE(SERVER_LOCK, 1, [Use a lock to prevent multiple servers on a display])
 AC_DEFINE(SMART_SCHEDULE, 1, [Include time-based scheduler])
 AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])
 
@@ -1653,11 +1658,13 @@ if test "x$XWIN" = xauto; then
 		mingw*) XWIN="yes" ;;
 		*) XWIN="no" ;;
 	esac
-	XWIN_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $OS_LIB $SHADOW_LIB"
+	XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
 	AC_SUBST([XWIN_LIBS])
 fi
 AC_MSG_RESULT([$XWIN])
 
+AM_CONDITIONAL(LIBCWRAPPER, [test "x$XWIN" = xno])
+
 if test "x$XWIN" = xyes; then
 	XWIN_SERVER_NAME=XWin
 	case $host_os in
@@ -1670,13 +1677,20 @@ if test "x$XWIN" = xyes; then
 		mingw*)
 			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
 			XWIN_SERVER_NAME=Xming
-			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
 			AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
-			XWIN_SYSTEM_LIBS=-lwinsock2
+			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
+			AC_DEFINE(ROOTLESS,1,[Build Rootless code])
+			AC_DEFINE(READ_FONTDIRS,1,[Read font path from fontdir file])
+			XWINMODULES_LIBS="${XWINMODULES_LIBS} -lX11 -lXau -lXdmcp -lXfont -lfontenc -lfreetype -lz -lgdi32 -lws2_32 -lpthreadGC2"
+			CFLAGS="$CFLAGS -DFD_SETSIZE=1024"
 			;;
 	esac
 	AC_SUBST(XWIN_SERVER_NAME)
-	AC_SUBST(XWIN_SYSTEM_LIBS)
+	AC_SUBST(XWINMODULES_LIBS)
+	AC_SUBST(CFLAGS)
+
+	GLX_DEFINES="-DAPIENTRY=__stdcall"
+	AC_SUBST([GLX_DEFINES])
 
 	if test "x$DEBUGGING" = xyes; then
 		AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
@@ -1697,14 +1711,12 @@ if test "x$XWIN" = xyes; then
 		AC_MSG_NOTICE([Disabling XF86Misc extension])
 		XF86MISC=no
 	fi
-	if test "x$COMPOSITE" = xyes; then
-		AC_MSG_NOTICE([Disabling Composite extension])
-		COMPOSITE=no
-	fi
+else
+	AC_DEFINE(SERVER_LOCK, 1, [Use a lock to prevent multiple servers on a display])
 fi
 AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
-AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && false])
+AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && false])
 AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes && false])
diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c
index 52f837e..af6225d 100644
--- a/hw/xwin/InitInput.c
+++ b/hw/xwin/InitInput.c
@@ -31,10 +31,8 @@
 #include <xwin-config.h>
 #endif
 #include "win.h"
-#ifdef XWIN_CLIPBOARD
-# include "../../Xext/xf86miscproc.h"
-#endif
 #include "dixstruct.h"
+#include "inputstr.h"
 
 
 /*
@@ -106,6 +104,12 @@ ProcessInputEvents (void)
 }
 
 
+void DDXRingBell(int volume, int pitch, int duration)
+{
+  MessageBeep (MB_OK); 
+}
+
+
 int
 TimeSinceLastInputEvent ()
 {
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 57e2010..e8b6103 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -121,8 +123,9 @@ SRCS =	InitInput.c \
 	winpriv.h \
 	winresource.h \
 	winwindow.h \
+	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/mi/miinitext.c \
-	$(top_srcdir)/fb/fbcmap.c \
+	$(top_srcdir)/fb/fbcmap_mi.c \
 	$(SRCS_CLIPBOARD) \
 	$(SRCS_GLX_WINDOWS) \
 	$(SRCS_MULTIWINDOW) \
@@ -147,7 +150,32 @@ INCLUDES = -I$(top_srcdir)/miext/rootless \
            -I$(top_srcdir)/miext/rootless/safeAlpha
 
 XWin_LDADD = $(XORG_CORE_LIBS) \
+	     XWin.res \
 	     $(top_builddir)/fb/libfb.la \
+	     $(top_builddir)/mi/libmi.la \
+	     $(top_builddir)/xfixes/libxfixes.la \
+	     $(top_builddir)/Xext/libXext.la \
+	     $(top_builddir)/dbe/libdbe.la \
+	     $(top_builddir)/XTrap/libxtrap.la \
+	     $(top_builddir)/record/librecord.la \
+	     $(top_builddir)/GL/glx/libglx.la \
+	     $(top_builddir)/GL/mesa/libGLcore.la \
+	     $(top_builddir)/render/librender.la \
+	     $(top_builddir)/randr/librandr.la \
+	     $(top_builddir)/damageext/libdamageext.la \
+	     $(top_builddir)/miext/damage/libdamage.la \
+	     $(top_builddir)/miext/shadow/libshadow.la \
+	     $(top_builddir)/Xi/libXi.la \
+	     $(top_builddir)/xkb/libxkb.la \
+	     $(top_builddir)/xkb/libxkbstubs.la \
+	     $(top_builddir)/composite/libcomposite.la \
+	     $(top_builddir)/dix/libdix.la \
+	     $(top_builddir)/config/libconfig.a \
+	     $(top_builddir)/dix/libxpstubs.la \
+	     $(top_builddir)/os/libos.la \
+	     $(top_builddir)/miext/rootless/librootless.la \
+	     $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
+	     $(top_builddir)/miext/rootless/accel/librlAccel.la \
              $(XWIN_LIBS) \
              $(XWINMODULES_LIBS)
 
@@ -156,21 +184,22 @@ XWin_LDFLAGS = -mwindows -static
 winprefsyacc.h: winprefsyacc.c
 winprefslex.c: winprefslex.l winprefsyacc.c winprefsyacc.h
 
-BUILT_SOURCES = winprefsyacc.h winprefsyacc.c winprefslex.c
+XWin.res: XWin.rc X.ico X-boxed.ico
+	mingw32-windres XWin.rc -DPROJECT_NAME="\\\"$(XWIN_SERVER_NAME)\\\"" -O coff -o XWin.res
+
+BUILT_SOURCES = winprefsyacc.h winprefsyacc.c winprefslex.c XWin.res
 CLEANFILES = $(BUILT_SOURCES)
 
 AM_YFLAGS = -d
 AM_LFLAGS = -i
 AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \
-            $(XWINMODULES_CFLAGS)
+            -DPROJECT_NAME="\"$(XWIN_SERVER_NAME)\"" \
+            -DXFree86Server $(XWINMODULES_CFLAGS)
 
 dist_man1_MANS = XWin.man XWinrc.man
 
 EXTRA_DIST = \
 	_usr_X11R6_lib_X11_system.XWinrc \
-	X-boxed.ico \
-	X.ico \
-	XWin.rc \
 	xlaunch/config.cc \
 	xlaunch/COPYING \
 	xlaunch/main.cc \
diff --git a/hw/xwin/winclipboard.h b/hw/xwin/winclipboard.h
index 445c01b..fdb6be7 100644
--- a/hw/xwin/winclipboard.h
+++ b/hw/xwin/winclipboard.h
@@ -38,8 +38,7 @@
 #ifdef __CYGWIN__
 #include <sys/select.h>
 #else
-#include "Xwinsock.h"
-#define HAS_WINSOCK
+#include <X11/Xwinsock.h>
 #endif
 #include <fcntl.h>
 #include <setjmp.h>
@@ -53,8 +52,8 @@
  * are usually bad, so someone should investigate this.
  */
 #include <X11/Xproto.h>
-#include "X11/Xutil.h"
-#include "X11/Xlocale.h"
+#include <X11/Xutil.h>
+#include <X11/Xlocale.h>
 
 /* Fixups to prevent collisions between Windows and X headers */
 #define ATOM			DWORD
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index 5401ecd..11da285 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -56,9 +56,9 @@
 /* Fixups to prevent collisions between Windows and X headers */
 #define ATOM DWORD
 
-#include <windows.h>
+#include <X11/windows.h>
 #else
-#include <Xwindows.h>
+#include <X11/Xwindows.h>
 #endif
 
 /* Local headers */
@@ -66,7 +66,7 @@
 #include "ddraw.h"
 #include "winwindow.h"
 #ifdef XWIN_MULTIWINDOWEXTWM
-#include "windowswmstr.h"
+#include <X11/extensions/windowswmstr.h>
 #endif
 
 extern void winDebug(const char *format, ...);
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index 832e36d..91db1e1 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -38,7 +38,7 @@
 #include "win.h"
 #include <winuser.h>
 #define _WINDOWSWM_SERVER_
-#include "windowswmstr.h"
+#include <X11/extensions/windowswmstr.h>
 #include "dixevents.h"
 #include "winmultiwindowclass.h"
 #include "winprefs.h"
@@ -51,9 +51,15 @@
 
 #define MOUSE_POLLING_INTERVAL		500
 
+#ifndef ULW_COLORKEY
 #define ULW_COLORKEY	0x00000001
+#endif
+#ifndef ULW_ALPHA
 #define ULW_ALPHA	0x00000002
+#endif
+#ifndef ULW_OPAQUE
 #define ULW_OPAQUE	0x00000004
+#endif
 #define AC_SRC_ALPHA	0x01
 
 /*
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 859aafd..7305539 100755
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -35,7 +35,7 @@
 #include "win.h"
 #include <winuser.h>
 #define _WINDOWSWM_SERVER_
-#include "windowswmstr.h"
+#include <X11/extensions/windowswmstr.h>
 #include "dixevents.h"
 #include "propertyst.h"
 #include <X11/Xatom.h>
diff --git a/hw/xwin/winwindowswm.c b/hw/xwin/winwindowswm.c
index e1994de..6a0b812 100755
--- a/hw/xwin/winwindowswm.c
+++ b/hw/xwin/winwindowswm.c
@@ -42,7 +42,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "servermd.h"
 #include "swaprep.h"
 #define _WINDOWSWM_SERVER_
-#include "windowswmstr.h"
+#include <X11/extensions/windowswmstr.h>
 
 static int WMErrorBase;
 
diff --git a/include/xwin-config.h.in b/include/xwin-config.h.in
index c8de110..5862df4 100644
--- a/include/xwin-config.h.in
+++ b/include/xwin-config.h.in
@@ -9,6 +9,12 @@
 /* Winsock networking */
 #undef HAS_WINSOCK
 
+/* Make PROJECT_ROOT relative to the xserver location */
+#undef RELOCATE_PROJECTROOT
+
+/* Add font pathes from fontdir file */
+#undef READ_FONTDIRS
+
 /* Cygwin has /dev/windows for signaling new win32 messages */
 #undef HAS_DEVWINDOWS
 
