File: libcthreads.m4

package info (click to toggle)
libbfio 20140105-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,800 kB
  • ctags: 2,962
  • sloc: ansic: 95,778; sh: 11,974; makefile: 714; sed: 16
file content (352 lines) | stat: -rw-r--r-- 8,848 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
dnl Functions for libcthreads
dnl
dnl Version: 20130509

dnl Function to detect if libcthreads is available
dnl ac_libcthreads_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
AC_DEFUN([AX_LIBCTHREADS_CHECK_LIB],
 [dnl Check if parameters were provided
 AS_IF(
  [test "x$ac_cv_with_libcthreads" != x && test "x$ac_cv_with_libcthreads" != xno && test "x$ac_cv_with_libcthreads" != xauto-detect],
  [AS_IF(
   [test -d "$ac_cv_with_libcthreads"],
   [CFLAGS="$CFLAGS -I${ac_cv_with_libcthreads}/include"
   LDFLAGS="$LDFLAGS -L${ac_cv_with_libcthreads}/lib"],
   [AC_MSG_WARN([no such directory: $ac_cv_with_libcthreads])
   ])
  ])

 AS_IF(
  [test "x$ac_cv_with_libcthreads" = xno],
  [ac_cv_libcthreads=no],
  [dnl Check for a pkg-config file
  AS_IF(
   [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"],
   [PKG_CHECK_MODULES(
    [libcthreads],
    [libcthreads >= 20130509],
    [ac_cv_libcthreads=yes],
    [ac_cv_libcthreads=no])
   ])

  AS_IF(
   [test "x$ac_cv_libcthreads" = xyes],
   [ac_cv_libcthreads_CPPFLAGS="$pkg_cv_libcthreads_CFLAGS"
   ac_cv_libcthreads_LIBADD="$pkg_cv_libcthreads_LIBS"],
   [dnl Check for headers
   AC_CHECK_HEADERS([libcthreads.h])

   AS_IF(
    [test "x$ac_cv_header_libcthreads_h" = xno],
    [ac_cv_libcthreads=no],
    [dnl Check for the individual functions
    ac_cv_libcthreads=yes

    AC_CHECK_LIB(
     cthreads,
     libcthreads_get_version,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Thread functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_create,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_join,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Thread attributes functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_attributes_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_attributes_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Condition functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_condition_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_condition_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_condition_broadcast,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_condition_signal,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_condition_wait,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Lock functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_lock_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_lock_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_lock_grab,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_lock_release,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Mutex functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_mutex_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_mutex_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_mutex_grab,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_mutex_try_grab,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_mutex_release,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Read/Write lock functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_grab_for_read,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_grab_for_write,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_release_for_read,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_read_write_lock_release_for_write,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Queue functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_queue_initialize,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_queue_free,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_queue_pop,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_queue_push,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    dnl Thread pool functions
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_pool_create,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_pool_push,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])
    AC_CHECK_LIB(
     cthreads,
     libcthreads_thread_pool_join,
     [ac_cv_libcthreads_dummy=yes],
     [ac_cv_libcthreads=no])

    ac_cv_libcthreads_LIBADD="-lcthreads"
    ])
   ])
  ])

 AS_IF(
  [test "x$ac_cv_libcthreads" = xyes],
  [AC_DEFINE(
   [HAVE_LIBCTHREADS],
   [1],
   [Define to 1 if you have the `cthreads' library (-lcthreads).])
  ])

 AS_IF(
  [test "x$ac_cv_libcthreads" = xyes],
  [ac_cv_libcthreads_multi_threading=libcthreads],
  [ac_cv_libcthreads_multi_threading=no])

 AS_IF(
  [test "x$ac_cv_libcthreads" = xyes],
  [AC_SUBST(
   [HAVE_LIBCTHREADS],
   [1]) ],
  [AC_SUBST(
   [HAVE_LIBCTHREADS],
   [0])
  ])
 ])

dnl Function to detect if libcthreads dependencies are available
AC_DEFUN([AX_LIBCTHREADS_CHECK_LOCAL],
 [AS_IF(
  [test "x$ac_cv_enable_winapi" = xno],
  [dnl Check for enabling pthread support
  AX_PTHREAD_CHECK_ENABLE
   ac_cv_libcthreads_multi_threading=$ac_cv_pthread],
  [ac_cv_libcthreads_multi_threading="winapi"])

 AS_IF(
  [test "x$ac_cv_libcthreads_multi_threading" != xno],
  [ac_cv_libcthreads_CPPFLAGS="-I../libcthreads";
  ac_cv_libcthreads_LIBADD="../libcthreads/libcthreads.la";

  ac_cv_libcthreads=local],
  [ac_cv_libcthreads=no])
 ])

dnl Function to detect how to enable libcthreads
AC_DEFUN([AX_LIBCTHREADS_CHECK_ENABLE],
 [AX_COMMON_ARG_ENABLE(
  [multi-threading-support],
  [multi_threading_support],
  [enable multi-threading support],
  [yes])
 AX_COMMON_ARG_WITH(
  [libcthreads],
  [libcthreads],
  [search for libcthreads in includedir and libdir or in the specified DIR, or no if to use local version],
  [auto-detect],
  [DIR])

 AS_IF(
  [test "x$ac_cv_enable_multi_threading_support" = xno],
  [ac_cv_libcthreads="no"
  ac_cv_libcthreads_multi_threading="no"],
  [dnl Check for a shared library version
  AX_LIBCTHREADS_CHECK_LIB

  dnl Check if the dependencies for the local library version
  AS_IF(
   [test "x$ac_cv_libcthreads" != xyes],
   [AX_LIBCTHREADS_CHECK_LOCAL

   AC_DEFINE(
    [HAVE_LOCAL_LIBCTHREADS],
    [1],
    [Define to 1 if the local version of libcthreads is used.])
   AC_SUBST(
    [HAVE_LOCAL_LIBCTHREADS],
    [1])
   ])
  ])

 AM_CONDITIONAL(
  [HAVE_LOCAL_LIBCTHREADS],
  [test "x$ac_cv_libcthreads" = xlocal])
 AS_IF(
  [test "x$ac_cv_libcthreads_CPPFLAGS" != "x"],
  [AC_SUBST(
   [LIBCTHREADS_CPPFLAGS],
   [$ac_cv_libcthreads_CPPFLAGS])
  ])
 AS_IF(
  [test "x$ac_cv_libcthreads_LIBADD" != "x"],
  [AC_SUBST(
   [LIBCTHREADS_LIBADD],
   [$ac_cv_libcthreads_LIBADD])
  ])

 AS_IF(
  [test "x$ac_cv_libcthreads" != xno],
  [AC_DEFINE(
   [HAVE_MULTI_THREAD_SUPPORT],
   [1],
   [Define to 1 if multi thread support should be used.])
  AC_SUBST(
   [HAVE_MULTI_THREAD_SUPPORT],
   [1]) ],
  [AC_SUBST(
   [HAVE_MULTI_THREAD_SUPPORT],
   [0])
  ])

 AS_IF(
  [test "x$ac_cv_libcthreads" = xyes],
  [AC_SUBST(
   [ax_libcthreads_pc_libs_private],
   [-lcthreads])
  ])

 AS_IF(
  [test "x$ac_cv_libcthreads" = xyes],
  [AC_SUBST(
   [ax_libcthreads_spec_requires],
   [libcthreads])
  AC_SUBST(
   [ax_libcthreads_spec_build_requires],
   [libcthreads-devel])
  ])
 ])