2 # Begin pthreads checking.
4 # First, decide whether to use multithreading or not.
6 # Enable multithreading by default on systems where it is known
7 # to work well, and where debugging of multithreaded programs
11 AC_MSG_CHECKING(whether to build with thread support)
17 # Thread signals are broken on Solaris 2.6; they are sometimes
18 # delivered to the wrong thread.
30 *-sco-sysv*uw*|*-*-sysv*UnixWare*)
37 if test -r /usr/lib/libpthread.so ; then
40 # Socket I/O optimizations introduced in 9.2 expose a
41 # bug in unproven-pthreads; see PR #12650
46 # OpenBSD users have reported that named dumps core on
47 # startup when built with threads.
52 # Thread signals do not work reliably on some versions of BSD/OS.
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().
65 AC_ARG_ENABLE(threads,
66 [ --enable-threads enable multithreading])
67 case "$enable_threads" in
75 # Use system-dependent default
78 AC_MSG_ERROR([--enable-threads takes yes or no])
92 # Search for / configure pthreads in a system-dependent fashion.
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.
104 AC_MSG_CHECKING(which NetBSD thread library to use)
107 [ --with-ptl2 on NetBSD, use the ptl2 thread library (experimental)],
108 use_ptl2="$withval", use_ptl2="no")
110 : ${LOCALBASE:=/usr/pkg}
112 if test "X$use_ptl2" = "Xyes"
116 [linking with PTL2 is highly experimental and not expected to work])
119 if test -r /usr/lib/libpthread.so
121 AC_MSG_RESULT(native)
122 LIBS="-lpthread $LIBS"
124 if test ! -d $LOCALBASE/pthreads
127 AC_MSG_ERROR("could not find thread libraries")
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"
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.
149 if test "X$GCC" = "Xyes"; then
152 AC_MSG_CHECKING(for gcc -pthread support);
153 AC_TRY_LINK([#include <pthread.h>],
154 [printf("%x\n", pthread_create);],
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")))))
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"))))))