[5200] | 1 | dnl |
---|
| 2 | dnl AX_CHECK_GL |
---|
| 3 | dnl |
---|
| 4 | dnl Check for an OpenGL implementation. If GL is found, the required compiler |
---|
| 5 | dnl and linker flags are included in the output variables "GL_CFLAGS" and |
---|
| 6 | dnl "GL_LIBS", respectively. If no usable GL implementation is found, "no_gl" |
---|
| 7 | dnl is set to "yes". |
---|
| 8 | dnl |
---|
| 9 | dnl If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the header |
---|
| 10 | dnl "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These preprocessor |
---|
| 11 | dnl definitions may not be mutually exclusive. |
---|
| 12 | dnl |
---|
| 13 | dnl version: 2.0 |
---|
| 14 | dnl author: Braden McDaniel <braden@endoframe.com> |
---|
| 15 | dnl |
---|
| 16 | dnl This program is free software; you can redistribute it and/or modify |
---|
| 17 | dnl it under the terms of the GNU General Public License as published by |
---|
| 18 | dnl the Free Software Foundation; either version 2, or (at your option) |
---|
| 19 | dnl any later version. |
---|
| 20 | dnl |
---|
| 21 | dnl This program is distributed in the hope that it will be useful, |
---|
| 22 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 23 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 24 | dnl GNU General Public License for more details. |
---|
| 25 | dnl |
---|
| 26 | dnl You should have received a copy of the GNU General Public License |
---|
| 27 | dnl along with this program; if not, write to the Free Software |
---|
| 28 | dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
| 29 | dnl 02110-1301, USA. |
---|
| 30 | dnl |
---|
| 31 | dnl As a special exception, the you may copy, distribute and modify the |
---|
| 32 | dnl configure scripts that are the output of Autoconf when processing |
---|
| 33 | dnl the Macro. You need not follow the terms of the GNU General Public |
---|
| 34 | dnl License when using or distributing such scripts. |
---|
| 35 | dnl |
---|
| 36 | AC_DEFUN([AX_CHECK_GL], |
---|
| 37 | [AC_REQUIRE([AC_PATH_X])dnl |
---|
| 38 | AC_REQUIRE([ACX_PTHREAD])dnl |
---|
| 39 | |
---|
| 40 | AC_LANG_PUSH([C]) |
---|
| 41 | AX_LANG_COMPILER_MS |
---|
| 42 | AS_IF([test X$ax_compiler_ms = Xno], |
---|
| 43 | [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"]) |
---|
| 44 | |
---|
| 45 | # |
---|
| 46 | # Use x_includes and x_libraries if they have been set (presumably by |
---|
| 47 | # AC_PATH_X). |
---|
| 48 | # |
---|
| 49 | AS_IF([test "X$no_x" != "Xyes"], |
---|
| 50 | [AS_IF([test -n "$x_includes"], |
---|
| 51 | [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])] |
---|
| 52 | AS_IF([test -n "$x_libraries"], |
---|
| 53 | [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"])) |
---|
| 54 | |
---|
| 55 | ax_save_CPPFLAGS="${CPPFLAGS}" |
---|
| 56 | CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" |
---|
| 57 | AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h]) |
---|
| 58 | CPPFLAGS="${ax_save_CPPFLAGS}" |
---|
| 59 | |
---|
| 60 | AC_CHECK_HEADERS([windows.h]) |
---|
| 61 | |
---|
| 62 | m4_define([AX_CHECK_GL_PROGRAM], |
---|
| 63 | [AC_LANG_PROGRAM([[ |
---|
| 64 | # if defined(HAVE_WINDOWS_H) && defined(_WIN32) |
---|
| 65 | # include <windows.h> |
---|
| 66 | # endif |
---|
| 67 | # ifdef HAVE_GL_GL_H |
---|
| 68 | # include <GL/gl.h> |
---|
| 69 | # elif defined(HAVE_OPENGL_GL_H) |
---|
| 70 | # include <OpenGL/gl.h> |
---|
| 71 | # else |
---|
| 72 | # error no gl.h |
---|
| 73 | # endif]], |
---|
| 74 | [[glBegin(0)]])]) |
---|
| 75 | |
---|
| 76 | AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl], |
---|
| 77 | [ax_cv_check_gl_libgl="no" |
---|
| 78 | ax_save_CPPFLAGS="${CPPFLAGS}" |
---|
| 79 | CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}" |
---|
| 80 | ax_save_LIBS="${LIBS}" |
---|
| 81 | LIBS="" |
---|
| 82 | ax_check_libs="-lopengl32 -lGL" |
---|
| 83 | for ax_lib in ${ax_check_libs}; do |
---|
| 84 | AS_IF([test X$ax_compiler_ms = Xyes], |
---|
| 85 | [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`], |
---|
| 86 | [ax_try_lib="${ax_lib}"]) |
---|
| 87 | LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}" |
---|
| 88 | AC_LINK_IFELSE( |
---|
| 89 | [AX_CHECK_GL_PROGRAM], |
---|
| 90 | [ax_cv_check_gl_libgl="${ax_try_lib}"; break], |
---|
| 91 | [ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib' |
---|
| 92 | LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}" |
---|
| 93 | AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], |
---|
| 94 | [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])]) |
---|
| 95 | done |
---|
| 96 | |
---|
| 97 | AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes], |
---|
| 98 | [LIBS='-framework OpenGL' |
---|
| 99 | AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM], |
---|
| 100 | [ax_cv_check_gl_libgl="$LIBS"])]) |
---|
| 101 | |
---|
| 102 | LIBS=${ax_save_LIBS} |
---|
| 103 | CPPFLAGS=${ax_save_CPPFLAGS}]) |
---|
| 104 | |
---|
| 105 | AS_IF([test "X$ax_cv_check_gl_libgl" = Xno], |
---|
| 106 | [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""], |
---|
| 107 | [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"]) |
---|
| 108 | AC_LANG_POP([C]) |
---|
| 109 | |
---|
| 110 | AC_SUBST([GL_CFLAGS]) |
---|
| 111 | AC_SUBST([GL_LIBS]) |
---|
| 112 | ])dnl |
---|