]> git.saurik.com Git - wxWidgets.git/blob - src/tiff/m4/acinclude.m4
Don't generate any events from wxSpinCtrl and wxSpinCtrlDouble methods.
[wxWidgets.git] / src / tiff / m4 / acinclude.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Message output
3 dnl ---------------------------------------------------------------------------
4 AC_DEFUN([LOC_MSG],[echo "$1"])
5
6 dnl ---------------------------------------------------------------------------
7 dnl Available from the GNU Autoconf Macro Archive at:
8 dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html
9 dnl ---------------------------------------------------------------------------
10
11 dnl @synopsis VL_PROG_CC_WARNINGS([ANSI])
12 dnl
13 dnl Enables a reasonable set of warnings for the C compiler.
14 dnl Optionally, if the first argument is nonempty, turns on flags which
15 dnl enforce and/or enable proper ANSI C if such are known with the
16 dnl compiler used.
17 dnl
18 dnl Currently this macro knows about GCC, Solaris C compiler, Digital
19 dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
20 dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
21 dnl 10.0.0.8) C compiler.
22 dnl
23 dnl @category C
24 dnl @author Ville Laurikari <vl@iki.fi>
25 dnl @version 2002-04-04
26 dnl @license AllPermissive
27
28 AC_DEFUN([VL_PROG_CC_WARNINGS], [
29 ansi=$1
30 if test -z "$ansi"; then
31 msg="for C compiler warning flags"
32 else
33 msg="for C compiler warning and ANSI conformance flags"
34 fi
35 AC_CACHE_CHECK($msg, vl_cv_prog_cc_warnings, [
36 if test -n "$CC"; then
37 cat > conftest.c <<EOF
38 int main(int argc, char **argv) { return 0; }
39 EOF
40
41 dnl GCC. -W option has been renamed in -wextra in latest gcc versions.
42 if test "$GCC" = "yes"; then
43 if test -z "$ansi"; then
44 vl_cv_prog_cc_warnings="-Wall -W"
45 else
46 vl_cv_prog_cc_warnings="-Wall -W -ansi -pedantic"
47 fi
48
49 dnl Most compilers print some kind of a version string with some command
50 dnl line options (often "-V"). The version string should be checked
51 dnl before doing a test compilation run with compiler-specific flags.
52 dnl This is because some compilers (like the Cray compiler) only
53 dnl produce a warning message for unknown flags instead of returning
54 dnl an error, resulting in a false positive. Also, compilers may do
55 dnl erratic things when invoked with flags meant for a different
56 dnl compiler.
57
58 dnl Solaris C compiler
59 elif $CC -V 2>&1 | grep -i "WorkShop" > /dev/null 2>&1 &&
60 $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
61 test -f conftest.o; then
62 if test -z "$ansi"; then
63 vl_cv_prog_cc_warnings="-v"
64 else
65 vl_cv_prog_cc_warnings="-v -Xc"
66 fi
67
68 dnl Digital Unix C compiler
69 elif $CC -V 2>&1 | grep -i "Digital UNIX Compiler" > /dev/null 2>&1 &&
70 $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
71 test -f conftest.o; then
72 if test -z "$ansi"; then
73 vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
74 else
75 vl_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
76 fi
77
78 dnl C for AIX Compiler
79 elif $CC 2>&1 | grep -i "C for AIX Compiler" > /dev/null 2>&1 &&
80 $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
81 test -f conftest.o; then
82 if test -z "$ansi"; then
83 vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
84 else
85 vl_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
86 fi
87
88 dnl IRIX C compiler
89 elif $CC -version 2>&1 | grep -i "MIPSpro Compilers" > /dev/null 2>&1 &&
90 $CC -c -fullwarn -ansi -ansiE conftest.c > /dev/null 2>&1 &&
91 test -f conftest.o; then
92 if test -z "$ansi"; then
93 vl_cv_prog_cc_warnings="-fullwarn"
94 else
95 vl_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
96 fi
97
98 dnl HP-UX C compiler
99 elif what $CC 2>&1 | grep -i "HP C Compiler" > /dev/null 2>&1 &&
100 $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
101 test -f conftest.o; then
102 if test -z "$ansi"; then
103 vl_cv_prog_cc_warnings="+w1"
104 else
105 vl_cv_prog_cc_warnings="+w1 -Aa"
106 fi
107
108 dnl The NEC SX-5 (Super-UX 10) C compiler
109 elif $CC -V 2>&1 | grep "/SX" > /dev/null 2>&1 &&
110 $CC -c -pvctl[,]fullmsg -Xc conftest.c > /dev/null 2>&1 &&
111 test -f conftest.o; then
112 if test -z "$ansi"; then
113 vl_cv_prog_cc_warnings="-pvctl[,]fullmsg"
114 else
115 vl_cv_prog_cc_warnings="-pvctl[,]fullmsg -Xc"
116 fi
117
118 dnl The Cray C compiler (Unicos)
119 elif $CC -V 2>&1 | grep -i "Cray" > /dev/null 2>&1 &&
120 $CC -c -h msglevel 2 conftest.c > /dev/null 2>&1 &&
121 test -f conftest.o; then
122 if test -z "$ansi"; then
123 vl_cv_prog_cc_warnings="-h msglevel 2"
124 else
125 vl_cv_prog_cc_warnings="-h msglevel 2 -h conform"
126 fi
127
128 fi
129 rm -f conftest.*
130 fi
131 if test -n "$vl_cv_prog_cc_warnings"; then
132 CFLAGS="$CFLAGS $vl_cv_prog_cc_warnings"
133 else
134 vl_cv_prog_cc_warnings="unknown"
135 fi
136 ])
137 ])dnl
138
139 dnl ---------------------------------------------------------------------------
140 dnl Available from the GNU Autoconf Macro Archive at:
141 dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html
142 dnl ---------------------------------------------------------------------------
143
144 dnl @synopsis AX_LANG_COMPILER_MS
145 dnl
146 dnl Check whether the compiler for the current language is Microsoft.
147 dnl
148 dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU
149 dnl Autoconf implementation.
150 dnl
151 dnl @category InstalledPackages
152 dnl @author Braden McDaniel <braden@endoframe.com>
153 dnl @version 2004-11-15
154 dnl @license AllPermissive
155
156 AC_DEFUN([AX_LANG_COMPILER_MS],
157 [AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler],
158 [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms],
159 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER
160 choke me
161 #endif
162 ]])],
163 [ax_compiler_ms=yes],
164 [ax_compiler_ms=no])
165 ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
166 ])])
167
168 dnl ---------------------------------------------------------------------------
169 dnl Available from the GNU Autoconf Macro Archive at:
170 dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html
171 dnl ---------------------------------------------------------------------------
172
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.
217
218 AC_DEFUN([AX_CHECK_GL],
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)
248 # include <windows.h>
249 # endif
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])
297
298 AC_SUBST([GL_CFLAGS])
299 AC_SUBST([GL_LIBS])
300 ])dnl
301
302 dnl ---------------------------------------------------------------------------
303 dnl Available from the GNU Autoconf Macro Archive at:
304 dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html
305 dnl ---------------------------------------------------------------------------
306
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.
356
357 AC_DEFUN([AX_CHECK_GLU],
358 [AC_REQUIRE([AX_CHECK_GL])dnl
359 AC_REQUIRE([AC_PROG_CXX])dnl
360 GLU_CFLAGS="${GL_CFLAGS}"
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)
370 # include <windows.h>
371 # endif
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}"])])
426 AC_SUBST([GLU_CFLAGS])
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])])])
452 ])
453
454 dnl ---------------------------------------------------------------------------
455 dnl Available from the GNU Autoconf Macro Archive at:
456 dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html
457 dnl ---------------------------------------------------------------------------
458
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.
503
504 AC_DEFUN([AX_CHECK_GLUT],
505 [AC_REQUIRE([AX_CHECK_GLU])dnl
506 AC_REQUIRE([AC_PATH_XTRA])dnl
507
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([[
518 # if HAVE_WINDOWS_H && defined(_WIN32)
519 # include <windows.h>
520 # endif
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}"])
565
566 AC_SUBST([GLUT_CFLAGS])
567 AC_SUBST([GLUT_LIBS])
568 ])dnl
569
570 dnl ---------------------------------------------------------------------------
571 dnl Available from the GNU Autoconf Macro Archive at:
572 dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html
573 dnl ---------------------------------------------------------------------------
574
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.
647
648 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
649 AC_DEFUN([AX_PTHREAD], [
650 AC_REQUIRE([AC_CANONICAL_HOST])
651 AC_LANG_SAVE
652 AC_LANG_C
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:
662 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
663 save_CFLAGS="$CFLAGS"
664 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
665 save_LIBS="$LIBS"
666 LIBS="$PTHREAD_LIBS $LIBS"
667 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
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
671 PTHREAD_LIBS=""
672 PTHREAD_CFLAGS=""
673 fi
674 LIBS="$save_LIBS"
675 CFLAGS="$save_CFLAGS"
676 fi
677
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)
709
710 case "${host_cpu}-${host_os}" in
711 *solaris*)
712
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:
720
721 ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
722 ;;
723
724 *-darwin*)
725 ax_pthread_flags="-pthread $ax_pthread_flags"
726 ;;
727 esac
728
729 if test x"$ax_pthread_ok" = xno; then
730 for flag in $ax_pthread_flags; do
731
732 case $flag in
733 none)
734 AC_MSG_CHECKING([whether pthreads work without any flags])
735 ;;
736
737 -*)
738 AC_MSG_CHECKING([whether pthreads work with $flag])
739 PTHREAD_CFLAGS="$flag"
740 ;;
741
742 pthread-config)
743 AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
744 if test x"$ax_pthread_config" = xno; then continue; fi
745 PTHREAD_CFLAGS="`pthread-config --cflags`"
746 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
747 ;;
748
749 *)
750 AC_MSG_CHECKING([for the pthreads library -l$flag])
751 PTHREAD_LIBS="-l$flag"
752 ;;
753 esac
754
755 save_LIBS="$LIBS"
756 save_CFLAGS="$CFLAGS"
757 LIBS="$PTHREAD_LIBS $LIBS"
758 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
759
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])
779
780 LIBS="$save_LIBS"
781 CFLAGS="$save_CFLAGS"
782
783 AC_MSG_RESULT($ax_pthread_ok)
784 if test "x$ax_pthread_ok" = xyes; then
785 break;
786 fi
787
788 PTHREAD_LIBS=""
789 PTHREAD_CFLAGS=""
790 done
791 fi
792
793 dnl Various other checks:
794 if test "x$ax_pthread_ok" = xyes; then
795 save_LIBS="$LIBS"
796 LIBS="$PTHREAD_LIBS $LIBS"
797 save_CFLAGS="$CFLAGS"
798 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
799
800 dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
801 AC_MSG_CHECKING([for joinable pthread attribute])
802 attr_name=unknown
803 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
804 AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
805 [attr_name=$attr; break])
806 done
807 AC_MSG_RESULT($attr_name)
808 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
809 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
810 [Define to necessary symbol if this constant
811 uses a non-standard name on your system.])
812 fi
813
814 AC_MSG_CHECKING([if more special flags are required for pthreads])
815 flag=no
816 case "${host_cpu}-${host_os}" in
817 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
818 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
819 esac
820 AC_MSG_RESULT(${flag})
821 if test "x$flag" != xno; then
822 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
823 fi
824
825 LIBS="$save_LIBS"
826 CFLAGS="$save_CFLAGS"
827
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
834 else
835 PTHREAD_CC="$CC"
836 fi
837
838 AC_SUBST(PTHREAD_LIBS)
839 AC_SUBST(PTHREAD_CFLAGS)
840 AC_SUBST(PTHREAD_CC)
841
842 dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
843 if test x"$ax_pthread_ok" = xyes; then
844 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
845 :
846 else
847 ax_pthread_ok=no
848 $2
849 fi
850 AC_LANG_RESTORE
851 ])dnl AX_PTHREAD