Added check for the presence of Mesa's header files.

diff --git a/include/acconfig.h b/include/acconfig.h
index 19e6bba..402ff71 100644
--- a/include/acconfig.h
+++ b/include/acconfig.h
@@ -76,4 +76,4 @@
 #undef HAVE_IPX_LINUX
 
 /* Define if Mesa is present on the system or not */
-#undef HAVE_MESAGL
+#undef HAVE_LIBMESAGL
diff --git a/include/config.h.in b/include/config.h.in
index fc41763..6c36816 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -79,7 +79,7 @@
 #undef HAVE_IPX_LINUX
 
 /* Define if Mesa is present on the system or not */
-#undef HAVE_MESAGL
+#undef HAVE_LIBMESAGL
 
 /* The number of bytes in a long long.  */
 #undef SIZEOF_LONG_LONG
@@ -126,6 +126,9 @@
 /* Define if you have the waitpid function.  */
 #undef HAVE_WAITPID
 
+/* Define if you have the <GL/osmesa.h> header file.  */
+#undef HAVE_GL_OSMESA_H
+
 /* Define if you have the <curses.h> header file.  */
 #undef HAVE_CURSES_H
 
diff --git a/include/d3d.h b/include/d3d.h
index 3637734..d88dcac 100644
--- a/include/d3d.h
+++ b/include/d3d.h
@@ -4,9 +4,7 @@
 #include "ddraw.h"
 
 /* This is needed for GL_LIGHT */
-#ifdef HAVE_MESAGL
 #include "wine_gl.h"
-#endif
 
 typedef BOOL32 *LPBOOL;
 typedef BOOL32 BOOL;
diff --git a/include/wine_gl.h b/include/wine_gl.h
index 3fc7c9c..8a35465 100644
--- a/include/wine_gl.h
+++ b/include/wine_gl.h
@@ -7,7 +7,11 @@
 #ifndef __WINE_GL_H
 #define __WINE_GL_H
 
-#ifdef HAVE_MESAGL
+#include "config.h"
+
+#if defined(HAVE_LIBMESAGL) && defined(HAVE_GL_OSMESA_H)
+
+#define HAVE_MESAGL
 
 #undef APIENTRY
 #undef CALLBACK
@@ -27,6 +31,10 @@
 #define WINAPI      __stdcall
 #define APIENTRY    WINAPI
 
-#endif /* HAVE_MESAGL */
+#else /* HAVE_LIBMESAGL */
+
+#undef HAVE_MESAGL
+
+#endif /* HAVE_LIBMESAGL */
 
 #endif /* __WINE_GL_H */