Fix the #include order for config.h.
Add #include "config.h" directives where needed.

diff --git a/include/cdrom.h b/include/cdrom.h
index 8b6e3c9..e7c4218 100644
--- a/include/cdrom.h
+++ b/include/cdrom.h
@@ -10,9 +10,12 @@
 #ifndef __WINE_CDROM_H__
 #define __WINE_CDROM_H__
 
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
+
 #include <stdlib.h>
 #include <unistd.h>
-#include "config.h"
 #include "windef.h"
 #include "wine/windef16.h"
 
diff --git a/include/config.h.in b/include/config.h.in
index 93af9fa..bc7dd60 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -538,3 +538,6 @@
 /* Define if struct sockaddr_un contains sun_len */
 #undef HAVE_SOCKADDR_SUN_LEN
 
+/* This must always be defined to allow checking for config.h inclusion */
+#undef __WINE_CONFIG_H
+
diff --git a/include/console.h b/include/console.h
index 82c23e6..85570d0 100644
--- a/include/console.h
+++ b/include/console.h
@@ -8,8 +8,11 @@
 #ifndef __WINE_CONSOLE_H
 #define __WINE_CONSOLE_H
 
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
+
 #include <stdio.h>
-#include "config.h"
 
 /* Can we compile with curses/ncurses? */
 #if (	(defined(HAVE_LIBNCURSES) || defined(HAVE_LIBCURSES)) &&	\
diff --git a/include/gdi.h b/include/gdi.h
index feff4ad..bb0eec1 100644
--- a/include/gdi.h
+++ b/include/gdi.h
@@ -7,8 +7,6 @@
 #ifndef __WINE_GDI_H
 #define __WINE_GDI_H
 
-#include "config.h"
-
 #include "windef.h"
 #include "wingdi.h"
 #include "wine/wingdi16.h"
diff --git a/include/heap.h b/include/heap.h
index 112eecb..b9fc6fc 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -7,9 +7,8 @@
 #ifndef __WINE_HEAP_H
 #define __WINE_HEAP_H
 
-#include "config.h"
-
 #include <string.h>
+
 #include "winbase.h"
 #include "winnls.h"
 #include "wine/unicode.h"
diff --git a/include/thread.h b/include/thread.h
index d132ea9..7a15948 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -7,8 +7,6 @@
 #ifndef __WINE_THREAD_H
 #define __WINE_THREAD_H
 
-#include "config.h"
-
 #include "ntdef.h" /* UNICODE_STRING */
 #include "wine/windef16.h"
 
diff --git a/include/ts_shape.h b/include/ts_shape.h
index 3535999..cff6c45 100644
--- a/include/ts_shape.h
+++ b/include/ts_shape.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around shape calls.
  * Always include this file instead of <X11/shape.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_SHAPE_H
 #define __WINE_TS_SHAPE_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXSHAPE
 #include <X11/IntrinsicP.h>
diff --git a/include/ts_xf86dga.h b/include/ts_xf86dga.h
index 289a3ce..2b7f9f1 100644
--- a/include/ts_xf86dga.h
+++ b/include/ts_xf86dga.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around xf86dga calls.
  * Always include this file instead of <X11/xf86dga.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XF86DGA_H
 #define __WINE_TS_XF86DGA_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXXF86DGA
 
diff --git a/include/ts_xf86dga2.h b/include/ts_xf86dga2.h
index f68760a..950f759 100644
--- a/include/ts_xf86dga2.h
+++ b/include/ts_xf86dga2.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around xf86dga2 calls.
  * Always include this file instead of <X11/xf86dga2.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XF86DGA2_H
 #define __WINE_TS_XF86DGA2_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXXF86DGA2
 
diff --git a/include/ts_xf86vmode.h b/include/ts_xf86vmode.h
index 29ba711..3ac833b 100644
--- a/include/ts_xf86vmode.h
+++ b/include/ts_xf86vmode.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around xf86vmode calls.
  * Always include this file instead of <X11/xf86vmode.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XF86VMODE_H
 #define __WINE_TS_XF86VMODE_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #include "windef.h"
 #ifdef HAVE_LIBXXF86VM
diff --git a/include/ts_xlib.h b/include/ts_xlib.h
index 8a91b56..029eb47 100644
--- a/include/ts_xlib.h
+++ b/include/ts_xlib.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around Xlib calls.
  * Always include this file instead of <X11/Xlib.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XLIB_H
 #define __WINE_TS_XLIB_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 
 #include <X11/Xlib.h>
diff --git a/include/ts_xpm.h b/include/ts_xpm.h
index 12950ee..e4e3396 100644
--- a/include/ts_xpm.h
+++ b/include/ts_xpm.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around xpm calls.
  * Always include this file instead of <X11/xpm.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XPM_H
 #define __WINE_TS_XPM_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXXPM
 
diff --git a/include/ts_xrender.h b/include/ts_xrender.h
index 17350e5..9e9126b 100644
--- a/include/ts_xrender.h
+++ b/include/ts_xrender.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around Xrender calls.
  * Always include this file instead of <X11/Xrender.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XRENDER_H
 #define __WINE_TS_XRENDER_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXRENDER
 
diff --git a/include/ts_xresource.h b/include/ts_xresource.h
index 2202090..1027168 100644
--- a/include/ts_xresource.h
+++ b/include/ts_xresource.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around Xresource calls.
  * Always include this file instead of <X11/Xresource.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XRESOURCE_H
 #define __WINE_TS_XRESOURCE_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 
 #include <X11/Xlib.h>
diff --git a/include/ts_xshm.h b/include/ts_xshm.h
index b54294f..db4459c 100644
--- a/include/ts_xshm.h
+++ b/include/ts_xshm.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around XShm calls.
  * Always include this file instead of <X11/XShm.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XSHM_H
 #define __WINE_TS_XSHM_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_LIBXXSHM
 
diff --git a/include/ts_xutil.h b/include/ts_xutil.h
index 2389447..42744ef 100644
--- a/include/ts_xutil.h
+++ b/include/ts_xutil.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around Xutil calls.
  * Always include this file instead of <X11/Xutil.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XUTIL_H
 #define __WINE_TS_XUTIL_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 
 #include <X11/Xlib.h>
@@ -24,7 +25,6 @@
 extern XWMHints * TSXAllocWMHints(void);
 extern int  TSXClipBox(Region, XRectangle*);
 extern Region  TSXCreateRegion(void);
-extern int  TSXDeleteContext(Display*, XID, XContext);
 extern int  TSXDestroyRegion(Region);
 extern int  TSXEmptyRegion(Region);
 extern int  TSXEqualRegion(Region, Region);
@@ -54,6 +54,7 @@
 extern struct _XImage * TSXSubImage(struct _XImage *, int, int, unsigned int, unsigned int);
 extern int TSXAddPixel(struct _XImage *, long);
 extern XContext TSXUniqueContext(void);
+extern int TSXDeleteContext(Display*,XID,XContext);
 
 
 #endif /* __WINE_TS_XUTIL_H */
diff --git a/include/ts_xvideo.h b/include/ts_xvideo.h
index d92acde..e8b5968 100644
--- a/include/ts_xvideo.h
+++ b/include/ts_xvideo.h
@@ -2,14 +2,15 @@
  * Thread safe wrappers around xvideo calls.
  * Always include this file instead of <X11/xvideo.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_XVIDEO_H
 #define __WINE_TS_XVIDEO_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 #ifdef HAVE_XVIDEO
 
diff --git a/include/wine/port.h b/include/wine/port.h
index 8f1635f..6d58602 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -6,7 +6,9 @@
 #ifndef __WINE_WINE_PORT_H
 #define __WINE_WINE_PORT_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H  
+# error You must include config.h to use this header  
+#endif  
 
 #include <fcntl.h>
 #include <sys/types.h>
diff --git a/include/wine_gl.h b/include/wine_gl.h
index 2f3144f..368124e 100644
--- a/include/wine_gl.h
+++ b/include/wine_gl.h
@@ -7,7 +7,9 @@
 #ifndef __WINE_WINE_GL_H
 #define __WINE_WINE_GL_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
 
 #if defined(HAVE_OPENGL)
 
diff --git a/include/x11drv.h b/include/x11drv.h
index bd6a90c..b145c36 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -5,7 +5,9 @@
 #ifndef __WINE_X11DRV_H
 #define __WINE_X11DRV_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
 
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>