aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/m4/efl_pthread.m4
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/evas/m4/efl_pthread.m4130
1 files changed, 130 insertions, 0 deletions
diff --git a/libraries/evas/m4/efl_pthread.m4 b/libraries/evas/m4/efl_pthread.m4
new file mode 100644
index 0000000..b90a045
--- /dev/null
+++ b/libraries/evas/m4/efl_pthread.m4
@@ -0,0 +1,130 @@
1dnl Copyright (C) 2010 Vincent Torri <vtorri at univ-evry dot fr>
2dnl That code is public domain and can be freely used or copied.
3
4dnl Macro that check if several pthread library is available or not.
5
6dnl Usage: EFL_CHECK_PTHREAD(want_pthread_spin[, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7dnl Call AC_SUBST(EFL_PTHREAD_CFLAGS)
8dnl Call AC_SUBST(EFL_PTHREAD_LIBS)
9dnl Define EFL_HAVE_PTHREAD
10dnl Define EFL_HAVE_PTHREAD_SPINLOCK
11
12AC_DEFUN([EFL_CHECK_PTHREAD],
13[
14
15dnl configure option
16
17AC_ARG_ENABLE([pthread],
18 [AC_HELP_STRING([--disable-pthread], [enable POSIX threads code @<:@default=auto@:>@])],
19 [
20 if test "x${enableval}" = "xyes" ; then
21 _efl_enable_pthread="yes"
22 else
23 _efl_enable_pthread="no"
24 fi
25 ],
26 [_efl_enable_pthread="auto"])
27
28AC_MSG_CHECKING([whether to build POSIX threads code])
29AC_MSG_RESULT([${_efl_enable_pthread}])
30
31dnl check if the compiler supports pthreads
32
33case "$host_os" in
34 mingw*)
35 _efl_pthread_cflags=""
36 _efl_pthread_libs="-lpthreadGC2"
37 ;;
38 solaris*)
39 _efl_pthread_cflags="-mt"
40 _efl_pthread_libs="-mt"
41 ;;
42 *)
43 _efl_pthread_cflags="-pthread"
44 _efl_pthread_libs="-pthread"
45 ;;
46esac
47
48_efl_have_pthread="no"
49
50if test "x${_efl_enable_pthread}" = "xyes" || test "x${_efl_enable_pthread}" = "xauto" ; then
51
52 SAVE_CFLAGS=${CFLAGS}
53 CFLAGS="${CFLAGS} ${_efl_pthread_cflags}"
54 SAVE_LIBS=${LIBS}
55 LIBS="${LIBS} ${_efl_pthread_libs}"
56 AC_LINK_IFELSE(
57 [AC_LANG_PROGRAM([[
58#include <pthread.h>
59 ]],
60 [[
61pthread_t id;
62id = pthread_self();
63 ]])],
64 [_efl_have_pthread="yes"],
65 [_efl_have_pthread="no"])
66 CFLAGS=${SAVE_CFLAGS}
67 LIBS=${SAVE_LIBS}
68
69fi
70
71AC_MSG_CHECKING([whether system support POSIX threads])
72AC_MSG_RESULT([${_efl_have_pthread}])
73if test "$x{_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread}" = "xno"; then
74 AC_MSG_ERROR([pthread support requested but not found.])
75fi
76
77EFL_PTHREAD_CFLAGS=""
78EFL_PTHREAD_LIBS=""
79if test "x${_efl_have_pthread}" = "xyes" ; then
80 EFL_PTHREAD_CFLAGS=${_efl_pthread_cflags}
81 EFL_PTHREAD_LIBS=${_efl_pthread_libs}
82fi
83
84AC_SUBST(EFL_PTHREAD_CFLAGS)
85AC_SUBST(EFL_PTHREAD_LIBS)
86
87if test "x${_efl_have_pthread}" = "xyes" ; then
88 AC_DEFINE(EFL_HAVE_PTHREAD, 1, [Define to mention that POSIX threads are supported])
89fi
90
91dnl check if the compiler supports pthreads spinlock
92
93_efl_have_pthread_spinlock="no"
94
95if test "x${_efl_have_pthread}" = "xyes" && test "x$1" = "xyes" ; then
96
97 SAVE_CFLAGS=${CFLAGS}
98 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
99 SAVE_LIBS=${LIBS}
100 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}"
101 AC_LINK_IFELSE(
102 [AC_LANG_PROGRAM([[
103#include <pthread.h>
104 ]],
105 [[
106pthread_spinlock_t lock;
107int res;
108res = pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
109 ]])],
110 [_efl_have_pthread_spinlock="yes"],
111 [_efl_have_pthread_spinlock="no"])
112 CFLAGS=${SAVE_CFLAGS}
113 LIBS=${SAVE_LIBS}
114
115fi
116
117AC_MSG_CHECKING([whether to build POSIX threads spinlock code])
118AC_MSG_RESULT([${_efl_have_pthread_spinlock}])
119if test "x${_efl_enable_pthread}" = "xyes" && test "x${_efl_have_pthread_spinlock}" = "xno" && test "x$1" = "xyes" ; then
120 AC_MSG_WARN([pthread support requested but spinlocks are not supported])
121fi
122
123if test "x${_efl_have_pthread_spinlock}" = "xyes" ; then
124 AC_DEFINE(EFL_HAVE_PTHREAD_SPINLOCK, 1, [Define to mention that POSIX threads spinlocks are supported])
125fi
126
127AS_IF([test "x$_efl_have_pthread" = "xyes"], [$2], [$3])
128AS_IF([test "x$_efl_have_pthread_spinlock" = "xyes"], [$4], [$5])
129
130])