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