66
66
dnl Check whether the current setup can use POSIX threads calls
67
67
dnl
68
68
AC_DEFUN ( [ PTHREADS_CHECK_COMPILE] , [
69
- AC_TRY_RUN ( [
69
+ AC_LINK_IFELSE ( [ AC_LANG_SOURCE ( [
70
70
#include <pthread.h>
71
71
#include <stddef.h>
72
72
@@ -80,18 +80,11 @@ int main() {
80
80
int data = 1;
81
81
pthread_mutexattr_init(&mattr);
82
82
return pthread_create(&thd, NULL, thread_routine, &data);
83
- } ] , [
84
- pthreads_working =yes
83
+ } ] ) ] , [
84
+ pthreads_checked =yes
85
85
] , [
86
- pthreads_working=no
87
- ] , [
88
- dnl For cross compiling running this test is of no use. NetWare supports pthreads
89
- pthreads_working=no
90
- case $host_alias in
91
- *netware*)
92
- pthreads_working=yes
93
- esac
94
- ]
86
+ pthreads_checked=no
87
+ ]
95
88
) ] ) dnl
96
89
dnl
97
90
dnl PTHREADS_CHECK()
@@ -129,30 +122,34 @@ else
129
122
CFLAGS="$CFLAGS $flag"
130
123
PTHREADS_CHECK_COMPILE
131
124
CFLAGS=$ac_save
132
- if test "$pthreads_working " = "yes"; then
125
+ if test "$pthreads_checked " = "yes"; then
133
126
ac_cv_pthreads_cflags=$flag
134
127
break
135
128
fi
136
129
done
137
130
fi
138
- fi
139
- ] )
131
+ ] )
132
+
133
+ AC_CACHE_CHECK ( for pthreads_lib , ac_cv_pthreads_lib ,[
134
+ ac_cv_pthreads_lib=
135
+ if test "$pthreads_working" != "yes"; then
136
+ for lib in pthread pthreads c_r; do
137
+ ac_save=$LIBS
138
+ LIBS="$LIBS -l$lib"
139
+ PTHREADS_CHECK_COMPILE
140
+ LIBS=$ac_save
141
+ if test "$pthreads_checked" = "yes"; then
142
+ ac_cv_pthreads_lib=$lib
143
+ break
144
+ fi
145
+ done
146
+ fi
147
+ ] )
140
148
141
- AC_CACHE_CHECK ( for pthreads_lib , ac_cv_pthreads_lib ,[
142
- ac_cv_pthreads_lib=
143
- if test "$pthreads_working" != "yes"; then
144
- for lib in pthread pthreads c_r; do
145
- ac_save=$LIBS
146
- LIBS="$LIBS -l$lib"
147
- PTHREADS_CHECK_COMPILE
148
- LIBS=$ac_save
149
- if test "$pthreads_working" = "yes"; then
150
- ac_cv_pthreads_lib=$lib
151
- break
152
- fi
153
- done
149
+ if test "x$ac_cv_pthreads_cflags" != "x" -o "x$ac_cv_pthreads_lib" != "x"; then
150
+ pthreads_working="yes"
151
+ fi
154
152
fi
155
- ] )
156
153
157
154
if test "$pthreads_working" = "yes"; then
158
155
threads_result="POSIX-Threads found"
0 commit comments