+ GL_save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$GL_CFLAGS"
+
+ GL_save_LIBS="$LIBS"
+ LIBS="$GL_X_LIBS"
+
+ dnl Including <GL/glut.h> instead of plain <GL/gl.h> avoids problems on
+ dnl platforms like WinDoze where special headers like <windows.h> or
+ dnl some macro trickery would be needed
+ FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glEnd, $GL_search_list, have_GL=yes, have_GL=no)
+
+ dnl TODO: The tests for GL features should better be cascaded and the
+ dnl results should be cached. A new macro would be helpful here.
+
+ AC_MSG_CHECKING(glTexSubImage1D)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glTexSubImage1D(GL_TEXTURE_1D,0,0,2,GL_INTENSITY,GL_BYTE,(void*)0)],
+ fptools_gl_texsubimage1d=yes,
+ fptools_gl_texsubimage1d=no);
+ AC_MSG_RESULT($fptools_gl_texsubimage1d)
+
+ AC_MSG_CHECKING(glDrawRangeElements)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glDrawRangeElements(GL_QUADS,0,0,0,GL_UNSIGNED_BYTE,(void*)0)],
+ fptools_gl_drawrangeelements=yes,
+ fptools_gl_drawrangeelements=no);
+ AC_MSG_RESULT($fptools_gl_drawrangeelements)
+
+ AC_MSG_CHECKING(glActiveTexture)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glActiveTexture(GL_TEXTURE1)],
+ fptools_gl_activetexture=yes,
+ fptools_gl_activetexture=no);
+ AC_MSG_RESULT($fptools_gl_activetexture)
+
+ AC_MSG_CHECKING(glMultiDrawArrays)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glMultiDrawArrays(GL_TRIANGLES, (GLint*)0, (GLsizei*)0, 0)],
+ fptools_gl_multidrawarrays=yes,
+ fptools_gl_multidrawarrays=no);
+ AC_MSG_RESULT($fptools_gl_multidrawarrays)
+
+ if test x"$fptools_gl_texsubimage1d" != xyes; then
+ fptools_gl_version=1.0
+ else
+ if test x"$fptools_gl_drawrangeelements" != xyes; then
+ fptools_gl_version=1.1
+ else
+ if test x"$fptools_gl_activetexture" != xyes; then
+ fptools_gl_version=1.2
+ else
+ if test x"$fptools_gl_multidrawarrays" != xyes; then
+ fptools_gl_version=1.3
+ else
+ fptools_gl_version=1.4
+ fi
+ fi
+ fi
+ fi
+ echo "It looks like GL version ${fptools_gl_version}"
+
+ dnl TODO: Cache the results of the tests for the imaging subset.
+
+ AC_MSG_CHECKING(EXT_blend_color)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glBlendColorEXT((GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0)],
+ hopengl_EXT_blend_color=yes,
+ hopengl_EXT_blend_color=no);
+ AC_MSG_RESULT($hopengl_EXT_blend_color)
+
+ AC_MSG_CHECKING(EXT_blend_minmax)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glBlendEquationEXT(GL_FUNC_ADD_EXT)],
+ hopengl_EXT_blend_minmax=yes,
+ hopengl_EXT_blend_minmax=no);
+ AC_MSG_RESULT($hopengl_EXT_blend_minmax)
+
+ AC_MSG_CHECKING(EXT_blend_subtract)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [glBlendEquationEXT(GL_FUNC_SUBTRACT_EXT)],
+ hopengl_EXT_blend_subtract=yes,
+ hopengl_EXT_blend_subtract=no);
+ AC_MSG_RESULT($hopengl_EXT_blend_subtract)
+
+ FPTOOLS_SEARCH_LIBS([#include <GL/glu.h>], gluNewQuadric, $GLU_search_list, have_GLU=yes, have_GLU=no)
+
+ dnl TODO: Cascade and cache...
+
+ AC_MSG_CHECKING(gluGetString)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [gluGetString(GLU_EXTENSIONS)],
+ fptools_glu_getstring=yes,
+ fptools_glu_getstring=no);
+ AC_MSG_RESULT($fptools_glu_getstring)
+
+ AC_MSG_CHECKING(gluTessEndPolygon)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [gluTessEndPolygon((GLUtesselator*)0)],
+ fptools_glu_tessendpolygon=yes,
+ fptools_glu_tessendpolygon=no);
+ AC_MSG_RESULT($fptools_glu_tessendpolygon)
+
+ AC_MSG_CHECKING(gluUnProject4)
+ AC_TRY_LINK([#include <GL/glut.h>],
+ [gluUnProject4(0.0,0.0,0.0,0.0,(GLdouble*)0,(GLdouble*)0,(GLint*)0,0.0,0.0,(GLdouble*)0,(GLdouble*)0,(GLdouble*)0,(GLdouble*)0)],
+ fptools_glu_unproject4=yes,
+ fptools_glu_unproject4=no);
+ AC_MSG_RESULT($fptools_glu_unproject4)
+
+ if test x"$fptools_glu_getstring" != xyes; then
+ fptools_glu_version=1.0
+ else
+ if test x"$fptools_glu_tessendpolygon" != xyes; then
+ fptools_glu_version=1.1
+ else
+ if test x"$fptools_glu_unproject4" != xyes; then
+ fptools_glu_version=1.2
+ else
+ fptools_glu_version=1.3
+ fi
+ fi
+ fi
+ echo "It looks like GLU version ${fptools_glu_version}"
+
+ FPTOOLS_SEARCH_LIBS([#include <GL/glx.h>], glXWaitX, $GLX_search_list, have_GLX=yes, have_GLX=no)
+ FPTOOLS_SEARCH_LIBS([#include <GL/glut.h>], glutMainLoop, glut32 glut, have_glut=yes, have_glut=no)
+
+ if test -n "$LIBS"; then
+ GL_LIBS="$LDFLAGS $LIBS"
+ else
+ GL_LIBS="$LDFLAGS"
+ GL_CFLAGS=
+ fi
+
+ AC_CACHE_CHECK([OpenGL flags], mdl_cv_gl_cflags, [mdl_cv_gl_cflags="$GL_CFLAGS"])
+ GL_CFLAGS="$mdl_cv_gl_cflags"
+ AC_SUBST(GL_CFLAGS)
+ AC_CACHE_CHECK([OpenGL libs], mdl_cv_gl_libs, [mdl_cv_gl_libs="$GL_LIBS"])
+ GL_LIBS="$mdl_cv_gl_libs"
+ AC_SUBST(GL_LIBS)
+
+dnl Reset GL_X_LIBS regardless, since it was just a temporary variable
+dnl and we don't want to be global namespace polluters.
+ GL_X_LIBS=
+
+ LIBS="$GL_save_LIBS"
+ CPPFLAGS="$GL_save_CPPFLAGS"
+
+ AC_LANG_RESTORE
+])
+
+# LocalWords: fi
+
+dnl
+dnl acspecific.m4's defn of AC_PROG_LEX is a bit too permissive, as it
+dnl defaults to 'lex' if 'flex' isn't found (without checking whether
+dnl 'lex' is actually present along the user's PATH).
+dnl
+AC_DEFUN(AC_PROG_LEX_STRICT,
+[AC_CHECK_PROG(LEX, flex, flex)
+if test -z "$LEX"
+then
+ AC_CHECK_PROG(LEX,lex,lex)
+ test -z "$LEX" && AC_MSG_ERROR(['lex' or 'flex' is required to compile GHC.])
+fi
+])
+
+dnl
+dnl Check to see whether CC (gcc) supports a particular option.
+dnl
+AC_DEFUN(FPTOOLS_CC_FLAG,
+[
+AC_CACHE_CHECK([whether $CC accepts $1], [ac_cv_cc_$2],
+[save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_LANG_C
+ AC_TRY_COMPILE(,[int main(){return(0);}],
+ [ac_cv_cc_$2=yes],
+ [ac_cv_cc_$2=no])
+ CFLAGS="$save_CFLAGS"
+])
+if test "$ac_cv_cc_$2"x = "yesx"; then
+ $2=$1;