]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-threads.m4
License change: Apache License, Version 2.0.
[thirdparty/cups.git] / config-scripts / cups-threads.m4
1 dnl
2 dnl Threading stuff for CUPS.
3 dnl
4 dnl Copyright 2007-2017 by Apple Inc.
5 dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
6 dnl
7 dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
8 dnl
9
10 AC_ARG_ENABLE(threads, [ --disable-threads disable multi-threading support])
11
12 have_pthread=no
13 PTHREAD_FLAGS=""
14
15 if test "x$enable_threads" != xno; then
16 AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
17
18 if test x$ac_cv_header_pthread_h = xyes; then
19 dnl Check various threading options for the platforms we support
20 for flag in -lpthreads -lpthread -pthread; do
21 AC_MSG_CHECKING([for pthread_create using $flag])
22 SAVELIBS="$LIBS"
23 LIBS="$flag $LIBS"
24 AC_TRY_LINK([#include <pthread.h>],
25 [pthread_create(0, 0, 0, 0);],
26 have_pthread=yes,
27 LIBS="$SAVELIBS")
28 AC_MSG_RESULT([$have_pthread])
29
30 if test $have_pthread = yes; then
31 PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
32
33 # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
34 # be POSIX-compliant... :(
35 if test $host_os_name = sunos; then
36 PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
37 fi
38 break
39 fi
40 done
41 fi
42 fi
43
44 AC_SUBST(PTHREAD_FLAGS)