Non-X11 compile fix for generated code.

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