source: anuga_work/development/anugavis/m4/ax_check_gl.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: 3.9 KB
Line 
1dnl
2dnl AX_CHECK_GL
3dnl
4dnl Check for an OpenGL implementation.  If GL is found, the required compiler
5dnl and linker flags are included in the output variables "GL_CFLAGS" and
6dnl "GL_LIBS", respectively.  If no usable GL implementation is found, "no_gl"
7dnl is set to "yes".
8dnl
9dnl If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined.  If the header
10dnl "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined.  These preprocessor
11dnl definitions may not be mutually exclusive.
12dnl
13dnl version: 2.0
14dnl author: Braden McDaniel <braden@endoframe.com>
15dnl
16dnl This program is free software; you can redistribute it and/or modify
17dnl it under the terms of the GNU General Public License as published by
18dnl the Free Software Foundation; either version 2, or (at your option)
19dnl any later version.
20dnl
21dnl This program is distributed in the hope that it will be useful,
22dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
23dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24dnl GNU General Public License for more details.
25dnl
26dnl You should have received a copy of the GNU General Public License
27dnl along with this program; if not, write to the Free Software
28dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29dnl 02110-1301, USA.
30dnl
31dnl As a special exception, the you may copy, distribute and modify the
32dnl configure scripts that are the output of Autoconf when processing
33dnl the Macro.  You need not follow the terms of the GNU General Public
34dnl License when using or distributing such scripts.
35dnl
36AC_DEFUN([AX_CHECK_GL],
37[AC_REQUIRE([AC_PATH_X])dnl
38AC_REQUIRE([ACX_PTHREAD])dnl
39
40AC_LANG_PUSH([C])
41AX_LANG_COMPILER_MS
42AS_IF([test X$ax_compiler_ms = Xno],
43      [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
44
45#
46# Use x_includes and x_libraries if they have been set (presumably by
47# AC_PATH_X).
48#
49AS_IF([test "X$no_x" != "Xyes"],
50      [AS_IF([test -n "$x_includes"],
51             [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
52       AS_IF([test -n "$x_libraries"],
53             [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
54
55ax_save_CPPFLAGS="${CPPFLAGS}"
56CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
57AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
58CPPFLAGS="${ax_save_CPPFLAGS}"
59
60AC_CHECK_HEADERS([windows.h])
61
62m4_define([AX_CHECK_GL_PROGRAM],
63          [AC_LANG_PROGRAM([[
64# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
65#   include <windows.h>
66# endif
67# ifdef HAVE_GL_GL_H
68#   include <GL/gl.h>
69# elif defined(HAVE_OPENGL_GL_H)
70#   include <OpenGL/gl.h>
71# else
72#   error no gl.h
73# endif]],
74                           [[glBegin(0)]])])
75
76AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
77[ax_cv_check_gl_libgl="no"
78ax_save_CPPFLAGS="${CPPFLAGS}"
79CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
80ax_save_LIBS="${LIBS}"
81LIBS=""
82ax_check_libs="-lopengl32 -lGL"
83for ax_lib in ${ax_check_libs}; do
84  AS_IF([test X$ax_compiler_ms = Xyes],
85        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
86        [ax_try_lib="${ax_lib}"])
87  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
88  AC_LINK_IFELSE(
89[AX_CHECK_GL_PROGRAM],
90[ax_cv_check_gl_libgl="${ax_try_lib}"; break],
91[ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib'
92LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
93AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
94               [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])
95done
96
97AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
98[LIBS='-framework OpenGL'
99AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
100               [ax_cv_check_gl_libgl="$LIBS"])])
101
102LIBS=${ax_save_LIBS}
103CPPFLAGS=${ax_save_CPPFLAGS}])
104
105AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
106      [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
107      [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
108AC_LANG_POP([C])
109
110AC_SUBST([GL_CFLAGS])
111AC_SUBST([GL_LIBS])
112])dnl
Note: See TracBrowser for help on using the repository browser.