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
|
dnl Copyright (c) 2005, Eric Crahen
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a copy
dnl of this software and associated documentation files (the "Software"), to deal
dnl in the Software without restriction, including without limitation the rights
dnl to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
dnl copies of the Software, and to permit persons to whom the Software is furnished
dnl to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included in all
dnl copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dnl AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
dnl WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
dnl CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dnl
dnl Enables AM_DETECT_PTHREAD to test for
dnl pthreads support
dnl
dnl --with-pthread
dnl
dnl If support is available, then HAVE_POSIX_THREADS
dnl will be set
dnl TODO: update the checks to only use -lrt when needed
dnl
ifdef(AM_DETECT_PTHREAD,,[
NO_PTHREAD_ERROR=<<"EOF"
Please install/update your POSIX threads (pthreads) library. Updates
should be available from either your system vendor, or, for GNU/Linux
systems, go to http://pauillac.inria.fr/~xleroy/linuxthreads/.
GNU Pth can also be used if it was configured with --enable-pthread.
EOF
AC_DEFUN(AM_DETECT_PTHREAD,
[
pthread_explicit="no"
AC_ARG_ENABLE(pthread,
AC_HELP_STRING([--enable-pthread],
[use pthreads [default=detect]]),
[pthread_explicit="yes"],
[enable_pthread="yes"])
AC_ARG_WITH(pthread-prefix,
[ --with-pthread-prefix POSIX threads library prefix (optional)],
[
if test x$pthread_prefix != x ; then
PTHREAD_LIBS="-L$withval/lib"
PTHREAD_CXXFLAGS="-I$withval/include"
fi
pthread_explicit="yes"
enable_pthread="yes"
],
[PTHREAD_LIBS=""
PTHREAD_CXXFLAGS=""
])
PTHREAD_CXXFLAGS="-DREENTRANT $PTHREAD_CXXFLAGS"
if test x$enable_pthread != xno; then
ac_save_LIBS="$LIBS"
ac_save_CXXFLAGS="$CXXFLAGS"
AC_CHECK_HEADER([pthread.h],
[AC_MSG_CHECKING([for linker option -pthread])
LIBS="ac_save_LIBS $PTHREAD_LIBS -pthread"
CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS"
AC_TRY_LINK([#include <pthread.h>],
[
pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0);
],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_POSIX_THREADS,,[defined when pthreads is available])
PTHREAD_LIBS="$PTHREAD_LIBS -pthread"
],
[AC_MSG_RESULT(no)
AC_MSG_CHECKING(for linker option -lpthread)
LIBS="$ac_save_LIBS $PTHREAD_LIBS -lpthread"
AC_TRY_LINK([#include <pthread.h>],
[
pthread_create((pthread_t*) 0,(pthread_attr_t*) 0, 0, 0);
],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_POSIX_THREADS,,[defined when pthreads is available])
PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
],
[AC_MSG_RESULT(no)
if test $pthread_explicit = "yes"; then
AC_MSG_ERROR(${NO_PTHREAD_ERROR})
fi
])
])
])
dnl Check for SunOS rt library
AC_CHECK_LIB(rt, sched_get_priority_max,
[ AC_DEFINE(HAVE_SCHED_RT,,[Defined if -lrt is needed for RT scheduling])
PTHREAD_LIBS="$LIBS -lrt" ])
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CXXFLAGS)
dnl Check for sched_yield
AC_MSG_CHECKING(for sched_yield);
AC_TRY_LINK([#include <sched.h>],
[ sched_yield(); ],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SCHED_YIELD,,[Defined if sched_yield() is available]) ],
[ AC_MSG_RESULT(no) ])
dnl Check for pthread_yield
AC_MSG_CHECKING(for pthread_yield);
AC_TRY_LINK([#include <pthread.h>],
[ pthread_yield(); ],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREAD_YIELD,,[Defined if pthread_yield() is available]) ],
[ AC_MSG_RESULT(no) ])
dnl Check for pthread_key_create
AC_MSG_CHECKING(for pthread_key_create)
AC_TRY_LINK([#include <pthread.h>],
[ pthread_key_create(0, 0);],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREADKEY_CREATE,,[Defined if pthread_key_create() is available]) ],
[ AC_MSG_RESULT(no)
AC_MSG_CHECKING(for pthread_keycreate)
AC_TRY_LINK([#include <pthread.h>],
[ pthread_keycreate(0,0); ],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_PTHREADKEYCREATE,,[Defined if pthread_keycreate() is available])
], AC_MSG_RESULT(no))
])
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
])
])
dnl Eric Crahen <crahen at code-foo dot com>
|