]> git.pld-linux.org Git - packages/amavisd.git/blob - amavisd-acx_pthread.patch
- drop obsolete and outdated manual inclusion of rpm macros
[packages/amavisd.git] / amavisd-acx_pthread.patch
1 diff -Nur amavisd-0.1.orig/acinclude.m4 amavisd-0.1.chng/acinclude.m4
2 --- amavisd-0.1.orig/acinclude.m4       Thu Jan  1 01:00:00 1970
3 +++ amavisd-0.1.chng/acinclude.m4       Sun Jan 19 23:31:33 2003
4 @@ -0,0 +1,190 @@
5 +dnl Available from the GNU Autoconf Macro Archive at:
6 +dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html
7 +dnl
8 +AC_DEFUN([ACX_PTHREAD], [
9 +AC_REQUIRE([AC_CANONICAL_HOST])
10 +AC_LANG_SAVE
11 +AC_LANG_C
12 +acx_pthread_ok=no
13 +
14 +# We used to check for pthread.h first, but this fails if pthread.h
15 +# requires special compiler flags (e.g. on True64 or Sequent).
16 +# It gets checked for in the link test anyway.
17 +
18 +# First of all, check if the user has set any of the PTHREAD_LIBS,
19 +# etcetera environment variables, and if threads linking works using
20 +# them:
21 +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
22 +        save_CFLAGS="$CFLAGS"
23 +        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
24 +        save_LIBS="$LIBS"
25 +        LIBS="$PTHREAD_LIBS $LIBS"
26 +        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
27 +        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
28 +        AC_MSG_RESULT($acx_pthread_ok)
29 +        if test x"$acx_pthread_ok" = xno; then
30 +                PTHREAD_LIBS=""
31 +                PTHREAD_CFLAGS=""
32 +        fi
33 +        LIBS="$save_LIBS"
34 +        CFLAGS="$save_CFLAGS"
35 +fi
36 +
37 +# We must check for the threads library under a number of different
38 +# names; the ordering is very important because some systems
39 +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
40 +# libraries is broken (non-POSIX).
41 +
42 +# Create a list of thread flags to try.  Items starting with a "-" are
43 +# C compiler flags, and other items are library names, except for "none"
44 +# which indicates that we try without any flags at all.
45 +
46 +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
47 +
48 +# The ordering *is* (sometimes) important.  Some notes on the
49 +# individual items follow:
50 +
51 +# pthreads: AIX (must check this before -lpthread)
52 +# none: in case threads are in libc; should be tried before -Kthread and
53 +#       other compiler flags to prevent continual compiler warnings
54 +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
55 +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
56 +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
57 +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
58 +# -pthreads: Solaris/gcc
59 +# -mthreads: Mingw32/gcc, Lynx/gcc
60 +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
61 +#      doesn't hurt to check since this sometimes defines pthreads too;
62 +#      also defines -D_REENTRANT)
63 +# pthread: Linux, etcetera
64 +# --thread-safe: KAI C++
65 +
66 +case "${host_cpu}-${host_os}" in
67 +        *solaris*)
68 +
69 +        # On Solaris (at least, for some versions), libc contains stubbed
70 +        # (non-functional) versions of the pthreads routines, so link-based
71 +        # tests will erroneously succeed.  (We need to link with -pthread or
72 +        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
73 +        # a function called by this macro, so we could check for that, but
74 +        # who knows whether they'll stub that too in a future libc.)  So,
75 +        # we'll just look for -pthreads and -lpthread first:
76 +
77 +        acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
78 +        ;;
79 +esac
80 +
81 +if test x"$acx_pthread_ok" = xno; then
82 +for flag in $acx_pthread_flags; do
83 +
84 +        case $flag in
85 +                none)
86 +                AC_MSG_CHECKING([whether pthreads work without any flags])
87 +                ;;
88 +
89 +                -*)
90 +                AC_MSG_CHECKING([whether pthreads work with $flag])
91 +                PTHREAD_CFLAGS="$flag"
92 +                ;;
93 +
94 +                *)
95 +                AC_MSG_CHECKING([for the pthreads library -l$flag])
96 +                PTHREAD_LIBS="-l$flag"
97 +                ;;
98 +        esac
99 +
100 +        save_LIBS="$LIBS"
101 +        save_CFLAGS="$CFLAGS"
102 +        LIBS="$PTHREAD_LIBS $LIBS"
103 +        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
104 +
105 +        # Check for various functions.  We must include pthread.h,
106 +        # since some functions may be macros.  (On the Sequent, we
107 +        # need a special flag -Kthread to make this header compile.)
108 +        # We check for pthread_join because it is in -lpthread on IRIX
109 +        # while pthread_create is in libc.  We check for pthread_attr_init
110 +        # due to DEC craziness with -lpthreads.  We check for
111 +        # pthread_cleanup_push because it is one of the few pthread
112 +        # functions on Solaris that doesn't have a non-functional libc stub.
113 +        # We try pthread_create on general principles.
114 +        AC_TRY_LINK([#include <pthread.h>],
115 +                    [pthread_t th; pthread_join(th, 0);
116 +                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
117 +                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
118 +                    [acx_pthread_ok=yes])
119 +
120 +        LIBS="$save_LIBS"
121 +        CFLAGS="$save_CFLAGS"
122 +
123 +        AC_MSG_RESULT($acx_pthread_ok)
124 +        if test "x$acx_pthread_ok" = xyes; then
125 +                break;
126 +        fi
127 +
128 +        PTHREAD_LIBS=""
129 +        PTHREAD_CFLAGS=""
130 +done
131 +fi
132 +
133 +# Various other checks:
134 +if test "x$acx_pthread_ok" = xyes; then
135 +        save_LIBS="$LIBS"
136 +        LIBS="$PTHREAD_LIBS $LIBS"
137 +        save_CFLAGS="$CFLAGS"
138 +        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
139 +
140 +        # Detect AIX lossage: threads are created detached by default
141 +        # and the JOINABLE attribute has a nonstandard name (UNDETACHED).
142 +        AC_MSG_CHECKING([for joinable pthread attribute])
143 +        AC_TRY_LINK([#include <pthread.h>],
144 +                    [int attr=PTHREAD_CREATE_JOINABLE;],
145 +                    ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
146 +        if test x"$ok" = xunknown; then
147 +                AC_TRY_LINK([#include <pthread.h>],
148 +                            [int attr=PTHREAD_CREATE_UNDETACHED;],
149 +                            ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
150 +        fi
151 +        if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
152 +                AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
153 +                          [Define to the necessary symbol if this constant
154 +                           uses a non-standard name on your system.])
155 +        fi
156 +        AC_MSG_RESULT(${ok})
157 +        if test x"$ok" = xunknown; then
158 +                AC_MSG_WARN([we do not know how to create joinable pthreads])
159 +        fi
160 +
161 +        AC_MSG_CHECKING([if more special flags are required for pthreads])
162 +        flag=no
163 +        case "${host_cpu}-${host_os}" in
164 +                *-aix* | *-freebsd*)     flag="-D_THREAD_SAFE";;
165 +                *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
166 +        esac
167 +        AC_MSG_RESULT(${flag})
168 +        if test "x$flag" != xno; then
169 +                PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
170 +        fi
171 +
172 +        LIBS="$save_LIBS"
173 +        CFLAGS="$save_CFLAGS"
174 +
175 +        # More AIX lossage: must compile with cc_r
176 +        AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
177 +else
178 +        PTHREAD_CC="$CC"
179 +fi
180 +
181 +AC_SUBST(PTHREAD_LIBS)
182 +AC_SUBST(PTHREAD_CFLAGS)
183 +AC_SUBST(PTHREAD_CC)
184 +
185 +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
186 +if test x"$acx_pthread_ok" = xyes; then
187 +        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
188 +        :
189 +else
190 +        acx_pthread_ok=no
191 +        $2
192 +fi
193 +AC_LANG_RESTORE
194 +])dnl ACX_PTHREAD
This page took 0.065433 seconds and 3 git commands to generate.