]> git.saurik.com Git - wxWidgets.git/blame - src/tiff/m4/acinclude.m4
Correctly restore the originally used C locale in wxLocale dtor.
[wxWidgets.git] / src / tiff / m4 / acinclude.m4
CommitLineData
8414a40c
VZ
1dnl ---------------------------------------------------------------------------
2dnl Message output
3dnl ---------------------------------------------------------------------------
4AC_DEFUN([LOC_MSG],[echo "$1"])
5
6dnl ---------------------------------------------------------------------------
7dnl Available from the GNU Autoconf Macro Archive at:
8dnl http://www.gnu.org/software/ac-archive/vl_prog_cc_warnings.html
9dnl ---------------------------------------------------------------------------
10
11dnl @synopsis VL_PROG_CC_WARNINGS([ANSI])
12dnl
13dnl Enables a reasonable set of warnings for the C compiler.
14dnl Optionally, if the first argument is nonempty, turns on flags which
15dnl enforce and/or enable proper ANSI C if such are known with the
16dnl compiler used.
17dnl
18dnl Currently this macro knows about GCC, Solaris C compiler, Digital
19dnl Unix C compiler, C for AIX Compiler, HP-UX C compiler, IRIX C
20dnl compiler, NEC SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos
21dnl 10.0.0.8) C compiler.
22dnl
23dnl @category C
24dnl @author Ville Laurikari <vl@iki.fi>
25dnl @version 2002-04-04
26dnl @license AllPermissive
27
28AC_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
38int main(int argc, char **argv) { return 0; }
39EOF
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
139dnl ---------------------------------------------------------------------------
140dnl Available from the GNU Autoconf Macro Archive at:
141dnl http://autoconf-archive.cryp.to/ax_lang_compiler_ms.html
142dnl ---------------------------------------------------------------------------
143
144dnl @synopsis AX_LANG_COMPILER_MS
145dnl
146dnl Check whether the compiler for the current language is Microsoft.
147dnl
148dnl This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU
149dnl Autoconf implementation.
150dnl
151dnl @category InstalledPackages
152dnl @author Braden McDaniel <braden@endoframe.com>
153dnl @version 2004-11-15
154dnl @license AllPermissive
155
156AC_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])
165ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
166])])
167
168dnl ---------------------------------------------------------------------------
169dnl Available from the GNU Autoconf Macro Archive at:
170dnl http://www.gnu.org/software/ac-archive/ax_check_gl.html
171dnl ---------------------------------------------------------------------------
172
80ed523f 173dnl SYNOPSIS
8414a40c 174dnl
80ed523f 175dnl AX_CHECK_GL
8414a40c 176dnl
80ed523f
VZ
177dnl DESCRIPTION
178dnl
179dnl Check for an OpenGL implementation. If GL is found, the required
180dnl compiler and linker flags are included in the output variables
181dnl "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
182dnl is found, "no_gl" is set to "yes".
183dnl
184dnl If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
185dnl header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
186dnl preprocessor definitions may not be mutually exclusive.
187dnl
188dnl LICENSE
189dnl
190dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
191dnl
192dnl This program is free software; you can redistribute it and/or modify it
193dnl under the terms of the GNU General Public License as published by the
194dnl Free Software Foundation; either version 2 of the License, or (at your
195dnl option) any later version.
196dnl
197dnl This program is distributed in the hope that it will be useful, but
198dnl WITHOUT ANY WARRANTY; without even the implied warranty of
199dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
200dnl Public License for more details.
201dnl
202dnl You should have received a copy of the GNU General Public License along
203dnl with this program. If not, see <http://www.gnu.org/licenses/>.
204dnl
205dnl As a special exception, the respective Autoconf Macro's copyright owner
206dnl gives unlimited permission to copy, distribute and modify the configure
207dnl scripts that are the output of Autoconf when processing the Macro. You
208dnl need not follow the terms of the GNU General Public License when using
209dnl or distributing such scripts, even though portions of the text of the
210dnl Macro appear in them. The GNU General Public License (GPL) does govern
211dnl all other use of the material that constitutes the Autoconf Macro.
212dnl
213dnl This special exception to the GPL applies to versions of the Autoconf
214dnl Macro released by the Autoconf Archive. When you make and distribute a
215dnl modified version of the Autoconf Macro, you may extend this special
216dnl exception to the GPL to apply to your modified version as well.
8414a40c
VZ
217
218AC_DEFUN([AX_CHECK_GL],
80ed523f
VZ
219[AC_REQUIRE([AC_CANONICAL_HOST])
220AC_REQUIRE([AC_PATH_X])dnl
221AC_REQUIRE([AX_PTHREAD])dnl
8414a40c 222
80ed523f
VZ
223AC_LANG_PUSH([C])
224AX_LANG_COMPILER_MS
225AS_IF([test X$ax_compiler_ms = Xno],
226 [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
8414a40c 227
80ed523f
VZ
228dnl
229dnl Use x_includes and x_libraries if they have been set (presumably by
230dnl AC_PATH_X).
231dnl
232AS_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
238ax_save_CPPFLAGS="${CPPFLAGS}"
239CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
240AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
241CPPFLAGS="${ax_save_CPPFLAGS}"
242
243AC_CHECK_HEADERS([windows.h])
244
245m4_define([AX_CHECK_GL_PROGRAM],
246 [AC_LANG_PROGRAM([[
247# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
8414a40c
VZ
248# include <windows.h>
249# endif
80ed523f
VZ
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
259AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
260[ax_cv_check_gl_libgl="no"
261case $host_cpu in
262 x86_64) ax_check_gl_libdir=lib64 ;;
263 *) ax_check_gl_libdir=lib ;;
264esac
265ax_save_CPPFLAGS="${CPPFLAGS}"
266CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
267ax_save_LIBS="${LIBS}"
268LIBS=""
269ax_check_libs="-lopengl32 -lGL"
270for 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}"
275AC_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}"
278AC_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}"
281AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
282 [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
283done
284
285AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
286[LIBS='-framework OpenGL'
287AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
288 [ax_cv_check_gl_libgl="$LIBS"])])
289
290LIBS=${ax_save_LIBS}
291CPPFLAGS=${ax_save_CPPFLAGS}])
292
293AS_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}"])
296AC_LANG_POP([C])
8414a40c
VZ
297
298AC_SUBST([GL_CFLAGS])
299AC_SUBST([GL_LIBS])
300])dnl
301
302dnl ---------------------------------------------------------------------------
303dnl Available from the GNU Autoconf Macro Archive at:
304dnl http://www.gnu.org/software/ac-archive/ax_check_glu.html
305dnl ---------------------------------------------------------------------------
306
80ed523f 307dnl SYNOPSIS
8414a40c 308dnl
80ed523f 309dnl AX_CHECK_GLU
8414a40c 310dnl
80ed523f
VZ
311dnl DESCRIPTION
312dnl
313dnl Check for GLU. If GLU is found, the required preprocessor and linker
314dnl flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
315dnl respectively. If no GLU implementation is found, "no_glu" is set to
316dnl "yes".
317dnl
318dnl If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
319dnl header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
320dnl preprocessor definitions may not be mutually exclusive.
321dnl
322dnl Some implementations (in particular, some versions of Mac OS X) are
323dnl known to treat the GLU tesselator callback function type as "GLvoid
324dnl (*)(...)" rather than the standard "GLvoid (*)()". If the former
325dnl condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
326dnl
327dnl LICENSE
328dnl
329dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
330dnl
331dnl This program is free software; you can redistribute it and/or modify it
332dnl under the terms of the GNU General Public License as published by the
333dnl Free Software Foundation; either version 2 of the License, or (at your
334dnl option) any later version.
335dnl
336dnl This program is distributed in the hope that it will be useful, but
337dnl WITHOUT ANY WARRANTY; without even the implied warranty of
338dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
339dnl Public License for more details.
340dnl
341dnl You should have received a copy of the GNU General Public License along
342dnl with this program. If not, see <http://www.gnu.org/licenses/>.
343dnl
344dnl As a special exception, the respective Autoconf Macro's copyright owner
345dnl gives unlimited permission to copy, distribute and modify the configure
346dnl scripts that are the output of Autoconf when processing the Macro. You
347dnl need not follow the terms of the GNU General Public License when using
348dnl or distributing such scripts, even though portions of the text of the
349dnl Macro appear in them. The GNU General Public License (GPL) does govern
350dnl all other use of the material that constitutes the Autoconf Macro.
351dnl
352dnl This special exception to the GPL applies to versions of the Autoconf
353dnl Macro released by the Autoconf Archive. When you make and distribute a
354dnl modified version of the Autoconf Macro, you may extend this special
355dnl exception to the GPL to apply to your modified version as well.
8414a40c
VZ
356
357AC_DEFUN([AX_CHECK_GLU],
358[AC_REQUIRE([AX_CHECK_GL])dnl
359AC_REQUIRE([AC_PROG_CXX])dnl
360GLU_CFLAGS="${GL_CFLAGS}"
80ed523f
VZ
361
362ax_save_CPPFLAGS="${CPPFLAGS}"
363CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
364AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
365CPPFLAGS="${ax_save_CPPFLAGS}"
366
367m4_define([AX_CHECK_GLU_PROGRAM],
368 [AC_LANG_PROGRAM([[
369# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
8414a40c
VZ
370# include <windows.h>
371# endif
80ed523f
VZ
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
381AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
382[ax_cv_check_glu_libglu="no"
383ax_save_CPPFLAGS="${CPPFLAGS}"
384CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
385ax_save_LIBS="${LIBS}"
386
387dnl
388dnl First, check for the possibility that everything we need is already in
389dnl GL_LIBS.
390dnl
391LIBS="${GL_LIBS} ${ax_save_LIBS}"
392dnl
393dnl libGLU typically links with libstdc++ on POSIX platforms.
394dnl However, setting the language to C++ means that test program
395dnl source is named "conftest.cc"; and Microsoft cl doesn't know what
396dnl to do with such a file.
397dnl
398AC_LANG_PUSH([C++])
399AS_IF([test X$ax_compiler_ms = Xyes],
400 [AC_LANG_PUSH([C])])
401AC_LINK_IFELSE(
402[AX_CHECK_GLU_PROGRAM],
403[ax_cv_check_glu_libglu=yes],
404[LIBS=""
405ax_check_libs="-lglu32 -lGLU"
406for 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])
413done
414])
415AS_IF([test X$ax_compiler_ms = Xyes],
416 [AC_LANG_POP([C])])
417AC_LANG_POP([C++])
418
419LIBS=${ax_save_LIBS}
420CPPFLAGS=${ax_save_CPPFLAGS}])
421AS_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}"])])
8414a40c
VZ
426AC_SUBST([GLU_CFLAGS])
427AC_SUBST([GLU_LIBS])
80ed523f
VZ
428
429dnl
430dnl Some versions of Mac OS X include a broken interpretation of the GLU
431dnl tesselation callback function signature.
432dnl
433AS_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
437ax_save_CFLAGS="$CFLAGS"
438CFLAGS="$GL_CFLAGS $CFLAGS"
439AC_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])
448CFLAGS="$ax_save_CFLAGS"])
449AS_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])])])
8414a40c
VZ
452])
453
454dnl ---------------------------------------------------------------------------
455dnl Available from the GNU Autoconf Macro Archive at:
456dnl http://www.gnu.org/software/ac-archive/ax_check_glut.html
457dnl ---------------------------------------------------------------------------
458
8414a40c 459dnl
80ed523f 460dnl SYNOPSIS
8414a40c 461dnl
80ed523f
VZ
462dnl AX_CHECK_GLUT
463dnl
464dnl DESCRIPTION
465dnl
466dnl Check for GLUT. If GLUT is found, the required compiler and linker flags
467dnl are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
468dnl respectively. If GLUT is not found, "no_glut" is set to "yes".
469dnl
470dnl If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
471dnl header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
472dnl preprocessor definitions may not be mutually exclusive.
473dnl
474dnl LICENSE
475dnl
476dnl Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
477dnl
478dnl This program is free software; you can redistribute it and/or modify it
479dnl under the terms of the GNU General Public License as published by the
480dnl Free Software Foundation; either version 2 of the License, or (at your
481dnl option) any later version.
482dnl
483dnl This program is distributed in the hope that it will be useful, but
484dnl WITHOUT ANY WARRANTY; without even the implied warranty of
485dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
486dnl Public License for more details.
487dnl
488dnl You should have received a copy of the GNU General Public License along
489dnl with this program. If not, see <http://www.gnu.org/licenses/>.
490dnl
491dnl As a special exception, the respective Autoconf Macro's copyright owner
492dnl gives unlimited permission to copy, distribute and modify the configure
493dnl scripts that are the output of Autoconf when processing the Macro. You
494dnl need not follow the terms of the GNU General Public License when using
495dnl or distributing such scripts, even though portions of the text of the
496dnl Macro appear in them. The GNU General Public License (GPL) does govern
497dnl all other use of the material that constitutes the Autoconf Macro.
498dnl
499dnl This special exception to the GPL applies to versions of the Autoconf
500dnl Macro released by the Autoconf Archive. When you make and distribute a
501dnl modified version of the Autoconf Macro, you may extend this special
502dnl exception to the GPL to apply to your modified version as well.
8414a40c
VZ
503
504AC_DEFUN([AX_CHECK_GLUT],
505[AC_REQUIRE([AX_CHECK_GLU])dnl
506AC_REQUIRE([AC_PATH_XTRA])dnl
507
80ed523f
VZ
508ax_save_CPPFLAGS="${CPPFLAGS}"
509CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
510AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
511CPPFLAGS="${ax_save_CPPFLAGS}"
8414a40c 512
80ed523f
VZ
513GLUT_CFLAGS=${GLU_CFLAGS}
514GLUT_LIBS=${GLU_LIBS}
8414a40c 515
80ed523f
VZ
516m4_define([AX_CHECK_GLUT_PROGRAM],
517 [AC_LANG_PROGRAM([[
8414a40c
VZ
518# if HAVE_WINDOWS_H && defined(_WIN32)
519# include <windows.h>
520# endif
80ed523f
VZ
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()]])])
8414a40c 529
80ed523f
VZ
530dnl
531dnl If X is present, assume GLUT depends on it.
532dnl
533AS_IF([test X$no_x != Xyes],
534 [GLUT_LIBS="${X_PRE_LIBS} -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
535
536AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
537[ax_cv_check_glut_libglut="no"
538AC_LANG_PUSH(C)
539ax_save_CPPFLAGS="${CPPFLAGS}"
540CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
541ax_save_LIBS="${LIBS}"
542LIBS=""
543ax_check_libs="-lglut32 -lglut"
544for 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])
551done
8414a40c 552
80ed523f
VZ
553AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
554[LIBS='-framework GLUT'
555AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
556 [ax_cv_check_glut_libglut="$LIBS"])])
557
558CPPFLAGS="${ax_save_CPPFLAGS}"
559LIBS="${ax_save_LIBS}"
560AC_LANG_POP(C)])
561
562AS_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}"])
8414a40c
VZ
565
566AC_SUBST([GLUT_CFLAGS])
567AC_SUBST([GLUT_LIBS])
568])dnl
569
570dnl ---------------------------------------------------------------------------
571dnl Available from the GNU Autoconf Macro Archive at:
80ed523f 572dnl http://www.gnu.org/software/autoconf-archive/ax_pthread.html
8414a40c
VZ
573dnl ---------------------------------------------------------------------------
574
80ed523f 575dnl SYNOPSIS
8414a40c 576dnl
80ed523f 577dnl AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
8414a40c 578dnl
80ed523f 579dnl DESCRIPTION
8414a40c 580dnl
80ed523f
VZ
581dnl This macro figures out how to build C programs using POSIX threads. It
582dnl sets the PTHREAD_LIBS output variable to the threads library and linker
583dnl flags, and the PTHREAD_CFLAGS output variable to any special C compiler
584dnl flags that are needed. (The user can also force certain compiler
585dnl flags/libs to be tested by setting these environment variables.)
8414a40c 586dnl
80ed523f
VZ
587dnl Also sets PTHREAD_CC to any special C compiler that is needed for
588dnl multi-threaded programs (defaults to the value of CC otherwise). (This
589dnl is necessary on AIX to use the special cc_r compiler alias.)
8414a40c 590dnl
80ed523f
VZ
591dnl NOTE: You are assumed to not only compile your program with these flags,
592dnl but also link it with them as well. e.g. you should link with
593dnl $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
8414a40c 594dnl
80ed523f
VZ
595dnl If you are only building threads programs, you may wish to use these
596dnl variables in your default LIBS, CFLAGS, and CC:
8414a40c 597dnl
80ed523f
VZ
598dnl LIBS="$PTHREAD_LIBS $LIBS"
599dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
600dnl CC="$PTHREAD_CC"
8414a40c 601dnl
80ed523f
VZ
602dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
603dnl has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
604dnl (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
8414a40c 605dnl
80ed523f
VZ
606dnl ACTION-IF-FOUND is a list of shell commands to run if a threads library
607dnl is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
608dnl is not found. If ACTION-IF-FOUND is not specified, the default action
609dnl will define HAVE_PTHREAD.
610dnl
611dnl Please let the authors know if this macro fails on any platform, or if
612dnl you have any other suggestions or comments. This macro was based on work
613dnl by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
614dnl from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
615dnl Alejandro Forero Cuervo to the autoconf macro repository. We are also
616dnl grateful for the helpful feedback of numerous users.
617dnl
618dnl LICENSE
619dnl
620dnl Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
621dnl
622dnl This program is free software: you can redistribute it and/or modify it
623dnl under the terms of the GNU General Public License as published by the
624dnl Free Software Foundation, either version 3 of the License, or (at your
625dnl option) any later version.
626dnl
627dnl This program is distributed in the hope that it will be useful, but
628dnl WITHOUT ANY WARRANTY; without even the implied warranty of
629dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
630dnl Public License for more details.
631dnl
632dnl You should have received a copy of the GNU General Public License along
633dnl with this program. If not, see <http://www.gnu.org/licenses/>.
634dnl
635dnl As a special exception, the respective Autoconf Macro's copyright owner
636dnl gives unlimited permission to copy, distribute and modify the configure
637dnl scripts that are the output of Autoconf when processing the Macro. You
638dnl need not follow the terms of the GNU General Public License when using
639dnl or distributing such scripts, even though portions of the text of the
640dnl Macro appear in them. The GNU General Public License (GPL) does govern
641dnl all other use of the material that constitutes the Autoconf Macro.
642dnl
643dnl This special exception to the GPL applies to versions of the Autoconf
644dnl Macro released by the Autoconf Archive. When you make and distribute a
645dnl modified version of the Autoconf Macro, you may extend this special
646dnl exception to the GPL to apply to your modified version as well.
8414a40c 647
80ed523f
VZ
648AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
649AC_DEFUN([AX_PTHREAD], [
8414a40c
VZ
650AC_REQUIRE([AC_CANONICAL_HOST])
651AC_LANG_SAVE
652AC_LANG_C
80ed523f 653ax_pthread_ok=no
8414a40c 654
80ed523f
VZ
655dnl We used to check for pthread.h first, but this fails if pthread.h
656dnl requires special compiler flags (e.g. on True64 or Sequent).
657dnl It gets checked for in the link test anyway.
8414a40c 658
80ed523f
VZ
659dnl First of all, check if the user has set any of the PTHREAD_LIBS,
660dnl etcetera environment variables, and if threads linking works using
661dnl them:
8414a40c
VZ
662if 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])
80ed523f
VZ
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
8414a40c
VZ
671 PTHREAD_LIBS=""
672 PTHREAD_CFLAGS=""
673 fi
674 LIBS="$save_LIBS"
675 CFLAGS="$save_CFLAGS"
676fi
677
80ed523f
VZ
678dnl We must check for the threads library under a number of different
679dnl names; the ordering is very important because some systems
680dnl (e.g. DEC) have both -lpthread and -lpthreads, where one of the
681dnl libraries is broken (non-POSIX).
682
683dnl Create a list of thread flags to try. Items starting with a "-" are
684dnl C compiler flags, and other items are library names, except for "none"
685dnl which indicates that we try without any flags at all, and "pthread-config"
686dnl which is a program returning the flags for the Pth emulation library.
687
688ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
689
690dnl The ordering *is* (sometimes) important. Some notes on the
691dnl individual items follow:
692
693dnl pthreads: AIX (must check this before -lpthread)
694dnl none: in case threads are in libc; should be tried before -Kthread and
695dnl other compiler flags to prevent continual compiler warnings
696dnl -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
697dnl -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
698dnl lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
699dnl -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
700dnl -pthreads: Solaris/gcc
701dnl -mthreads: Mingw32/gcc, Lynx/gcc
702dnl -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
703dnl doesn't hurt to check since this sometimes defines pthreads too;
704dnl also defines -D_REENTRANT)
705dnl ... -mt is also the pthreads flag for HP/aCC
706dnl pthread: Linux, etcetera
707dnl --thread-safe: KAI C++
708dnl pthread-config: use pthread-config program (for GNU Pth library)
8414a40c
VZ
709
710case "${host_cpu}-${host_os}" in
711 *solaris*)
712
80ed523f
VZ
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:
8414a40c 720
80ed523f 721 ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
8414a40c 722 ;;
80ed523f
VZ
723
724 *-darwin*)
725 ax_pthread_flags="-pthread $ax_pthread_flags"
726 ;;
8414a40c
VZ
727esac
728
80ed523f
VZ
729if test x"$ax_pthread_ok" = xno; then
730for flag in $ax_pthread_flags; do
8414a40c
VZ
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)
80ed523f
VZ
743 AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
744 if test x"$ax_pthread_config" = xno; then continue; fi
8414a40c
VZ
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
80ed523f
VZ
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])
8414a40c
VZ
779
780 LIBS="$save_LIBS"
781 CFLAGS="$save_CFLAGS"
782
80ed523f
VZ
783 AC_MSG_RESULT($ax_pthread_ok)
784 if test "x$ax_pthread_ok" = xyes; then
8414a40c
VZ
785 break;
786 fi
787
788 PTHREAD_LIBS=""
789 PTHREAD_CFLAGS=""
790done
791fi
792
80ed523f
VZ
793dnl Various other checks:
794if test "x$ax_pthread_ok" = xyes; then
8414a40c
VZ
795 save_LIBS="$LIBS"
796 LIBS="$PTHREAD_LIBS $LIBS"
797 save_CFLAGS="$CFLAGS"
798 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
799
80ed523f 800 dnl Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
8414a40c
VZ
801 AC_MSG_CHECKING([for joinable pthread attribute])
802 attr_name=unknown
803 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
80ed523f 804 AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
8414a40c
VZ
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
80ed523f
VZ
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
8414a40c
VZ
834else
835 PTHREAD_CC="$CC"
836fi
837
838AC_SUBST(PTHREAD_LIBS)
839AC_SUBST(PTHREAD_CFLAGS)
840AC_SUBST(PTHREAD_CC)
841
80ed523f
VZ
842dnl Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
843if test x"$ax_pthread_ok" = xyes; then
8414a40c
VZ
844 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
845 :
846else
80ed523f 847 ax_pthread_ok=no
8414a40c
VZ
848 $2
849fi
850AC_LANG_RESTORE
80ed523f 851])dnl AX_PTHREAD