s4:torture: Adapt KDC canon test to Heimdal upstream changes
[samba.git] / source4 / heimdal / cf / pthreads.m4
1 Dnl $Id$
2
3 AC_DEFUN([KRB_PTHREADS], [
4 AC_MSG_CHECKING(if compiling threadsafe libraries)
5
6 AC_ARG_ENABLE(pthread-support,
7         AS_HELP_STRING([--enable-pthread-support],
8                         [if you want thread safe libraries]),
9         [],[enable_pthread_support=maybe])
10
11 case "$host" in 
12 *-*-solaris2*)
13         native_pthread_support=yes
14         if test "$GCC" = yes; then
15                 PTHREAD_CFLAGS="-D_REENTRANT -D_TS_ERRNO"
16                 PTHREAD_LIBADD=-lpthread
17         else
18                 PTHREAD_CFLAGS="-mt -D_REENTRANT -D_TS_ERRNO"
19                 PTHREAD_LDADD=-mt
20                 PTHREAD_LIBADD="-mt -lpthread"
21         fi
22         ;;
23 *-*-netbsd[[12]]*)
24         native_pthread_support="if running netbsd 1.6T or newer"
25         dnl heim_threads.h knows this
26         PTHREAD_LIBADD="-lpthread"
27         ;;
28 *-*-netbsd[[3456789]]*)
29         native_pthread_support="netbsd 3 uses explict pthread"
30         dnl heim_threads.h knows this
31         PTHREAD_LIBADD="-lpthread"
32         ;;
33 *-*-freebsd[[1234]])
34     ;;
35 *-*-freebsd*)
36         native_pthread_support=yes
37         PTHREAD_LIBADD="-pthread"
38         ;;
39 *-*-openbsd*)
40         native_pthread_support=yes
41         PTHREAD_CFLAGS=-pthread
42         PTHREAD_LIBADD=-pthread
43         ;;
44 *-*-gnu*)
45         native_pthread_support=yes
46         PTHREADS_CFLAGS=-pthread
47         PTHREAD_LIBADD="-pthread -lpthread"
48         ;;
49 *-*-linux* | *-*-linux-gnu)
50         case `uname -r` in
51         2.*|3.*)
52                 native_pthread_support=yes
53                 PTHREAD_CFLAGS=-pthread
54                 PTHREAD_LIBADD=-pthread
55                 ;;
56         esac
57         ;;
58 *-*-kfreebsd*-gnu*)
59         native_pthread_support=yes
60         PTHREAD_CFLAGS=-pthread
61         PTHREAD_LIBADD=-pthread
62         ;;
63 *-*-aix*)
64         dnl AIX is disabled since we don't handle the utmp/utmpx
65         dnl problems that aix causes when compiling with pthread support
66         dnl (2016-11-14, we longer use utmp).  Original logic was:
67         dnl     if test "$GCC" = yes; then
68         dnl             native_pthread_support=yes
69         dnl             PTHREADS_LIBS="-pthread"
70         dnl     elif expr "$CC" : ".*_r" > /dev/null ; then
71         dnl             native_pthread_support=yes
72         dnl             PTHREADS_CFLAGS=""
73         dnl             PTHREADS_LIBS=""
74         dnl     else
75         dnl             native_pthread_support=no
76         dnl     fi
77         native_pthread_support=no
78         ;;
79 mips-sgi-irix6.[[5-9]])  # maybe works for earlier versions too
80         native_pthread_support=yes
81         PTHREAD_LIBADD="-lpthread"
82         ;;
83 *-*-darwin*)
84         native_pthread_support=yes
85         ;;
86 *)
87         native_pthread_support=no
88         ;;
89 esac
90
91 if test "$enable_pthread_support" = maybe ; then
92         enable_pthread_support="$native_pthread_support"
93 fi
94         
95 if test "$enable_pthread_support" != no; then
96     AC_DEFINE(ENABLE_PTHREAD_SUPPORT, 1,
97         [Define if you want have a thread safe libraries])
98     dnl This sucks, but libtool doesn't save the depenecy on -pthread
99     dnl for libraries.
100     LIBS="$PTHREAD_LIBADD $LIBS"
101 else
102   PTHREAD_CFLAGS=""
103   PTHREAD_LIBADD=""
104 fi
105
106 AM_CONDITIONAL(ENABLE_PTHREAD_SUPPORT, test "$enable_pthread_support" != no)
107
108 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
109 LDADD="$LDADD $PTHREAD_LDADD"
110 LIBADD="$LIBADD $PTHREAD_LIBADD"
111
112 AC_SUBST(PTHREAD_CFLAGS)
113 AC_SUBST(PTHREAD_LDADD)
114 AC_SUBST(PTHREAD_LIBADD)
115
116 AC_MSG_RESULT($enable_pthread_support)
117 ])