1# generated automatically by aclocal 1.10.2 -*- Autoconf -*- 2 3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 5# This file is free software; the Free Software Foundation 6# gives unlimited permission to copy and/or distribute it, 7# with or without modifications, as long as this notice is preserved. 8 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11# even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12# PARTICULAR PURPOSE. 13 14dnl ______ /usr/share/aclocal/Installed_Packages/acx_pthread.m4 ______ 15dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 16dnl 17dnl This macro figures out how to build C programs using POSIX 18dnl threads. It sets the PTHREAD_LIBS output variable to the threads 19dnl library and linker flags, and the PTHREAD_CFLAGS output variable 20dnl to any special C compiler flags that are needed. (The user can also 21dnl force certain compiler flags/libs to be tested by setting these 22dnl environment variables.) 23dnl 24dnl Also sets PTHREAD_CC to any special C compiler that is needed for 25dnl multi-threaded programs (defaults to the value of CC otherwise). 26dnl (This is necessary on AIX to use the special cc_r compiler alias.) 27dnl 28dnl If you are only building threads programs, you may wish to 29dnl use these variables in your default LIBS, CFLAGS, and CC: 30dnl 31dnl LIBS="$PTHREAD_LIBS $LIBS" 32dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 33dnl CC="$PTHREAD_CC" 34dnl 35dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute 36dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE 37dnl to that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). 38dnl 39dnl ACTION-IF-FOUND is a list of shell commands to run if a threads 40dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands 41dnl to run it if it is not found. If ACTION-IF-FOUND is not specified, 42dnl the default action will define HAVE_PTHREAD. 43dnl 44dnl Please let the authors know if this macro fails on any platform, 45dnl or if you have any other suggestions or comments. This macro was 46dnl based on work by SGJ on autoconf scripts for FFTW (www.fftw.org) 47dnl (with help from M. Frigo), as well as ac_pthread and hb_pthread 48dnl macros posted by AFC to the autoconf macro repository. We are also 49dnl grateful for the helpful feedback of numerous users. 50dnl 51dnl @version %Id: acx_pthread.m4,v 1.3 2002/12/12 23:15:12 guidod Exp % 52dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Alejandro Forero Cuervo <bachue@bachue.com> 53 54AC_DEFUN([ACX_PTHREAD], [ 55AC_REQUIRE([AC_CANONICAL_HOST]) 56AC_LANG_SAVE 57AC_LANG_C 58acx_pthread_ok=no 59 60# We used to check for pthread.h first, but this fails if pthread.h 61# requires special compiler flags (e.g. on True64 or Sequent). 62# It gets checked for in the link test anyway. 63 64# First of all, check if the user has set any of the PTHREAD_LIBS, 65# etcetera environment variables, and if threads linking works using 66# them: 67if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then 68 save_CFLAGS="$CFLAGS" 69 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 70 save_LIBS="$LIBS" 71 LIBS="$PTHREAD_LIBS $LIBS" 72 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) 73 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) 74 AC_MSG_RESULT($acx_pthread_ok) 75 if test x"$acx_pthread_ok" = xno; then 76 PTHREAD_LIBS="" 77 PTHREAD_CFLAGS="" 78 fi 79 LIBS="$save_LIBS" 80 CFLAGS="$save_CFLAGS" 81fi 82 83# We must check for the threads library under a number of different 84# names; the ordering is very important because some systems 85# (e.g. DEC) have both -lpthread and -lpthreads, where one of the 86# libraries is broken (non-POSIX). 87 88# Create a list of thread flags to try. Items starting with a "-" are 89# C compiler flags, and other items are library names, except for "none" 90# which indicates that we try without any flags at all. 91 92acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" 93 94# The ordering *is* (sometimes) important. Some notes on the 95# individual items follow: 96 97# pthreads: AIX (must check this before -lpthread) 98# none: in case threads are in libc; should be tried before -Kthread and 99# other compiler flags to prevent continual compiler warnings 100# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) 101# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) 102# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) 103# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) 104# -pthreads: Solaris/gcc 105# -mthreads: Mingw32/gcc, Lynx/gcc 106# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it 107# doesn't hurt to check since this sometimes defines pthreads too; 108# also defines -D_REENTRANT) 109# pthread: Linux, etcetera 110# --thread-safe: KAI C++ 111 112case "${host_cpu}-${host_os}" in 113 *solaris*) 114 115 # On Solaris (at least, for some versions), libc contains stubbed 116 # (non-functional) versions of the pthreads routines, so link-based 117 # tests will erroneously succeed. (We need to link with -pthread or 118 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather 119 # a function called by this macro, so we could check for that, but 120 # who knows whether they'll stub that too in a future libc.) So, 121 # we'll just look for -pthreads and -lpthread first: 122 123 acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" 124 ;; 125esac 126 127if test x"$acx_pthread_ok" = xno; then 128for flag in $acx_pthread_flags; do 129 130 case $flag in 131 none) 132 AC_MSG_CHECKING([whether pthreads work without any flags]) 133 ;; 134 135 -*) 136 AC_MSG_CHECKING([whether pthreads work with $flag]) 137 PTHREAD_CFLAGS="$flag" 138 ;; 139 140 *) 141 AC_MSG_CHECKING([for the pthreads library -l$flag]) 142 PTHREAD_LIBS="-l$flag" 143 ;; 144 esac 145 146 save_LIBS="$LIBS" 147 save_CFLAGS="$CFLAGS" 148 LIBS="$PTHREAD_LIBS $LIBS" 149 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 150 151 # Check for various functions. We must include pthread.h, 152 # since some functions may be macros. (On the Sequent, we 153 # need a special flag -Kthread to make this header compile.) 154 # We check for pthread_join because it is in -lpthread on IRIX 155 # while pthread_create is in libc. We check for pthread_attr_init 156 # due to DEC craziness with -lpthreads. We check for 157 # pthread_cleanup_push because it is one of the few pthread 158 # functions on Solaris that doesn't have a non-functional libc stub. 159 # We try pthread_create on general principles. 160 AC_TRY_LINK([#include <pthread.h>], 161 [pthread_t th; pthread_join(th, 0); 162 pthread_attr_init(0); pthread_cleanup_push(0, 0); 163 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], 164 [acx_pthread_ok=yes]) 165 166 LIBS="$save_LIBS" 167 CFLAGS="$save_CFLAGS" 168 169 AC_MSG_RESULT($acx_pthread_ok) 170 if test "x$acx_pthread_ok" = xyes; then 171 break; 172 fi 173 174 PTHREAD_LIBS="" 175 PTHREAD_CFLAGS="" 176done 177fi 178 179# Various other checks: 180if test "x$acx_pthread_ok" = xyes; then 181 save_LIBS="$LIBS" 182 LIBS="$PTHREAD_LIBS $LIBS" 183 save_CFLAGS="$CFLAGS" 184 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 185 186 # Detect AIX lossage: threads are created detached by default 187 # and the JOINABLE attribute has a nonstandard name (UNDETACHED). 188 AC_MSG_CHECKING([for joinable pthread attribute]) 189 AC_TRY_LINK([#include <pthread.h>], 190 [int attr=PTHREAD_CREATE_JOINABLE;], 191 ok=PTHREAD_CREATE_JOINABLE, ok=unknown) 192 if test x"$ok" = xunknown; then 193 AC_TRY_LINK([#include <pthread.h>], 194 [int attr=PTHREAD_CREATE_UNDETACHED;], 195 ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) 196 fi 197 if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then 198 AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, 199 [Define to the necessary symbol if this constant 200 uses a non-standard name on your system.]) 201 fi 202 AC_MSG_RESULT(${ok}) 203 if test x"$ok" = xunknown; then 204 AC_MSG_WARN([we do not know how to create joinable pthreads]) 205 fi 206 207 AC_MSG_CHECKING([if more special flags are required for pthreads]) 208 flag=no 209 case "${host_cpu}-${host_os}" in 210 *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; 211 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; 212 esac 213 AC_MSG_RESULT(${flag}) 214 if test "x$flag" != xno; then 215 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" 216 fi 217 218 LIBS="$save_LIBS" 219 CFLAGS="$save_CFLAGS" 220 221 # More AIX lossage: must compile with cc_r 222 AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) 223else 224 PTHREAD_CC="$CC" 225fi 226 227AC_SUBST(PTHREAD_LIBS) 228AC_SUBST(PTHREAD_CFLAGS) 229AC_SUBST(PTHREAD_CC) 230 231# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: 232if test x"$acx_pthread_ok" = xyes; then 233 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) 234 : 235else 236 acx_pthread_ok=no 237 $2 238fi 239AC_LANG_RESTORE 240])dnl ACX_PTHREAD 241 242dnl 243dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 244dnl 245AC_DEFUN([AM_PATH_CPPUNIT], 246[ 247 248AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)], 249 cppunit_config_prefix="$withval", cppunit_config_prefix="") 250AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)], 251 cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="") 252 253 if test x$cppunit_config_exec_prefix != x ; then 254 cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix" 255 if test x${CPPUNIT_CONFIG+set} != xset ; then 256 CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config 257 fi 258 fi 259 if test x$cppunit_config_prefix != x ; then 260 cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix" 261 if test x${CPPUNIT_CONFIG+set} != xset ; then 262 CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config 263 fi 264 fi 265 266 AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no) 267 cppunit_version_min=$1 268 269 AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min) 270 no_cppunit="" 271 if test "$CPPUNIT_CONFIG" = "no" ; then 272 AC_MSG_RESULT(no) 273 no_cppunit=yes 274 else 275 CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags` 276 CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs` 277 cppunit_version=`$CPPUNIT_CONFIG --version` 278 279 cppunit_major_version=`echo $cppunit_version | \ 280 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 281 cppunit_minor_version=`echo $cppunit_version | \ 282 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 283 cppunit_micro_version=`echo $cppunit_version | \ 284 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 285 286 cppunit_major_min=`echo $cppunit_version_min | \ 287 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 288 if test "x${cppunit_major_min}" = "x" ; then 289 cppunit_major_min=0 290 fi 291 292 cppunit_minor_min=`echo $cppunit_version_min | \ 293 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 294 if test "x${cppunit_minor_min}" = "x" ; then 295 cppunit_minor_min=0 296 fi 297 298 cppunit_micro_min=`echo $cppunit_version_min | \ 299 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 300 if test "x${cppunit_micro_min}" = "x" ; then 301 cppunit_micro_min=0 302 fi 303 304 cppunit_version_proper=`expr \ 305 $cppunit_major_version \> $cppunit_major_min \| \ 306 $cppunit_major_version \= $cppunit_major_min \& \ 307 $cppunit_minor_version \> $cppunit_minor_min \| \ 308 $cppunit_major_version \= $cppunit_major_min \& \ 309 $cppunit_minor_version \= $cppunit_minor_min \& \ 310 $cppunit_micro_version \>= $cppunit_micro_min ` 311 312 if test "$cppunit_version_proper" = "1" ; then 313 AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version]) 314 else 315 AC_MSG_RESULT(no) 316 no_cppunit=yes 317 fi 318 fi 319 320 if test "x$no_cppunit" = x ; then 321 ifelse([$2], , :, [$2]) 322 else 323 CPPUNIT_CFLAGS="" 324 CPPUNIT_LIBS="" 325 ifelse([$3], , :, [$3]) 326 fi 327 328 AC_SUBST(CPPUNIT_CFLAGS) 329 AC_SUBST(CPPUNIT_LIBS) 330]) 331 332 333 334 335