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 11AC_MSG_CHECKING(whether to build with thread support) 12 13case $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[1234].*]) 37 # NetBSD earlier than NetBSD 5.0 has poor pthreads. 38 # Don't use it by default. 39 use_threads=false ;; 40*-netbsd*) 41 use_threads=true ;; 42*-openbsd*) 43 # OpenBSD users have reported that named dumps core on 44 # startup when built with threads. 45 use_threads=false ;; 46*-freebsd*) 47 use_threads=false ;; 48[*-bsdi[234]*]) 49 # Thread signals do not work reliably on some versions of BSD/OS. 50 use_threads=false ;; 51*-bsdi5*) 52 use_threads=true ;; 53*-linux*) 54 # Threads are disabled on Linux by default because most 55 # Linux kernels produce unusable core dumps from multithreaded 56 # programs, and because of limitations in setuid(). 57 use_threads=false ;; 58*) 59 use_threads=false ;; 60esac 61 62AC_ARG_ENABLE(threads, 63 [ --enable-threads enable multithreading]) 64case "$enable_threads" in 65 yes) 66 use_threads=true 67 ;; 68 no) 69 use_threads=false 70 ;; 71 '') 72 # Use system-dependent default 73 ;; 74 *) 75 AC_MSG_ERROR([--enable-threads takes yes or no]) 76 ;; 77esac 78 79if $use_threads 80then 81 AC_MSG_RESULT(yes) 82else 83 AC_MSG_RESULT(no) 84fi 85 86if $use_threads 87then 88 # 89 # Search for / configure pthreads in a system-dependent fashion. 90 # 91 case "$host" in 92 *-freebsd*) 93 # We don't want to set -lpthread as that break 94 # the ability to choose threads library at final 95 # link time and is not valid for all architectures. 96 97 PTHREAD= 98 if test "X$GCC" = "Xyes"; then 99 saved_cc="$CC" 100 CC="$CC -pthread" 101 AC_MSG_CHECKING(for gcc -pthread support); 102 AC_TRY_LINK([#include <pthread.h>], 103 [printf("%x\n", pthread_create);], 104 PTHREAD="yes" 105 AC_MSG_RESULT(yes), 106 AC_MSG_RESULT(no)) 107 CC="$saved_cc" 108 fi 109 if test "X$PTHREAD" != "Xyes"; then 110 AC_CHECK_LIB(pthread, pthread_create,, 111 AC_CHECK_LIB(thr, thread_create,, 112 AC_CHECK_LIB(c_r, pthread_create,, 113 AC_CHECK_LIB(c, pthread_create,, 114 AC_MSG_ERROR("could not find thread libraries"))))) 115 fi 116 ;; 117 *) 118 AC_CHECK_LIB(pthread, pthread_create,, 119 AC_CHECK_LIB(pthread, __pthread_create,, 120 AC_CHECK_LIB(pthread, __pthread_create_system,, 121 AC_CHECK_LIB(c_r, pthread_create,, 122 AC_CHECK_LIB(c, pthread_create,, 123 AC_MSG_ERROR("could not find thread libraries")))))) 124 ;; 125 esac 126fi 127