117d15b25SDag-Erling Smørgrav# =========================================================================== 217d15b25SDag-Erling Smørgrav# http://www.gnu.org/software/autoconf-archive/ax_pthread.html 317d15b25SDag-Erling Smørgrav# =========================================================================== 417d15b25SDag-Erling Smørgrav# 517d15b25SDag-Erling Smørgrav# SYNOPSIS 617d15b25SDag-Erling Smørgrav# 717d15b25SDag-Erling Smørgrav# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 817d15b25SDag-Erling Smørgrav# 917d15b25SDag-Erling Smørgrav# DESCRIPTION 1017d15b25SDag-Erling Smørgrav# 1117d15b25SDag-Erling Smørgrav# This macro figures out how to build C programs using POSIX threads. It 1217d15b25SDag-Erling Smørgrav# sets the PTHREAD_LIBS output variable to the threads library and linker 1317d15b25SDag-Erling Smørgrav# flags, and the PTHREAD_CFLAGS output variable to any special C compiler 1417d15b25SDag-Erling Smørgrav# flags that are needed. (The user can also force certain compiler 1517d15b25SDag-Erling Smørgrav# flags/libs to be tested by setting these environment variables.) 1617d15b25SDag-Erling Smørgrav# 1717d15b25SDag-Erling Smørgrav# Also sets PTHREAD_CC to any special C compiler that is needed for 1817d15b25SDag-Erling Smørgrav# multi-threaded programs (defaults to the value of CC otherwise). (This 1917d15b25SDag-Erling Smørgrav# is necessary on AIX to use the special cc_r compiler alias.) 2017d15b25SDag-Erling Smørgrav# 2117d15b25SDag-Erling Smørgrav# NOTE: You are assumed to not only compile your program with these flags, 2217d15b25SDag-Erling Smørgrav# but also link it with them as well. e.g. you should link with 2317d15b25SDag-Erling Smørgrav# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS 2417d15b25SDag-Erling Smørgrav# 2517d15b25SDag-Erling Smørgrav# If you are only building threads programs, you may wish to use these 2617d15b25SDag-Erling Smørgrav# variables in your default LIBS, CFLAGS, and CC: 2717d15b25SDag-Erling Smørgrav# 2817d15b25SDag-Erling Smørgrav# LIBS="$PTHREAD_LIBS $LIBS" 2917d15b25SDag-Erling Smørgrav# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 3017d15b25SDag-Erling Smørgrav# CC="$PTHREAD_CC" 3117d15b25SDag-Erling Smørgrav# 3217d15b25SDag-Erling Smørgrav# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant 3317d15b25SDag-Erling Smørgrav# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name 3417d15b25SDag-Erling Smørgrav# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). 3517d15b25SDag-Erling Smørgrav# 3617d15b25SDag-Erling Smørgrav# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the 3717d15b25SDag-Erling Smørgrav# PTHREAD_PRIO_INHERIT symbol is defined when compiling with 3817d15b25SDag-Erling Smørgrav# PTHREAD_CFLAGS. 3917d15b25SDag-Erling Smørgrav# 4017d15b25SDag-Erling Smørgrav# ACTION-IF-FOUND is a list of shell commands to run if a threads library 4117d15b25SDag-Erling Smørgrav# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it 4217d15b25SDag-Erling Smørgrav# is not found. If ACTION-IF-FOUND is not specified, the default action 4317d15b25SDag-Erling Smørgrav# will define HAVE_PTHREAD. 4417d15b25SDag-Erling Smørgrav# 4517d15b25SDag-Erling Smørgrav# Please let the authors know if this macro fails on any platform, or if 4617d15b25SDag-Erling Smørgrav# you have any other suggestions or comments. This macro was based on work 4717d15b25SDag-Erling Smørgrav# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help 4817d15b25SDag-Erling Smørgrav# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by 4917d15b25SDag-Erling Smørgrav# Alejandro Forero Cuervo to the autoconf macro repository. We are also 5017d15b25SDag-Erling Smørgrav# grateful for the helpful feedback of numerous users. 5117d15b25SDag-Erling Smørgrav# 5217d15b25SDag-Erling Smørgrav# Updated for Autoconf 2.68 by Daniel Richard G. 5317d15b25SDag-Erling Smørgrav# 5417d15b25SDag-Erling Smørgrav# LICENSE 5517d15b25SDag-Erling Smørgrav# 5617d15b25SDag-Erling Smørgrav# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> 5717d15b25SDag-Erling Smørgrav# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG> 5817d15b25SDag-Erling Smørgrav# 5917d15b25SDag-Erling Smørgrav# This program is free software: you can redistribute it and/or modify it 6017d15b25SDag-Erling Smørgrav# under the terms of the GNU General Public License as published by the 6117d15b25SDag-Erling Smørgrav# Free Software Foundation, either version 3 of the License, or (at your 6217d15b25SDag-Erling Smørgrav# option) any later version. 6317d15b25SDag-Erling Smørgrav# 6417d15b25SDag-Erling Smørgrav# This program is distributed in the hope that it will be useful, but 6517d15b25SDag-Erling Smørgrav# WITHOUT ANY WARRANTY; without even the implied warranty of 6617d15b25SDag-Erling Smørgrav# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 6717d15b25SDag-Erling Smørgrav# Public License for more details. 6817d15b25SDag-Erling Smørgrav# 6917d15b25SDag-Erling Smørgrav# You should have received a copy of the GNU General Public License along 7017d15b25SDag-Erling Smørgrav# with this program. If not, see <http://www.gnu.org/licenses/>. 7117d15b25SDag-Erling Smørgrav# 7217d15b25SDag-Erling Smørgrav# As a special exception, the respective Autoconf Macro's copyright owner 7317d15b25SDag-Erling Smørgrav# gives unlimited permission to copy, distribute and modify the configure 7417d15b25SDag-Erling Smørgrav# scripts that are the output of Autoconf when processing the Macro. You 7517d15b25SDag-Erling Smørgrav# need not follow the terms of the GNU General Public License when using 7617d15b25SDag-Erling Smørgrav# or distributing such scripts, even though portions of the text of the 7717d15b25SDag-Erling Smørgrav# Macro appear in them. The GNU General Public License (GPL) does govern 7817d15b25SDag-Erling Smørgrav# all other use of the material that constitutes the Autoconf Macro. 7917d15b25SDag-Erling Smørgrav# 8017d15b25SDag-Erling Smørgrav# This special exception to the GPL applies to versions of the Autoconf 8117d15b25SDag-Erling Smørgrav# Macro released by the Autoconf Archive. When you make and distribute a 8217d15b25SDag-Erling Smørgrav# modified version of the Autoconf Macro, you may extend this special 8317d15b25SDag-Erling Smørgrav# exception to the GPL to apply to your modified version as well. 8417d15b25SDag-Erling Smørgrav 85*f61ef7f6SDag-Erling Smørgrav#serial 21 8617d15b25SDag-Erling Smørgrav 8717d15b25SDag-Erling SmørgravAU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) 8817d15b25SDag-Erling SmørgravAC_DEFUN([AX_PTHREAD], [ 8917d15b25SDag-Erling SmørgravAC_REQUIRE([AC_CANONICAL_HOST]) 9017d15b25SDag-Erling SmørgravAC_LANG_PUSH([C]) 9117d15b25SDag-Erling Smørgravax_pthread_ok=no 9217d15b25SDag-Erling Smørgrav 9317d15b25SDag-Erling Smørgrav# We used to check for pthread.h first, but this fails if pthread.h 9417d15b25SDag-Erling Smørgrav# requires special compiler flags (e.g. on True64 or Sequent). 9517d15b25SDag-Erling Smørgrav# It gets checked for in the link test anyway. 9617d15b25SDag-Erling Smørgrav 9717d15b25SDag-Erling Smørgrav# First of all, check if the user has set any of the PTHREAD_LIBS, 9817d15b25SDag-Erling Smørgrav# etcetera environment variables, and if threads linking works using 9917d15b25SDag-Erling Smørgrav# them: 10017d15b25SDag-Erling Smørgravif test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then 10117d15b25SDag-Erling Smørgrav save_CFLAGS="$CFLAGS" 10217d15b25SDag-Erling Smørgrav CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 10317d15b25SDag-Erling Smørgrav save_LIBS="$LIBS" 10417d15b25SDag-Erling Smørgrav LIBS="$PTHREAD_LIBS $LIBS" 10517d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) 106*f61ef7f6SDag-Erling Smørgrav AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) 107*f61ef7f6SDag-Erling Smørgrav AC_MSG_RESULT([$ax_pthread_ok]) 10817d15b25SDag-Erling Smørgrav if test x"$ax_pthread_ok" = xno; then 10917d15b25SDag-Erling Smørgrav PTHREAD_LIBS="" 11017d15b25SDag-Erling Smørgrav PTHREAD_CFLAGS="" 11117d15b25SDag-Erling Smørgrav fi 11217d15b25SDag-Erling Smørgrav LIBS="$save_LIBS" 11317d15b25SDag-Erling Smørgrav CFLAGS="$save_CFLAGS" 11417d15b25SDag-Erling Smørgravfi 11517d15b25SDag-Erling Smørgrav 11617d15b25SDag-Erling Smørgrav# We must check for the threads library under a number of different 11717d15b25SDag-Erling Smørgrav# names; the ordering is very important because some systems 11817d15b25SDag-Erling Smørgrav# (e.g. DEC) have both -lpthread and -lpthreads, where one of the 11917d15b25SDag-Erling Smørgrav# libraries is broken (non-POSIX). 12017d15b25SDag-Erling Smørgrav 12117d15b25SDag-Erling Smørgrav# Create a list of thread flags to try. Items starting with a "-" are 12217d15b25SDag-Erling Smørgrav# C compiler flags, and other items are library names, except for "none" 12317d15b25SDag-Erling Smørgrav# which indicates that we try without any flags at all, and "pthread-config" 12417d15b25SDag-Erling Smørgrav# which is a program returning the flags for the Pth emulation library. 12517d15b25SDag-Erling Smørgrav 12617d15b25SDag-Erling Smørgravax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" 12717d15b25SDag-Erling Smørgrav 12817d15b25SDag-Erling Smørgrav# The ordering *is* (sometimes) important. Some notes on the 12917d15b25SDag-Erling Smørgrav# individual items follow: 13017d15b25SDag-Erling Smørgrav 13117d15b25SDag-Erling Smørgrav# pthreads: AIX (must check this before -lpthread) 13217d15b25SDag-Erling Smørgrav# none: in case threads are in libc; should be tried before -Kthread and 13317d15b25SDag-Erling Smørgrav# other compiler flags to prevent continual compiler warnings 13417d15b25SDag-Erling Smørgrav# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) 13517d15b25SDag-Erling Smørgrav# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) 13617d15b25SDag-Erling Smørgrav# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) 13717d15b25SDag-Erling Smørgrav# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) 13817d15b25SDag-Erling Smørgrav# -pthreads: Solaris/gcc 13917d15b25SDag-Erling Smørgrav# -mthreads: Mingw32/gcc, Lynx/gcc 14017d15b25SDag-Erling Smørgrav# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it 14117d15b25SDag-Erling Smørgrav# doesn't hurt to check since this sometimes defines pthreads too; 14217d15b25SDag-Erling Smørgrav# also defines -D_REENTRANT) 14317d15b25SDag-Erling Smørgrav# ... -mt is also the pthreads flag for HP/aCC 14417d15b25SDag-Erling Smørgrav# pthread: Linux, etcetera 14517d15b25SDag-Erling Smørgrav# --thread-safe: KAI C++ 14617d15b25SDag-Erling Smørgrav# pthread-config: use pthread-config program (for GNU Pth library) 14717d15b25SDag-Erling Smørgrav 14817d15b25SDag-Erling Smørgravcase ${host_os} in 14917d15b25SDag-Erling Smørgrav solaris*) 15017d15b25SDag-Erling Smørgrav 15117d15b25SDag-Erling Smørgrav # On Solaris (at least, for some versions), libc contains stubbed 15217d15b25SDag-Erling Smørgrav # (non-functional) versions of the pthreads routines, so link-based 15317d15b25SDag-Erling Smørgrav # tests will erroneously succeed. (We need to link with -pthreads/-mt/ 15417d15b25SDag-Erling Smørgrav # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather 15517d15b25SDag-Erling Smørgrav # a function called by this macro, so we could check for that, but 15617d15b25SDag-Erling Smørgrav # who knows whether they'll stub that too in a future libc.) So, 15717d15b25SDag-Erling Smørgrav # we'll just look for -pthreads and -lpthread first: 15817d15b25SDag-Erling Smørgrav 15917d15b25SDag-Erling Smørgrav ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" 16017d15b25SDag-Erling Smørgrav ;; 16117d15b25SDag-Erling Smørgrav 16217d15b25SDag-Erling Smørgrav darwin*) 16317d15b25SDag-Erling Smørgrav ax_pthread_flags="-pthread $ax_pthread_flags" 16417d15b25SDag-Erling Smørgrav ;; 16517d15b25SDag-Erling Smørgravesac 16617d15b25SDag-Erling Smørgrav 167*f61ef7f6SDag-Erling Smørgrav# Clang doesn't consider unrecognized options an error unless we specify 168*f61ef7f6SDag-Erling Smørgrav# -Werror. We throw in some extra Clang-specific options to ensure that 169*f61ef7f6SDag-Erling Smørgrav# this doesn't happen for GCC, which also accepts -Werror. 170*f61ef7f6SDag-Erling Smørgrav 171*f61ef7f6SDag-Erling SmørgravAC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) 172*f61ef7f6SDag-Erling Smørgravsave_CFLAGS="$CFLAGS" 173*f61ef7f6SDag-Erling Smørgravax_pthread_extra_flags="-Werror" 174*f61ef7f6SDag-Erling SmørgravCFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" 175*f61ef7f6SDag-Erling SmørgravAC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], 176*f61ef7f6SDag-Erling Smørgrav [AC_MSG_RESULT([yes])], 177*f61ef7f6SDag-Erling Smørgrav [ax_pthread_extra_flags= 178*f61ef7f6SDag-Erling Smørgrav AC_MSG_RESULT([no])]) 179*f61ef7f6SDag-Erling SmørgravCFLAGS="$save_CFLAGS" 180*f61ef7f6SDag-Erling Smørgrav 18117d15b25SDag-Erling Smørgravif test x"$ax_pthread_ok" = xno; then 18217d15b25SDag-Erling Smørgravfor flag in $ax_pthread_flags; do 18317d15b25SDag-Erling Smørgrav 18417d15b25SDag-Erling Smørgrav case $flag in 18517d15b25SDag-Erling Smørgrav none) 18617d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([whether pthreads work without any flags]) 18717d15b25SDag-Erling Smørgrav ;; 18817d15b25SDag-Erling Smørgrav 18917d15b25SDag-Erling Smørgrav -*) 19017d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([whether pthreads work with $flag]) 19117d15b25SDag-Erling Smørgrav PTHREAD_CFLAGS="$flag" 19217d15b25SDag-Erling Smørgrav ;; 19317d15b25SDag-Erling Smørgrav 19417d15b25SDag-Erling Smørgrav pthread-config) 195*f61ef7f6SDag-Erling Smørgrav AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) 19617d15b25SDag-Erling Smørgrav if test x"$ax_pthread_config" = xno; then continue; fi 19717d15b25SDag-Erling Smørgrav PTHREAD_CFLAGS="`pthread-config --cflags`" 19817d15b25SDag-Erling Smørgrav PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" 19917d15b25SDag-Erling Smørgrav ;; 20017d15b25SDag-Erling Smørgrav 20117d15b25SDag-Erling Smørgrav *) 20217d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([for the pthreads library -l$flag]) 20317d15b25SDag-Erling Smørgrav PTHREAD_LIBS="-l$flag" 20417d15b25SDag-Erling Smørgrav ;; 20517d15b25SDag-Erling Smørgrav esac 20617d15b25SDag-Erling Smørgrav 20717d15b25SDag-Erling Smørgrav save_LIBS="$LIBS" 20817d15b25SDag-Erling Smørgrav save_CFLAGS="$CFLAGS" 20917d15b25SDag-Erling Smørgrav LIBS="$PTHREAD_LIBS $LIBS" 210*f61ef7f6SDag-Erling Smørgrav CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" 21117d15b25SDag-Erling Smørgrav 21217d15b25SDag-Erling Smørgrav # Check for various functions. We must include pthread.h, 21317d15b25SDag-Erling Smørgrav # since some functions may be macros. (On the Sequent, we 21417d15b25SDag-Erling Smørgrav # need a special flag -Kthread to make this header compile.) 21517d15b25SDag-Erling Smørgrav # We check for pthread_join because it is in -lpthread on IRIX 21617d15b25SDag-Erling Smørgrav # while pthread_create is in libc. We check for pthread_attr_init 21717d15b25SDag-Erling Smørgrav # due to DEC craziness with -lpthreads. We check for 21817d15b25SDag-Erling Smørgrav # pthread_cleanup_push because it is one of the few pthread 21917d15b25SDag-Erling Smørgrav # functions on Solaris that doesn't have a non-functional libc stub. 22017d15b25SDag-Erling Smørgrav # We try pthread_create on general principles. 22117d15b25SDag-Erling Smørgrav AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> 22217d15b25SDag-Erling Smørgrav static void routine(void *a) { *((int*)a) = 0; } 22317d15b25SDag-Erling Smørgrav static void *start_routine(void *a) { return a; }], 22417d15b25SDag-Erling Smørgrav [pthread_t th; pthread_attr_t attr; 22517d15b25SDag-Erling Smørgrav pthread_create(&th, 0, start_routine, 0); 22617d15b25SDag-Erling Smørgrav pthread_join(th, 0); 22717d15b25SDag-Erling Smørgrav pthread_attr_init(&attr); 22817d15b25SDag-Erling Smørgrav pthread_cleanup_push(routine, 0); 22917d15b25SDag-Erling Smørgrav pthread_cleanup_pop(0) /* ; */])], 23017d15b25SDag-Erling Smørgrav [ax_pthread_ok=yes], 23117d15b25SDag-Erling Smørgrav []) 23217d15b25SDag-Erling Smørgrav 23317d15b25SDag-Erling Smørgrav LIBS="$save_LIBS" 23417d15b25SDag-Erling Smørgrav CFLAGS="$save_CFLAGS" 23517d15b25SDag-Erling Smørgrav 236*f61ef7f6SDag-Erling Smørgrav AC_MSG_RESULT([$ax_pthread_ok]) 23717d15b25SDag-Erling Smørgrav if test "x$ax_pthread_ok" = xyes; then 23817d15b25SDag-Erling Smørgrav break; 23917d15b25SDag-Erling Smørgrav fi 24017d15b25SDag-Erling Smørgrav 24117d15b25SDag-Erling Smørgrav PTHREAD_LIBS="" 24217d15b25SDag-Erling Smørgrav PTHREAD_CFLAGS="" 24317d15b25SDag-Erling Smørgravdone 24417d15b25SDag-Erling Smørgravfi 24517d15b25SDag-Erling Smørgrav 24617d15b25SDag-Erling Smørgrav# Various other checks: 24717d15b25SDag-Erling Smørgravif test "x$ax_pthread_ok" = xyes; then 24817d15b25SDag-Erling Smørgrav save_LIBS="$LIBS" 24917d15b25SDag-Erling Smørgrav LIBS="$PTHREAD_LIBS $LIBS" 25017d15b25SDag-Erling Smørgrav save_CFLAGS="$CFLAGS" 25117d15b25SDag-Erling Smørgrav CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 25217d15b25SDag-Erling Smørgrav 25317d15b25SDag-Erling Smørgrav # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. 25417d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([for joinable pthread attribute]) 25517d15b25SDag-Erling Smørgrav attr_name=unknown 25617d15b25SDag-Erling Smørgrav for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do 25717d15b25SDag-Erling Smørgrav AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], 25817d15b25SDag-Erling Smørgrav [int attr = $attr; return attr /* ; */])], 25917d15b25SDag-Erling Smørgrav [attr_name=$attr; break], 26017d15b25SDag-Erling Smørgrav []) 26117d15b25SDag-Erling Smørgrav done 262*f61ef7f6SDag-Erling Smørgrav AC_MSG_RESULT([$attr_name]) 26317d15b25SDag-Erling Smørgrav if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then 264*f61ef7f6SDag-Erling Smørgrav AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], 26517d15b25SDag-Erling Smørgrav [Define to necessary symbol if this constant 26617d15b25SDag-Erling Smørgrav uses a non-standard name on your system.]) 26717d15b25SDag-Erling Smørgrav fi 26817d15b25SDag-Erling Smørgrav 26917d15b25SDag-Erling Smørgrav AC_MSG_CHECKING([if more special flags are required for pthreads]) 27017d15b25SDag-Erling Smørgrav flag=no 27117d15b25SDag-Erling Smørgrav case ${host_os} in 27217d15b25SDag-Erling Smørgrav aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; 27317d15b25SDag-Erling Smørgrav osf* | hpux*) flag="-D_REENTRANT";; 27417d15b25SDag-Erling Smørgrav solaris*) 27517d15b25SDag-Erling Smørgrav if test "$GCC" = "yes"; then 27617d15b25SDag-Erling Smørgrav flag="-D_REENTRANT" 27717d15b25SDag-Erling Smørgrav else 278*f61ef7f6SDag-Erling Smørgrav # TODO: What about Clang on Solaris? 27917d15b25SDag-Erling Smørgrav flag="-mt -D_REENTRANT" 28017d15b25SDag-Erling Smørgrav fi 28117d15b25SDag-Erling Smørgrav ;; 28217d15b25SDag-Erling Smørgrav esac 283*f61ef7f6SDag-Erling Smørgrav AC_MSG_RESULT([$flag]) 28417d15b25SDag-Erling Smørgrav if test "x$flag" != xno; then 28517d15b25SDag-Erling Smørgrav PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" 28617d15b25SDag-Erling Smørgrav fi 28717d15b25SDag-Erling Smørgrav 28817d15b25SDag-Erling Smørgrav AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], 289*f61ef7f6SDag-Erling Smørgrav [ax_cv_PTHREAD_PRIO_INHERIT], [ 290*f61ef7f6SDag-Erling Smørgrav AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], 291*f61ef7f6SDag-Erling Smørgrav [[int i = PTHREAD_PRIO_INHERIT;]])], 29217d15b25SDag-Erling Smørgrav [ax_cv_PTHREAD_PRIO_INHERIT=yes], 29317d15b25SDag-Erling Smørgrav [ax_cv_PTHREAD_PRIO_INHERIT=no]) 29417d15b25SDag-Erling Smørgrav ]) 29517d15b25SDag-Erling Smørgrav AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], 296*f61ef7f6SDag-Erling Smørgrav [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) 29717d15b25SDag-Erling Smørgrav 29817d15b25SDag-Erling Smørgrav LIBS="$save_LIBS" 29917d15b25SDag-Erling Smørgrav CFLAGS="$save_CFLAGS" 30017d15b25SDag-Erling Smørgrav 30117d15b25SDag-Erling Smørgrav # More AIX lossage: compile with *_r variant 30217d15b25SDag-Erling Smørgrav if test "x$GCC" != xyes; then 30317d15b25SDag-Erling Smørgrav case $host_os in 30417d15b25SDag-Erling Smørgrav aix*) 30517d15b25SDag-Erling Smørgrav AS_CASE(["x/$CC"], 30617d15b25SDag-Erling Smørgrav [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], 30717d15b25SDag-Erling Smørgrav [#handle absolute path differently from PATH based program lookup 30817d15b25SDag-Erling Smørgrav AS_CASE(["x$CC"], 30917d15b25SDag-Erling Smørgrav [x/*], 31017d15b25SDag-Erling Smørgrav [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], 31117d15b25SDag-Erling Smørgrav [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) 31217d15b25SDag-Erling Smørgrav ;; 31317d15b25SDag-Erling Smørgrav esac 31417d15b25SDag-Erling Smørgrav fi 31517d15b25SDag-Erling Smørgravfi 31617d15b25SDag-Erling Smørgrav 31717d15b25SDag-Erling Smørgravtest -n "$PTHREAD_CC" || PTHREAD_CC="$CC" 31817d15b25SDag-Erling Smørgrav 319*f61ef7f6SDag-Erling SmørgravAC_SUBST([PTHREAD_LIBS]) 320*f61ef7f6SDag-Erling SmørgravAC_SUBST([PTHREAD_CFLAGS]) 321*f61ef7f6SDag-Erling SmørgravAC_SUBST([PTHREAD_CC]) 32217d15b25SDag-Erling Smørgrav 32317d15b25SDag-Erling Smørgrav# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: 32417d15b25SDag-Erling Smørgravif test x"$ax_pthread_ok" = xyes; then 325*f61ef7f6SDag-Erling Smørgrav ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) 32617d15b25SDag-Erling Smørgrav : 32717d15b25SDag-Erling Smørgravelse 32817d15b25SDag-Erling Smørgrav ax_pthread_ok=no 32917d15b25SDag-Erling Smørgrav $2 33017d15b25SDag-Erling Smørgravfi 33117d15b25SDag-Erling SmørgravAC_LANG_POP 33217d15b25SDag-Erling Smørgrav])dnl AX_PTHREAD 333