source: anuga_work/development/anugavis/m4/ax_check_glut.m4 @ 5200

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

Some useful autoconf macros and basic structure.

File size: 3.3 KB
Line 
1dnl
2dnl AX_CHECK_GLUT
3dnl
4dnl Check for GLUT.  If GLUT is found, the required compiler and linker flags
5dnl are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
6dnl respectively.  If GLUT is not found, "no_glut" is set to "yes".
7dnl
8dnl If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined.  If the
9dnl header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined.  These
10dnl preprocessor definitions may not be mutually exclusive.
11dnl
12dnl version: 2.0
13dnl author: Braden McDaniel <braden@endoframe.com>
14dnl
15dnl This program is free software; you can redistribute it and/or modify
16dnl it under the terms of the GNU General Public License as published by
17dnl the Free Software Foundation; either version 2, or (at your option)
18dnl any later version.
19dnl
20dnl This program is distributed in the hope that it will be useful,
21dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23dnl GNU General Public License for more details.
24dnl
25dnl You should have received a copy of the GNU General Public License
26dnl along with this program; if not, write to the Free Software
27dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28dnl 02110-1301, USA.
29dnl
30dnl As a special exception, the you may copy, distribute and modify the
31dnl configure scripts that are the output of Autoconf when processing
32dnl the Macro.  You need not follow the terms of the GNU General Public
33dnl License when using or distributing such scripts.
34dnl
35AC_DEFUN([AX_CHECK_GLUT],
36[AC_REQUIRE([AX_CHECK_GLU])dnl
37AC_REQUIRE([AC_PATH_XTRA])dnl
38
39ax_save_CPPFLAGS="${CPPFLAGS}"
40CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
41AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
42CPPFLAGS="${ax_save_CPPFLAGS}"
43
44GLUT_CFLAGS=${GLU_CFLAGS}
45GLUT_LIBS=${GLU_LIBS}
46
47m4_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#
64AS_IF([test X$no_x != Xyes],
65      [GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
66
67AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
68[ax_cv_check_glut_libglut="no"
69AC_LANG_PUSH(C)
70ax_save_CPPFLAGS="${CPPFLAGS}"
71CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
72ax_save_LIBS="${LIBS}"
73LIBS=""
74ax_check_libs="-lglut32 -lglut"
75for 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])
82done
83
84AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
85[LIBS='-framework GLUT'
86AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
87               [ax_cv_check_glut_libglut="$LIBS"])])
88
89CPPFLAGS="${ax_save_CPPFLAGS}"
90LIBS="${ax_save_LIBS}"
91AC_LANG_POP(C)])
92
93AS_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
97AC_SUBST([GLUT_CFLAGS])
98AC_SUBST([GLUT_LIBS])
99])dnl
Note: See TracBrowser for help on using the repository browser.