1dnl Available from the GNU Autoconf Macro Archive at: 2dnl http://www.gnu.org/software/ac-archive/htmldoc/ax_check_gl.html 3dnl 4AC_DEFUN([AX_CHECK_GL], 5[AC_REQUIRE([AC_PATH_X])dnl 6AC_REQUIRE([ACX_PTHREAD])dnl 7 8# 9# There isn't a reliable way to know we should use the Apple OpenGL framework 10# without a configure option. A Mac OS X user may have installed an 11# alternative GL implementation (e.g., Mesa), which may or may not depend on X. 12# 13AC_ARG_WITH([apple-opengl-framework], 14 [AC_HELP_STRING([--with-apple-opengl-framework], 15 [use Apple OpenGL framework (Mac OS X only)])]) 16if test "X$with_apple_opengl_framework" = "Xyes"; then 17 AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], 18 [Use the Apple OpenGL framework.]) 19 GL_LIBS="-framework OpenGL" 20else 21 AC_LANG_PUSH(C) 22 23 if test x$prefix = xNONE ; then 24 prefix=$ac_default_prefix 25 fi 26 27 AX_LANG_COMPILER_MS 28 if test X$ax_compiler_ms = Xno; then 29 GL_CFLAGS="${PTHREAD_CFLAGS}" 30 GL_LIBS="${PTHREAD_LIBS} -lm" 31 fi 32 33 # 34 # Use x_includes and x_libraries if they have been set (presumably by 35 # AC_PATH_X). 36 # 37 if test "X$no_x" != "Xyes"; then 38 if test -n "$x_includes"; then 39 GL_CFLAGS="-I${x_includes} -I${prefix}/include ${GL_CFLAGS}" 40 fi 41 if test -n "$x_libraries"; then 42 GL_LIBS="-L${x_libraries} -L${prefix}/lib -lX11 ${GL_LIBS}" 43 fi 44 fi 45 46 AC_CHECK_HEADERS([windows.h]) 47 48 AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], 49 [ax_cv_check_gl_libgl="no" 50 ax_save_CPPFLAGS="${CPPFLAGS}" 51 CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" 52 ax_save_LIBS="${LIBS}" 53 LIBS="" 54 ax_check_libs="-lopengl32 -lGL" 55 for ax_lib in ${ax_check_libs}; do 56 if test X$ax_compiler_ms = Xyes; then 57 ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` 58 else 59 ax_try_lib="${ax_lib}" 60 fi 61 LIBS="-L${prefix}/lib ${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" 62 AC_LINK_IFELSE( 63 [AC_LANG_PROGRAM([[ 64# if HAVE_WINDOWS_H && defined(_WIN32) 65# include <windows.h> 66# endif 67# include <GL/gl.h>]], 68 [[glBegin(0)]])], 69 [ax_cv_check_gl_libgl="-L${prefix}/lib ${ax_try_lib}"; break]) 70 done 71 LIBS=${ax_save_LIBS} 72 CPPFLAGS=${ax_save_CPPFLAGS}]) 73 74 if test "X${ax_cv_check_gl_libgl}" = "Xno"; then 75 no_gl="yes" 76 GL_CFLAGS="" 77 GL_LIBS="" 78 else 79 GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}" 80 fi 81 AC_LANG_POP(C) 82fi 83 84AC_SUBST([GL_CFLAGS]) 85AC_SUBST([GL_LIBS]) 86])dnl 87