summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-11-12 16:06:22 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-12 16:06:22 +0900
commit2a29732e0734af82294d7b1fccc52595f3020f15 (patch)
tree49e5fc8c9428ea8af790ac50710065d541321708 /m4
parentd2ff8d70a5d88307a1567f92c910abc0d9c4c272 (diff)
efl: let's try to detect in a portable way phtread around the world.
Linking to Pthread seems to be highly not portable. Look at lock.m4 macro if you want to understand the hell it is ! By following it closely we should now have better portability than the 1.7.x release. And of course than our alpha...
Diffstat (limited to 'm4')
-rw-r--r--m4/efl_threads.m456
1 files changed, 24 insertions, 32 deletions
diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4
index e7a84b3..acea5a9 100644
--- a/m4/efl_threads.m4
+++ b/m4/efl_threads.m4
@@ -17,49 +17,40 @@ dnl Generic thread detection
17EFL_PTHREAD_CFLAGS="" 17EFL_PTHREAD_CFLAGS=""
18EFL_PTHREAD_LIBS="" 18EFL_PTHREAD_LIBS=""
19 19
20_efl_enable_posix_threads="no"
21_efl_have_posix_threads="no" 20_efl_have_posix_threads="no"
22_efl_have_win32_threads="no" 21_efl_have_win32_threads="no"
23 22
23dnl Use generic infrastructure for pthread detection (What a hell of a mess !)
24gl_LOCK
25
26AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
27
24case "$host_os" in 28case "$host_os" in
25 mingw*) 29 mingw*)
26 _efl_have_win32_threads="yes" 30 _efl_have_win32_threads="yes"
27 efl_have_setaffinity="yes" 31 efl_have_setaffinity="yes"
28 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported]) 32 AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported])
29 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
30 ;; 33 ;;
31 *) 34 *)
32 _efl_enable_posix_threads="yes" 35 _efl_have_posix_threads="${gl_use_threads}"
33 _efl_threads_cflags="-D_REENTRANT" 36 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
34 _efl_threads_libs="-lpthread"
35 ;; 37 ;;
36esac 38esac
37 39
38dnl check if the compiler supports POSIX threads 40dnl System specific CFLAGS
39 41if test "x${_efl_have_posix_threads}" = "xyes"; then
42 case "$host_os" in
43 osf*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
44 aix* | freebsd*) EFL_PTHREAD_CFLAGS="-D_THREAD_SAFE" ;;
45 solaris*) EFL_PTHREAD_CFLAGS="-D_REENTRANT" ;;
46 esac
47fi
40 48
41if test "x${_efl_enable_posix_threads}" = "xyes" ; then 49dnl check if the compiler supports POSIX threads
50if test "x${_efl_have_posix_threads}" = "xyes" ; then
42 51
43 SAVE_CFLAGS=${CFLAGS}
44 CFLAGS="${CFLAGS} ${_efl_threads_cflags}"
45 SAVE_LIBS=${LIBS} 52 SAVE_LIBS=${LIBS}
46 LIBS="${LIBS} ${_efl_threads_libs}" 53 LIBS="${LIBS} ${LIBMULTITHREAD}"
47 AC_LINK_IFELSE(
48 [AC_LANG_PROGRAM([[
49#include <pthread.h>
50 ]],
51 [[
52pthread_t id;
53id = pthread_self();
54 ]])],
55 [
56 _efl_have_posix_threads="yes"
57 AC_DEFINE([EFL_HAVE_POSIX_THREADS], [1], [Define to mention that POSIX threads are supported])
58 AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported])
59 EFL_PTHREAD_CFLAGS=${_efl_threads_cflags}
60 EFL_PTHREAD_LIBS=${_efl_threads_libs}
61 ],
62 [_efl_have_posix_threads="no"])
63 AC_LINK_IFELSE( 54 AC_LINK_IFELSE(
64 [AC_LANG_PROGRAM([[ 55 [AC_LANG_PROGRAM([[
65#include <pthread.h> 56#include <pthread.h>
@@ -83,7 +74,6 @@ pthread_attr_setaffinity_np(NULL, 0, NULL);
83 [efl_have_setaffinity="no"]) 74 [efl_have_setaffinity="no"])
84 CFLAGS=${SAVE_CFLAGS} 75 CFLAGS=${SAVE_CFLAGS}
85 LIBS=${SAVE_LIBS} 76 LIBS=${SAVE_LIBS}
86
87fi 77fi
88 78
89AC_MSG_CHECKING([which threads API is used]) 79AC_MSG_CHECKING([which threads API is used])
@@ -100,6 +90,8 @@ else
100fi 90fi
101AC_MSG_RESULT([${efl_have_threads}]) 91AC_MSG_RESULT([${efl_have_threads}])
102 92
93EFL_PTHREAD_LIBS="${LTLIBMULTITHREAD}"
94
103AC_SUBST(EFL_PTHREAD_CFLAGS) 95AC_SUBST(EFL_PTHREAD_CFLAGS)
104AC_SUBST(EFL_PTHREAD_LIBS) 96AC_SUBST(EFL_PTHREAD_LIBS)
105 97
@@ -108,11 +100,8 @@ dnl check if the compiler supports pthreads spinlock
108efl_have_posix_threads_spinlock="no" 100efl_have_posix_threads_spinlock="no"
109 101
110if test "x${_efl_have_posix_threads}" = "xyes" ; then 102if test "x${_efl_have_posix_threads}" = "xyes" ; then
111
112 SAVE_CFLAGS=${CFLAGS}
113 CFLAGS="${CFLAGS} ${EFL_PTHREAD_CFLAGS}"
114 SAVE_LIBS=${LIBS} 103 SAVE_LIBS=${LIBS}
115 LIBS="${LIBS} ${EFL_PTHREAD_LIBS}" 104 LIBS="${LIBS} ${LIBMULTITHREAD}"
116 AC_LINK_IFELSE( 105 AC_LINK_IFELSE(
117 [AC_LANG_PROGRAM([[ 106 [AC_LANG_PROGRAM([[
118#include <pthread.h> 107#include <pthread.h>
@@ -138,6 +127,9 @@ if test "x${efl_have_posix_threads_spinlock}" = "xyes" ; then
138 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported]) 127 AC_DEFINE([EFL_HAVE_POSIX_THREADS_SPINLOCK], [1], [Define to mention that POSIX threads spinlocks are supported])
139fi 128fi
140 129
130echo "_efl_have_posix_threads: ${_efl_have_posix_threads}"
131echo "_efl_have_win32_threads: ${_efl_have_win32_threads}"
132
141AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"], 133AS_IF([test "x$_efl_have_posix_threads" = "xyes" || test "x$_efl_have_win32_threads" = "xyes"],
142 [$1], 134 [$1],
143 [m4_if([$2], [$2], [AC_MSG_ERROR([Threads are required.])])]) 135 [m4_if([$2], [$2], [AC_MSG_ERROR([Threads are required.])])])