scm_array_map & co
[bpt/guile.git] / threads.m4
CommitLineData
733943b9
TT
1dnl
2dnl CY_AC_WITH_THREADS determines which thread library the user intends
3dnl to put underneath guile. Pass it the path to find the guile top-level
4dnl source directory. Eg CY_AC_WITH_THREADS(../..) for tcl/unix.
5dnl
6
7AC_DEFUN([CY_AC_WITH_THREADS],[
8AC_CACHE_CHECK("threads package type",cy_cv_threads_package,[
9AC_CACHE_VAL(cy_cv_threads_cflags,[
10AC_CACHE_VAL(cy_cv_threads_libs,[
11use_threads=no;
12AC_ARG_WITH(threads,[ --with-threads thread interface],
13 use_threads=$withval, use_threads=no)
14test -n "$use_threads" || use_threads=qt
15threads_package=unknown
16if test "$use_threads" != no; then
17dnl
18dnl Test for the qt threads package - used for cooperative threads
19dnl This may not necessarily be built yet - so just check for the
20dnl header files.
21dnl
22 if test "$use_threads" = yes || test "$use_threads" = qt; then
fe4d391f
JB
23 # Look for qt in source directory.
24 if test -f $srcdir/qt/qt.c; then
25 qtsrcdir="`(cd $srcdir; pwd)`/qt"
733943b9 26 threads_package=COOP
fe4d391f 27 cy_cv_threads_cflags="-I$qtsrcdir -I../qt"
b110e21e 28 cy_cv_threads_libs="../qt/libqt.a"
733943b9
TT
29 fi
30 else
31 if test -f $use_threads/qt.c; then
32 # FIXME seems as though we should try to use an installed qt here.
33 threads_package=COOP
34 cy_cv_threads_cflags="-I$use_threads -I../qt"
b110e21e 35 cy_cv_threads_libs="../qt/libqt.a"
733943b9
TT
36 fi
37 fi
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
43 threads_package=MIT
44 cy_cv_threads_cflags="-I$srcdir/../../pthreads/include"
45 cy_cv_threads_libs="-L../../pthreads/lib -lpthread"
46 fi
47 fi
48 saved_CPP="$CPPFLAGS"
49 saved_LD="$LDFLAGS"
50 saved_LIBS="$LIBS"
51 if test "$threads_package" = unknown; then
52dnl
53dnl Test for the FSU threads package
54dnl
55 CPPFLAGS="-I$use_threads/include"
56 LDFLAGS="-L$use_threads/lib"
57 LIBS="-lgthreads -lmalloc"
58 AC_TRY_LINK([#include <pthread.h>],[
59pthread_equal(NULL,NULL);
60], threads_package=FSU)
61 fi
62 if test "$threads_package" = unknown; then
63dnl
64dnl Test for the MIT threads package
65dnl
66 LIBS="-lpthread"
67 AC_TRY_LINK([#include <pthread.h>],[
68pthread_equal(NULL,NULL);
69], threads_package=MIT)
70 fi
71 if test "$threads_package" = unknown; then
72dnl
73dnl Test for the PCthreads package
74dnl
75 LIBS="-lpthreads"
76 AC_TRY_LINK([#include <pthread.h>],[
77pthread_equal(NULL,NULL);
78], threads_package=PCthreads)
79 fi
80dnl
81dnl Set the appropriate flags!
82dnl
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
86 CPPFLAGS="$saved_CPP"
87 LDFLAGS="$saved_LD"
88 LIBS="$saved_LIBS"
89 if test "$threads_package" = unknown; then
90 AC_MSG_ERROR("cannot find thread library installation")
91 fi
92fi
93])
94])
95],
96dnl
97dnl Set flags according to what is cached.
98dnl
99CPPFLAGS="$cy_cv_threads_cflags"
100LIBS="$cy_cv_threads_libs"
101)
102])