gsstest: fixed compilation errors
[tridge/bind9.git] / config.threads.in
1 #
2 # Begin pthreads checking.
3 #
4 # First, decide whether to use multithreading or not.
5 #
6 # Enable multithreading by default on systems where it is known
7 # to work well, and where debugging of multithreaded programs
8 # is supported.
9 #
10
11 AC_MSG_CHECKING(whether to build with thread support)
12
13 case $host in
14 *-dec-osf*)
15         use_threads=true ;;
16 [*-solaris2.[0-6]])
17         # Thread signals are broken on Solaris 2.6; they are sometimes
18         # delivered to the wrong thread.
19         use_threads=false ;;
20 *-solaris*)
21         use_threads=true ;;
22 *-ibm-aix*)
23         use_threads=true ;;
24 *-hp-hpux10*)
25         use_threads=false ;;
26 *-hp-hpux11*)
27         use_threads=true ;;
28 *-sgi-irix*)
29         use_threads=true ;;
30 *-sco-sysv*uw*|*-*-sysv*UnixWare*)
31         # UnixWare
32         use_threads=false ;;
33 *-*-sysv*OpenUNIX*)
34         # UnixWare
35         use_threads=true ;;
36 *-netbsd*)
37         if test -r /usr/lib/libpthread.so ; then
38             use_threads=true
39         else
40             # Socket I/O optimizations introduced in 9.2 expose a
41             # bug in unproven-pthreads; see PR #12650
42             use_threads=false
43         fi
44         ;;
45 *-openbsd*)
46         # OpenBSD users have reported that named dumps core on
47         # startup when built with threads.
48         use_threads=false ;;
49 *-freebsd*)
50         use_threads=false ;;
51 *-bsdi[234]*)
52         # Thread signals do not work reliably on some versions of BSD/OS.
53         use_threads=false ;;
54 *-bsdi5*)
55         use_threads=true ;;
56 *-linux*)
57         # Threads are disabled on Linux by default because most
58         # Linux kernels produce unusable core dumps from multithreaded
59         # programs, and because of limitations in setuid().
60         use_threads=false ;;    
61 *)
62         use_threads=false ;;
63 esac
64
65 AC_ARG_ENABLE(threads,
66         [  --enable-threads     enable multithreading])
67 case "$enable_threads" in
68         yes)
69                 use_threads=true
70                 ;;
71         no)
72                 use_threads=false
73                 ;;
74         '')
75                 # Use system-dependent default
76                 ;;
77         *)
78                 AC_MSG_ERROR([--enable-threads takes yes or no])
79                 ;;
80 esac
81
82 if $use_threads
83 then
84         AC_MSG_RESULT(yes)
85 else
86         AC_MSG_RESULT(no)       
87 fi
88
89 if $use_threads
90 then
91         #
92         # Search for / configure pthreads in a system-dependent fashion.
93         #
94         case "$host" in
95           *-netbsd*)
96                 # NetBSD has multiple pthreads implementations.  The
97                 # recommended one to use is "unproven-pthreads".  The
98                 # older "mit-pthreads" may also work on some NetBSD
99                 # versions.  The PTL2 thread library does not
100                 # currently work with bind9, but can be chosen with
101                 # the --with-ptl2 option for those who wish to
102                 # experiment with it.
103                 CC="gcc"
104                 AC_MSG_CHECKING(which NetBSD thread library to use)
105
106                 AC_ARG_WITH(ptl2,
107 [  --with-ptl2          on NetBSD, use the ptl2 thread library (experimental)],
108                     use_ptl2="$withval", use_ptl2="no")
109
110                 : ${LOCALBASE:=/usr/pkg}
111
112                 if test "X$use_ptl2" = "Xyes"
113                 then
114                         AC_MSG_RESULT(PTL2)
115                         AC_MSG_WARN(
116 [linking with PTL2 is highly experimental and not expected to work])
117                         CC=ptlgcc
118                 else
119                         if test -r /usr/lib/libpthread.so
120                         then
121                                 AC_MSG_RESULT(native)
122                                 LIBS="-lpthread $LIBS"
123                         else
124                                 if test ! -d $LOCALBASE/pthreads
125                                 then
126                                         AC_MSG_RESULT(none)
127                                         AC_MSG_ERROR("could not find thread libraries")
128                                 fi
129
130                                 if $use_threads
131                                 then
132                                         AC_MSG_RESULT(mit-pthreads/unproven-pthreads)
133                                         pkg="$LOCALBASE/pthreads"
134                                         lib1="-L$pkg/lib -Wl,-R$pkg/lib"
135                                         lib2="-lpthread -lm -lgcc -lpthread"
136                                         LIBS="$lib1 $lib2 $LIBS"
137                                         CPPFLAGS="$CPPFLAGS -I$pkg/include"
138                                         STD_CINCLUDES="$STD_CINCLUDES -I$pkg/include"
139                                 fi
140                         fi
141                 fi
142                 ;;
143                 *-freebsd*)
144                         # We don't want to set -lpthread as that break
145                         # the ability to choose threads library at final
146                         # link time and is not valid for all architectures.
147                         
148                         PTHREAD=
149                         if test "X$GCC" = "Xyes"; then
150                                 saved_cc="$CC"
151                                 CC="$CC -pthread"
152                                 AC_MSG_CHECKING(for gcc -pthread support);
153                                 AC_TRY_LINK([#include <pthread.h>],
154                                             [printf("%x\n", pthread_create);],
155                                             PTHREAD="yes"
156                                             AC_MSG_RESULT(yes),
157                                             AC_MSG_RESULT(no))
158                                 CC="$saved_cc"
159                         fi
160                         if test "X$PTHREAD" != "Xyes"; then
161                                 AC_CHECK_LIB(pthread, pthread_create,,
162                                 AC_CHECK_LIB(thr, thread_create,,
163                                 AC_CHECK_LIB(c_r, pthread_create,,
164                                 AC_CHECK_LIB(c, pthread_create,,
165                                 AC_MSG_ERROR("could not find thread libraries")))))
166                         fi
167                         ;;
168                 *)
169                         AC_CHECK_LIB(pthread, pthread_create,,
170                                 AC_CHECK_LIB(pthread, __pthread_create,,
171                                 AC_CHECK_LIB(pthread, __pthread_create_system,,
172                                 AC_CHECK_LIB(c_r, pthread_create,,
173                                 AC_CHECK_LIB(c, pthread_create,,
174                                 AC_MSG_ERROR("could not find thread libraries"))))))
175                 ;;
176         esac
177 fi