Non-X11 compile fix for generated code.

diff --git a/include/ts_xf86dga.h b/include/ts_xf86dga.h
index e529ee1..0cc3cb2 100644
--- a/include/ts_xf86dga.h
+++ b/include/ts_xf86dga.h
@@ -9,6 +9,12 @@
 #ifndef __WINE_TSXF86DGA_H
 #define __WINE_TSXF86DGA_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#ifdef HAVE_LIBXXF86DGA
+
 #include <X11/Xlib.h>
 #include <X11/extensions/xf86dga.h>
 
@@ -22,4 +28,8 @@
 extern Status TSXF86DGAQueryDirectVideo(Display*,int,int*);
 extern Status TSXF86DGAViewPortChanged(Display*,int,int);
 
+#endif /* defined(HAVE_LIBXXF86DGA) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXF86DGA_H */
diff --git a/include/ts_xf86vmode.h b/include/ts_xf86vmode.h
index 556a9ac..825c84f 100644
--- a/include/ts_xf86vmode.h
+++ b/include/ts_xf86vmode.h
@@ -9,6 +9,14 @@
 #ifndef __WINE_TSXF86VMODE_H
 #define __WINE_TSXF86VMODE_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#include "wintypes.h"
+#ifdef HAVE_LIBXXF86VM
+#define XMD_H
+
 #include <X11/Xlib.h>
 #include <X11/extensions/xf86vmode.h>
 
@@ -27,4 +35,8 @@
 extern Bool TSXF86VidModeGetViewPort(Display*,int,int*,int*);
 extern Bool TSXF86VidModeSetViewPort(Display*,int,int,int);
 
+#endif /* defined(HAVE_LIBXXF86VM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXF86VMODE_H */
diff --git a/include/ts_xlib.h b/include/ts_xlib.h
index 43e390c..cf7099c 100644
--- a/include/ts_xlib.h
+++ b/include/ts_xlib.h
@@ -9,6 +9,11 @@
 #ifndef __WINE_TSXLIB_H
 #define __WINE_TSXLIB_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
 
 extern XFontStruct * TSXLoadQueryFont(Display*, const  char*);
@@ -129,4 +134,7 @@
 extern int (*TSXSynchronize(Display *, Bool))(Display *);
 extern void TS_XInitImageFuncPtrs(XImage *);
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXLIB_H */
diff --git a/include/ts_xpm.h b/include/ts_xpm.h
index 05aeef3..592b160 100644
--- a/include/ts_xpm.h
+++ b/include/ts_xpm.h
@@ -9,9 +9,19 @@
 #ifndef __WINE_TSXPM_H
 #define __WINE_TSXPM_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#ifdef HAVE_LIBXXPM
+
 #include <X11/xpm.h>
 
 extern int TSXpmCreatePixmapFromData(Display *, Drawable, char **, Pixmap *, Pixmap *, XpmAttributes *);
 extern int TSXpmAttributesSize(void);
 
+#endif /* defined(HAVE_LIBXXPM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXPM_H */
diff --git a/include/ts_xresource.h b/include/ts_xresource.h
index ddacdd1..a447d42 100644
--- a/include/ts_xresource.h
+++ b/include/ts_xresource.h
@@ -9,6 +9,11 @@
 #ifndef __WINE_TSXRESOURCE_H
 #define __WINE_TSXRESOURCE_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 
@@ -19,4 +24,7 @@
 extern void  TSXrmMergeDatabases(XrmDatabase, XrmDatabase*);
 extern void  TSXrmParseCommand(XrmDatabase*, XrmOptionDescList, int, const  char*, int*, char**);
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXRESOURCE_H */
diff --git a/include/ts_xshm.h b/include/ts_xshm.h
index 9d51eed..b382c7c 100644
--- a/include/ts_xshm.h
+++ b/include/ts_xshm.h
@@ -9,6 +9,12 @@
 #ifndef __WINE_TSXSHM_H
 #define __WINE_TSXSHM_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#ifdef HAVE_LIBXXSHM
+
 #include <X11/Xlib.h>
 #include <X11/extensions/XShm.h>
 
@@ -22,4 +28,8 @@
 extern XImage * TSXShmCreateImage(Display *, Visual *, unsigned int, int, char *, XShmSegmentInfo *, unsigned int, unsigned int);
 extern Pixmap TSXShmCreatePixmap(Display *, Drawable, char *, XShmSegmentInfo *, unsigned int, unsigned int, unsigned int);
 
+#endif /* defined(HAVE_LIBXXSHM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXSHM_H */
diff --git a/include/ts_xutil.h b/include/ts_xutil.h
index 01bef38..73238e7 100644
--- a/include/ts_xutil.h
+++ b/include/ts_xutil.h
@@ -9,6 +9,11 @@
 #ifndef __WINE_TSXUTIL_H
 #define __WINE_TSXUTIL_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
@@ -47,4 +52,7 @@
 extern int TSXAddPixel(struct _XImage *, long);
 extern XContext TSXUniqueContext(void);
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TSXUTIL_H */
diff --git a/tools/make_X11wrappers b/tools/make_X11wrappers
index 2784515..477c694 100755
--- a/tools/make_X11wrappers
+++ b/tools/make_X11wrappers
@@ -54,17 +54,23 @@
     if($name eq "xf86dga")  {
     	$x11_incl = "#include <X11/Xlib.h>\n";
 	$extensions_dir = "extensions/";
-	$pre_file = "#include \"config.h\"\n#ifdef HAVE_LIBXXF86DGA\n";
-	$post_file = "#endif";
+	$pre_file = "#ifdef HAVE_LIBXXF86DGA\n";
+	$post_file = "#endif /* defined(HAVE_LIBXXF86DGA) */\n";
     }
     if($name eq "XShm") {
 	$extensions_dir = "extensions/";
+	$pre_file = "#ifdef HAVE_LIBXXSHM\n";
+	$post_file = "#endif /* defined(HAVE_LIBXXSHM) */\n";
+    }
+    if($name eq "xpm") {
+	$pre_file = "#ifdef HAVE_LIBXXPM\n";
+	$post_file = "#endif /* defined(HAVE_LIBXXPM) */\n";
     }
     if($name eq "xf86vmode") {
      	$x11_incl = "#include <X11/Xlib.h>\n";
 	$extensions_dir = "extensions/";
 	$pre_file = "#include \"wintypes.h\"\n#ifdef HAVE_LIBXXF86VM\n#define XMD_H\n";
-	$post_file = "#endif";
+	$post_file = "#endif /* defined(HAVE_LIBXXF86VM) */\n";
     }
 
     print OUTH <<END;
@@ -79,6 +85,11 @@
 #ifndef __WINE_TS$ucname\_H
 #define __WINE_TS$ucname\_H
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+$pre_file
 $x11_incl#include <X11/$extensions_dir$name.h>
 
 END
@@ -89,10 +100,15 @@
  * This file was generated automatically by tools/make_X11wrappers
  * DO NOT EDIT!
  */
+
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
 $pre_file
 $x11_incl#include <X11/$extensions_dir$name.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 END
 
     if($name eq "xpm") {	# Handle as special case.
@@ -323,10 +339,15 @@
 
     print OUTH <<END;
 
+$post_file
+#endif /* !defined(X_DISPLAY_MISSING) */
+
 #endif /* __WINE_TS$ucname\_H */
 END
     print OUTC <<END;
+
 $post_file
+#endif /* !defined(X_DISPLAY_MISSING) */
 END
 
 
diff --git a/tsx11/ts_xf86dga.c b/tsx11/ts_xf86dga.c
index c72586f..393bf15 100644
--- a/tsx11/ts_xf86dga.c
+++ b/tsx11/ts_xf86dga.c
@@ -3,13 +3,17 @@
  * This file was generated automatically by tools/make_X11wrappers
  * DO NOT EDIT!
  */
+
 #include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
 #ifdef HAVE_LIBXXF86DGA
 
 #include <X11/Xlib.h>
 #include <X11/extensions/xf86dga.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 Bool TSXF86DGAQueryVersion(Display*a0,int*a1,int*a2)
 {
@@ -109,4 +113,7 @@
   TRACE(x11, "Ret XF86DGAViewPortChanged\n");
   return r;
 }
-#endif
+
+#endif /* defined(HAVE_LIBXXF86DGA) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xf86vmode.c b/tsx11/ts_xf86vmode.c
index e4e7df5..5091df5 100644
--- a/tsx11/ts_xf86vmode.c
+++ b/tsx11/ts_xf86vmode.c
@@ -3,14 +3,19 @@
  * This file was generated automatically by tools/make_X11wrappers
  * DO NOT EDIT!
  */
+
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
 #include "wintypes.h"
 #ifdef HAVE_LIBXXF86VM
 #define XMD_H
 
 #include <X11/Xlib.h>
 #include <X11/extensions/xf86vmode.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 Bool TSXF86VidModeQueryVersion(Display*a0,int*a1,int*a2)
 {
@@ -165,4 +170,7 @@
   TRACE(x11, "Ret XF86VidModeSetViewPort\n");
   return r;
 }
-#endif
+
+#endif /* defined(HAVE_LIBXXF86VM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xlib.c b/tsx11/ts_xlib.c
index f34546c..6f3a9f0 100644
--- a/tsx11/ts_xlib.c
+++ b/tsx11/ts_xlib.c
@@ -4,9 +4,14 @@
  * DO NOT EDIT!
  */
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 XFontStruct * TSXLoadQueryFont(Display* a0, const  char* a1)
 {
@@ -1293,3 +1298,5 @@
   TRACE(x11, "Ret _XInitImageFuncPtrs\n");
 }
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xpm.c b/tsx11/ts_xpm.c
index ca5e334..a7a1803 100644
--- a/tsx11/ts_xpm.c
+++ b/tsx11/ts_xpm.c
@@ -4,9 +4,15 @@
  * DO NOT EDIT!
  */
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#ifdef HAVE_LIBXXPM
+
 #include <X11/xpm.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 int TSXpmCreatePixmapFromData(Display *a0, Drawable a1, char **a2, Pixmap *a3, Pixmap *a4, XpmAttributes *a5)
 {
@@ -30,3 +36,6 @@
   return r;
 }
 
+#endif /* defined(HAVE_LIBXXPM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xresource.c b/tsx11/ts_xresource.c
index 5bb5e8b..ba5c542 100644
--- a/tsx11/ts_xresource.c
+++ b/tsx11/ts_xresource.c
@@ -4,10 +4,15 @@
  * DO NOT EDIT!
  */
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 XrmQuark  TSXrmUniqueQuark(void)
 {
@@ -71,3 +76,5 @@
   TRACE(x11, "Ret XrmParseCommand\n");
 }
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xshm.c b/tsx11/ts_xshm.c
index ed6dfe8..e2f7b39 100644
--- a/tsx11/ts_xshm.c
+++ b/tsx11/ts_xshm.c
@@ -4,10 +4,16 @@
  * DO NOT EDIT!
  */
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+#ifdef HAVE_LIBXXSHM
+
 #include <X11/Xlib.h>
 #include <X11/extensions/XShm.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 Bool TSXShmQueryExtension(Display *a0)
 {
@@ -108,3 +114,6 @@
   return r;
 }
 
+#endif /* defined(HAVE_LIBXXSHM) */
+
+#endif /* !defined(X_DISPLAY_MISSING) */
diff --git a/tsx11/ts_xutil.c b/tsx11/ts_xutil.c
index e9647f8..0f6e294 100644
--- a/tsx11/ts_xutil.c
+++ b/tsx11/ts_xutil.c
@@ -4,11 +4,16 @@
  * DO NOT EDIT!
  */
 
+#include "config.h"
+
+#ifndef X_DISPLAY_MISSING
+
+
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
-#include "x11drv.h"
 #include "debug.h"
+#include "x11drv.h"
 
 XClassHint * TSXAllocClassHint(void)
 {
@@ -369,3 +374,5 @@
   return r;
 }
 
+
+#endif /* !defined(X_DISPLAY_MISSING) */