1dnl @synopsis AX_CHECK_GL 2dnl 3dnl Check for an OpenGL implementation. If GL is found, the required 4dnl compiler and linker flags are included in the output variables 5dnl "GL_CFLAGS" and "GL_LIBS", respectively. This macro adds the 6dnl configure option "--with-apple-opengl-framework", which users can 7dnl use to indicate that Apple's OpenGL framework should be used on Mac 8dnl OS X. If Apple's OpenGL framework is used, the symbol 9dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GL implementation 10dnl is found, "no_gl" is set to "yes". 11dnl 12dnl @category InstalledPackages 13dnl @author Braden McDaniel <braden@endoframe.com> 14dnl @version 2004-11-15 15dnl @license AllPermissive 16 17AC_DEFUN([AX_CHECK_GL], 18[ 19 20# 21# There isn't a reliable way to know we should use the Apple OpenGL framework 22# without a configure option. A Mac OS X user may have installed an 23# alternative GL implementation (e.g., Mesa), which may or may not depend on X. 24# 25AC_ARG_WITH([apple-opengl-framework], 26 [AC_HELP_STRING([--with-apple-opengl-framework], 27 [use Apple OpenGL framework (Mac OS X only)])]) 28if test "X$with_apple_opengl_framework" = "Xyes"; then 29 AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1], 30 [Use the Apple OpenGL framework.]) 31 GL_LIBS="-framework OpenGL" 32else 33 AC_REQUIRE([AC_PATH_X])dnl 34 AC_REQUIRE([ACX_PTHREAD])dnl 35 36 AC_LANG_PUSH(C) 37 38 AX_LANG_COMPILER_MS 39 if test X$ax_compiler_ms = Xno; then 40 GL_CFLAGS="${PTHREAD_CFLAGS}" 41 GL_LIBS="${PTHREAD_LIBS} -lm" 42 fi 43 44 # 45 # Use x_includes and x_libraries if they have been set (presumably by 46 # AC_PATH_X). 47 # 48 if test "X$no_x" != "Xyes"; then 49 if test -n "$x_includes"; then 50 GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}" 51 fi 52 if test -n "$x_libraries"; then 53 GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}" 54 fi 55 fi 56 57 AC_CHECK_HEADERS([windows.h]) 58 59 AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], 60 [ax_cv_check_gl_libgl="no" 61 ax_save_CPPFLAGS="${CPPFLAGS}" 62 CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" 63 ax_save_LIBS="${LIBS}" 64 LIBS="" 65 ax_check_libs="-lopengl32 -lGL" 66 for ax_lib in ${ax_check_libs}; do 67 if test X$ax_compiler_ms = Xyes; then 68 ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'` 69 else 70 ax_try_lib="${ax_lib}" 71 fi 72 LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" 73 AC_LINK_IFELSE( 74 [AC_LANG_PROGRAM([[ 75# if HAVE_WINDOWS_H && defined(_WIN32) 76# include <windows.h> 77# endif 78# include <GL/gl.h>]], 79 [[glBegin(0)]])], 80 [ax_cv_check_gl_libgl="${ax_try_lib}"; break]) 81 done 82 LIBS=${ax_save_LIBS} 83 CPPFLAGS=${ax_save_CPPFLAGS}]) 84 85 if test "X${ax_cv_check_gl_libgl}" = "Xno"; then 86 no_gl="yes" 87 GL_CFLAGS="" 88 GL_LIBS="" 89 else 90 GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}" 91 fi 92 AC_LANG_POP(C) 93fi 94 95AC_SUBST([GL_CFLAGS]) 96AC_SUBST([GL_LIBS]) 97])dnl 98