~ubuntu-branches/ubuntu/trusty/tiff/trusty

« back to all changes in this revision

Viewing changes to m4/acinclude.m4

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2012-06-24 13:45:42 UTC
  • mfrom: (15.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120624134542-u7dltcqwnb6orprf
Tags: 4.0.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
170
170
dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html
171
171
dnl ---------------------------------------------------------------------------
172
172
 
173
 
dnl @synopsis AX_CHECK_GL
174
 
dnl
175
 
dnl Check for an OpenGL implementation. If GL is found, the required
176
 
dnl compiler and linker flags are included in the output variables
177
 
dnl "GL_CFLAGS" and "GL_LIBS", respectively. This macro adds the
178
 
dnl configure option "--with-apple-opengl-framework", which users can
179
 
dnl use to indicate that Apple's OpenGL framework should be used on Mac
180
 
dnl OS X. If Apple's OpenGL framework is used, the symbol
181
 
dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GL implementation
182
 
dnl is found, "no_gl" is set to "yes".
183
 
dnl
184
 
dnl @category InstalledPackages
185
 
dnl @author Braden McDaniel <braden@endoframe.com>
186
 
dnl @version 2004-11-15
187
 
dnl @license AllPermissive
 
173
dnl SYNOPSIS
 
174
dnl
 
175
dnl   AX_CHECK_GL
 
176
dnl
 
177
dnl DESCRIPTION
 
178
dnl
 
179
dnl   Check for an OpenGL implementation. If GL is found, the required
 
180
dnl   compiler and linker flags are included in the output variables
 
181
dnl   "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
 
182
dnl   is found, "no_gl" is set to "yes".
 
183
dnl
 
184
dnl   If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
 
185
dnl   header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
 
186
dnl   preprocessor definitions may not be mutually exclusive.
 
187
dnl
 
188
dnl LICENSE
 
189
dnl
 
190
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
 
191
dnl
 
192
dnl   This program is free software; you can redistribute it and/or modify it
 
193
dnl   under the terms of the GNU General Public License as published by the
 
194
dnl   Free Software Foundation; either version 2 of the License, or (at your
 
195
dnl   option) any later version.
 
196
dnl
 
197
dnl   This program is distributed in the hope that it will be useful, but
 
198
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
 
199
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
200
dnl   Public License for more details.
 
201
dnl
 
202
dnl   You should have received a copy of the GNU General Public License along
 
203
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
 
204
dnl
 
205
dnl   As a special exception, the respective Autoconf Macro's copyright owner
 
206
dnl   gives unlimited permission to copy, distribute and modify the configure
 
207
dnl   scripts that are the output of Autoconf when processing the Macro. You
 
208
dnl   need not follow the terms of the GNU General Public License when using
 
209
dnl   or distributing such scripts, even though portions of the text of the
 
210
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
 
211
dnl   all other use of the material that constitutes the Autoconf Macro.
 
212
dnl
 
213
dnl   This special exception to the GPL applies to versions of the Autoconf
 
214
dnl   Macro released by the Autoconf Archive. When you make and distribute a
 
215
dnl   modified version of the Autoconf Macro, you may extend this special
 
216
dnl   exception to the GPL to apply to your modified version as well.
188
217
 
189
218
AC_DEFUN([AX_CHECK_GL],
190
 
[AC_REQUIRE([AC_PATH_X])dnl
191
 
AC_REQUIRE([ACX_PTHREAD])dnl
192
 
 
193
 
#
194
 
# There isn't a reliable way to know we should use the Apple OpenGL framework
195
 
# without a configure option.  A Mac OS X user may have installed an
196
 
# alternative GL implementation (e.g., Mesa), which may or may not depend on X.
197
 
#
198
 
AC_ARG_WITH([apple-opengl-framework],
199
 
            [AC_HELP_STRING([--with-apple-opengl-framework],
200
 
                            [use Apple OpenGL framework (Mac OS X only)])])
201
 
if test "X$with_apple_opengl_framework" = "Xyes"; then
202
 
  AC_DEFINE([HAVE_APPLE_OPENGL_FRAMEWORK], [1],
203
 
            [Use the Apple OpenGL framework.])
204
 
  GL_LIBS="-framework OpenGL"
205
 
else
206
 
  AC_LANG_PUSH(C)
207
 
 
208
 
  AX_LANG_COMPILER_MS
209
 
  if test X$ax_compiler_ms = Xno; then
210
 
    GL_CFLAGS="${PTHREAD_CFLAGS}"
211
 
    GL_LIBS="${PTHREAD_LIBS} -lm"
212
 
  fi
213
 
 
214
 
  #
215
 
  # Use x_includes and x_libraries if they have been set (presumably by
216
 
  # AC_PATH_X).
217
 
  #
218
 
  if test "X$no_x" != "Xyes"; then
219
 
    if test -n "$x_includes"; then
220
 
      GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"
221
 
    fi
222
 
    if test -n "$x_libraries"; then
223
 
      GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"
224
 
    fi
225
 
  fi
226
 
 
227
 
  AC_CHECK_HEADERS([windows.h])
228
 
 
229
 
  AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
230
 
  [ax_cv_check_gl_libgl="no"
231
 
  ax_save_CPPFLAGS="${CPPFLAGS}"
232
 
  CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
233
 
  ax_save_LIBS="${LIBS}"
234
 
  LIBS=""
235
 
  ax_check_libs="-lopengl32 -lGL"
236
 
  for ax_lib in ${ax_check_libs}; do
237
 
    if test X$ax_compiler_ms = Xyes; then
238
 
      ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
239
 
    else
240
 
      ax_try_lib="${ax_lib}"
241
 
    fi
242
 
    LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
243
 
    AC_LINK_IFELSE(
244
 
    [AC_LANG_PROGRAM([[
245
 
# if HAVE_WINDOWS_H && defined(_WIN32)
 
219
[AC_REQUIRE([AC_CANONICAL_HOST])
 
220
AC_REQUIRE([AC_PATH_X])dnl
 
221
AC_REQUIRE([AX_PTHREAD])dnl
 
222
 
 
223
AC_LANG_PUSH([C])
 
224
AX_LANG_COMPILER_MS
 
225
AS_IF([test X$ax_compiler_ms = Xno],
 
226
      [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
 
227
 
 
228
dnl
 
229
dnl Use x_includes and x_libraries if they have been set (presumably by
 
230
dnl AC_PATH_X).
 
231
dnl
 
232
AS_IF([test "X$no_x" != "Xyes"],
 
233
      [AS_IF([test -n "$x_includes"],
 
234
             [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
 
235
       AS_IF([test -n "$x_libraries"],
 
236
             [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
 
237
 
 
238
ax_save_CPPFLAGS="${CPPFLAGS}"
 
239
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
 
240
AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
 
241
CPPFLAGS="${ax_save_CPPFLAGS}"
 
242
 
 
243
AC_CHECK_HEADERS([windows.h])
 
244
 
 
245
m4_define([AX_CHECK_GL_PROGRAM],
 
246
          [AC_LANG_PROGRAM([[
 
247
# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
246
248
#   include <windows.h>
247
249
# endif
248
 
# include <GL/gl.h>]],
249
 
                     [[glBegin(0)]])],
250
 
    [ax_cv_check_gl_libgl="${ax_try_lib}"; break])
251
 
  done
252
 
  LIBS=${ax_save_LIBS}
253
 
  CPPFLAGS=${ax_save_CPPFLAGS}])
254
 
 
255
 
  if test "X${ax_cv_check_gl_libgl}" = "Xno"; then
256
 
    no_gl="yes"
257
 
    GL_CFLAGS=""
258
 
    GL_LIBS=""
259
 
  else
260
 
    GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"
261
 
  fi
262
 
  AC_LANG_POP(C)
263
 
fi
 
250
# ifdef HAVE_GL_GL_H
 
251
#   include <GL/gl.h>
 
252
# elif defined(HAVE_OPENGL_GL_H)
 
253
#   include <OpenGL/gl.h>
 
254
# else
 
255
#   error no gl.h
 
256
# endif]],
 
257
                           [[glBegin(0)]])])
 
258
 
 
259
AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
 
260
[ax_cv_check_gl_libgl="no"
 
261
case $host_cpu in
 
262
  x86_64) ax_check_gl_libdir=lib64 ;;
 
263
  *)      ax_check_gl_libdir=lib ;;
 
264
esac
 
265
ax_save_CPPFLAGS="${CPPFLAGS}"
 
266
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
 
267
ax_save_LIBS="${LIBS}"
 
268
LIBS=""
 
269
ax_check_libs="-lopengl32 -lGL"
 
270
for ax_lib in ${ax_check_libs}; do
 
271
  AS_IF([test X$ax_compiler_ms = Xyes],
 
272
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
 
273
        [ax_try_lib="${ax_lib}"])
 
274
  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
 
275
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
 
276
               [ax_cv_check_gl_libgl="${ax_try_lib}"; break],
 
277
               [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}"
 
278
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
 
279
               [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break],
 
280
               [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' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
 
281
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
 
282
               [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
 
283
done
 
284
 
 
285
AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
 
286
[LIBS='-framework OpenGL'
 
287
AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
 
288
               [ax_cv_check_gl_libgl="$LIBS"])])
 
289
 
 
290
LIBS=${ax_save_LIBS}
 
291
CPPFLAGS=${ax_save_CPPFLAGS}])
 
292
 
 
293
AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
 
294
      [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
 
295
      [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
 
296
AC_LANG_POP([C])
264
297
 
265
298
AC_SUBST([GL_CFLAGS])
266
299
AC_SUBST([GL_LIBS])
271
304
dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html
272
305
dnl ---------------------------------------------------------------------------
273
306
 
274
 
dnl @synopsis AX_CHECK_GLU
275
 
dnl
276
 
dnl Check for GLU. If GLU is found, the required preprocessor and
277
 
dnl linker flags are included in the output variables "GLU_CFLAGS" and
278
 
dnl "GLU_LIBS", respectively. This macro adds the configure option
279
 
dnl "--with-apple-opengl-framework", which users can use to indicate
280
 
dnl that Apple's OpenGL framework should be used on Mac OS X. If
281
 
dnl Apple's OpenGL framework is used, the symbol
282
 
dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If no GLU implementation
283
 
dnl is found, "no_glu" is set to "yes".
284
 
dnl
285
 
dnl @category InstalledPackages
286
 
dnl @author Braden McDaniel <braden@endoframe.com>
287
 
dnl @version 2004-11-15
288
 
dnl @license AllPermissive
 
307
dnl SYNOPSIS
 
308
dnl
 
309
dnl   AX_CHECK_GLU
 
310
dnl
 
311
dnl DESCRIPTION
 
312
dnl
 
313
dnl   Check for GLU. If GLU is found, the required preprocessor and linker
 
314
dnl   flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
 
315
dnl   respectively. If no GLU implementation is found, "no_glu" is set to
 
316
dnl   "yes".
 
317
dnl
 
318
dnl   If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
 
319
dnl   header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
 
320
dnl   preprocessor definitions may not be mutually exclusive.
 
321
dnl
 
322
dnl   Some implementations (in particular, some versions of Mac OS X) are
 
323
dnl   known to treat the GLU tesselator callback function type as "GLvoid
 
324
dnl   (*)(...)" rather than the standard "GLvoid (*)()". If the former
 
325
dnl   condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
 
326
dnl
 
327
dnl LICENSE
 
328
dnl
 
329
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
 
330
dnl
 
331
dnl   This program is free software; you can redistribute it and/or modify it
 
332
dnl   under the terms of the GNU General Public License as published by the
 
333
dnl   Free Software Foundation; either version 2 of the License, or (at your
 
334
dnl   option) any later version.
 
335
dnl
 
336
dnl   This program is distributed in the hope that it will be useful, but
 
337
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
 
338
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
339
dnl   Public License for more details.
 
340
dnl
 
341
dnl   You should have received a copy of the GNU General Public License along
 
342
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
 
343
dnl
 
344
dnl   As a special exception, the respective Autoconf Macro's copyright owner
 
345
dnl   gives unlimited permission to copy, distribute and modify the configure
 
346
dnl   scripts that are the output of Autoconf when processing the Macro. You
 
347
dnl   need not follow the terms of the GNU General Public License when using
 
348
dnl   or distributing such scripts, even though portions of the text of the
 
349
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
 
350
dnl   all other use of the material that constitutes the Autoconf Macro.
 
351
dnl
 
352
dnl   This special exception to the GPL applies to versions of the Autoconf
 
353
dnl   Macro released by the Autoconf Archive. When you make and distribute a
 
354
dnl   modified version of the Autoconf Macro, you may extend this special
 
355
dnl   exception to the GPL to apply to your modified version as well.
289
356
 
290
357
AC_DEFUN([AX_CHECK_GLU],
291
358
[AC_REQUIRE([AX_CHECK_GL])dnl
292
359
AC_REQUIRE([AC_PROG_CXX])dnl
293
360
GLU_CFLAGS="${GL_CFLAGS}"
294
 
if test "X${with_apple_opengl_framework}" != "Xyes"; then
295
 
  AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
296
 
  [ax_cv_check_glu_libglu="no"
297
 
  ax_save_CPPFLAGS="${CPPFLAGS}"
298
 
  CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
299
 
  ax_save_LIBS="${LIBS}"
300
 
  LIBS=""
301
 
  ax_check_libs="-lglu32 -lGLU"
302
 
  for ax_lib in ${ax_check_libs}; do
303
 
    if test X$ax_compiler_ms = Xyes; then
304
 
      ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
305
 
    else
306
 
      ax_try_lib="${ax_lib}"
307
 
    fi
308
 
    LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
309
 
    #
310
 
    # libGLU typically links with libstdc++ on POSIX platforms. However,
311
 
    # setting the language to C++ means that test program source is named
312
 
    # "conftest.cc"; and Microsoft cl doesn't know what to do with such a
313
 
    # file.
314
 
    #
315
 
    AC_LANG_PUSH([C++])
316
 
    if test X$ax_compiler_ms = Xyes; then
317
 
      AC_LANG_PUSH([C])
318
 
    fi
319
 
    AC_LINK_IFELSE(
320
 
    [AC_LANG_PROGRAM([[
321
 
# if HAVE_WINDOWS_H && defined(_WIN32)
 
361
 
 
362
ax_save_CPPFLAGS="${CPPFLAGS}"
 
363
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
 
364
AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
 
365
CPPFLAGS="${ax_save_CPPFLAGS}"
 
366
 
 
367
m4_define([AX_CHECK_GLU_PROGRAM],
 
368
          [AC_LANG_PROGRAM([[
 
369
# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
322
370
#   include <windows.h>
323
371
# endif
324
 
# include <GL/glu.h>]],
325
 
                     [[gluBeginCurve(0)]])],
326
 
    [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
327
 
    if test X$ax_compiler_ms = Xyes; then
328
 
      AC_LANG_POP([C])
329
 
    fi
330
 
    AC_LANG_POP([C++])
331
 
  done
332
 
  LIBS=${ax_save_LIBS}
333
 
  CPPFLAGS=${ax_save_CPPFLAGS}])
334
 
  if test "X${ax_cv_check_glu_libglu}" = "Xno"; then
335
 
    no_glu="yes"
336
 
    GLU_CFLAGS=""
337
 
    GLU_LIBS=""
338
 
  else
339
 
    GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"
340
 
  fi
341
 
fi
 
372
# ifdef HAVE_GL_GLU_H
 
373
#   include <GL/glu.h>
 
374
# elif defined(HAVE_OPENGL_GLU_H)
 
375
#   include <OpenGL/glu.h>
 
376
# else
 
377
#   error no glu.h
 
378
# endif]],
 
379
                           [[gluBeginCurve(0)]])])
 
380
 
 
381
AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
 
382
[ax_cv_check_glu_libglu="no"
 
383
ax_save_CPPFLAGS="${CPPFLAGS}"
 
384
CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
 
385
ax_save_LIBS="${LIBS}"
 
386
 
 
387
dnl
 
388
dnl First, check for the possibility that everything we need is already in
 
389
dnl GL_LIBS.
 
390
dnl
 
391
LIBS="${GL_LIBS} ${ax_save_LIBS}"
 
392
dnl
 
393
dnl libGLU typically links with libstdc++ on POSIX platforms.
 
394
dnl However, setting the language to C++ means that test program
 
395
dnl source is named "conftest.cc"; and Microsoft cl doesn't know what
 
396
dnl to do with such a file.
 
397
dnl
 
398
AC_LANG_PUSH([C++])
 
399
AS_IF([test X$ax_compiler_ms = Xyes],
 
400
      [AC_LANG_PUSH([C])])
 
401
AC_LINK_IFELSE(
 
402
[AX_CHECK_GLU_PROGRAM],
 
403
[ax_cv_check_glu_libglu=yes],
 
404
[LIBS=""
 
405
ax_check_libs="-lglu32 -lGLU"
 
406
for ax_lib in ${ax_check_libs}; do
 
407
  AS_IF([test X$ax_compiler_ms = Xyes],
 
408
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
 
409
        [ax_try_lib="${ax_lib}"])
 
410
  LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
 
411
  AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
 
412
                 [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
 
413
done
 
414
])
 
415
AS_IF([test X$ax_compiler_ms = Xyes],
 
416
      [AC_LANG_POP([C])])
 
417
AC_LANG_POP([C++])
 
418
 
 
419
LIBS=${ax_save_LIBS}
 
420
CPPFLAGS=${ax_save_CPPFLAGS}])
 
421
AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
 
422
      [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
 
423
      [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
 
424
             [GLU_LIBS="$GL_LIBS"],
 
425
             [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
342
426
AC_SUBST([GLU_CFLAGS])
343
427
AC_SUBST([GLU_LIBS])
 
428
 
 
429
dnl
 
430
dnl Some versions of Mac OS X include a broken interpretation of the GLU
 
431
dnl tesselation callback function signature.
 
432
dnl
 
433
AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
 
434
[AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
 
435
                [ax_cv_varargs_glu_tesscb],
 
436
[ax_cv_varargs_glu_tesscb=no
 
437
ax_save_CFLAGS="$CFLAGS"
 
438
CFLAGS="$GL_CFLAGS $CFLAGS"
 
439
AC_COMPILE_IFELSE(
 
440
[AC_LANG_PROGRAM([[
 
441
# ifdef HAVE_GL_GLU_H
 
442
#   include <GL/glu.h>
 
443
# else
 
444
#   include <OpenGL/glu.h>
 
445
# endif]],
 
446
                 [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
 
447
[ax_cv_varargs_glu_tesscb=yes])
 
448
CFLAGS="$ax_save_CFLAGS"])
 
449
AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
 
450
      [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
 
451
                 [Use nonstandard varargs form for the GLU tesselator callback])])])
344
452
])
345
453
 
346
454
dnl ---------------------------------------------------------------------------
348
456
dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html
349
457
dnl ---------------------------------------------------------------------------
350
458
 
351
 
dnl @synopsis AX_CHECK_GLUT
352
 
dnl
353
 
dnl Check for GLUT. If GLUT is found, the required compiler and linker
354
 
dnl flags are included in the output variables "GLUT_CFLAGS" and
355
 
dnl "GLUT_LIBS", respectively. This macro adds the configure option
356
 
dnl "--with-apple-opengl-framework", which users can use to indicate
357
 
dnl that Apple's OpenGL framework should be used on Mac OS X. If
358
 
dnl Apple's OpenGL framework is used, the symbol
359
 
dnl "HAVE_APPLE_OPENGL_FRAMEWORK" is defined. If GLUT is not found,
360
 
dnl "no_glut" is set to "yes".
361
 
dnl
362
 
dnl @category InstalledPackages
363
 
dnl @author Braden McDaniel <braden@endoframe.com>
364
 
dnl @version 2004-11-15
365
 
dnl @license AllPermissive
 
459
dnl
 
460
dnl SYNOPSIS
 
461
dnl
 
462
dnl   AX_CHECK_GLUT
 
463
dnl
 
464
dnl DESCRIPTION
 
465
dnl
 
466
dnl   Check for GLUT. If GLUT is found, the required compiler and linker flags
 
467
dnl   are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
 
468
dnl   respectively. If GLUT is not found, "no_glut" is set to "yes".
 
469
dnl
 
470
dnl   If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
 
471
dnl   header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
 
472
dnl   preprocessor definitions may not be mutually exclusive.
 
473
dnl
 
474
dnl LICENSE
 
475
dnl
 
476
dnl   Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
 
477
dnl
 
478
dnl   This program is free software; you can redistribute it and/or modify it
 
479
dnl   under the terms of the GNU General Public License as published by the
 
480
dnl   Free Software Foundation; either version 2 of the License, or (at your
 
481
dnl   option) any later version.
 
482
dnl
 
483
dnl   This program is distributed in the hope that it will be useful, but
 
484
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
 
485
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
486
dnl   Public License for more details.
 
487
dnl
 
488
dnl   You should have received a copy of the GNU General Public License along
 
489
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
 
490
dnl
 
491
dnl   As a special exception, the respective Autoconf Macro's copyright owner
 
492
dnl   gives unlimited permission to copy, distribute and modify the configure
 
493
dnl   scripts that are the output of Autoconf when processing the Macro. You
 
494
dnl   need not follow the terms of the GNU General Public License when using
 
495
dnl   or distributing such scripts, even though portions of the text of the
 
496
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
 
497
dnl   all other use of the material that constitutes the Autoconf Macro.
 
498
dnl
 
499
dnl   This special exception to the GPL applies to versions of the Autoconf
 
500
dnl   Macro released by the Autoconf Archive. When you make and distribute a
 
501
dnl   modified version of the Autoconf Macro, you may extend this special
 
502
dnl   exception to the GPL to apply to your modified version as well.
366
503
 
367
504
AC_DEFUN([AX_CHECK_GLUT],
368
505
[AC_REQUIRE([AX_CHECK_GLU])dnl
369
506
AC_REQUIRE([AC_PATH_XTRA])dnl
370
507
 
371
 
if test "X$with_apple_opengl_framework" = "Xyes"; then
372
 
  GLUT_CFLAGS="${GLU_CFLAGS}"
373
 
  GLUT_LIBS="-framework GLUT -lobjc ${GL_LIBS}"
374
 
else
375
 
  GLUT_CFLAGS=${GLU_CFLAGS}
376
 
  GLUT_LIBS=${GLU_LIBS}
377
 
 
378
 
  #
379
 
  # If X is present, assume GLUT depends on it.
380
 
  #
381
 
  if test "X${no_x}" != "Xyes"; then
382
 
    GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"
383
 
  fi
384
 
 
385
 
  AC_LANG_PUSH(C)
386
 
 
387
 
  ax_save_CPPFLAGS="${CPPFLAGS}"
388
 
  CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
389
 
 
390
 
  AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
391
 
  [ax_cv_check_glut_libglut="no"
392
 
  ax_save_LIBS="${LIBS}"
393
 
  LIBS=""
394
 
  ax_check_libs="-lglut32 -lglut"
395
 
  for ax_lib in ${ax_check_libs}; do
396
 
    if test X$ax_compiler_ms = Xyes; then
397
 
      ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
398
 
    else
399
 
      ax_try_lib="${ax_lib}"
400
 
    fi
401
 
    LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
402
 
    AC_LINK_IFELSE(
403
 
    [AC_LANG_PROGRAM([[
 
508
ax_save_CPPFLAGS="${CPPFLAGS}"
 
509
CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
 
510
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
 
511
CPPFLAGS="${ax_save_CPPFLAGS}"
 
512
 
 
513
GLUT_CFLAGS=${GLU_CFLAGS}
 
514
GLUT_LIBS=${GLU_LIBS}
 
515
 
 
516
m4_define([AX_CHECK_GLUT_PROGRAM],
 
517
          [AC_LANG_PROGRAM([[
404
518
# if HAVE_WINDOWS_H && defined(_WIN32)
405
519
#   include <windows.h>
406
520
# endif
407
 
# include <GL/glut.h>]],
408
 
                     [[glutMainLoop()]])],
409
 
    [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
410
 
 
411
 
  done
412
 
  LIBS=${ax_save_LIBS}
413
 
  ])
414
 
  CPPFLAGS="${ax_save_CPPFLAGS}"
415
 
  AC_LANG_POP(C)
416
 
 
417
 
  if test "X${ax_cv_check_glut_libglut}" = "Xno"; then
418
 
    no_glut="yes"
419
 
    GLUT_CFLAGS=""
420
 
    GLUT_LIBS=""
421
 
  else
422
 
    GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"
423
 
  fi
424
 
fi
 
521
# ifdef HAVE_GL_GLUT_H
 
522
#   include <GL/glut.h>
 
523
# elif defined(HAVE_GLUT_GLUT_H)
 
524
#   include <GLUT/glut.h>
 
525
# else
 
526
#   error no glut.h
 
527
# endif]],
 
528
                           [[glutMainLoop()]])])
 
529
 
 
530
dnl
 
531
dnl If X is present, assume GLUT depends on it.
 
532
dnl
 
533
AS_IF([test X$no_x != Xyes],
 
534
      [GLUT_LIBS="${X_PRE_LIBS} -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
 
535
 
 
536
AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
 
537
[ax_cv_check_glut_libglut="no"
 
538
AC_LANG_PUSH(C)
 
539
ax_save_CPPFLAGS="${CPPFLAGS}"
 
540
CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
 
541
ax_save_LIBS="${LIBS}"
 
542
LIBS=""
 
543
ax_check_libs="-lglut32 -lglut"
 
544
for ax_lib in ${ax_check_libs}; do
 
545
  AS_IF([test X$ax_compiler_ms = Xyes],
 
546
        [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
 
547
        [ax_try_lib="${ax_lib}"])
 
548
  LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
 
549
  AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
 
550
                 [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
 
551
done
 
552
 
 
553
AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
 
554
[LIBS='-framework GLUT'
 
555
AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
 
556
               [ax_cv_check_glut_libglut="$LIBS"])])
 
557
 
 
558
CPPFLAGS="${ax_save_CPPFLAGS}"
 
559
LIBS="${ax_save_LIBS}"
 
560
AC_LANG_POP(C)])
 
561
 
 
562
AS_IF([test "X$ax_cv_check_glut_libglut" = Xno],
 
563
      [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""],
 
564
      [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"])
425
565
 
426
566
AC_SUBST([GLUT_CFLAGS])
427
567
AC_SUBST([GLUT_LIBS])
429
569
 
430
570
dnl ---------------------------------------------------------------------------
431
571
dnl Available from the GNU Autoconf Macro Archive at:
432
 
dnl http://www.gnu.org/software/ac-archive/acx_pthread.html
 
572
dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html
433
573
dnl ---------------------------------------------------------------------------
434
574
 
435
 
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
436
 
dnl
437
 
dnl This macro figures out how to build C programs using POSIX threads.
438
 
dnl It sets the PTHREAD_LIBS output variable to the threads library and
439
 
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
440
 
dnl C compiler flags that are needed. (The user can also force certain
441
 
dnl compiler flags/libs to be tested by setting these environment
442
 
dnl variables.)
443
 
dnl
444
 
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
445
 
dnl multi-threaded programs (defaults to the value of CC otherwise).
446
 
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
447
 
dnl
448
 
dnl NOTE: You are assumed to not only compile your program with these
449
 
dnl flags, but also link it with them as well. e.g. you should link
450
 
dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
451
 
dnl $LIBS
452
 
dnl
453
 
dnl If you are only building threads programs, you may wish to use
454
 
dnl these variables in your default LIBS, CFLAGS, and CC:
455
 
dnl
456
 
dnl        LIBS="$PTHREAD_LIBS $LIBS"
457
 
dnl        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
458
 
dnl        CC="$PTHREAD_CC"
459
 
dnl
460
 
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
461
 
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
462
 
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
463
 
dnl
464
 
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
465
 
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
466
 
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
467
 
dnl default action will define HAVE_PTHREAD.
468
 
dnl
469
 
dnl Please let the authors know if this macro fails on any platform, or
470
 
dnl if you have any other suggestions or comments. This macro was based
471
 
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
472
 
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
473
 
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
474
 
dnl We are also grateful for the helpful feedback of numerous users.
475
 
dnl
476
 
dnl @category InstalledPackages
477
 
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
478
 
dnl @version 2005-01-14
479
 
dnl @license GPLWithACException
 
575
dnl SYNOPSIS
 
576
dnl
 
577
dnl   AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
 
578
dnl
 
579
dnl DESCRIPTION
 
580
dnl
 
581
dnl   This macro figures out how to build C programs using POSIX threads. It
 
582
dnl   sets the PTHREAD_LIBS output variable to the threads library and linker
 
583
dnl   flags, and the PTHREAD_CFLAGS output variable to any special C compiler
 
584
dnl   flags that are needed. (The user can also force certain compiler
 
585
dnl   flags/libs to be tested by setting these environment variables.)
 
586
dnl
 
587
dnl   Also sets PTHREAD_CC to any special C compiler that is needed for
 
588
dnl   multi-threaded programs (defaults to the value of CC otherwise). (This
 
589
dnl   is necessary on AIX to use the special cc_r compiler alias.)
 
590
dnl
 
591
dnl   NOTE: You are assumed to not only compile your program with these flags,
 
592
dnl   but also link it with them as well. e.g. you should link with
 
593
dnl   $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
 
594
dnl
 
595
dnl   If you are only building threads programs, you may wish to use these
 
596
dnl   variables in your default LIBS, CFLAGS, and CC:
 
597
dnl
 
598
dnl     LIBS="$PTHREAD_LIBS $LIBS"
 
599
dnl     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 
600
dnl     CC="$PTHREAD_CC"
 
601
dnl
 
602
dnl   In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
 
603
dnl   has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
 
604
dnl   (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
 
605
dnl
 
606
dnl   ACTION-IF-FOUND is a list of shell commands to run if a threads library
 
607
dnl   is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
 
608
dnl   is not found. If ACTION-IF-FOUND is not specified, the default action
 
609
dnl   will define HAVE_PTHREAD.
 
610
dnl
 
611
dnl   Please let the authors know if this macro fails on any platform, or if
 
612
dnl   you have any other suggestions or comments. This macro was based on work
 
613
dnl   by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
 
614
dnl   from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
 
615
dnl   Alejandro Forero Cuervo to the autoconf macro repository. We are also
 
616
dnl   grateful for the helpful feedback of numerous users.
 
617
dnl
 
618
dnl LICENSE
 
619
dnl
 
620
dnl   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
 
621
dnl
 
622
dnl   This program is free software: you can redistribute it and/or modify it
 
623
dnl   under the terms of the GNU General Public License as published by the
 
624
dnl   Free Software Foundation, either version 3 of the License, or (at your
 
625
dnl   option) any later version.
 
626
dnl
 
627
dnl   This program is distributed in the hope that it will be useful, but
 
628
dnl   WITHOUT ANY WARRANTY; without even the implied warranty of
 
629
dnl   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 
630
dnl   Public License for more details.
 
631
dnl
 
632
dnl   You should have received a copy of the GNU General Public License along
 
633
dnl   with this program. If not, see <http://www.gnu.org/licenses/>.
 
634
dnl
 
635
dnl   As a special exception, the respective Autoconf Macro's copyright owner
 
636
dnl   gives unlimited permission to copy, distribute and modify the configure
 
637
dnl   scripts that are the output of Autoconf when processing the Macro. You
 
638
dnl   need not follow the terms of the GNU General Public License when using
 
639
dnl   or distributing such scripts, even though portions of the text of the
 
640
dnl   Macro appear in them. The GNU General Public License (GPL) does govern
 
641
dnl   all other use of the material that constitutes the Autoconf Macro.
 
642
dnl
 
643
dnl   This special exception to the GPL applies to versions of the Autoconf
 
644
dnl   Macro released by the Autoconf Archive. When you make and distribute a
 
645
dnl   modified version of the Autoconf Macro, you may extend this special
 
646
dnl   exception to the GPL to apply to your modified version as well.
480
647
 
481
 
AC_DEFUN([ACX_PTHREAD], [
 
648
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
 
649
AC_DEFUN([AX_PTHREAD], [
482
650
AC_REQUIRE([AC_CANONICAL_HOST])
483
651
AC_LANG_SAVE
484
652
AC_LANG_C
485
 
acx_pthread_ok=no
486
 
 
487
 
# We used to check for pthread.h first, but this fails if pthread.h
488
 
# requires special compiler flags (e.g. on True64 or Sequent).
489
 
# It gets checked for in the link test anyway.
490
 
 
491
 
# First of all, check if the user has set any of the PTHREAD_LIBS,
492
 
# etcetera environment variables, and if threads linking works using
493
 
# them:
 
653
ax_pthread_ok=no
 
654
 
 
655
dnl We used to check for pthread.h first, but this fails if pthread.h
 
656
dnl requires special compiler flags (e.g. on True64 or Sequent).
 
657
dnl It gets checked for in the link test anyway.
 
658
 
 
659
dnl First of all, check if the user has set any of the PTHREAD_LIBS,
 
660
dnl etcetera environment variables, and if threads linking works using
 
661
dnl them:
494
662
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
495
663
        save_CFLAGS="$CFLAGS"
496
664
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
497
665
        save_LIBS="$LIBS"
498
666
        LIBS="$PTHREAD_LIBS $LIBS"
499
667
        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
500
 
        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
501
 
        AC_MSG_RESULT($acx_pthread_ok)
502
 
        if test x"$acx_pthread_ok" = xno; then
 
668
        AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
 
669
        AC_MSG_RESULT($ax_pthread_ok)
 
670
        if test x"$ax_pthread_ok" = xno; then
503
671
                PTHREAD_LIBS=""
504
672
                PTHREAD_CFLAGS=""
505
673
        fi
507
675
        CFLAGS="$save_CFLAGS"
508
676
fi
509
677
 
510
 
# We must check for the threads library under a number of different
511
 
# names; the ordering is very important because some systems
512
 
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
513
 
# libraries is broken (non-POSIX).
514
 
 
515
 
# Create a list of thread flags to try.  Items starting with a "-" are
516
 
# C compiler flags, and other items are library names, except for "none"
517
 
# which indicates that we try without any flags at all, and "pthread-config"
518
 
# which is a program returning the flags for the Pth emulation library.
519
 
 
520
 
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
521
 
 
522
 
# The ordering *is* (sometimes) important.  Some notes on the
523
 
# individual items follow:
524
 
 
525
 
# pthreads: AIX (must check this before -lpthread)
526
 
# none: in case threads are in libc; should be tried before -Kthread and
527
 
#       other compiler flags to prevent continual compiler warnings
528
 
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
529
 
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
530
 
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
531
 
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
532
 
# -pthreads: Solaris/gcc
533
 
# -mthreads: Mingw32/gcc, Lynx/gcc
534
 
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
535
 
#      doesn't hurt to check since this sometimes defines pthreads too;
536
 
#      also defines -D_REENTRANT)
537
 
# pthread: Linux, etcetera
538
 
# --thread-safe: KAI C++
539
 
# pthread-config: use pthread-config program (for GNU Pth library)
 
678
dnl We must check for the threads library under a number of different
 
679
dnl names; the ordering is very important because some systems
 
680
dnl (e.g. DEC) have both -lpthread and -lpthreads, where one of the
 
681
dnl libraries is broken (non-POSIX).
 
682
 
 
683
dnl Create a list of thread flags to try.  Items starting with a "-" are
 
684
dnl C compiler flags, and other items are library names, except for "none"
 
685
dnl which indicates that we try without any flags at all, and "pthread-config"
 
686
dnl which is a program returning the flags for the Pth emulation library.
 
687
 
 
688
ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
 
689
 
 
690
dnl The ordering *is* (sometimes) important.  Some notes on the
 
691
dnl individual items follow:
 
692
 
 
693
dnl pthreads: AIX (must check this before -lpthread)
 
694
dnl none: in case threads are in libc; should be tried before -Kthread and
 
695
dnl       other compiler flags to prevent continual compiler warnings
 
696
dnl -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
 
697
dnl -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
 
698
dnl lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
 
699
dnl -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
 
700
dnl -pthreads: Solaris/gcc
 
701
dnl -mthreads: Mingw32/gcc, Lynx/gcc
 
702
dnl -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
 
703
dnl      doesn't hurt to check since this sometimes defines pthreads too;
 
704
dnl      also defines -D_REENTRANT)
 
705
dnl      ... -mt is also the pthreads flag for HP/aCC
 
706
dnl pthread: Linux, etcetera
 
707
dnl --thread-safe: KAI C++
 
708
dnl pthread-config: use pthread-config program (for GNU Pth library)
540
709
 
541
710
case "${host_cpu}-${host_os}" in
542
711
        *solaris*)
543
712
 
544
 
        # On Solaris (at least, for some versions), libc contains stubbed
545
 
        # (non-functional) versions of the pthreads routines, so link-based
546
 
        # tests will erroneously succeed.  (We need to link with -pthread or
547
 
        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
548
 
        # a function called by this macro, so we could check for that, but
549
 
        # who knows whether they'll stub that too in a future libc.)  So,
550
 
        # we'll just look for -pthreads and -lpthread first:
 
713
        dnl On Solaris (at least, for some versions), libc contains stubbed
 
714
        dnl (non-functional) versions of the pthreads routines, so link-based
 
715
        dnl tests will erroneously succeed.  (We need to link with -pthreads/-mt/
 
716
        dnl -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
 
717
        dnl a function called by this macro, so we could check for that, but
 
718
        dnl who knows whether they'll stub that too in a future libc.)  So,
 
719
        dnl we'll just look for -pthreads and -lpthread first:
551
720
 
552
 
        acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
 
721
        ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
553
722
        ;;
 
723
 
 
724
        *-darwin*)
 
725
        ax_pthread_flags="-pthread $ax_pthread_flags"
 
726
        ;;
554
727
esac
555
728
 
556
 
if test x"$acx_pthread_ok" = xno; then
557
 
for flag in $acx_pthread_flags; do
 
729
if test x"$ax_pthread_ok" = xno; then
 
730
for flag in $ax_pthread_flags; do
558
731
 
559
732
        case $flag in
560
733
                none)
567
740
                ;;
568
741
 
569
742
                pthread-config)
570
 
                AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
571
 
                if test x"$acx_pthread_config" = xno; then continue; fi
 
743
                AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
 
744
                if test x"$ax_pthread_config" = xno; then continue; fi
572
745
                PTHREAD_CFLAGS="`pthread-config --cflags`"
573
746
                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
574
747
                ;;
584
757
        LIBS="$PTHREAD_LIBS $LIBS"
585
758
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
586
759
 
587
 
        # Check for various functions.  We must include pthread.h,
588
 
        # since some functions may be macros.  (On the Sequent, we
589
 
        # need a special flag -Kthread to make this header compile.)
590
 
        # We check for pthread_join because it is in -lpthread on IRIX
591
 
        # while pthread_create is in libc.  We check for pthread_attr_init
592
 
        # due to DEC craziness with -lpthreads.  We check for
593
 
        # pthread_cleanup_push because it is one of the few pthread
594
 
        # functions on Solaris that doesn't have a non-functional libc stub.
595
 
        # We try pthread_create on general principles.
596
 
        AC_TRY_LINK([#include <pthread.h>],
597
 
                    [pthread_t th; pthread_join(th, 0);
598
 
                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
599
 
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
600
 
                    [acx_pthread_ok=yes])
 
760
        dnl Check for various functions.  We must include pthread.h,
 
761
        dnl since some functions may be macros.  (On the Sequent, we
 
762
        dnl need a special flag -Kthread to make this header compile.)
 
763
        dnl We check for pthread_join because it is in -lpthread on IRIX
 
764
        dnl while pthread_create is in libc.  We check for pthread_attr_init
 
765
        dnl due to DEC craziness with -lpthreads.  We check for
 
766
        dnl pthread_cleanup_push because it is one of the few pthread
 
767
        dnl functions on Solaris that doesn't have a non-functional libc stub.
 
768
        dnl We try pthread_create on general principles.
 
769
        AC_TRY_LINK([#include <pthread.h>
 
770
                     static void routine(void* a) {a=0;}
 
771
                     static void* start_routine(void* a) {return a;}],
 
772
                    [pthread_t th; pthread_attr_t attr;
 
773
                     pthread_create(&th,0,start_routine,0);
 
774
                     pthread_join(th, 0);
 
775
                     pthread_attr_init(&attr);
 
776
                     pthread_cleanup_push(routine, 0);
 
777
                     pthread_cleanup_pop(0); ],
 
778
                    [ax_pthread_ok=yes])
601
779
 
602
780
        LIBS="$save_LIBS"
603
781
        CFLAGS="$save_CFLAGS"
604
782
 
605
 
        AC_MSG_RESULT($acx_pthread_ok)
606
 
        if test "x$acx_pthread_ok" = xyes; then
 
783
        AC_MSG_RESULT($ax_pthread_ok)
 
784
        if test "x$ax_pthread_ok" = xyes; then
607
785
                break;
608
786
        fi
609
787
 
612
790
done
613
791
fi
614
792
 
615
 
# Various other checks:
616
 
if test "x$acx_pthread_ok" = xyes; then
 
793
dnl Various other checks:
 
794
if test "x$ax_pthread_ok" = xyes; then
617
795
        save_LIBS="$LIBS"
618
796
        LIBS="$PTHREAD_LIBS $LIBS"
619
797
        save_CFLAGS="$CFLAGS"
620
798
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
621
799
 
622
 
        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
 
800
        dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
623
801
        AC_MSG_CHECKING([for joinable pthread attribute])
624
802
        attr_name=unknown
625
803
        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
626
 
            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr;],
 
804
            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
627
805
                        [attr_name=$attr; break])
628
806
        done
629
807
        AC_MSG_RESULT($attr_name)
647
825
        LIBS="$save_LIBS"
648
826
        CFLAGS="$save_CFLAGS"
649
827
 
650
 
        # More AIX lossage: must compile with cc_r
651
 
        AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
 
828
        dnl More AIX lossage: must compile with xlc_r or cc_r
 
829
        if test x"$GCC" != xyes; then
 
830
          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
 
831
        else
 
832
          PTHREAD_CC=$CC
 
833
        fi
652
834
else
653
835
        PTHREAD_CC="$CC"
654
836
fi
657
839
AC_SUBST(PTHREAD_CFLAGS)
658
840
AC_SUBST(PTHREAD_CC)
659
841
 
660
 
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
661
 
if test x"$acx_pthread_ok" = xyes; then
 
842
dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
 
843
if test x"$ax_pthread_ok" = xyes; then
662
844
        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
663
845
        :
664
846
else
665
 
        acx_pthread_ok=no
 
847
        ax_pthread_ok=no
666
848
        $2
667
849
fi
668
850
AC_LANG_RESTORE
669
 
])dnl ACX_PTHREAD
 
851
])dnl AX_PTHREAD