Debian Codegraph @

m4/gl.m4

raw
1 dnl FTGL_CHECK_GL()
2 dnl Check for OpenGL development environment and GLU >= 1.2
3 dnl
4 AC_DEFUN([FTGL_CHECK_GL],
5 [dnl
6 AC_REQUIRE([AC_PROG_CC])
7 AC_REQUIRE([AC_PATH_X])
8 AC_REQUIRE([AC_PATH_XTRA])
9
10 AC_ARG_WITH([--with-gl-inc],
11 AC_HELP_STRING([--with-gl-inc=DIR],[Directory where GL/gl.h is installed]))
12 AC_ARG_WITH([--with-gl-lib],
13 AC_HELP_STRING([--with-gl-lib=DIR],[Directory where OpenGL libraries are installed]))
14 AC_ARG_WITH([--with-glu-lib],
15 AC_HELP_STRING([--with-glu-lib=DIR],[Directory where OpenGL GLU library is installed]))
16
17 AC_LANG_SAVE
18 AC_LANG_C
19
20 GL_SAVE_CPPFLAGS="$CPPFLAGS"
21 GL_SAVE_LIBS="$LIBS"
22
23 if test "x$no_x" != xyes ; then
24 GL_CFLAGS="$X_CFLAGS"
25 GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu $X_EXTRA_LIBS"
26 fi
27
28 if test "x$with_gl_inc" != "xnone" ; then
29 if test -d "$with_gl_inc" ; then
30 GL_CFLAGS="-I$with_gl_inc"
31 else
32 GL_CFLAGS="$with_gl_inc"
33 fi
34 else
35 GL_CFLAGS=
36 fi
37
38 CPPFLAGS="$GL_CFLAGS"
39 AC_CHECK_HEADER([GL/gl.h], [AC_DEFINE([HAVE_GL_GL_H], 1, [Define to 1 if you have the <GL/gl.h header])], [
40 AC_CHECK_HEADER([OpenGL/gl.h], [AC_DEFINE([HAVE_OPENGL_GL_H], 1, [Define to 1 if you have the <OpenGL/gl.h header])], [
41 AC_MSG_ERROR([GL/gl.h or OpenGL/gl.h is needed, please specify its location with --with-gl-inc. If this still fails, please contact [email protected], include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
42 ])
43 ])
44
45 dnl check whether the OpenGL framework is available
46 AC_MSG_CHECKING([for OpenGL framework (Darwin-specific)])
47 FRAMEWORK_OPENGL=""
48 PRELIBS="$LIBS"
49 LIBS="$LIBS -Xlinker -framework -Xlinker OpenGL"
50 # -Xlinker is used because libtool is busted prior to 1.6 wrt frameworks
51 AC_TRY_LINK([#include <OpenGL/gl.h>], [glBegin(GL_POINTS)],
52 [GL_DYLIB="/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
53 FRAMEWORK_OPENGL="-Xlinker -framework -Xlinker OpenGL -dylib_file $GL_DYLIB: $GL_DYLIB"
54 ac_cv_search_glBegin="$FRAMEWORK_OPENGL"
55 AC_MSG_RESULT(yes)],
56 [AC_MSG_RESULT(no)])
57 if test x"$FRAMEWORK_OPENGL" != "x"; then
58 with_gl_lib="$FRAMEWORK_OPENGL"
59 fi
60 AC_SUBST(FRAMEWORK_OPENGL)
61 LIBS="$PRELIBS"
62
63 AC_MSG_CHECKING([for GL library])
64 echo host=$host
65 case "x${host}" in
66 x*-mingw32) GL_GL_LIBS="-lopengl32"
67 GL_GLU_LIBS="-lglu32"
68 ;;
69 x*) GL_GL_LIBS="-lGL"
70 GL_GLU_LIBS="-lGLU"
71 ;;
72 esac
73
74 if test "x$with_gl_lib" != "x" ; then
75 if test -d "$with_gl_lib" ; then
76 LIBS="-L$with_gl_lib $GL_GL_LIBS"
77 else
78 LIBS="$with_gl_lib"
79 fi
80 else
81 LIBS="$GL_GL_LIBS"
82 fi
83 AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes],[
84 dnl This is done here so that we can check for the Win32 version of the
85 dnl GL library, which may not use cdecl calling convention.
86 AC_TRY_LINK([#include <GL/gl.h>],[glBegin(GL_POINTS)],[HAVE_GL=yes],[HAVE_GL=no])]
87 )
88
89 if test "x$HAVE_GL" = xno ; then
90 if test "x$GL_X_LIBS" != x ; then
91 LIBS="$GL_GL_LIBS $GL_X_LIBS"
92 AC_LINK_IFELSE([AC_LANG_CALL([],[glBegin])],[HAVE_GL=yes], [HAVE_GL=no])
93 fi
94 fi
95 if test "x$HAVE_GL" = xyes ; then
96 AC_MSG_RESULT([yes])
97 GL_LIBS=$LIBS
98 else
99 AC_MSG_RESULT([no])
100 AC_MSG_ERROR([GL library could not be found, please specify its location with --with-gl-lib. If this still fails, please contact [email protected], include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
101 fi
102
103 AC_CHECK_HEADER([GL/glu.h], [AC_DEFINE([HAVE_GL_GLU_H], 1, [Define to 1 if you have the <GL/glu.h header])], [
104 AC_CHECK_HEADER([OpenGL/glu.h], [AC_DEFINE([HAVE_OPENGL_GLU_H], 1, [Define to 1 if you have the <OpenGL/glu.h header])], [
105 AC_MSG_ERROR([GL/glu.h or OpenGL/glu.h is needed, please specify its location with --with-gl-inc. If this still fails, please contact [email protected], include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
106 ])
107 ])
108 AC_MSG_CHECKING([for GLU version >= 1.2])
109 AC_TRY_COMPILE([
110 #ifdef HAVE_GL_GLU_H
111 # include <GL/glu.h>
112 #endif
113 #ifdef HAVE_OPENGL_GLU_H
114 # include <OpenGL/glu.h>
115 #endif
116 ], [
117 #if !defined(GLU_VERSION_1_2)
118 #error GLU too old
119 #endif
120 ],
121 [AC_MSG_RESULT([yes])],
122 [AC_MSG_RESULT([no])
123 AC_MSG_ERROR([GLU >= 1.2 is needed to compile this library])
124 ])
125
126 if test "x$FRAMEWORK_OPENGL" = "x" ; then
127
128 AC_MSG_CHECKING([for GLU library])
129 if test "x$with_glu_lib" != "x" ; then
130 if test -d "$with_glu_lib" ; then
131 LIBS="$GL_LIBS -L$with_glu_lib $GL_GLU_LIBS"
132 else
133 LIBS="$GL_LIBS $with_glu_lib"
134 fi
135 else
136 LIBS="$GL_LIBS $GL_GLU_LIBS"
137 fi
138 AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [
139 dnl This is done here so that we can check for the Win32 version of the
140 dnl GL library, which may not use cdecl calling convention.
141 AC_TRY_LINK([#include <GL/glu.h>],[gluNewTess()],[HAVE_GLU=yes],[HAVE_GLU=no])]
142 )
143 if test "x$HAVE_GLU" = xno ; then
144 if test "x$GL_X_LIBS" != x ; then
145 LIBS="$GL_GLU_LIBS $GL_LIBS $GL_X_LIBS"
146 AC_LINK_IFELSE([AC_LANG_CALL([],[gluNewTess])],[HAVE_GLU=yes], [HAVE_GLU=no])
147 fi
148 fi
149 if test "x$HAVE_GLU" = xyes ; then
150 AC_MSG_RESULT([yes])
151 GL_LIBS="$LIBS"
152 else
153 AC_MSG_RESULT([no])
154 AC_MSG_ERROR([GLU library could not be found, please specify its location with --with-gl-lib. If this still fails, please contact [email protected], include the string FTGL somewhere in the subject line and provide a copy of the config.log file that was left behind.])
155 fi
156
157 fi
158
159 AC_SUBST(GL_CFLAGS)
160 AC_SUBST(GL_LIBS)
161
162 CPPFLAGS="$GL_SAVE_CPPFLAGS"
163 LIBS="$GL_SAVE_LIBS"
164 AC_LANG_RESTORE
165 GL_X_LIBS=""
166 ])