1 # -*- mode: autoconf -*-
5 # Check for GLU. If GLU is found, the required preprocessor and linker flags
6 # are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
7 # respectively. If no GLU implementation is found, "no_glu" is set to "yes".
9 # If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
10 # header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
11 # preprocessor definitions may not be mutually exclusive.
13 # Some implementations (in particular, some versions of Mac OS X) are known
14 # to treat the GLU tesselator callback function type as "GLvoid (*)(...)"
15 # rather than the standard "GLvoid (*)()". If the former condition is
16 # detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
19 # author: Braden McDaniel <braden@endoframe.com>
21 # This program is free software; you can redistribute it and/or modify
22 # it under the terms of the GNU General Public License as published by
23 # the Free Software Foundation; either version 2, or (at your option)
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
31 # You should have received a copy of the GNU General Public License
32 # along with this program; if not, write to the Free Software
33 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
36 # As a special exception, the you may copy, distribute and modify the
37 # configure scripts that are the output of Autoconf when processing
38 # the Macro. You need not follow the terms of the GNU General Public
39 # License when using or distributing such scripts.
41 AC_DEFUN([AX_CHECK_GLU],
42 [AC_REQUIRE([AX_CHECK_GL])dnl
43 AC_REQUIRE([AC_PROG_CXX])dnl
46 ax_save_CPPFLAGS=$CPPFLAGS
47 CPPFLAGS="$GL_CFLAGS $CPPFLAGS"
48 AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h], , , [
49 # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
53 CPPFLAGS=$ax_save_CPPFLAGS
55 m4_define([AX_CHECK_GLU_PROGRAM],
57 # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
62 # elif defined(HAVE_OPENGL_GLU_H)
63 # include <OpenGL/glu.h>
67 [[gluBeginCurve(0)]])])
69 AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
70 [ax_cv_check_glu_libglu=no
71 ax_save_CPPFLAGS=$CPPFLAGS
72 CPPFLAGS="$GL_CFLAGS $CPPFLAGS"
73 ax_save_LDFLAGS=$LDFLAGS
77 # First, check for the possibility that everything we need is already in
80 LDFLAGS="$ax_save_LDFLAGS $GL_LIBS"
82 # libGLU typically links with libstdc++ on POSIX platforms.
83 # However, setting the language to C++ means that test program
84 # source is named "conftest.cc"; and Microsoft cl doesn't know what
85 # to do with such a file.
88 AS_IF([test X$ax_compiler_ms = Xyes],
90 AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
91 [ax_cv_check_glu_libglu=yes],
93 ax_check_libs="-lglu32 -lGLU"
94 for ax_lib in ${ax_check_libs}; do
95 AS_IF([test X$ax_compiler_ms = Xyes],
96 [ax_try_lib=`echo $ax_lib | $SED -e 's/^-l//' -e 's/$/.lib/'`],
98 LIBS="$ax_try_lib $ax_save_LIBS"
99 AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
100 [ax_cv_check_glu_libglu=$ax_try_lib; break])
102 AS_IF([test X$ax_compiler_ms = Xyes],
107 LDFLAGS=$ax_save_LDFLAGS
108 CPPFLAGS=$ax_save_CPPFLAGS])
109 AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
110 [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
111 [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
113 [GLU_LIBS="$ax_cv_check_glu_libglu"])])
114 AC_SUBST([GLU_CFLAGS])
118 # Some versions of Mac OS X include a broken interpretation of the GLU
119 # tesselation callback function signature when using the C++ compiler.
121 AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
122 [AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
123 [ax_cv_varargs_glu_tesscb],
125 ax_cv_varargs_glu_tesscb=no
126 ax_save_CXXFLAGS=$CXXFLAGS
127 CXXFLAGS="$GL_CFLAGS $CXXFLAGS"
128 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
129 # ifdef HAVE_GL_GLU_H
132 # include <OpenGL/glu.h>
134 [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
135 [ax_cv_varargs_glu_tesscb=yes])
136 CXXFLAGS=$ax_save_CXXFLAGS
138 AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
139 [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
140 [Use nonstandard varargs form for the GLU tesselator callback])])])