| 1 |
dnl Functions for pthread |
| 2 |
dnl |
| 3 |
dnl Version: 20240513 |
| 4 |
|
| 5 |
dnl Function to detect if pthread is available |
| 6 |
AC_DEFUN([AX_PTHREAD_CHECK_LIB], |
| 7 |
[AS_IF( |
| 8 |
[test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_pthread" = xno], |
| 9 |
[ac_cv_pthread=no], |
| 10 |
[ac_cv_pthread=check |
| 11 |
dnl Check if parameters were provided |
| 12 |
dnl For both --with-pthread which returns "yes" and --with-pthread= which returns "" |
| 13 |
dnl treat them as auto-detection. |
| 14 |
AS_IF( |
| 15 |
[test "x$ac_cv_with_pthread" != x && test "x$ac_cv_with_pthread" != xauto-detect && test "x$ac_cv_with_pthread" != xyes], |
| 16 |
[AX_CHECK_LIB_DIRECTORY_EXISTS([pthread])]) |
| 17 |
]) |
| 18 |
|
| 19 |
AS_IF( |
| 20 |
[test "x$ac_cv_pthread" = xcheck], |
| 21 |
[dnl Check for headers |
| 22 |
AC_CHECK_HEADERS([pthread.h]) |
| 23 |
|
| 24 |
AS_IF( |
| 25 |
[test "x$ac_cv_header_pthread_h" = xno], |
| 26 |
[ac_cv_pthread=no], |
| 27 |
[ac_cv_pthread=yes |
| 28 |
|
| 29 |
AX_CHECK_LIB_FUNCTIONS( |
| 30 |
[pthread], |
| 31 |
[pthread], |
| 32 |
[[pthread_create], |
| 33 |
[pthread_exit], |
| 34 |
[pthread_join], |
| 35 |
[pthread_cond_init], |
| 36 |
[pthread_cond_destroy], |
| 37 |
[pthread_cond_broadcast], |
| 38 |
[pthread_cond_signal], |
| 39 |
[pthread_cond_wait], |
| 40 |
[pthread_mutex_init], |
| 41 |
[pthread_mutex_destroy], |
| 42 |
[pthread_mutex_lock], |
| 43 |
[pthread_mutex_trylock], |
| 44 |
[pthread_mutex_unlock], |
| 45 |
[pthread_rwlock_init], |
| 46 |
[pthread_rwlock_destroy], |
| 47 |
[pthread_rwlock_rdlock], |
| 48 |
[pthread_rwlock_wrlock], |
| 49 |
[pthread_rwlock_unlock]]) |
| 50 |
|
| 51 |
ac_cv_pthread_LIBADD="-lpthread" |
| 52 |
]) |
| 53 |
|
| 54 |
AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([pthread]) |
| 55 |
]) |
| 56 |
|
| 57 |
AS_IF( |
| 58 |
[test "x$ac_cv_pthread" = xpthread], |
| 59 |
[AC_DEFINE( |
| 60 |
[HAVE_PTHREAD], |
| 61 |
[1], |
| 62 |
[Define to 1 if you have the 'pthread' library (-lpthread).]) |
| 63 |
]) |
| 64 |
|
| 65 |
AS_IF( |
| 66 |
[test "x$ac_cv_pthread" != xno], |
| 67 |
[AC_SUBST( |
| 68 |
[HAVE_PTHREAD], |
| 69 |
[1]) ], |
| 70 |
[AC_SUBST( |
| 71 |
[HAVE_PTHREAD], |
| 72 |
[0]) |
| 73 |
]) |
| 74 |
]) |
| 75 |
|
| 76 |
dnl Function to detect how to enable pthread |
| 77 |
AC_DEFUN([AX_PTHREAD_CHECK_ENABLE], |
| 78 |
[AX_COMMON_ARG_WITH( |
| 79 |
[pthread], |
| 80 |
[pthread], |
| 81 |
[search for pthread in includedir and libdir or in the specified DIR, or no if not to use pthread], |
| 82 |
[auto-detect], |
| 83 |
[DIR]) |
| 84 |
|
| 85 |
dnl Check for a shared library version |
| 86 |
AX_PTHREAD_CHECK_LIB |
| 87 |
|
| 88 |
AS_IF( |
| 89 |
[test "x$ac_cv_pthread_CPPFLAGS" != "x"], |
| 90 |
[AC_SUBST( |
| 91 |
[PTHREAD_CPPFLAGS], |
| 92 |
[$ac_cv_pthread_CPPFLAGS]) |
| 93 |
]) |
| 94 |
AS_IF( |
| 95 |
[test "x$ac_cv_pthread_LIBADD" != "x"], |
| 96 |
[AC_SUBST( |
| 97 |
[PTHREAD_LIBADD], |
| 98 |
[$ac_cv_pthread_LIBADD]) |
| 99 |
]) |
| 100 |
|
| 101 |
AS_IF( |
| 102 |
[test "x$ac_cv_pthread" = xpthread], |
| 103 |
[AC_SUBST( |
| 104 |
[ax_pthread_pc_libs_private], |
| 105 |
[-lpthread]) |
| 106 |
]) |
| 107 |
]) |
| 108 |
|