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