1 | dnl |
---|
2 | dnl AX_CHECK_GLUT |
---|
3 | dnl |
---|
4 | dnl Check for GLUT. If GLUT is found, the required compiler and linker flags |
---|
5 | dnl are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS", |
---|
6 | dnl respectively. If GLUT is not found, "no_glut" is set to "yes". |
---|
7 | dnl |
---|
8 | dnl If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the |
---|
9 | dnl header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These |
---|
10 | dnl preprocessor definitions may not be mutually exclusive. |
---|
11 | dnl |
---|
12 | dnl version: 2.0 |
---|
13 | dnl author: Braden McDaniel <braden@endoframe.com> |
---|
14 | dnl |
---|
15 | dnl This program is free software; you can redistribute it and/or modify |
---|
16 | dnl it under the terms of the GNU General Public License as published by |
---|
17 | dnl the Free Software Foundation; either version 2, or (at your option) |
---|
18 | dnl any later version. |
---|
19 | dnl |
---|
20 | dnl This program is distributed in the hope that it will be useful, |
---|
21 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | dnl GNU General Public License for more details. |
---|
24 | dnl |
---|
25 | dnl You should have received a copy of the GNU General Public License |
---|
26 | dnl along with this program; if not, write to the Free Software |
---|
27 | dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
28 | dnl 02110-1301, USA. |
---|
29 | dnl |
---|
30 | dnl As a special exception, the you may copy, distribute and modify the |
---|
31 | dnl configure scripts that are the output of Autoconf when processing |
---|
32 | dnl the Macro. You need not follow the terms of the GNU General Public |
---|
33 | dnl License when using or distributing such scripts. |
---|
34 | dnl |
---|
35 | AC_DEFUN([AX_CHECK_GLUT], |
---|
36 | [AC_REQUIRE([AX_CHECK_GLU])dnl |
---|
37 | AC_REQUIRE([AC_PATH_XTRA])dnl |
---|
38 | |
---|
39 | ax_save_CPPFLAGS="${CPPFLAGS}" |
---|
40 | CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}" |
---|
41 | AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h]) |
---|
42 | CPPFLAGS="${ax_save_CPPFLAGS}" |
---|
43 | |
---|
44 | GLUT_CFLAGS=${GLU_CFLAGS} |
---|
45 | GLUT_LIBS=${GLU_LIBS} |
---|
46 | |
---|
47 | m4_define([AX_CHECK_GLUT_PROGRAM], |
---|
48 | [AC_LANG_PROGRAM([[ |
---|
49 | # if HAVE_WINDOWS_H && defined(_WIN32) |
---|
50 | # include <windows.h> |
---|
51 | # endif |
---|
52 | # ifdef HAVE_GL_GLUT_H |
---|
53 | # include <GL/glut.h> |
---|
54 | # elif defined(HAVE_GLUT_GLUT_H) |
---|
55 | # include <GLUT/glut.h> |
---|
56 | # else |
---|
57 | # error no glut.h |
---|
58 | # endif]], |
---|
59 | [[glutMainLoop()]])]) |
---|
60 | |
---|
61 | # |
---|
62 | # If X is present, assume GLUT depends on it. |
---|
63 | # |
---|
64 | AS_IF([test X$no_x != Xyes], |
---|
65 | [GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"]) |
---|
66 | |
---|
67 | AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut], |
---|
68 | [ax_cv_check_glut_libglut="no" |
---|
69 | AC_LANG_PUSH(C) |
---|
70 | ax_save_CPPFLAGS="${CPPFLAGS}" |
---|
71 | CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}" |
---|
72 | ax_save_LIBS="${LIBS}" |
---|
73 | LIBS="" |
---|
74 | ax_check_libs="-lglut32 -lglut" |
---|
75 | for ax_lib in ${ax_check_libs}; do |
---|
76 | AS_IF([test X$ax_compiler_ms = Xyes], |
---|
77 | [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`], |
---|
78 | [ax_try_lib="${ax_lib}"]) |
---|
79 | LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}" |
---|
80 | AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM], |
---|
81 | [ax_cv_check_glut_libglut="${ax_try_lib}"; break]) |
---|
82 | done |
---|
83 | |
---|
84 | AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes], |
---|
85 | [LIBS='-framework GLUT' |
---|
86 | AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM], |
---|
87 | [ax_cv_check_glut_libglut="$LIBS"])]) |
---|
88 | |
---|
89 | CPPFLAGS="${ax_save_CPPFLAGS}" |
---|
90 | LIBS="${ax_save_LIBS}" |
---|
91 | AC_LANG_POP(C)]) |
---|
92 | |
---|
93 | AS_IF([test "X$ax_cv_check_glut_libglut" = Xno], |
---|
94 | [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""], |
---|
95 | [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"]) |
---|
96 | |
---|
97 | AC_SUBST([GLUT_CFLAGS]) |
---|
98 | AC_SUBST([GLUT_LIBS]) |
---|
99 | ])dnl |
---|