source: anuga_work/development/anugavis/m4/ax_check_glu.m4 @ 5587

Last change on this file since 5587 was 5200, checked in by jack, 16 years ago

Some useful autoconf macros and basic structure.

File size: 4.6 KB
Line 
1dnl
2dnl AX_CHECK_GLU
3dnl
4dnl Check for GLU.  If GLU is found, the required preprocessor and linker flags
5dnl are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
6dnl respectively.  If no GLU implementation is found, "no_glu" is set to "yes".
7dnl
8dnl If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined.  If the
9dnl header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined.  These
10dnl preprocessor definitions may not be mutually exclusive.
11dnl
12dnl Some implementations (in particular, some versions of Mac OS X) are known
13dnl to treat the GLU tesselator callback function type as "GLvoid (*)(...)"
14dnl rather than the standard "GLvoid (*)()".  If the former condition is
15dnl detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
16dnl
17dnl version: 2.1
18dnl author: Braden McDaniel <braden@endoframe.com>
19dnl
20dnl This program is free software; you can redistribute it and/or modify
21dnl it under the terms of the GNU General Public License as published by
22dnl the Free Software Foundation; either version 2, or (at your option)
23dnl any later version.
24dnl
25dnl This program is distributed in the hope that it will be useful,
26dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
27dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28dnl GNU General Public License for more details.
29dnl
30dnl You should have received a copy of the GNU General Public License
31dnl along with this program; if not, write to the Free Software
32dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33dnl 02110-1301, USA.
34dnl
35dnl As a special exception, the you may copy, distribute and modify the
36dnl configure scripts that are the output of Autoconf when processing
37dnl the Macro.  You need not follow the terms of the GNU General Public
38dnl License when using or distributing such scripts.
39dnl
40AC_DEFUN([AX_CHECK_GLU],
41[AC_REQUIRE([AX_CHECK_GL])dnl
42AC_REQUIRE([AC_PROG_CXX])dnl
43GLU_CFLAGS="${GL_CFLAGS}"
44
45ax_save_CPPFLAGS="${CPPFLAGS}"
46CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
47AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
48CPPFLAGS="${ax_save_CPPFLAGS}"
49
50m4_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
64AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
65[ax_cv_check_glu_libglu="no"
66ax_save_CPPFLAGS="${CPPFLAGS}"
67CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
68ax_save_LIBS="${LIBS}"
69
70#
71# First, check for the possibility that everything we need is already in
72# GL_LIBS.
73#
74LIBS="${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#
81AC_LANG_PUSH([C++])
82AS_IF([test X$ax_compiler_ms = Xyes],
83      [AC_LANG_PUSH([C])])
84AC_LINK_IFELSE(
85[AX_CHECK_GLU_PROGRAM],
86[ax_cv_check_glu_libglu=yes],
87[LIBS=""
88ax_check_libs="-lglu32 -lGLU"
89for 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])
96done
97])
98AS_IF([test X$ax_compiler_ms = Xyes],
99      [AC_LANG_POP([C])])
100AC_LANG_POP([C++])
101
102LIBS=${ax_save_LIBS}
103CPPFLAGS=${ax_save_CPPFLAGS}])
104AS_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}"])])
109AC_SUBST([GLU_CFLAGS])
110AC_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#
116AS_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
120ax_save_CFLAGS="$CFLAGS"
121CFLAGS="$GL_CFLAGS $CFLAGS"
122AC_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])
131CFLAGS="$ax_save_CFLAGS"])
132AS_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])
Note: See TracBrowser for help on using the repository browser.