1dnl 2dnl Threading stuff for CUPS. 3dnl 4dnl Copyright © 2020-2024 by OpenPrinting. 5dnl Copyright © 2007-2017 by Apple Inc. 6dnl Copyright © 1997-2005 by Easy Software Products, all rights reserved. 7dnl 8dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information. 9dnl 10 11have_pthread="no" 12PTHREAD_FLAGS="" 13AC_SUBST([PTHREAD_FLAGS]) 14 15AC_CHECK_HEADER([pthread.h], [ 16 AC_DEFINE([HAVE_PTHREAD_H], [1], [Do we have the <pthread.h> header?]) 17]) 18 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]) 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 49AS_IF([test $have_pthread = no], [ 50 AC_MSG_ERROR([CUPS requires threading support.]) 51]) 52