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