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