2 dnl CY_AC_WITH_THREADS determines which thread library the user intends
3 dnl to put underneath guile. Pass it the path to find the guile top-level
4 dnl source directory. Eg CY_AC_WITH_THREADS(../..) for tcl/unix.
7 AC_DEFUN([CY_AC_WITH_THREADS],[
8 AC_CACHE_CHECK("threads package type",cy_cv_threads_package,[
9 AC_CACHE_VAL(cy_cv_threads_cflags,[
10 AC_CACHE_VAL(cy_cv_threads_libs,[
12 AC_ARG_WITH(threads,[ --with-threads thread interface],
13 use_threads=$withval, use_threads=no)
14 test -n "$use_threads" || use_threads=qt
15 threads_package=unknown
16 if test "$use_threads" != no; then
18 dnl Test for the qt threads package - used for cooperative threads
19 dnl This may not necessarily be built yet - so just check for the
22 if test "$use_threads" = yes || test "$use_threads" = qt; then
23 # Look for qt in source directory.
24 if test -f $srcdir/qt/qt.c; then
25 qtsrcdir="`(cd $srcdir; pwd)`/qt"
27 cy_cv_threads_cflags="-I$qtsrcdir -I../qt"
28 cy_cv_threads_libs="../qt/libqt.a"
31 if test -f $use_threads/qt.c; then
32 # FIXME seems as though we should try to use an installed qt here.
34 cy_cv_threads_cflags="-I$use_threads -I../qt"
35 cy_cv_threads_libs="../qt/libqt.a"
38 if test "$use_threads" = pthreads; then
39 # Look for pthreads in srcdir. See above to understand why
40 # we always set threads_package.
41 if test -f $srcdir/../../pthreads/pthreads/queue.c \
42 || test -f $srcdir/../pthreads/pthreads/queue.c; then
44 cy_cv_threads_cflags="-I$srcdir/../../pthreads/include"
45 cy_cv_threads_libs="-L../../pthreads/lib -lpthread"
51 if test "$threads_package" = unknown; then
53 dnl Test for the FSU threads package
55 CPPFLAGS="-I$use_threads/include"
56 LDFLAGS="-L$use_threads/lib"
57 LIBS="-lgthreads -lmalloc"
58 AC_TRY_LINK([#include <pthread.h>],[
59 pthread_equal(NULL,NULL);
60 ], threads_package=FSU)
62 if test "$threads_package" = unknown; then
64 dnl Test for the MIT threads package
67 AC_TRY_LINK([#include <pthread.h>],[
68 pthread_equal(NULL,NULL);
69 ], threads_package=MIT)
71 if test "$threads_package" = unknown; then
73 dnl Test for the PCthreads package
76 AC_TRY_LINK([#include <pthread.h>],[
77 pthread_equal(NULL,NULL);
78 ], threads_package=PCthreads)
81 dnl Set the appropriate flags!
83 cy_cv_threads_cflags="$CPPFLAGS $cy_cv_threads_cflags"
84 cy_cv_threads_libs="$LDFLAGS $LIBS $cy_cv_threads_libs"
85 cy_cv_threads_package=$threads_package
89 if test "$threads_package" = unknown; then
90 AC_MSG_ERROR("cannot find thread library installation")
97 dnl Set flags according to what is cached.
99 CPPFLAGS="$cy_cv_threads_cflags"
100 LIBS="$cy_cv_threads_libs"