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

diff --git a/configure b/configure
index 81f50aa..75249b4 100755
--- a/configure
+++ b/configure
@@ -6925,6 +6925,11 @@
 
 
 
+cat >> confdefs.h <<\EOF
+#define __WINE_CONFIG_H 1
+EOF
+
+
 
 
 MAKE_RULES=Make.rules
diff --git a/configure.in b/configure.in
index 749d7f7..daab697 100644
--- a/configure.in
+++ b/configure.in
@@ -1182,6 +1182,9 @@
 
 dnl **** Generate output files ****
 
+AC_DEFINE(__WINE_CONFIG_H, 1,
+          [This must always be defined to allow checking for config.h inclusion])
+
 AC_OUTPUT_COMMANDS([
 extra_subdirs="\
 dlls/ddraw/d3ddevice \
diff --git a/console/xterm.c b/console/xterm.c
index 38da373..4b56418 100644
--- a/console/xterm.c
+++ b/console/xterm.c
@@ -8,6 +8,8 @@
    It does not currently support changing the title bar.
 */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <signal.h>
diff --git a/controls/menu.c b/controls/menu.c
index 931d438..36ffec8 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -12,6 +12,7 @@
  * This is probably not the meaning this style has in MS-Windows.
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/dlls/ddraw/mesa.c b/dlls/ddraw/mesa.c
index c8be600..e18430d 100644
--- a/dlls/ddraw/mesa.c
+++ b/dlls/ddraw/mesa.c
@@ -3,6 +3,8 @@
    
    This file contains all MESA common code */
 
+#include "config.h"
+
 #include "windef.h"
 #include "wine/obj_base.h"
 #include "ddraw.h"
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index 7bf6582..f155013 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -6,6 +6,7 @@
  *
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <string.h>
diff --git a/dlls/kernel/comm.c b/dlls/kernel/comm.c
index 3eab1fd..4823cd3 100644
--- a/dlls/kernel/comm.c
+++ b/dlls/kernel/comm.c
@@ -32,6 +32,7 @@
  * 
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <stdlib.h>
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 70ff5f5..3115597 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -1,15 +1,15 @@
 #ifndef __WINE_MSVCRT_H
 #define __WINE_MSVCRT_H
 
-#include "config.h"
+#include <stdarg.h>
+#include <ctype.h>
+#include <string.h>
+
 #include "windef.h"
 #include "debugtools.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "winnls.h"
-#include <stdarg.h>
-#include <ctype.h>
-#include <string.h>
 
 /* TLS data */
 extern DWORD MSVCRT_tls_index;
diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c
index 3610ed9..9154fd5 100644
--- a/dlls/ntdll/misc.c
+++ b/dlls/ntdll/misc.c
@@ -1,11 +1,12 @@
 /*
  * Helper functions for ntdll
  */
-#include <time.h>
-#include <math.h>
 
 #include "config.h"
 
+#include <time.h>
+#include <math.h>
+
 #include "debugtools.h"
 #include "ntdll_misc.h"
 
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 83a8287..93166d6 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -9,6 +9,7 @@
  *
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <stdio.h>
diff --git a/dlls/ttydrv/bitmap.c b/dlls/ttydrv/bitmap.c
index e3ece64..9a09d5f 100644
--- a/dlls/ttydrv/bitmap.c
+++ b/dlls/ttydrv/bitmap.c
@@ -4,7 +4,10 @@
  * Copyright 1999 Patrik Stridvall
  */
 
+#include "config.h"
+
 #include <string.h>
+
 #include "bitmap.h"
 #include "gdi.h"
 #include "ttydrv.h"
diff --git a/dlls/ttydrv/objects.c b/dlls/ttydrv/objects.c
index 1c27ae6..0165b54 100644
--- a/dlls/ttydrv/objects.c
+++ b/dlls/ttydrv/objects.c
@@ -4,6 +4,8 @@
  * Copyright 1999 Patrik Stridvall
  */
 
+#include "config.h"
+
 #include "bitmap.h"
 #include "gdi.h"
 #include "ttydrv.h"
diff --git a/dlls/ttydrv/palette.c b/dlls/ttydrv/palette.c
index 0ec9006..c727eb8 100644
--- a/dlls/ttydrv/palette.c
+++ b/dlls/ttydrv/palette.c
@@ -4,6 +4,8 @@
  * Copyright 1999 Patrik Stridvall
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 
 #include "color.h"
diff --git a/dlls/ttydrv/ttydrv.h b/dlls/ttydrv/ttydrv.h
index 6d0cae7..7190142 100644
--- a/dlls/ttydrv/ttydrv.h
+++ b/dlls/ttydrv/ttydrv.h
@@ -5,7 +5,9 @@
 #ifndef __WINE_TTYDRV_H
 #define __WINE_TTYDRV_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
 
 #undef ERR
 #ifdef HAVE_NCURSES_H
diff --git a/dlls/ttydrv/user.c b/dlls/ttydrv/user.c
index 0aeaf7b..38f2f76 100644
--- a/dlls/ttydrv/user.c
+++ b/dlls/ttydrv/user.c
@@ -4,6 +4,8 @@
  * Copyright 1998 Patrik Stridvall
  */
 
+#include "config.h"
+
 #include "dinput.h"
 #include "gdi.h"
 #include "ttydrv.h"
diff --git a/dlls/winmm/wineoss/oss.h b/dlls/winmm/wineoss/oss.h
index a8aab79..f890fc8 100644
--- a/dlls/winmm/wineoss/oss.h
+++ b/dlls/winmm/wineoss/oss.h
@@ -1,6 +1,8 @@
 /* Definition for OSS drivers : wine multimedia system */
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
 
 #if defined(HAVE_SYS_SOUNDCARD_H)
 # include <sys/soundcard.h>
diff --git a/dlls/winsock/async.c b/dlls/winsock/async.c
index 75dea38..48b748e 100644
--- a/dlls/winsock/async.c
+++ b/dlls/winsock/async.c
@@ -19,6 +19,7 @@
  *	  whole stuff did not work anyway to other changes).
  */
  
+#include "config.h"
 #include "wine/port.h"
 
 #include <string.h>
diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c
index 1c4730a..8547df0 100644
--- a/dlls/winsock/socket.c
+++ b/dlls/winsock/socket.c
@@ -15,6 +15,7 @@
  * ws_XXXXent32 (winsock2.h) and 1-byte forced ws_XXXXent16 (winsock16.h).
  */
  
+#include "config.h"
 #include "wine/port.h"
 
 #include <stdio.h>
diff --git a/dlls/x11drv/dga2.h b/dlls/x11drv/dga2.h
index 5ee1844..226234f 100644
--- a/dlls/x11drv/dga2.h
+++ b/dlls/x11drv/dga2.h
@@ -5,7 +5,11 @@
  */
 #ifndef __WINE_DGA2_H
 #define __WINE_DGA2_H
-#include "config.h"
+
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
+
 #ifdef HAVE_LIBXXF86DGA2
 #include "ddrawi.h"
 
diff --git a/dlls/x11drv/x11ddraw.h b/dlls/x11drv/x11ddraw.h
index 9faf11d..0836f64 100644
--- a/dlls/x11drv/x11ddraw.h
+++ b/dlls/x11drv/x11ddraw.h
@@ -5,7 +5,11 @@
  */
 #ifndef __WINE_X11DDRAW_H
 #define __WINE_X11DDRAW_H
-#include "config.h"
+
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
+
 #include "ddrawi.h"
 
 extern LPDDRAWI_DDRAWSURFACE_LCL X11DRV_DD_Primary;
diff --git a/dlls/x11drv/xvidmode.h b/dlls/x11drv/xvidmode.h
index 992cf3e..5bc8d51 100644
--- a/dlls/x11drv/xvidmode.h
+++ b/dlls/x11drv/xvidmode.h
@@ -5,7 +5,11 @@
  */
 #ifndef __WINE_XVIDMODE_H
 #define __WINE_XVIDMODE_H
-#include "config.h"
+
+#ifndef __WINE_CONFIG_H 
+# error You must include config.h to use this header 
+#endif 
+
 #ifdef HAVE_LIBXXF86VM
 #include "ddrawi.h"
 
diff --git a/files/drive.c b/files/drive.c
index 9a8882e..809e536 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -10,6 +10,7 @@
  *
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
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>
diff --git a/library/port.c b/library/port.c
index ebf15d6..aa0ddf0 100644
--- a/library/port.c
+++ b/library/port.c
@@ -4,6 +4,7 @@
  * Copyright 1996 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #ifdef __BEOS__
diff --git a/loader/elf.c b/loader/elf.c
index c93d418..378a7fe 100644
--- a/loader/elf.c
+++ b/loader/elf.c
@@ -9,6 +9,7 @@
  * IDEA(s):	could be used to split up shell32,comctl32... 
  */
 
+#include "config.h"
 #include "wine/port.h" 
 
 #include <assert.h>
diff --git a/loader/ne/module.c b/loader/ne/module.c
index fc8b5b9..a2ed4a0 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -4,6 +4,7 @@
  * Copyright 1995 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h" 
 
 #include <assert.h>
diff --git a/loader/ne/resource.c b/loader/ne/resource.c
index fdebb0d..ac3bf82 100644
--- a/loader/ne/resource.c
+++ b/loader/ne/resource.c
@@ -6,6 +6,7 @@
  * Copyright 1997 Alex Korobka
  */
 
+#include "config.h"
 #include "wine/port.h" 
 
 #include <stdio.h>
diff --git a/memory/global.c b/memory/global.c
index d2f54cb..23ebf29 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -5,6 +5,7 @@
  */
 /* 0xffff sometimes seems to mean: CURRENT_DS */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <sys/types.h>
diff --git a/memory/virtual.c b/memory/virtual.c
index bb31cbf..2234674 100644
--- a/memory/virtual.c
+++ b/memory/virtual.c
@@ -4,6 +4,7 @@
  * Copyright 1997 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/misc/cpu.c b/misc/cpu.c
index ac1074e..5b6fa1f 100644
--- a/misc/cpu.c
+++ b/misc/cpu.c
@@ -5,6 +5,7 @@
  * Copyright 1997-1998 Marcus Meissner
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <ctype.h>
diff --git a/msdos/dosmem.c b/msdos/dosmem.c
index 0bf62ee..55e8008 100644
--- a/msdos/dosmem.c
+++ b/msdos/dosmem.c
@@ -5,6 +5,7 @@
  * Copyright 1996 Marcus Meissner
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <signal.h>
@@ -820,7 +821,7 @@
    LPVOID       lin;
 
    lin=DOSMEM_dosmem+(x&0xffff)+(((x&0xffff0000)>>16)*16);
-   TRACE_(selector)("(0x%08lx) returns 0x%p.\n", x, lin );
+   TRACE_(selector)("(0x%08lx) returns %p.\n", x, lin );
    return lin;
 }
 
diff --git a/msdos/dpmi.c b/msdos/dpmi.c
index 11b9bff..e40d4ee 100644
--- a/msdos/dpmi.c
+++ b/msdos/dpmi.c
@@ -4,6 +4,7 @@
  * Copyright 1995 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <unistd.h>
diff --git a/msdos/int10.c b/msdos/int10.c
index c55a105..ffa9755 100644
--- a/msdos/int10.c
+++ b/msdos/int10.c
@@ -2,7 +2,10 @@
  * BIOS interrupt 10h handler
  */
 
+#include "config.h"
+
 #include <stdlib.h>
+
 #include "miscemu.h"
 #include "vga.h"
 #include "debugtools.h"
diff --git a/scheduler/client.c b/scheduler/client.c
index f467948..a8cb4dd 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -4,6 +4,7 @@
  * Copyright (C) 1998 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c
index b931e77..69da094 100644
--- a/scheduler/sysdeps.c
+++ b/scheduler/sysdeps.c
@@ -4,6 +4,7 @@
  * Copyright 1998 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <signal.h>
diff --git a/scheduler/thread.c b/scheduler/thread.c
index b3ce6f3..e3cf2cd 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -4,6 +4,7 @@
  * Copyright 1996 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/server/request.c b/server/request.c
index b7207a1..ba420a0 100644
--- a/server/request.c
+++ b/server/request.c
@@ -4,6 +4,7 @@
  * Copyright (C) 1998 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/tools/make_X11wrappers b/tools/make_X11wrappers
index edf86e5..b1a1ae0 100755
--- a/tools/make_X11wrappers
+++ b/tools/make_X11wrappers
@@ -106,14 +106,15 @@
  * Thread safe wrappers around $name calls.
  * Always include this file instead of <X11/$name.h>.
  * This file was generated automatically by tools/make_X11wrappers
- *
- * Copyright 1998 Kristian Nielsen
+ * DO NOT EDIT!
  */
 
 #ifndef __WINE_TS_$ucname\_H
 #define __WINE_TS_$ucname\_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H
+# error You must include config.h to use this header
+#endif
 
 $pre_file
 $x11_incl#include <X11/$extensions_dir$inc_name.h>
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h
index a74fe7f..1ef1a91 100644
--- a/tools/winebuild/build.h
+++ b/tools/winebuild/build.h
@@ -9,7 +9,10 @@
 #ifndef __WINE_BUILD_H
 #define __WINE_BUILD_H
 
-#include "config.h"
+#ifndef __WINE_CONFIG_H  
+# error You must include config.h to use this header  
+#endif  
+
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c
index 12807fb..39e50d5 100644
--- a/tools/winebuild/spec16.c
+++ b/tools/winebuild/spec16.c
@@ -8,6 +8,7 @@
  * Copyright 1999 Ulrich Weigand
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <assert.h>
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c
index 93944e7..95c399d 100644
--- a/tools/winebuild/utils.c
+++ b/tools/winebuild/utils.c
@@ -1,5 +1,7 @@
 /* small utility functions for winebuild */
 
+#include "config.h"
+
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l
index ec8b3ab..75fb754 100644
--- a/tools/wrc/parser.l
+++ b/tools/wrc/parser.l
@@ -79,8 +79,6 @@
 
 /*#define LEX_DEBUG*/
 
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tools/wrc/ppl.l b/tools/wrc/ppl.l
index 4b25008..412d100 100644
--- a/tools/wrc/ppl.l
+++ b/tools/wrc/ppl.l
@@ -138,8 +138,6 @@
 ul	[uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
 
 %{
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/win32/device.c b/win32/device.c
index d95d279..1e85018 100644
--- a/win32/device.c
+++ b/win32/device.c
@@ -7,6 +7,7 @@
  *
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <stdlib.h>
diff --git a/windows/class.c b/windows/class.c
index e0bacb0..80c03db 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -12,6 +12,7 @@
  *   classes are getting registered with wrong hInstance.
  */
 
+#include "config.h"
 #include "wine/port.h"
 
 #include <stdlib.h>
diff --git a/windows/dialog.c b/windows/dialog.c
index 576a75e..45ff1f5 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -4,6 +4,7 @@
  * Copyright 1993, 1994, 1996 Alexandre Julliard
  */
 
+#include "config.h"
 #include "wine/port.h" 
 
 #include <ctype.h>
diff --git a/windows/x11drv/clipboard.c b/windows/x11drv/clipboard.c
index 8cf9994..4dcd92c 100644
--- a/windows/x11drv/clipboard.c
+++ b/windows/x11drv/clipboard.c
@@ -45,7 +45,7 @@
  *
  */
 
-#include "ts_xlib.h"
+#include "config.h"
 
 #include <string.h>
 #include <stdio.h>
@@ -53,6 +53,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 
+#include "ts_xlib.h"
 #include "winreg.h"
 #include "clipboard.h"
 #include "win.h"