summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2008-10-08 00:32:23 +0200
committerPeter Simons <simons@cryp.to>2008-10-08 00:32:23 +0200
commit8f0b0984e7a551228a3f6b363548ec2bc2612b5f (patch)
treec22c32c8cabb1ae2e507fc3d81ce59a95332fcbb
parent4858c05d74321bebadcb0a5359aee93fbdcb2756 (diff)
downloadautoconf-archive-8f0b0984e7a551228a3f6b363548ec2bc2612b5f.tar.gz
AX_CHECK_GL: updated to latest versions from Braden McDaniel
-rw-r--r--ax_check_gl.m4175
-rw-r--r--ax_check_glu.m4179
-rw-r--r--ax_check_glut.m4137
3 files changed, 306 insertions, 185 deletions
diff --git a/ax_check_gl.m4 b/ax_check_gl.m4
index a28b267..0da5cc4 100644
--- a/ax_check_gl.m4
+++ b/ax_check_gl.m4
@@ -10,99 +10,126 @@
#
# Check for an OpenGL implementation. If GL is found, the required
# compiler and linker flags are included in the output variables
-# "GL_CFLAGS" and "GL_LIBS", respectively. This macro adds the configure
-# option "--with-apple-opengl-framework", which users can use to indicate
-# that Apple's OpenGL framework should be used on Mac OS X. If Apple's
-# OpenGL framework is used, the symbol "HAVE_APPLE_OPENGL_FRAMEWORK" is
-# defined. If no GL implementation is found, "no_gl" is set to "yes".
+# "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
+# is found, "no_gl" is set to "yes".
+#
+# If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
+# header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
#
# LAST MODIFICATION
#
-# 2008-04-12
+# 2008-10-07
#
# COPYLEFT
#
# Copyright (c) 2008 Braden McDaniel <braden@endoframe.com>
#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Macro Archive. When you make and
+# distribute a modified version of the Autoconf Macro, you may extend this
+# special exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_CHECK_GL],
-[AC_REQUIRE([AC_PATH_X])dnl
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PATH_X])dnl
AC_REQUIRE([ACX_PTHREAD])dnl
-#
-# There isn't a reliable way to know we should use the Apple OpenGL framework
-# without a configure option. A Mac OS X user may have installed an
-# alternative GL implementation (e.g., Mesa), which may or may not depend on X.
-#
-AC_ARG_WITH([apple-opengl-framework],
- [AC_HELP_STRING([--with-apple-opengl-framework],
- [use Apple OpenGL framework (Mac OS X only)])])
-if test "X$with_apple_opengl_framework" = "Xyes"; then
- AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1],
- [Use the Apple OpenGL framework.])
- GL_LIBS="-framework OpenGL"
-else
- AC_LANG_PUSH(C)
+AC_LANG_PUSH([C])
+AX_LANG_COMPILER_MS
+AS_IF([test X$ax_compiler_ms = Xno],
+ [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
- AX_LANG_COMPILER_MS
- if test X$ax_compiler_ms = Xno; then
- GL_CFLAGS="${PTHREAD_CFLAGS}"
- GL_LIBS="${PTHREAD_LIBS} -lm"
- fi
+#
+# Use x_includes and x_libraries if they have been set (presumably by
+# AC_PATH_X).
+#
+AS_IF([test "X$no_x" != "Xyes"],
+ [AS_IF([test -n "$x_includes"],
+ [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
+ AS_IF([test -n "$x_libraries"],
+ [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
- #
- # Use x_includes and x_libraries if they have been set (presumably by
- # AC_PATH_X).
- #
- if test "X$no_x" != "Xyes"; then
- if test -n "$x_includes"; then
- GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"
- fi
- if test -n "$x_libraries"; then
- GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"
- fi
- fi
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
- AC_CHECK_HEADERS([windows.h])
+AC_CHECK_HEADERS([windows.h])
- AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
- [ax_cv_check_gl_libgl="no"
- ax_save_CPPFLAGS="${CPPFLAGS}"
- CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
- ax_save_LIBS="${LIBS}"
- LIBS=""
- ax_check_libs="-lopengl32 -lGL"
- for ax_lib in ${ax_check_libs}; do
- if test X$ax_compiler_ms = Xyes; then
- ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
- else
- ax_try_lib="${ax_lib}"
- fi
- LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[
-# if HAVE_WINDOWS_H && defined(_WIN32)
+m4_define([AX_CHECK_GL_PROGRAM],
+ [AC_LANG_PROGRAM([[
+# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
# include <windows.h>
# endif
-# include <GL/gl.h>]],
- [[glBegin(0)]])],
- [ax_cv_check_gl_libgl="${ax_try_lib}"; break])
- done
- LIBS=${ax_save_LIBS}
- CPPFLAGS=${ax_save_CPPFLAGS}])
+# ifdef HAVE_GL_GL_H
+# include <GL/gl.h>
+# elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+# else
+# error no gl.h
+# endif]],
+ [[glBegin(0)]])])
+
+AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
+[ax_cv_check_gl_libgl="no"
+case $host_cpu in
+ x86_64) ax_check_gl_libdir=lib64 ;;
+ *) ax_check_gl_libdir=lib ;;
+esac
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+LIBS=""
+ax_check_libs="-lopengl32 -lGL"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib}"; break],
+ [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break],
+ [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' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
+done
+
+AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
+[LIBS='-framework OpenGL'
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="$LIBS"])])
+
+LIBS=${ax_save_LIBS}
+CPPFLAGS=${ax_save_CPPFLAGS}])
- if test "X${ax_cv_check_gl_libgl}" = "Xno"; then
- no_gl="yes"
- GL_CFLAGS=""
- GL_LIBS=""
- else
- GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"
- fi
- AC_LANG_POP(C)
-fi
+AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
+ [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
+ [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
+AC_LANG_POP([C])
AC_SUBST([GL_CFLAGS])
AC_SUBST([GL_LIBS])
diff --git a/ax_check_glu.m4 b/ax_check_glu.m4
index c5405b7..5a31d45 100644
--- a/ax_check_glu.m4
+++ b/ax_check_glu.m4
@@ -10,76 +10,145 @@
#
# Check for GLU. If GLU is found, the required preprocessor and linker
# flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
-# respectively. This macro adds the configure option
-# "--with-apple-opengl-framework", which users can use to indicate that
-# Apple's OpenGL framework should be used on Mac OS X. If Apple's OpenGL
-# framework is used, the symbol "HAVE_APPLE_OPENGL_FRAMEWORK" is defined.
-# If no GLU implementation is found, "no_glu" is set to "yes".
+# respectively. If no GLU implementation is found, "no_glu" is set to
+# "yes".
+#
+# If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
+# header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
+#
+# Some implementations (in particular, some versions of Mac OS X) are
+# known to treat the GLU tesselator callback function type as "GLvoid
+# (*)(...)" rather than the standard "GLvoid (*)()". If the former
+# condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
#
# LAST MODIFICATION
#
-# 2008-04-12
+# 2008-10-07
#
# COPYLEFT
#
# Copyright (c) 2008 Braden McDaniel <braden@endoframe.com>
#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Macro Archive. When you make and
+# distribute a modified version of the Autoconf Macro, you may extend this
+# special exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_CHECK_GLU],
[AC_REQUIRE([AX_CHECK_GL])dnl
AC_REQUIRE([AC_PROG_CXX])dnl
GLU_CFLAGS="${GL_CFLAGS}"
-if test "X${with_apple_opengl_framework}" != "Xyes"; then
- AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
- [ax_cv_check_glu_libglu="no"
- ax_save_CPPFLAGS="${CPPFLAGS}"
- CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
- ax_save_LIBS="${LIBS}"
- LIBS=""
- ax_check_libs="-lglu32 -lGLU"
- for ax_lib in ${ax_check_libs}; do
- if test X$ax_compiler_ms = Xyes; then
- ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
- else
- ax_try_lib="${ax_lib}"
- fi
- LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
- #
- # libGLU typically links with libstdc++ on POSIX platforms. However,
- # setting the language to C++ means that test program source is named
- # "conftest.cc"; and Microsoft cl doesn't know what to do with such a
- # file.
- #
- AC_LANG_PUSH([C++])
- if test X$ax_compiler_ms = Xyes; then
- AC_LANG_PUSH([C])
- fi
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[
-# if HAVE_WINDOWS_H && defined(_WIN32)
+
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
+
+m4_define([AX_CHECK_GLU_PROGRAM],
+ [AC_LANG_PROGRAM([[
+# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
# include <windows.h>
# endif
-# include <GL/glu.h>]],
- [[gluBeginCurve(0)]])],
- [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
- if test X$ax_compiler_ms = Xyes; then
- AC_LANG_POP([C])
- fi
- AC_LANG_POP([C++])
- done
- LIBS=${ax_save_LIBS}
- CPPFLAGS=${ax_save_CPPFLAGS}])
- if test "X${ax_cv_check_glu_libglu}" = "Xno"; then
- no_glu="yes"
- GLU_CFLAGS=""
- GLU_LIBS=""
- else
- GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"
- fi
-fi
+# ifdef HAVE_GL_GLU_H
+# include <GL/glu.h>
+# elif defined(HAVE_OPENGL_GLU_H)
+# include <OpenGL/glu.h>
+# else
+# error no glu.h
+# endif]],
+ [[gluBeginCurve(0)]])])
+
+AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
+[ax_cv_check_glu_libglu="no"
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+
+#
+# First, check for the possibility that everything we need is already in
+# GL_LIBS.
+#
+LIBS="${GL_LIBS} ${ax_save_LIBS}"
+#
+# libGLU typically links with libstdc++ on POSIX platforms.
+# However, setting the language to C++ means that test program
+# source is named "conftest.cc"; and Microsoft cl doesn't know what
+# to do with such a file.
+#
+AC_LANG_PUSH([C++])
+AS_IF([test X$ax_compiler_ms = Xyes],
+ [AC_LANG_PUSH([C])])
+AC_LINK_IFELSE(
+[AX_CHECK_GLU_PROGRAM],
+[ax_cv_check_glu_libglu=yes],
+[LIBS=""
+ax_check_libs="-lglu32 -lGLU"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+ AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
+ [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
+done
+])
+AS_IF([test X$ax_compiler_ms = Xyes],
+ [AC_LANG_POP([C])])
+AC_LANG_POP([C++])
+
+LIBS=${ax_save_LIBS}
+CPPFLAGS=${ax_save_CPPFLAGS}])
+AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
+ [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
+ [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
+ [GLU_LIBS="$GL_LIBS"],
+ [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
AC_SUBST([GLU_CFLAGS])
AC_SUBST([GLU_LIBS])
+
+#
+# Some versions of Mac OS X include a broken interpretation of the GLU
+# tesselation callback function signature.
+#
+AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
+[AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
+ [ax_cv_varargs_glu_tesscb],
+[ax_cv_varargs_glu_tesscb=no
+ax_save_CFLAGS="$CFLAGS"
+CFLAGS="$GL_CFLAGS $CFLAGS"
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([[
+# ifdef HAVE_GL_GLU_H
+# include <GL/glu.h>
+# else
+# include <OpenGL/glu.h>
+# endif]],
+ [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
+[ax_cv_varargs_glu_tesscb=yes])
+CFLAGS="$ax_save_CFLAGS"])
+AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
+ [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
+ [Use nonstandard varargs form for the GLU tesselator callback])])])
])
diff --git a/ax_check_glut.m4 b/ax_check_glut.m4
index 2eee10b..418f46b 100644
--- a/ax_check_glut.m4
+++ b/ax_check_glut.m4
@@ -10,82 +10,107 @@
#
# Check for GLUT. If GLUT is found, the required compiler and linker flags
# are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
-# respectively. This macro adds the configure option
-# "--with-apple-opengl-framework", which users can use to indicate that
-# Apple's OpenGL framework should be used on Mac OS X. If Apple's OpenGL
-# framework is used, the symbol "HAVE_APPLE_OPENGL_FRAMEWORK" is defined.
-# If GLUT is not found, "no_glut" is set to "yes".
+# respectively. If GLUT is not found, "no_glut" is set to "yes".
+#
+# If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
+# header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
#
# LAST MODIFICATION
#
-# 2008-04-12
+# 2008-10-07
#
# COPYLEFT
#
# Copyright (c) 2008 Braden McDaniel <braden@endoframe.com>
#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Macro Archive. When you make and
+# distribute a modified version of the Autoconf Macro, you may extend this
+# special exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_CHECK_GLUT],
[AC_REQUIRE([AX_CHECK_GLU])dnl
AC_REQUIRE([AC_PATH_XTRA])dnl
-if test "X$with_apple_opengl_framework" = "Xyes"; then
- GLUT_CFLAGS="${GLU_CFLAGS}"
- GLUT_LIBS="-framework GLUT -lobjc ${GL_LIBS}"
-else
- GLUT_CFLAGS=${GLU_CFLAGS}
- GLUT_LIBS=${GLU_LIBS}
-
- #
- # If X is present, assume GLUT depends on it.
- #
- if test "X${no_x}" != "Xyes"; then
- GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"
- fi
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
- AC_LANG_PUSH(C)
+GLUT_CFLAGS=${GLU_CFLAGS}
+GLUT_LIBS=${GLU_LIBS}
- ax_save_CPPFLAGS="${CPPFLAGS}"
- CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
-
- AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
- [ax_cv_check_glut_libglut="no"
- ax_save_LIBS="${LIBS}"
- LIBS=""
- ax_check_libs="-lglut32 -lglut"
- for ax_lib in ${ax_check_libs}; do
- if test X$ax_compiler_ms = Xyes; then
- ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
- else
- ax_try_lib="${ax_lib}"
- fi
- LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[
+m4_define([AX_CHECK_GLUT_PROGRAM],
+ [AC_LANG_PROGRAM([[
# if HAVE_WINDOWS_H && defined(_WIN32)
# include <windows.h>
# endif
-# include <GL/glut.h>]],
- [[glutMainLoop()]])],
- [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
+# ifdef HAVE_GL_GLUT_H
+# include <GL/glut.h>
+# elif defined(HAVE_GLUT_GLUT_H)
+# include <GLUT/glut.h>
+# else
+# error no glut.h
+# endif]],
+ [[glutMainLoop()]])])
+
+#
+# If X is present, assume GLUT depends on it.
+#
+AS_IF([test X$no_x != Xyes],
+ [GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
+
+AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
+[ax_cv_check_glut_libglut="no"
+AC_LANG_PUSH(C)
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+LIBS=""
+ax_check_libs="-lglut32 -lglut"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
+ AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
+ [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
+done
+
+AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
+[LIBS='-framework GLUT'
+AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
+ [ax_cv_check_glut_libglut="$LIBS"])])
- done
- LIBS=${ax_save_LIBS}
- ])
- CPPFLAGS="${ax_save_CPPFLAGS}"
- AC_LANG_POP(C)
+CPPFLAGS="${ax_save_CPPFLAGS}"
+LIBS="${ax_save_LIBS}"
+AC_LANG_POP(C)])
- if test "X${ax_cv_check_glut_libglut}" = "Xno"; then
- no_glut="yes"
- GLUT_CFLAGS=""
- GLUT_LIBS=""
- else
- GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"
- fi
-fi
+AS_IF([test "X$ax_cv_check_glut_libglut" = Xno],
+ [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""],
+ [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"])
AC_SUBST([GLUT_CFLAGS])
AC_SUBST([GLUT_LIBS])