Commit | Line | Data |
---|---|---|
733943b9 TT |
1 | dnl |
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. | |
5 | dnl | |
6 | ||
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,[ | |
11 | use_threads=no; | |
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 | |
17 | dnl | |
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 | |
20 | dnl header files. | |
21 | dnl | |
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 | |
52 | dnl | |
53 | dnl Test for the FSU threads package | |
54 | dnl | |
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) | |
61 | fi | |
62 | if test "$threads_package" = unknown; then | |
63 | dnl | |
64 | dnl Test for the MIT threads package | |
65 | dnl | |
66 | LIBS="-lpthread" | |
67 | AC_TRY_LINK([#include <pthread.h>],[ | |
68 | pthread_equal(NULL,NULL); | |
69 | ], threads_package=MIT) | |
70 | fi | |
71 | if test "$threads_package" = unknown; then | |
72 | dnl | |
73 | dnl Test for the PCthreads package | |
74 | dnl | |
75 | LIBS="-lpthreads" | |
76 | AC_TRY_LINK([#include <pthread.h>],[ | |
77 | pthread_equal(NULL,NULL); | |
78 | ], threads_package=PCthreads) | |
79 | fi | |
80 | dnl | |
81 | dnl Set the appropriate flags! | |
82 | dnl | |
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 | |
92 | fi | |
93 | ]) | |
94 | ]) | |
95 | ], | |
96 | dnl | |
97 | dnl Set flags according to what is cached. | |
98 | dnl | |
99 | CPPFLAGS="$cy_cv_threads_cflags" | |
100 | LIBS="$cy_cv_threads_libs" | |
101 | ) | |
102 | ]) |