1dnl @synopsis AX_CHECK_GLU
2dnl
3dnl Check for GLU.  If GLU is found, the required preprocessor and linker flags
4dnl are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
5dnl respectively.  This macro adds the configure option
6dnl "--with-apple-opengl-framework", which users can use to indicate that
7dnl Apple's OpenGL framework should be used on Mac OS X.  If Apple's OpenGL
8dnl framework is used, the symbol "HAVE_APPLE_OPENGL_FRAMEWORK" is defined.  If
9dnl no GLU implementation is found, "no_glu" is set to "yes".
10dnl
11dnl @version 1.2
12dnl @author Braden McDaniel <braden@endoframe.com>
13dnl
14AC_DEFUN([AX_CHECK_GLU],
15[AC_REQUIRE([AX_CHECK_GL])dnl
16AC_REQUIRE([AC_PROG_CXX])dnl
17GLU_CFLAGS="${GL_CFLAGS}"
18if test "X${with_apple_opengl_framework}" != "Xyes"; then
19  AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
20  [ax_cv_check_glu_libglu="no"
21  ax_save_CPPFLAGS="${CPPFLAGS}"
22  CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
23  ax_save_LIBS="${LIBS}"
24  LIBS=""
25  ax_check_libs="-lglu32 -lGLU"
26  for ax_lib in ${ax_check_libs}; do
27    if test X$ax_compiler_ms = Xyes; then
28      ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
29    else
30      ax_try_lib="${ax_lib}"
31    fi
32    LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
33    #
34    # libGLU typically links with libstdc++ on POSIX platforms. However,
35    # setting the language to C++ means that test program source is named
36    # "conftest.cc"; and Microsoft cl doesn't know what to do with such a
37    # file.
38    #
39    AC_LANG_PUSH([C++])
40    if test X$ax_compiler_ms = Xyes; then
41      AC_LANG_PUSH([C])
42    fi
43    AC_LINK_IFELSE(
44    [AC_LANG_PROGRAM([[
45# if HAVE_WINDOWS_H && defined(_WIN32)
46#   include <windows.h>
47# endif
48# include <GL/glu.h>]],
49                     [[gluBeginCurve(0)]])],
50    [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
51    if test X$ax_compiler_ms = Xyes; then
52      AC_LANG_POP([C])
53    fi
54    AC_LANG_POP([C++])
55  done
56  LIBS=${ax_save_LIBS}
57  CPPFLAGS=${ax_save_CPPFLAGS}])
58  if test "X${ax_cv_check_glu_libglu}" = "Xno"; then
59    no_glu="yes"
60    GLU_CFLAGS=""
61    GLU_LIBS=""
62  else
63    GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"
64  fi
65fi
66AC_SUBST([GLU_CFLAGS])
67AC_SUBST([GLU_LIBS])
68])
69