~d-ci/libmemcached/pushtest

« back to all changes in this revision

Viewing changes to m4/ax_pthread.m4

  • Committer: Continuous Integration
  • Date: 2013-11-04 17:14:31 UTC
  • mfrom: (1079.33.11 workspace)
  • Revision ID: ci@tangent.org-20131104171431-yj69t4kajuanut6c
Merge lp:libmemcached/1.0 Build: jenkins-Libmemcached-377

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
#   modified version of the Autoconf Macro, you may extend this special
83
83
#   exception to the GPL to apply to your modified version as well.
84
84
 
85
 
#serial 20
 
85
#serial 22
86
86
 
87
87
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
88
88
AC_DEFUN([AX_PTHREAD], [
103
103
        save_LIBS="$LIBS"
104
104
        LIBS="$PTHREAD_LIBS $LIBS"
105
105
        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
106
 
        AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
107
 
        AC_MSG_RESULT($ax_pthread_ok)
 
106
        AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
 
107
        AC_MSG_RESULT([$ax_pthread_ok])
108
108
        if test x"$ax_pthread_ok" = xno; then
109
109
                PTHREAD_LIBS=""
110
110
                PTHREAD_CFLAGS=""
160
160
        ;;
161
161
 
162
162
        darwin*)
163
 
        ax_pthread_flags="-pthread $ax_pthread_flags"
 
163
        ax_pthread_flags="none -pthread $ax_pthread_flags"
164
164
        ;;
165
165
esac
166
166
 
 
167
# Clang doesn't consider unrecognized options an error unless we specify
 
168
# -Werror. We throw in some extra Clang-specific options to ensure that
 
169
# this doesn't happen for GCC, which also accepts -Werror.
 
170
 
 
171
AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
 
172
save_CFLAGS="$CFLAGS"
 
173
ax_pthread_extra_flags="-Werror"
 
174
CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
 
175
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
 
176
                  [AC_MSG_RESULT([yes])],
 
177
                  [ax_pthread_extra_flags=
 
178
                   AC_MSG_RESULT([no])])
 
179
CFLAGS="$save_CFLAGS"
 
180
 
167
181
if test x"$ax_pthread_ok" = xno; then
168
182
for flag in $ax_pthread_flags; do
169
183
 
178
192
                ;;
179
193
 
180
194
                pthread-config)
181
 
                AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
 
195
                AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
182
196
                if test x"$ax_pthread_config" = xno; then continue; fi
183
197
                PTHREAD_CFLAGS="`pthread-config --cflags`"
184
198
                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
193
207
        save_LIBS="$LIBS"
194
208
        save_CFLAGS="$CFLAGS"
195
209
        LIBS="$PTHREAD_LIBS $LIBS"
196
 
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 
210
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
197
211
 
198
212
        # Check for various functions.  We must include pthread.h,
199
213
        # since some functions may be macros.  (On the Sequent, we
219
233
        LIBS="$save_LIBS"
220
234
        CFLAGS="$save_CFLAGS"
221
235
 
222
 
        AC_MSG_RESULT($ax_pthread_ok)
 
236
        AC_MSG_RESULT([$ax_pthread_ok])
223
237
        if test "x$ax_pthread_ok" = xyes; then
224
238
                break;
225
239
        fi
245
259
                [attr_name=$attr; break],
246
260
                [])
247
261
        done
248
 
        AC_MSG_RESULT($attr_name)
 
262
        AC_MSG_RESULT([$attr_name])
249
263
        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
250
 
            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
 
264
            AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
251
265
                               [Define to necessary symbol if this constant
252
266
                                uses a non-standard name on your system.])
253
267
        fi
261
275
            if test "$GCC" = "yes"; then
262
276
                flag="-D_REENTRANT"
263
277
            else
 
278
                # TODO: What about Clang on Solaris?
264
279
                flag="-mt -D_REENTRANT"
265
280
            fi
266
281
            ;;
267
282
        esac
268
 
        AC_MSG_RESULT(${flag})
 
283
        AC_MSG_RESULT([$flag])
269
284
        if test "x$flag" != xno; then
270
285
            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
271
286
        fi
272
287
 
273
288
        AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
274
 
            ax_cv_PTHREAD_PRIO_INHERIT, [
275
 
                AC_LINK_IFELSE([
276
 
                    AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
 
289
            [ax_cv_PTHREAD_PRIO_INHERIT], [
 
290
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
 
291
                                                [[int i = PTHREAD_PRIO_INHERIT;]])],
277
292
                    [ax_cv_PTHREAD_PRIO_INHERIT=yes],
278
293
                    [ax_cv_PTHREAD_PRIO_INHERIT=no])
279
294
            ])
280
295
        AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
281
 
            AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
 
296
            [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
282
297
 
283
298
        LIBS="$save_LIBS"
284
299
        CFLAGS="$save_CFLAGS"
301
316
 
302
317
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
303
318
 
304
 
AC_SUBST(PTHREAD_LIBS)
305
 
AC_SUBST(PTHREAD_CFLAGS)
306
 
AC_SUBST(PTHREAD_CC)
 
319
AC_SUBST([PTHREAD_LIBS])
 
320
AC_SUBST([PTHREAD_CFLAGS])
 
321
AC_SUBST([PTHREAD_CC])
307
322
 
308
323
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
309
324
if test x"$ax_pthread_ok" = xyes; then
310
 
        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
 
325
        ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
311
326
        :
312
327
else
313
328
        ax_pthread_ok=no