# LIBPTHREAD_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for pthread.
#
# This macro sets @LIBPTHREAD_LDFLAGS@, @LIBPTHREAD_CFLAGS@ and @LIBPTHREAD_LIBS@ to the necessary
# values.
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([LIBPTHREAD_TRY_LINK],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <pthread.h>
]], [[
pthread_mutexattr_t mta;
pthread_mutex_t mutex;
pthread_mutexattr_init(&mta);
pthread_mutex_init(&mutex, &mta);
]])],[found_libpthread="yes"],[])
])dnl
AC_DEFUN([LIBPTHREAD_TRY_RUN],
[
AC_RUN_IFELSE(
[
AC_LANG_SOURCE(
#include <pthread.h>
int main()
{
pthread_mutexattr_t mta;
pthread_rwlockattr_t rwa;
pthread_mutex_t mutex;
pthread_rwlock_t rwlock;
if (0 != pthread_mutexattr_init(&mta))
return 1;
if (0 != pthread_mutexattr_setpshared(&mta, PTHREAD_PROCESS_SHARED))
return 2;
if (0 != pthread_mutex_init(&mutex, &mta))
return 3;
if (0 != pthread_rwlockattr_init(&rwa))
return 4;
if (0 != pthread_rwlockattr_setpshared(&rwa, PTHREAD_PROCESS_SHARED))
return 5;
if (0 != pthread_rwlock_init(&rwlock, &rwa))
return 6;
return 0;
}
)
]
,
found_libpthread_process_shared="yes",
found_libpthread_process_shared="no",
found_libpthread_process_shared="no" dnl action-if-cross-compiling
)
])
AC_DEFUN([LIBPTHREAD_CHECK_CONFIG],
[
AC_ARG_WITH([libpthread],[
If you want to specify pthread installation directories:
AS_HELP_STRING([--with-libpthread@<:@=DIR@:>@], [use libpthread from given base install directory (DIR), default is to search through a number of common places for the libpthread files.])],
[
test "x$withval" = "xyes" && withval=/usr
LIBPTHREAD_CFLAGS="-I$withval/include"
LIBPTHREAD_LDFLAGS="-L$withval/lib"
_libpthread_dir_set="yes"
]
)
AC_ARG_WITH([libpthread-include],
AS_HELP_STRING([--with-libpthread-include@<:@=DIR@:>@],
[use libpthread include headers from given path.]
),
[
LIBPTHREAD_CFLAGS="-I$withval"
_libpthread_dir_set="yes"
]
)