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