-dnl ########################### -*- Mode: M4 -*- #######################
-dnl Copyright (C) 98, 1999 Matthew D. Langston <langston@SLAC.Stanford.EDU>
-dnl
-dnl This file is free software; you can redistribute it and/or modify it
-dnl under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This file is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this file; if not, write to:
-dnl
-dnl Free Software Foundation, Inc.
-dnl Suite 330
-dnl 59 Temple Place
-dnl Boston, MA 02111-1307, USA.
-dnl ####################################################################
-
-dnl @synopsis FPTOOLS_HAVE_OPENGL
-dnl
-dnl Search for OpenGL. We search first for Mesa (a GPL'ed version of
-dnl OpenGL) before a vendor's version of OpenGL if we were specifically
-dnl asked to with `--with-Mesa=yes' or `--with-Mesa'.
-dnl
-dnl The four "standard" OpenGL libraries are searched for: "-lGL",
-dnl "-lGLU", "-lGLX" (or "-lMesaGL", "-lMesaGLU" as the case may be) and
-dnl "-lglut".
-dnl
-dnl All of the libraries that are found (since "-lglut" or "-lGLX" might
-dnl be missing) are added to the shell output variable "GL_LIBS", along
-dnl with any other libraries that are necessary to successfully link an
-dnl OpenGL application (e.g. the X11 libraries). Care has been taken to
-dnl make sure that all of the libraries in "GL_LIBS" are listed in the
-dnl proper order.
-dnl
-dnl Additionally, the shell output variable "GL_CFLAGS" is set to any
-dnl flags (e.g. "-I" flags) that are necessary to successfully compile
-dnl an OpenGL application.
-dnl
-dnl The following shell variable (which are not output variables) are
-dnl also set to either "yes" or "no" (depending on which libraries were
-dnl found) to help you determine exactly what was found.
-dnl
-dnl have_GL
-dnl have_GLU
-dnl have_GLX
-dnl have_glut
-dnl
-dnl A complete little toy "Automake `make distcheck'" package of how to
-dnl use this macro is available at:
-dnl
-dnl ftp://ftp.slac.stanford.edu/users/langston/autoconf/ac_opengl-0.01.tar.gz
-dnl
-dnl Please note that as the ac_opengl macro and the toy example evolves,
-dnl the version number increases, so you may have to adjust the above
-dnl URL accordingly.
-dnl
-dnl @author Matthew D. Langston <langston@SLAC.Stanford.EDU>
-
-AC_DEFUN(FPTOOLS_HAVE_OPENGL,
-[
- AC_REQUIRE([AC_PROG_CC])
- AC_REQUIRE([AC_PATH_X])
- AC_REQUIRE([AC_PATH_XTRA])
- AC_REQUIRE([FPTOOLS_CHECK_LIBM])
-
-dnl Check for Mesa first if we were asked to.
- AC_ARG_ENABLE(Mesa,
-[ --enable-mesa
- Prefer Mesa over a vendor's native OpenGL library (default=no)
-],
- use_Mesa=$enableval,
- use_Mesa=no)
+if test x"$enable_opengl" = xno; then
+ no_GL=yes
+else
+ use_quartz_opengl=no
+ case $target_os in
+ darwin*)
+ if test x"$enable_opengl" != xx11; then
+ AC_DEFINE([USE_QUARTZ_OPENGL], [1],
+ [Define to 1 if native OpenGL should be used on Mac OS X])
+ use_quartz_opengl=yes
+ fi
+ ;;
+ esac
+
+ if test x"$use_quartz_opengl" != xyes; then
+ AC_CHECK_LIB([m], [atan], [GL_LIBS="-lm $GL_LIBS"])
+
+ if test x"$no_x" != xyes; then
+ test -n "$x_includes" && GL_CFLAGS="-I$x_includes $GL_CFLAGS"
+ test -n "$x_libraries" && GL_LIBS="-L$x_libraries -lX11 $GL_LIBS"
+ fi
+
+ FP_CHECK_GL_HELPER([GL], [-lGL -lopengl32], [@%:@include <GL/gl.h>], [glEnd()])
+
+ if test x"$no_GL" != xyes; then
+ # Ugly: To get wglGetProcAddress on Windows, we have to link with
+ # opengl32.dll, too, even when we are using Cygwin with X11.
+ case "$GL_LIBS" in
+ *-lopengl32*|*opengl32.lib*) ;;
+ *) fp_save_LIBS="$LIBS"
+ LIBS="$LIBS -lopengl32"
+ AC_TRY_LINK([@%:@include <GL/gl.h>], [glEnd()],
+ [GL_LIBS="$GL_LIBS -lopengl32"; GL_LIBS0="$GL_LIBS0 -lopengl32"])
+ LIBS="$fp_save_LIBS"
+ ;;
+ esac
+ fi
+ fi
+fi