1 # Configure paths for libogg
2 # Jack Moffitt <jack@icecast.org> 10-21-2000
3 # Shamelessly stolen from Owen Taylor and Manish Singh
5 dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
8 AC_DEFUN([XIPH_PATH_OGG],
10 dnl Get the cflags and libraries
12 AC_ARG_WITH(ogg,AC_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="")
13 AC_ARG_WITH(ogg-libraries,AC_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="")
14 AC_ARG_WITH(ogg-includes,AC_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="")
15 AC_ARG_ENABLE(oggtest,AC_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes)
17 if test "x$ogg_libraries" != "x" ; then
18 OGG_LIBS="-L$ogg_libraries"
19 elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
21 elif test "x$ogg_prefix" != "x" ; then
22 OGG_LIBS="-L$ogg_prefix/lib"
23 elif test "x$prefix" != "xNONE" ; then
24 OGG_LIBS="-L$prefix/lib"
27 if test "x$ogg_prefix" != "xno" ; then
28 OGG_LIBS="$OGG_LIBS -logg"
31 if test "x$ogg_includes" != "x" ; then
32 OGG_CFLAGS="-I$ogg_includes"
33 elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
35 elif test "x$ogg_prefix" != "x" ; then
36 OGG_CFLAGS="-I$ogg_prefix/include"
37 elif test "x$prefix" != "xNONE"; then
38 OGG_CFLAGS="-I$prefix/include"
41 AC_MSG_CHECKING(for Ogg)
42 if test "x$ogg_prefix" = "xno" ; then
50 if test "x$enable_oggtest" = "xyes" ; then
51 ac_save_CFLAGS="$CFLAGS"
53 CFLAGS="$CFLAGS $OGG_CFLAGS"
54 LIBS="$LIBS $OGG_LIBS"
56 dnl Now check if the installed Ogg is sufficiently new.
67 system("touch conf.oggtest");
71 ],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
72 CFLAGS="$ac_save_CFLAGS"
76 if test "x$no_ogg" = "xdisabled" ; then
78 ifelse([$2], , :, [$2])
79 elif test "x$no_ogg" = "x" ; then
81 ifelse([$1], , :, [$1])
84 if test -f conf.oggtest ; then
87 echo "*** Could not run Ogg test program, checking why..."
88 CFLAGS="$CFLAGS $OGG_CFLAGS"
89 LIBS="$LIBS $OGG_LIBS"
94 [ echo "*** The test program compiled, but did not run. This usually means"
95 echo "*** that the run-time linker is not finding Ogg or finding the wrong"
96 echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
97 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
98 echo "*** to the installed location Also, make sure you have run ldconfig if that"
99 echo "*** is required on your system"
101 echo "*** If you have an old version installed, it is best to remove it, although"
102 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
103 [ echo "*** The test program failed to compile or link. See the file config.log for the"
104 echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
105 echo "*** or that you have moved Ogg since it was installed. In the latter case, you"
106 echo "*** may want to edit the ogg-config script: $OGG_CONFIG" ])
107 CFLAGS="$ac_save_CFLAGS"
112 ifelse([$2], , :, [$2])
119 # Configure paths for libvorbis
120 # Jack Moffitt <jack@icecast.org> 10-21-2000
121 # Shamelessly stolen from Owen Taylor and Manish Singh
123 dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
124 dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
126 AC_DEFUN([XIPH_PATH_VORBIS],
128 dnl Get the cflags and libraries
130 AC_ARG_WITH(vorbis,AC_HELP_STRING([--with-vorbis=PFX],[Prefix where libvorbis is installed (optional)]), vorbis_prefix="$withval", vorbis_prefix="")
131 AC_ARG_WITH(vorbis-libraries,AC_HELP_STRING([--with-vorbis-libraries=DIR],[Directory where libvorbis library is installed (optional)]), vorbis_libraries="$withval", vorbis_libraries="")
132 AC_ARG_WITH(vorbis-includes,AC_HELP_STRING([--with-vorbis-includes=DIR],[Directory where libvorbis header files are installed (optional)]), vorbis_includes="$withval", vorbis_includes="")
133 AC_ARG_ENABLE(vorbistest,AC_HELP_STRING([--disable-vorbistest],[Do not try to compile and run a test Vorbis program]),, enable_vorbistest=yes)
135 if test "x$vorbis_libraries" != "x" ; then
136 VORBIS_LIBS="-L$vorbis_libraries"
137 elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
139 elif test "x$vorbis_prefix" != "x" ; then
140 VORBIS_LIBS="-L$vorbis_prefix/lib"
141 elif test "x$prefix" != "xNONE"; then
142 VORBIS_LIBS="-L$prefix/lib"
145 VORBISFILE_LIBS="$VORBIS_LIBS -lvorbisfile"
146 VORBISENC_LIBS="$VORBIS_LIBS -lvorbisenc"
147 if test "x$vorbis_prefix" != "xno" ; then
148 VORBIS_LIBS="$VORBIS_LIBS -lvorbis"
151 if test "x$vorbis_includes" != "x" ; then
152 VORBIS_CFLAGS="-I$vorbis_includes"
153 elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
155 elif test "x$vorbis_prefix" != "x" ; then
156 VORBIS_CFLAGS="-I$vorbis_prefix/include"
157 elif test "x$prefix" != "xNONE"; then
158 VORBIS_CFLAGS="-I$prefix/include"
161 xiph_saved_LIBS="$LIBS"
163 AC_SEARCH_LIBS(cos, m, [VORBIS_LIBS="$VORBIS_LIBS $LIBS"], [
164 AC_MSG_WARN([cos() not found in math library, vorbis installation may not work])
166 LIBS="$xiph_saved_LIBS"
168 AC_MSG_CHECKING(for Vorbis)
169 if test "x$vorbis_prefix" = "xno" ; then
171 enable_vorbistest="no"
177 if test "x$enable_vorbistest" = "xyes" ; then
178 ac_save_CFLAGS="$CFLAGS"
180 CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
181 LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
183 dnl Now check if the installed Vorbis is sufficiently new.
185 rm -f conf.vorbistest
190 #include <vorbis/codec.h>
194 system("touch conf.vorbistest");
198 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
199 CFLAGS="$ac_save_CFLAGS"
203 if test "x$no_vorbis" = "xdisabled" ; then
205 ifelse([$2], , :, [$2])
206 elif test "x$no_vorbis" = "x" ; then
208 ifelse([$1], , :, [$1])
211 if test -f conf.vorbistest ; then
214 echo "*** Could not run Vorbis test program, checking why..."
215 CFLAGS="$CFLAGS $VORBIS_CFLAGS"
216 LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
219 #include <vorbis/codec.h>
221 [ echo "*** The test program compiled, but did not run. This usually means"
222 echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
223 echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
224 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
225 echo "*** to the installed location Also, make sure you have run ldconfig if that"
226 echo "*** is required on your system"
228 echo "*** If you have an old version installed, it is best to remove it, although"
229 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
230 [ echo "*** The test program failed to compile or link. See the file config.log for the"
231 echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
232 echo "*** or that you have moved Vorbis since it was installed." ])
233 CFLAGS="$ac_save_CFLAGS"
240 ifelse([$2], , :, [$2])
242 AC_SUBST(VORBIS_CFLAGS)
243 AC_SUBST(VORBIS_LIBS)
244 AC_SUBST(VORBISFILE_LIBS)
245 AC_SUBST(VORBISENC_LIBS)
246 rm -f conf.vorbistest
250 # Configure paths for libao
251 # Jack Moffitt <jack@icecast.org> 10-21-2000
252 # Shamelessly stolen from Owen Taylor and Manish Singh
254 dnl XIPH_PATH_AO([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
255 dnl Test for libao, and define AO_CFLAGS and AO_LIBS
257 AC_DEFUN([XIPH_PATH_AO],
259 dnl Get the cflags and libraries
261 AC_ARG_WITH(ao,AC_HELP_STRING([--with-ao=PFX],[Prefix where libao is installed (optional)]), ao_prefix="$withval", ao_prefix="")
262 AC_ARG_WITH(ao-libraries,AC_HELP_STRING([--with-ao-libraries=DIR],[Directory where libao library is installed (optional)]), ao_libraries="$withval", ao_libraries="")
263 AC_ARG_WITH(ao-includes,AC_HELP_STRING([--with-ao-includes=DIR],[Directory where libao header files are installed (optional)]), ao_includes="$withval", ao_includes="")
264 AC_ARG_ENABLE(aotest,AC_HELP_STRING([--disable-aotest],[Do not try to compile and run a test ao program]),, enable_aotest=yes)
266 if test "x$ao_prefix" != "xno"
268 if test "x$ao_libraries" != "x" ; then
269 AO_LIBS="-L$ao_libraries"
270 elif test "x$ao_prefix" = "xno" || test "x$ao_prefix" = "xyes" ; then
272 elif test "x$ao_prefix" != "x" -a "x$ao_prefix" != "xyes"; then
273 AO_LIBS="-L$ao_prefix/lib"
274 elif test "x$prefix" != "xNONE"; then
275 AO_LIBS="-L$prefix/lib"
278 if test "x$ao_includes" != "x" ; then
279 AO_CFLAGS="-I$ao_includes"
280 elif test "x$ao_prefix" = "xno" || test "x$ao_prefix" = "xyes" ; then
282 elif test "x$ao_prefix" != "x" -a "x$ao_prefix" != "xyes"; then
283 AO_CFLAGS="-I$ao_prefix/include"
284 elif test "x$prefix" != "xNONE"; then
285 AO_CFLAGS="-I$prefix/include"
288 # see where dl* and friends live
289 AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [
290 AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [
291 AC_MSG_WARN([could not find dlopen() needed by libao sound drivers
292 your system may not be supported.])
296 if test "x$ao_prefix" != "xno" ; then
297 AO_LIBS="$AO_LIBS -lao $AO_DL_LIBS"
300 AC_MSG_CHECKING(for ao)
301 if test "x$ao_prefix" = "xno" ; then
309 if test "x$enable_aotest" = "xyes" ; then
310 ac_save_CFLAGS="$CFLAGS"
312 CFLAGS="$CFLAGS $AO_CFLAGS"
313 LIBS="$LIBS $AO_LIBS"
315 dnl Now check if the installed ao is sufficiently new.
326 system("touch conf.aotest");
330 ],, no_ao=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
331 CFLAGS="$ac_save_CFLAGS"
335 if test "x$no_ao" = "xdisabled" ; then
337 ifelse([$2], , :, [$2])
338 elif test "x$no_ao" = "x" ; then
340 ifelse([$1], , :, [$1])
343 if test -f conf.aotest ; then
346 echo "*** Could not run ao test program, checking why..."
347 CFLAGS="$CFLAGS $AO_CFLAGS"
348 LIBS="$LIBS $AO_LIBS"
353 [ echo "*** The test program compiled, but did not run. This usually means"
354 echo "*** that the run-time linker is not finding ao or finding the wrong"
355 echo "*** version of ao. If it is not finding ao, you'll need to set your"
356 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
357 echo "*** to the installed location Also, make sure you have run ldconfig if that"
358 echo "*** is required on your system"
360 echo "*** If you have an old version installed, it is best to remove it, although"
361 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
362 [ echo "*** The test program failed to compile or link. See the file config.log for the"
363 echo "*** exact error that occured. This usually means ao was incorrectly installed"
364 echo "*** or that you have moved ao since it was installed." ])
365 CFLAGS="$ac_save_CFLAGS"
370 ifelse([$2], , :, [$2])
378 dnl This macros shamelessly stolen from
379 dnl http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg01398.html.
380 dnl Written by Bruno Haible.
384 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
385 dnl those with the standalone portable GNU libiconv installed).
387 AC_ARG_WITH([libiconv-prefix],
388 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
389 for dir in `echo "$withval" | tr : ' '`; do
390 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
391 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
395 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
396 am_cv_func_iconv="no, consider installing GNU libiconv"
398 AC_TRY_LINK([#include <stdlib.h>
400 [iconv_t cd = iconv_open("","");
401 iconv(cd,NULL,NULL,NULL,NULL);
403 am_cv_func_iconv=yes)
404 if test "$am_cv_func_iconv" != yes; then
407 AC_TRY_LINK([#include <stdlib.h>
409 [iconv_t cd = iconv_open("","");
410 iconv(cd,NULL,NULL,NULL,NULL);
413 am_cv_func_iconv=yes)
417 if test "$am_cv_func_iconv" = yes; then
418 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
419 AC_MSG_CHECKING([for iconv declaration])
420 AC_CACHE_VAL(am_cv_proto_iconv, [
428 #if defined(__STDC__) || defined(__cplusplus)
429 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
433 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
434 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
435 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
436 AC_MSG_RESULT([$]{ac_t:-
437 }[$]am_cv_proto_iconv)
438 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
439 [Define as const if the declaration of iconv() needs const.])
442 if test "$am_cv_lib_iconv" = yes; then
448 dnl From Bruno Haible.
450 AC_DEFUN([AM_LANGINFO_CODESET],
452 AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
453 [AC_TRY_LINK([#include <langinfo.h>],
454 [char* cs = nl_langinfo(CODESET);],
455 am_cv_langinfo_codeset=yes,
456 am_cv_langinfo_codeset=no)
458 if test $am_cv_langinfo_codeset = yes; then
459 AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
460 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
464 dnl AM_PATH_CURL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
465 dnl Test for libcurl, and define CURL_CFLAGS and CURL_LIBS
467 AC_DEFUN([AM_PATH_CURL],
469 dnl Get the cflags and libraries
471 AC_ARG_WITH(curl,[ --with-curl=PFX Prefix where libcurl is installed (optional)], curl_prefix="$withval", curl_prefix="")
472 AC_ARG_WITH(curl-libraries,[ --with-curl-libraries=DIR Directory where libcurl library is installed (optional)], curl_libraries="$withval", curl_libraries="")
473 AC_ARG_WITH(curl-includes,[ --with-curl-includes=DIR Directory where libcurl header files are installed (optional)], curl_includes="$withval", curl_includes="")
474 AC_ARG_ENABLE(curltest, [ --disable-curltest Do not try to compile and run a test libcurl program],, enable_curltest=yes)
476 if test "x$curl_prefix" != "xno" ; then
478 if test "x$curl_libraries" != "x" ; then
479 CURL_LIBS="-L$curl_libraries"
480 elif test "x$curl_prefix" != "x" ; then
481 CURL_LIBS="-L$curl_prefix/lib"
482 elif test "x$prefix" != "xNONE" ; then
483 CURL_LIBS="-L$prefix/lib"
486 CURL_LIBS="$CURL_LIBS -lcurl"
488 if test "x$curl_includes" != "x" ; then
489 CURL_CFLAGS="-I$curl_includes"
490 elif test "x$curl_prefix" != "x" ; then
491 CURL_CFLAGS="-I$curl_prefix/include"
492 elif test "x$prefix" != "xNONE"; then
493 CURL_CFLAGS="-I$prefix/include"
496 AC_MSG_CHECKING(for libcurl)
500 if test "x$enable_curltest" = "xyes" ; then
501 ac_save_CFLAGS="$CFLAGS"
503 CFLAGS="$CFLAGS $CURL_CFLAGS"
504 LIBS="$LIBS $CURL_LIBS"
506 dnl Now check if the installed libcurl is sufficiently new.
513 #include <curl/curl.h>
517 system("touch conf.curltest");
521 ],, no_curl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
522 CFLAGS="$ac_save_CFLAGS"
526 if test "x$no_curl" = "x" ; then
528 AC_DEFINE(HAVE_CURL, 1, [Define if you have libcurl.])
529 ifelse([$1], , :, [$1])
532 if test -f conf.curltest ; then
535 echo "*** Could not run libcurl test program, checking why..."
536 CFLAGS="$CFLAGS $CURL_CFLAGS"
537 LIBS="$LIBS $CURL_LIBS"
540 #include <curl/curl.h>
542 [ echo "*** The test program compiled, but did not run. This usually means"
543 echo "*** that the run-time linker is not finding libcurl or finding the wrong"
544 echo "*** version of libcurl. If it is not finding libcurl, you'll need to set your"
545 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
546 echo "*** to the installed location Also, make sure you have run ldconfig if that"
547 echo "*** is required on your system"
549 echo "*** If you have an old version installed, it is best to remove it, although"
550 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
551 [ echo "*** The test program failed to compile or link. See the file config.log for the"
552 echo "*** exact error that occured. This usually means libcurl was incorrectly installed"
553 echo "*** or that you have moved libcurl since it was installed." ])
554 CFLAGS="$ac_save_CFLAGS"
559 ifelse([$2], , :, [$2])
565 AC_SUBST(CURL_CFLAGS)
571 dnl ACX_PTHREAD macro by Steven G. Johnson <stevenj@alum.mit.edu> and
572 dnl Alejandro Forero Cuervo <bachue@bachue.com>. Found at:
573 dnl http://www.gnu.org/software/ac-archive/Installed_Packages/acx_pthread.html
575 AC_DEFUN([ACX_PTHREAD], [
576 AC_REQUIRE([AC_CANONICAL_HOST])
579 # First, check if the POSIX threads header, pthread.h, is available.
580 # If it isn't, don't bother looking for the threads libraries.
581 AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader)
583 # We must check for the threads library under a number of different
584 # names; the ordering is very important because some systems
585 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
586 # libraries is broken (non-POSIX).
588 # First of all, check if the user has set any of the PTHREAD_LIBS,
589 # etcetera environment variables, and if threads linking works using
591 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
592 save_CFLAGS="$CFLAGS"
593 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
595 LIBS="$PTHREAD_LIBS $LIBS"
596 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
597 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
598 AC_MSG_RESULT($acx_pthread_ok)
599 if test x"$acx_pthread_ok" = xno; then
604 CFLAGS="$save_CFLAGS"
607 # Create a list of thread flags to try. Items starting with a "-" are
608 # C compiler flags, and other items are library names, except for "none"
609 # which indicates that we try without any flags at all.
611 acx_pthread_flags="pthreads none -Kthread -kthread lthread pthread -pthread -pthreads -mthreads --thread-safe -mt"
613 # The ordering *is* (sometimes) important. Some notes on the
614 # individual items follow:
616 # pthreads: AIX (must check this before -lpthread)
617 # none: in case threads are in libc; should be tried before -Kthread and
618 # other compiler flags to prevent continual compiler warnings
619 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
620 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
621 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
622 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
623 # -pthreads: Solaris/gcc
624 # -mthreads: Mingw32/gcc, Lynx/gcc
625 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
626 # doesn't hurt to check since this sometimes defines pthreads too;
627 # also defines -D_REENTRANT)
628 # pthread: Linux, etcetera
629 # --thread-safe: KAI C++
631 case "${host_cpu}-${host_os}" in
634 # On Solaris (at least, for some versions), libc contains stubbed
635 # (non-functional) versions of the pthreads routines, so link-based
636 # tests will erroneously succeed. (We need to link with -pthread or
637 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
638 # a function called by this macro, so we could check for that, but
639 # who knows whether they'll stub that too in a future libc.) So,
640 # we'll just look for -pthreads and -lpthread first:
641 acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
645 if test x"$acx_pthread_ok" = xno; then
646 for flag in $acx_pthread_flags; do
650 AC_MSG_CHECKING([whether pthreads work without any flags])
654 AC_MSG_CHECKING([whether pthreads work with $flag])
655 PTHREAD_CFLAGS="$flag"
659 AC_MSG_CHECKING([for the pthreads library -l$flag])
660 PTHREAD_LIBS="-l$flag"
665 save_CFLAGS="$CFLAGS"
666 LIBS="$PTHREAD_LIBS $LIBS"
667 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
669 # Check for various functions. We must include pthread.h,
670 # since some functions may be macros. (On the Sequent, we
671 # need a special flag -Kthread to make this header compile.)
672 # We check for pthread_join because it is in -lpthread on IRIX
673 # while pthread_create is in libc. We check for pthread_attr_init
674 # due to DEC craziness with -lpthreads. We check for
675 # pthread_cleanup_push because it is one of the few pthread
676 # functions on Solaris that doesn't have a non-functional libc stub.
677 # We try pthread_create on general principles.
678 AC_TRY_LINK([#include <pthread.h>],
679 [pthread_t th; pthread_join(th, 0);
680 pthread_attr_init(0); pthread_cleanup_push(0, 0);
681 pthread_create(0,0,0,0);
682 pthread_cancel(0); pthread_cleanup_pop(0); ],
683 [acx_pthread_ok=yes])
686 CFLAGS="$save_CFLAGS"
688 AC_MSG_RESULT($acx_pthread_ok)
689 if test "x$acx_pthread_ok" = xyes; then
698 # Various other checks:
699 if test "x$acx_pthread_ok" = xyes; then
701 LIBS="$PTHREAD_LIBS $LIBS"
702 save_CFLAGS="$CFLAGS"
703 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
705 # Detect AIX lossage: threads are created detached by default
706 # and the JOINABLE attribute has a nonstandard name (UNDETACHED).
707 AC_MSG_CHECKING([for joinable pthread attribute])
708 AC_TRY_LINK([#include <pthread.h>],
709 [int attr=PTHREAD_CREATE_JOINABLE;],
710 ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
711 if test x"$ok" = xunknown; then
712 AC_TRY_LINK([#include <pthread.h>],
713 [int attr=PTHREAD_CREATE_UNDETACHED;],
714 ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
716 if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
717 AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
718 [Define to the necessary symbol if this constant
719 uses a non-standard name on your system.])
722 if test x"$ok" = xunknown; then
723 AC_MSG_WARN([we do not know how to create joinable pthreads])
726 AC_MSG_CHECKING([if more special flags are required for pthreads])
728 case "${host_cpu}-${host_os}" in
729 *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
730 *solaris* | alpha*-osf*) flag="-D_REENTRANT";;
732 AC_MSG_RESULT(${flag})
733 if test "x$flag" != xno; then
734 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
738 CFLAGS="$save_CFLAGS"
740 # More AIX lossage: must compile with cc_r
741 AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
746 AC_SUBST(PTHREAD_LIBS)
747 AC_SUBST(PTHREAD_CFLAGS)
750 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
751 if test x"$acx_pthread_ok" = xyes; then
752 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])