]> git.ipfire.org Git - thirdparty/cups.git/blame - config-scripts/cups-threads.m4
Merge pull request #1311 from weblate/weblate-cups-cups
[thirdparty/cups.git] / config-scripts / cups-threads.m4
CommitLineData
ef416fc2 1dnl
503b54c9 2dnl Threading stuff for CUPS.
ef416fc2 3dnl
76b6aade 4dnl Copyright © 2020-2024 by OpenPrinting.
82529ea0
MS
5dnl Copyright © 2007-2017 by Apple Inc.
6dnl Copyright © 1997-2005 by Easy Software Products, all rights reserved.
ef416fc2 7dnl
e3101897 8dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
ef416fc2 9dnl
10
82529ea0 11have_pthread="no"
b423cd4c 12PTHREAD_FLAGS=""
a356bbb0 13AC_SUBST([PTHREAD_FLAGS])
ef416fc2 14
a356bbb0
MS
15AC_CHECK_HEADER([pthread.h], [
16 AC_DEFINE([HAVE_PTHREAD_H], [1], [Do we have the <pthread.h> header?])
17])
ef416fc2 18
a356bbb0
MS
19AS_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])
b423cd4c 35
61b0f4a2 36 AS_IF([test $have_pthread = yes], [
a356bbb0 37 PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
2abf387c 38
a356bbb0
MS
39 # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
40 # compliant... :(
e1cfb900 41 AS_IF([test $host_os_name = sunos -o $host_os_name = solaris], [
a356bbb0 42 PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
82529ea0 43 ])
a356bbb0
MS
44 break
45 ])
46 done
82529ea0 47])
ef416fc2 48
a356bbb0
MS
49AS_IF([test $have_pthread = no], [
50 AC_MSG_ERROR([CUPS requires threading support.])
51])