]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-threads.m4
bd5c69867e1cc9ae8090a701494276a552d1e720
[thirdparty/cups.git] / config-scripts / cups-threads.m4
1 dnl
2 dnl "$Id$"
3 dnl
4 dnl Threading stuff for CUPS.
5 dnl
6 dnl Copyright 2007-2011 by Apple Inc.
7 dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
8 dnl
9 dnl These coded instructions, statements, and computer programs are the
10 dnl property of Apple Inc. and are protected by Federal copyright
11 dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 dnl which should have been included with this file. If this file is
13 dnl file is missing or damaged, see the license at "http://www.cups.org/".
14 dnl
15
16 AC_ARG_ENABLE(threads, [ --disable-threads disable multi-threading support])
17
18 have_pthread=no
19 PTHREAD_FLAGS=""
20
21 if test "x$enable_threads" != xno; then
22 AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
23
24 if test x$ac_cv_header_pthread_h = xyes; then
25 dnl Check various threading options for the platforms we support
26 for flag in -lpthreads -lpthread -pthread; do
27 AC_MSG_CHECKING([for pthread_create using $flag])
28 SAVELIBS="$LIBS"
29 LIBS="$flag $LIBS"
30 AC_TRY_LINK([#include <pthread.h>],
31 [pthread_create(0, 0, 0, 0);],
32 have_pthread=yes,
33 LIBS="$SAVELIBS")
34 AC_MSG_RESULT([$have_pthread])
35
36 if test $have_pthread = yes; then
37 PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
38
39 # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
40 # be POSIX-compliant... :(
41 if test $uname = SunOS; then
42 PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
43 fi
44 break
45 fi
46 done
47 fi
48 fi
49
50 AC_SUBST(PTHREAD_FLAGS)
51
52 dnl
53 dnl End of "$Id$".
54 dnl