summaryrefslogtreecommitdiff
blob: b408dba941565489d945e0d73708c8edebe99938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
Fix broken multilib gl and glu detection
https://bugs.gentoo.org/543050
https://bugs.gentoo.org/578482

--- gtkglext-1.2.0/configure.in
+++ gtkglext-1.2.0/configure.in
@@ -139,6 +139,7 @@
 AC_ISC_POSIX
 #AM_DISABLE_STATIC
 AC_LIBTOOL_WIN32_DLL
+AC_PROG_CXX
 AC_PROG_LIBTOOL
 
 platform_win32=no
@@ -502,275 +503,59 @@
 # Checks for OpenGL
 ##################################################
 
-GL_CFLAGS=""
-GL_LDFLAGS=""
-GL_LIBS=""
-
-AC_ARG_WITH([gl-prefix],
-            [AC_HELP_STRING([--with-gl-prefix=DIR],
-                            [OpenGL (Mesa) is installed in DIR [default=auto]])], ,
-            [with_gl_prefix=auto])
-
-AC_ARG_WITH([gl-includedir],
-            [AC_HELP_STRING([--with-gl-includedir=DIR],
-                            [OpenGL (Mesa) headers are in DIR [default=auto]])], ,
-            [with_gl_includedir=auto])
-
-AC_ARG_WITH([gl-libdir],
-            [AC_HELP_STRING([--with-gl-libdir=DIR],
-                            [OpenGL (Mesa) libraries are in DIR [default=auto]])], ,
-            [with_gl_libdir=auto])
-
-if test "x$with_gl_includedir" != "xauto"; then
-  GL_CFLAGS="-I$with_gl_includedir"
-elif test "x$with_gl_prefix" != "xauto"; then
-  GL_CFLAGS="-I$with_gl_prefix/include"
-fi
-
-if test "x$with_gl_libdir" != "xauto"; then
-  GL_LDFLAGS="-L$with_gl_libdir"
-elif test "x$with_gl_prefix" != "xauto"; then
-  GL_LDFLAGS="-L$with_gl_prefix/lib"
-fi
-
-save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $GL_CFLAGS $WINDOWING_CFLAGS"
-save_LIBS="$LIBS"
-LIBS="$LIBS $GL_LDFLAGS $WINDOWING_LIBS $MATH_LIB"
-
 if test "x$gdktarget" = "xx11"; then
-  AC_CHECK_HEADERS([GL/glx.h], ,
-                   [AC_MSG_ERROR([Cannot find GLX header])])
+  with_gl=x
 fi
 
-AC_CHECK_HEADERS([GL/gl.h GL/glu.h], ,
-                 [AC_MSG_ERROR([Cannot find OpenGL headers])])
-
-if test "x$gdktarget" = "xx11"; then
-
-  # for X11
-
-  THREAD_LIB="-lpthread"
-  STDCXX_LIB="-lstdc++"
-
-  have_GL=no
-  GL_LIB_NAME=GL
-
-  # GLcore and GL (SGI)
-  AC_CHECK_LIB([GLcore], [glVertex3d],
-               [GL_LIBS="-lGLcore"])
-  if test "x$ac_cv_lib_GLcore_glVertex3d" = "xyes" ; then
-    # if GLcore found, then also check for GL
-    AC_CHECK_LIB([GL], [glXCreateContext],
-                 [GL_LIBS="-lGL $GL_LIBS"
-                  have_GL=yes])
-  fi
-
-  # GL
-  if test "x$have_GL" = "xno" ; then
-    # if no GLcore and GL, check for GL
-    AC_CHECK_LIB([GL], [glVertex3d],
-                 [GL_LIBS="-lGL"
-                  have_GL=yes])
-    if test "x$ac_cv_lib_GL_glVertex3d" = "xno" ; then
-      # GL may need to be linked with the thread library explicitly
-      AC_CHECK_LIB([GL], [glVertex3f],
-                   [GL_LIBS="-lGL $THREAD_LIB"
-                    have_GL=yes], ,
-                   [$THREAD_LIB])
-      if test "x$ac_cv_lib_GL_glVertex3f" = "xno" ; then
-        # GL may need to be linked with std C++ library explicitly
-        AC_CHECK_LIB([GL], [glVertex3i],
-                     [GL_LIBS="-lGL $STDCXX_LIB"
-                      have_GL=yes], ,
-                     [$STDCXX_LIB])
-        if test "x$ac_cv_lib_GL_glVertex3i" = "xno" ; then
-          # GL may need to be linked with std C++ and thread libraries explicitly
-          AC_CHECK_LIB([GL], [glVertex3s],
-                       [GL_LIBS="-lGL $STDCXX_LIB $THREAD_LIB"
-                        have_GL=yes], ,
-                       [$STDCXX_LIB $THREAD_LIB])
-        fi
-      fi
-    fi
-  fi
-
-  # MesaGL
-  if test "x$have_GL" = "xno" ; then
-    # if no GL, check for MesaGL
-    AC_CHECK_LIB([MesaGL], [glVertex3d],
-                 [GL_LIBS="-lMesaGL"
-                  have_GL=yes
-                  GL_LIB_NAME=MesaGL])
-  fi
-
-  if test "x$have_GL" = "xno" ; then
-    # no GL found
-    AC_MSG_ERROR([Cannot find GL library])
-  fi
-
-  # GLU
-
-  have_GLU=no
-  have_SGI_GLU=no
-
-  AC_CHECK_LIB([GLU], [gluSphere],
-               [GL_LIBS="-lGLU $GL_LIBS"
-                have_GLU=yes], ,
-               [$GL_LIBS])
-  if test "x$ac_cv_lib_GLU_gluSphere" = "xno" ; then
-    # GLU may need to be linked with the thread library explicitly
-    AC_CHECK_LIB([GLU], [gluCylinder],
-                 [GL_LIBS="-lGLU $GL_LIBS $THREAD_LIB"
-                  have_GLU=yes], ,
-                 [$GL_LIBS $THREAD_LIB])
-    if test "x$ac_cv_lib_GLU_gluCylinder" = "xno" ; then
-      # GLU may need to be linked with std C++ library explicitly
-      AC_CHECK_LIB([GLU], [gluDisk],
-                   [GL_LIBS="-lGLU $GL_LIBS $STDCXX_LIB"
-                    have_GLU=yes
-                    have_SGI_GLU=yes], ,
-                   [$GL_LIBS $STDCXX_LIB])
-      if test "x$ac_cv_lib_GLU_gluDisk" = "xno" ; then
-        # GLU may need to be linked with std C++ and thread libraries explicitly
-        AC_CHECK_LIB([GLU], [gluPartialDisk],
-                     [GL_LIBS="-lGLU $GL_LIBS $STDCXX_LIB $THREAD_LIB"
-                      have_GLU=yes
-                      have_SGI_GLU=yes], ,
-                     [$GL_LIBS $STDCXX_LIB $THREAD_LIB])
-      fi
-    fi
-  fi
-
-  if test "x$have_GLU" = "xno" ; then
-    # if no GLU, check for MesaGLU
-    AC_CHECK_LIB([MesaGLU], [gluSphere],
-                 [GL_LIBS="-lMesaGLU $GL_LIBS"
-                  have_GLU=yes], ,
-                 [$GL_LIBS])
-  fi
-
-  if test "x$have_GLU" = "xno" ; then
-    # no GLU found
-    AC_MSG_ERROR([Cannot find GLU library])
-  fi
-
-  # Checks for SGI's GLU library
-  if test "x$have_SGI_GLU" = "xno" ; then
-    # Try static linking
-    save_LDFLAGS="$LDFLAGS"
-    LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static"
-
-    AC_CHECK_LIB([GLU], [gluBeginCurve],
-                 [have_SGI_GLU=no], ,
-                 [$GL_LIBS])
-    if test "x$ac_cv_lib_GLU_gluBeginCurve" = "xno" ; then
-      AC_CHECK_LIB([GLU], [gluBeginPolygon],
-                   [GL_LIBS="$GL_LIBS $STDCXX_LIB"
-                    have_SGI_GLU=yes], ,
-                   [$GL_LIBS $STDCXX_LIB])
-    fi
-
-    LDFLAGS="$save_LDFLAGS"
-  fi
-
-  AC_MSG_CHECKING([whether libGLU needs to be linked with the std C++ library])
-  AC_MSG_RESULT([$have_SGI_GLU])
-
-  # Checks for some types in gdk/GL/glxext.h
-
-  # GLXFBConfigSGIX
-  GDKGLEXT_NEED_GLXFBCONFIGSGIX_TYPEDEF=no
-  AC_CHECK_TYPES([GLXFBConfigSGIX], , ,
-                 [#include <GL/glx.h>])
-  if test "x$ac_cv_type_GLXFBConfigSGIX" = "xno" ; then
-    GDKGLEXT_NEED_GLXFBCONFIGSGIX_TYPEDEF=yes
-  fi
-
-  # GLXFBConfigIDSGIX
-  GDKGLEXT_NEED_GLXFBCONFIGIDSGIX_TYPEDEF=no
-  AC_CHECK_TYPES([GLXFBConfigIDSGIX], , ,
-                 [#include <GL/glx.h>])
-  if test "x$ac_cv_type_GLXFBConfigIDSGIX" = "xno" ; then
-    GDKGLEXT_NEED_GLXFBCONFIGIDSGIX_TYPEDEF=yes
-  fi
-
-  # GLXPbufferSGIX
-  GDKGLEXT_NEED_GLXPBUFFERSGIX_TYPEDEF=no
-  AC_CHECK_TYPES([GLXPbufferSGIX], , ,
-                 [#include <GL/glx.h>])
-  if test "x$ac_cv_type_GLXPbufferSGIX" = "xno" ; then
-    GDKGLEXT_NEED_GLXPBUFFERSGIX_TYPEDEF=yes
-  fi
-
-  # GLXVideoSourceSGIX
-  GDKGLEXT_NEED_GLXVIDEOSOURCESGIX_TYPEDEF=no
-  AC_CHECK_TYPES([GLXVideoSourceSGIX], , ,
-                 [#include <GL/glx.h>])
-  if test "x$ac_cv_type_GLXVideoSourceSGIX" = "xno" ; then
-    GDKGLEXT_NEED_GLXVIDEOSOURCESGIX_TYPEDEF=yes
-  fi
-
-  # __GLXextFuncPtr
-  GDKGLEXT_NEED_GLXEXTFUNCPTR_TYPEDEF=no
-  AC_CHECK_TYPES([__GLXextFuncPtr], , ,
-                 [#include <GL/glx.h>])
-  if test "x$ac_cv_type___GLXextFuncPtr" = "xno" ; then
-    GDKGLEXT_NEED_GLXEXTFUNCPTR_TYPEDEF=yes
-  fi
-
-else
-
-  # for Win32
-
-  AC_MSG_CHECKING([for glNewList in -lopengl32])
-  have_opengl32=no
-  LIBS="-lopengl32 $LIBS"
-  AC_TRY_LINK([#include <windows.h>
-               #include <GL/gl.h>], 
-              [glVertex3d(0.0, 0.0, 0.0);], 
-              [GL_LIBS="-lopengl32"
-               have_opengl32=yes])
-  AC_MSG_RESULT([$have_opengl32])
-  if test "x$have_opengl32" = "xno" ; then
-    AC_MSG_ERROR([Cannot find GL library])
-  fi
-
-  AC_MSG_CHECKING([for gluNewQuadric in -lglu32])
-  have_glu32=no
-  LIBS="-lglu32 $LIBS"
-  AC_TRY_LINK([#include <windows.h>
-               #include <GL/gl.h>
-               #include <GL/glu.h>], 
-              [gluNewQuadric();], 
-              [GL_LIBS="-lglu32 $GL_LIBS"
-               have_glu32=yes])
-  AC_MSG_RESULT([$have_glu32])
-  if test "x$have_glu32" = "xno" ; then
-    AC_MSG_ERROR([Cannot find GLU library])
-  fi
-
-dnl   AC_CHECK_LIB(opengl32, glNewList,
-dnl                GL_LIBS="-lopengl32",
-dnl                AC_MSG_ERROR(Cannot find GL library))
-
-dnl   AC_CHECK_LIB(glu32, gluNewQuadric,
-dnl                GL_LIBS="-lglu32 $GL_LIBS",
-dnl                AC_MSG_ERROR(Cannot find GLU library),
-dnl                $GL_LIBS)
-
+AX_CHECK_GL
+AS_IF([test X$no_gl = Xyes],
+      [AC_MSG_FAILURE([OpenGL is required.])])
+AX_CHECK_GLU
+# FIXME: AX_CHECK_GLU's behavior diverges from common autoconf conventions
+AM_CONDITIONAL([GLU],[test "$no_glu" != yes])
+
+# Checks for some types in gdk/GL/glxext.h
+
+# GLXFBConfigSGIX
+GDKGLEXT_NEED_GLXFBCONFIGSGIX_TYPEDEF=no
+AC_CHECK_TYPES([GLXFBConfigSGIX], , ,
+               [#include <GL/glx.h>])
+if test "x$ac_cv_type_GLXFBConfigSGIX" = "xno" ; then
+  GDKGLEXT_NEED_GLXFBCONFIGSGIX_TYPEDEF=yes
+fi
+
+# GLXFBConfigIDSGIX
+GDKGLEXT_NEED_GLXFBCONFIGIDSGIX_TYPEDEF=no
+AC_CHECK_TYPES([GLXFBConfigIDSGIX], , ,
+               [#include <GL/glx.h>])
+if test "x$ac_cv_type_GLXFBConfigIDSGIX" = "xno" ; then
+  GDKGLEXT_NEED_GLXFBCONFIGIDSGIX_TYPEDEF=yes
+fi
+
+# GLXPbufferSGIX
+GDKGLEXT_NEED_GLXPBUFFERSGIX_TYPEDEF=no
+AC_CHECK_TYPES([GLXPbufferSGIX], , ,
+               [#include <GL/glx.h>])
+if test "x$ac_cv_type_GLXPbufferSGIX" = "xno" ; then
+  GDKGLEXT_NEED_GLXPBUFFERSGIX_TYPEDEF=yes
+fi
+
+# GLXVideoSourceSGIX
+GDKGLEXT_NEED_GLXVIDEOSOURCESGIX_TYPEDEF=no
+AC_CHECK_TYPES([GLXVideoSourceSGIX], , ,
+               [#include <GL/glx.h>])
+if test "x$ac_cv_type_GLXVideoSourceSGIX" = "xno" ; then
+  GDKGLEXT_NEED_GLXVIDEOSOURCESGIX_TYPEDEF=yes
+fi
+
+# __GLXextFuncPtr
+GDKGLEXT_NEED_GLXEXTFUNCPTR_TYPEDEF=no
+AC_CHECK_TYPES([__GLXextFuncPtr], , ,
+               [#include <GL/glx.h>])
+if test "x$ac_cv_type___GLXextFuncPtr" = "xno" ; then
+  GDKGLEXT_NEED_GLXEXTFUNCPTR_TYPEDEF=yes
 fi
 
-dnl # if using mesa, check for xmesa.h
-dnl if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
-dnl   AC_CHECK_HEADERS([GL/xmesa.h])
-dnl   AM_CONDITIONAL(ENABLE_XMESA_FX, \
-dnl                  test "x$ac_cv_header_GL_xmesa_h" = "xyes")
-dnl else
-dnl   # force a failed check
-dnl   AM_CONDITIONAL(ENABLE_XMESA_FX, test "no" = "yes")
-dnl fi
-
 # Checks for typedefs in gdk/GL/glext.h
 
 # GLhalfNV
@@ -781,22 +566,13 @@
   GDKGLEXT_NEED_GLHALFNV_TYPEDEF=yes
 fi
 
-GL_LIBS="$GL_LDFLAGS $GL_LIBS"
-
-AC_SUBST([GL_CFLAGS])
-AC_SUBST([GL_LIBS])
-
-CPPFLAGS="$save_CPPFLAGS"
-LIBS="$save_LIBS"
-
-
 ##################################################
 # CFLAGS and LIBS
 ##################################################
 
 GDKGLEXT_PACKAGES="gdk_pkg pango_pkg pangox_pkg gmodule_pkg"
 GDKGLEXT_EXTRA_CFLAGS="$GL_CFLAGS $GDKGLEXT_WIN_CFLAGS"
-GDKGLEXT_EXTRA_LIBS="$GL_LIBS $GDKGLEXT_WIN_LIBS"
+GDKGLEXT_EXTRA_LIBS="$GL_LIBS $GLU_LIBS $GDKGLEXT_WIN_LIBS"
 GDKGLEXT_DEP_CFLAGS="$GDKGLEXT_EXTRA_CFLAGS `$PKG_CONFIG --cflags $GDKGLEXT_PACKAGES`"
 GDKGLEXT_DEP_LIBS="$GDKGLEXT_EXTRA_LIBS `$PKG_CONFIG --libs $GDKGLEXT_PACKAGES` $MATH_LIB"
 AC_SUBST([GDKGLEXT_PACKAGES])