--- gtkglareamm-0.4/configure.in.orig	Sat Apr  3 19:13:14 1999
+++ gtkglareamm-0.4/configure.in	Mon Dec  6 15:22:04 1999
@@ -47,15 +47,37 @@
 
 AC_LANG_SAVE
 AC_LANG_C
-AC_CHECK_LIB(MesaGL, glBegin, have_MesaGL=yes, ,${GTK_LIBS} ${GL_LDOPTS})
-AC_CHECK_LIB(GL,     glBegin, have_GL=yes,     ,${GTK_LIBS} ${GL_LDOPTS})
+
+saved_LIBS="$LIBS"
+
+AC_MSG_CHECKING([Mesa])
+LIBS="$saved_LIBS $GTK_LIBS $GL_LDOPTS -lMesaGL"
+AC_TRY_LINK( ,[ char glBegin(); glBegin(); ], have_MesaGL=yes, have_MesaGL=no)
+AC_MSG_RESULT($have_MesaGL)
+
+if test "x$have_MesaGL" = "xno"; then
+ AC_MSG_CHECKING([Mesa with pthreads])
+ LIBS="$saved_LIBS $GTK_LIBS $GL_LDOPTS -lMesaGL -lpthread"
+ AC_TRY_LINK( ,[ char glBegin(); glBegin(); ], have_MesaGL_pthread=yes, have_MesaGL_pthread=no)
+ AC_MSG_RESULT($have_MesaGL_pthread)
+fi
+
+if test "x$have_MesaGL" = "xno" && test "x$have_MesaGL_pthread" = "xno"; then
+ AC_MSG_CHECKING([OpenGL])
+ LIBS="$saved_LIBS $GTK_LIBS $GL_LDOPTS -lGL"
+ AC_TRY_LINK( ,[ char glBegin(); glBegin(); ], have_GL=yes, have_GL=no)
+ AC_MSG_RESULT($have_GL)
+fi
+
+LIBS="$saved_LIBS"
+
 AC_LANG_RESTORE
 
 if test "$have_GL" != yes && test "$with_lib_GL" = yes; then
  AC_MSG_ERROR([Missing GL library])
 fi
 
-if test "$have_MesaGL" != yes && test "$with_lib_MesaGL" = yes; then
+if test "$have_MesaGL" != yes && test "$with_lib_MesaGL" = yes && test "$with_lib_MesaGL_pthread" = yes; then
  AC_MSG_ERROR([Missing MesaGL library])
 fi
 
@@ -63,6 +85,8 @@
  GL_LIBS="${GL_LDOPTS} -lGLU -lGL"
 elif test "$have_MesaGL" = yes; then
  GL_LIBS="${GL_LDOPTS} -lMesaGLU -lMesaGL"
+elif test "$have_MesaGL_pthread" = yes; then
+ GL_LIBS="${GL_LDOPTS} -lMesaGLU -lMesaGL -lpthread"
 else
  AC_MSG_ERROR([You need GL or MesaGL libraries])
 fi
