2010-02-28 09:27:23 -08:00
|
|
|
dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
|
2008-10-03 08:28:13 -07:00
|
|
|
dnl That code is public domain and can be freely used or copied.
|
|
|
|
|
2010-02-28 09:27:23 -08:00
|
|
|
dnl Macro that check if several pthread library is available or not.
|
2008-10-03 08:28:13 -07:00
|
|
|
|
2010-02-28 09:27:23 -08:00
|
|
|
dnl Usage: EFL_CHECK_PTHREAD(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
|
|
|
dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
|
|
|
|
dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
|
2008-10-03 08:28:13 -07:00
|
|
|
dnl Define EFL_HAVE_PTHREAD
|
2010-02-28 09:27:23 -08:00
|
|
|
dnl Define EFL_HAVE_PTHREAD_SPINLOCK
|
2008-10-03 08:28:13 -07:00
|
|
|
|
|
|
|
AC_DEFUN([EFL_CHECK_PTHREAD],
|
|
|
|
[
|
|
|
|
|
|
|
|
dnl configure option
|
|
|
|
|
|
|
|
AC_ARG_ENABLE([pthread],
|
2010-02-28 09:27:23 -08:00
|
|
|
[AC_HELP_STRING([--disable-pthread], [enable POSIX threads code @<:@default=auto@:>@])],
|
2008-10-03 08:28:13 -07:00
|
|
|
[
|
|
|
|
if test "x${enableval}" = "xyes" ; then
|
|
|
|
_efl_enable_pthread="yes"
|
|
|
|
else
|
|
|
|
_efl_enable_pthread="no"
|
|
|
|
fi
|
|
|
|
],
|
2010-02-28 09:27:23 -08:00
|
|
|
[_efl_enable_pthread="auto"])
|
2009-08-20 01:31:26 -07:00
|
|
|
|
2008-10-03 08:28:13 -07:00
|
|
|
AC_MSG_CHECKING([whether to build POSIX threads code])
|
|
|
|
AC_MSG_RESULT([${_efl_enable_pthread}])
|
|
|
|
|
|
|
|
dnl check if the compiler supports pthreads
|
|
|
|
|
2010-05-01 22:19:00 -07:00
|
|
|
case "$host_os" in
|
|
|
|
mingw*)
|
|
|
|
_efl_pthread_cflags=""
|
|
|
|
_efl_pthread_libs="-lpthreadGC2"
|
|
|
|
;;
|
|
|
|
solaris*)
|
|
|
|
_efl_pthread_cflags="-mt"
|
|
|
|
_efl_pthread_libs="-mt"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_efl_pthread_cflags="-pthread"
|
|
|
|
_efl_pthread_libs="-pthread"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-10-03 08:28:13 -07:00
|
|
|
_efl_have_pthread="no"
|
|
|
|
|
2010-02-28 09:27:23 -08:00
|
|
|
if test "x${_efl_enable_pthread}" = "xyes" || test "x${_efl_enable_pthread}" = "xauto" ; then
|
2009-12-25 03:29:08 -08:00
|
|
|
|
2010-05-01 22:19:00 -07:00
|
|
|
SAVE_CFLAGS=${CFLAGS}
|
|
|
|
CFLAGS="${CFLAGS} ${_efl_pthread_cflags}"
|
2010-05-28 11:57:19 -07:00
|
|
|
SAVE_LIBS=${LIBS}
|
|
|
|
LIBS="${LIBS} ${_efl_pthread_libs}"
|
2010-05-01 22:19:00 -07:00
|
|
|
AC_LINK_IFELSE(
|
2009-12-25 03:29:08 -08:00
|
|
|
[AC_LANG_PROGRAM([[
|
|
|
|
#include <pthread.h>
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
pthread_t id;
|
|
|
|
id = pthread_self();
|
|
|
|
]])],
|
2009-08-20 01:31:26 -07:00
|
|
|
[_efl_have_pthread="yes"],
|
|
|
|
[_efl_have_pthread="no"])
|
2010-05-01 22:19:00 -07:00
|
|
|
CFLAGS=${SAVE_CFLAGS}
|
2010-05-28 11:57:19 -07:00
|
|
|
LIBS=${SAVE_LIBS}
|
2009-12-25 03:29:08 -08:00
|
|
|
|
2008-10-03 08:28:13 -07:00
|
|
|
fi
|
|
|
|
|
2009-08-20 01:31:26 -07:00
|
|
|
AC_MSG_CHECKING([whether system support POSIX threads])
|
2010-02-28 09:27:23 -08:00
|
|
|
AC_MSG_RESULT([${_efl_have_pthread}])
|
|
|
|
if test "$x{_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread}" = "xno"; then
|
|
|
|
AC_MSG_ERROR([pthread support requested but not found.])
|
|
|
|
fi
|
2009-02-17 06:18:14 -08:00
|
|
|
|
2010-05-01 22:19:00 -07:00
|
|
|
EFL_PTHREAD_CFLAGS=""
|
|
|
|
EFL_PTHREAD_LIBS=""
|
2009-08-20 01:31:26 -07:00
|
|
|
if test "x${_efl_have_pthread}" = "xyes" ; then
|
2010-05-01 22:19:00 -07:00
|
|
|
EFL_PTHREAD_CFLAGS=${_efl_pthread_cflags}
|
|
|
|
EFL_PTHREAD_LIBS=${_efl_pthread_libs}
|
2009-02-17 06:18:14 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
AC_SUBST(EFL_PTHREAD_CFLAGS)
|
|
|
|
AC_SUBST(EFL_PTHREAD_LIBS)
|
2008-10-03 08:28:13 -07:00
|
|
|
|
|
|
|
if test "x${_efl_have_pthread}" = "xyes" ; then
|
|
|
|
AC_DEFINE(EFL_HAVE_PTHREAD, 1, [Define to mention that POSIX threads are supported])
|
|
|
|
fi
|
|
|
|
|
2009-12-25 03:29:08 -08:00
|
|
|
dnl check if the compiler supports pthreads spinlock
|
|
|
|
|
|
|
|
_efl_have_pthread_spinlock="no"
|
|
|
|
|
|
|
|
if test "x${_efl_have_pthread}" = "xyes" && test "x$1" = "xyes" ; then
|
|
|
|
|
2010-05-01 22:19:00 -07:00
|
|
|
SAVE_CFLAGS=${CFLAGS}
|
|
|
|
CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
|
2010-05-28 11:57:19 -07:00
|
|
|
SAVE_LIBS=${LIBS}
|
|
|
|
LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
|
2010-05-01 13:37:56 -07:00
|
|
|
AC_LINK_IFELSE(
|
2009-12-25 03:29:08 -08:00
|
|
|
[AC_LANG_PROGRAM([[
|
|
|
|
#include <pthread.h>
|
|
|
|
]],
|
|
|
|
[[
|
|
|
|
pthread_spinlock_t lock;
|
|
|
|
int res;
|
|
|
|
res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
|
|
|
|
]])],
|
|
|
|
[_efl_have_pthread_spinlock="yes"],
|
|
|
|
[_efl_have_pthread_spinlock="no"])
|
2010-05-01 22:19:00 -07:00
|
|
|
CFLAGS=${SAVE_CFLAGS}
|
2010-05-28 11:57:19 -07:00
|
|
|
LIBS=${SAVE_LIBS}
|
2009-12-25 03:29:08 -08:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
|
|
|
|
AC_MSG_RESULT([${_efl_have_pthread_spinlock}])
|
2010-03-07 04:13:30 -08:00
|
|
|
if test "x${_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread_spinlock}" = "xno" && test "x$1" = "xyes" ; then
|
2010-05-01 22:19:00 -07:00
|
|
|
AC_MSG_WARN([pthread support requested but spinlocks are not supported])
|
2010-02-28 09:27:23 -08:00
|
|
|
fi
|
2009-12-25 03:29:08 -08:00
|
|
|
|
|
|
|
if test "x${_efl_have_pthread_spinlock}" = "xyes" ; then
|
|
|
|
AC_DEFINE(EFL_HAVE_PTHREAD_SPINLOCK, 1, [Define to mention that POSIX threads spinlocks are supported])
|
2008-10-03 08:28:13 -07:00
|
|
|
fi
|
2009-12-25 03:29:08 -08:00
|
|
|
|
|
|
|
AS_IF([test "x$_efl_have_pthread" = "xyes"], [$2], [$3])
|
|
|
|
AS_IF([test "x$_efl_have_pthread_spinlock" = "xyes"], [$4], [$5])
|
|
|
|
|
2008-10-03 08:28:13 -07:00
|
|
|
])
|