1 # AST_GCC_ATTRIBUTE([attribute name])
3 AC_DEFUN([AST_GCC_ATTRIBUTE],
5 AC_MSG_CHECKING(for compiler 'attribute $1' support)
7 CFLAGS="$CFLAGS -Werror"
9 AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
12 AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
15 CFLAGS="$saved_CFLAGS"
18 # AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
20 AC_DEFUN([AST_EXT_LIB_SETUP],
24 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
40 AC_SUBST([$1_INCLUDE])
45 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data], [additional INCLUDE data])
47 AC_DEFUN([AST_EXT_LIB_CHECK],
49 if test "${USE_$1}" != "no"; then
51 if test "x${$1_DIR}" != "x"; then
52 if test -d ${$1_DIR}/lib; then
53 pbxlibdir="-L${$1_DIR}/lib"
55 pbxlibdir="-L${$1_DIR}"
58 AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
60 if test "${AST_$1_FOUND}" = "yes"; then
63 if test "x${$1_DIR}" != "x"; then
64 $1_LIB="${pbxlibdir} ${$1_LIB}"
65 $1_INCLUDE="-I${$1_DIR}/include"
67 $1_INCLUDE="${$1_INCLUDE} $6"
68 saved_cppflags="${CPPFLAGS}"
69 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
70 if test "x$4" != "x" ; then
71 AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
73 CPPFLAGS="${saved_cppflags}"
74 if test "x${$1_HEADER_FOUND}" = "x0" ; then
75 if test -n "${$1_MANDATORY}" ;
78 AC_MSG_NOTICE([*** It appears that you do not have the $2 development package installed.])
79 AC_MSG_NOTICE([*** Please install it to include ${$1_DESCRIP} support, or re-run configure])
80 AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
88 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
90 elif test -n "${$1_MANDATORY}";
93 AC_MSG_NOTICE([*** The ${$1_DESCRIP} installation on this system appears to be broken.])
94 AC_MSG_NOTICE([*** Either correct the installation, or run configure])
95 AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
101 # The next three functions check for the availability of a given package.
102 # AST_C_DEFINE_CHECK looks for the presence of a #define in a header file,
103 # AST_C_COMPILE_CHECK can be used for testing for various items in header files,
104 # AST_EXT_LIB_CHECK looks for a symbol in a given library, or at least
105 # for the presence of a header file.
106 # AST_EXT_TOOL_CHECK looks for a symbol in using $1-config to determine CFLAGS and LIBS
108 # They are only run if PBX_$1 != 1 (where $1 is the package),
109 # so you can call them multiple times and stop at the first matching one.
110 # On success, they both set PBX_$1 = 1, set $1_INCLUDE and $1_LIB as applicable,
111 # and also #define HAVE_$1 1 and #define HAVE_$1_VERSION ${last_argument}
112 # in autoconfig.h so you can tell which test succeeded.
113 # They should be called after AST_EXT_LIB_SETUP($1, ...)
115 # Check if a given macro is defined in a certain header.
117 # AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
118 AC_DEFUN([AST_C_DEFINE_CHECK],
120 if test "x${PBX_$1}" != "x1"; then
121 AC_MSG_CHECKING([for $2 in $3])
122 saved_cppflags="${CPPFLAGS}"
123 if test "x${$1_DIR}" != "x"; then
124 $1_INCLUDE="-I${$1_DIR}/include"
126 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
129 [ AC_LANG_PROGRAM( [#include <$3>],
139 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
140 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
142 [ AC_MSG_RESULT(no) ]
144 CPPFLAGS="${saved_cppflags}"
149 # AST_C_COMPILE_CHECK can be used for testing for various items in header files
151 # AST_C_COMPILE_CHECK([package], [expression], [header file], [version])
152 AC_DEFUN([AST_C_COMPILE_CHECK],
154 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
155 AC_MSG_CHECKING([if "$2" compiles using $3])
156 saved_cppflags="${CPPFLAGS}"
157 if test "x${$1_DIR}" != "x"; then
158 $1_INCLUDE="-I${$1_DIR}/include"
160 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
163 [ AC_LANG_PROGRAM( [#include <$3>],
168 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
169 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
171 [ AC_MSG_RESULT(no) ]
173 CPPFLAGS="${saved_cppflags}"
178 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
179 GNU_MAKE='Not Found' ;
180 GNU_MAKE_VERSION_MAJOR=0 ;
181 GNU_MAKE_VERSION_MINOR=0 ;
182 for a in make gmake gnumake ; do
183 if test -z "$a" ; then continue ; fi ;
184 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
186 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
187 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
192 if test "x$GNU_MAKE" = "xNot Found" ; then
193 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
205 if test "${PWLIBDIR:-unset}" != "unset" ; then
206 AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
208 if test "${HAS_PWLIB:-unset}" = "unset" ; then
209 if test "${OPENH323DIR:-unset}" != "unset"; then
210 AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
212 if test "${HAS_PWLIB:-unset}" != "unset" ; then
213 PWLIBDIR="${OPENH323DIR}/../pwlib"
215 AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
216 if test "${HAS_PWLIB:-unset}" != "unset" ; then
217 PWLIBDIR="${HOME}/pwlib"
219 AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
220 if test "${HAS_PWLIB:-unset}" != "unset" ; then
221 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
222 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
223 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
225 PWLIB_INCDIR="/usr/local/include"
226 PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
227 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
228 if test "x$LIB64" != "x"; then
229 PWLIB_LIBDIR="/usr/local/lib64"
231 PWLIB_LIBDIR="/usr/local/lib"
234 PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
235 PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
237 AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
238 if test "${HAS_PWLIB:-unset}" != "unset" ; then
239 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
240 PWLIB_INCDIR="/usr/include"
241 PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
242 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
243 if test "x$LIB64" != "x"; then
244 PWLIB_LIBDIR="/usr/lib64"
246 PWLIB_LIBDIR="/usr/lib"
249 PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
250 PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
257 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
258 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
262 if test "${HAS_PWLIB:-unset}" != "unset" ; then
263 if test "${PWLIBDIR:-unset}" = "unset" ; then
264 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
265 PWLIBDIR=`$PTLIB_CONFIG --prefix`
267 echo "Cannot find ptlib-config - please install and try again"
272 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
273 PWLIBDIR="/usr/share/pwlib"
274 PWLIB_INCDIR="/usr/include"
275 if test "x$LIB64" != "x"; then
276 PWLIB_LIBDIR="/usr/lib64"
278 PWLIB_LIBDIR="/usr/lib"
281 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
282 PWLIBDIR="/usr/local/share/pwlib"
283 PWLIB_INCDIR="/usr/local/include"
284 if test "x$LIB64" != "x"; then
285 PWLIB_LIBDIR="/usr/local/lib64"
287 PWLIB_LIBDIR="/usr/local/lib"
291 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
292 PWLIB_INCDIR="${PWLIBDIR}/include"
294 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
295 PWLIB_LIBDIR="${PWLIBDIR}/lib"
299 AC_SUBST([PWLIB_INCDIR])
300 AC_SUBST([PWLIB_LIBDIR])
307 [AST_CHECK_OPENH323_PLATFORM], [
310 linux*) PWLIB_OSTYPE=linux ;
312 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
314 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
315 ENDLDLIBS="-lossaudio" ;
317 netbsd* ) PWLIB_OSTYPE=NetBSD ;
318 ENDLDLIBS="-lossaudio" ;
320 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
322 darwin* ) PWLIB_OSTYPE=Darwin ;
324 beos*) PWLIB_OSTYPE=beos ;
325 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
327 cygwin*) PWLIB_OSTYPE=cygwin ;
329 mingw*) PWLIB_OSTYPE=mingw ;
330 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
331 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
333 * ) PWLIB_OSTYPE="$host_os" ;
334 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
340 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
343 x86_64) PWLIB_MACHTYPE=x86_64 ;
348 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
352 sparc ) PWLIB_MACHTYPE=sparc ;
355 powerpc ) PWLIB_MACHTYPE=ppc ;
358 ppc ) PWLIB_MACHTYPE=ppc ;
361 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
366 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
371 ia64) PWLIB_MACHTYPE=ia64 ;
375 s390x) PWLIB_MACHTYPE=s390x ;
380 s390) PWLIB_MACHTYPE=s390 ;
383 * ) PWLIB_MACHTYPE="$host_cpu";
384 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
387 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
389 AC_SUBST([PWLIB_PLATFORM])
394 [AST_CHECK_OPENH323], [
398 if test "${OPENH323DIR:-unset}" != "unset" ; then
399 AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
401 if test "${HAS_OPENH323:-unset}" = "unset" ; then
402 AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
403 if test "${HAS_OPENH323:-unset}" != "unset" ; then
404 OPENH323DIR="${PWLIBDIR}/../openh323"
405 saved_cppflags="${CPPFLAGS}"
406 CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
407 AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
408 CPPFLAGS="${saved_cppflags}"
410 saved_cppflags="${CPPFLAGS}"
411 CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
412 AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
413 CPPFLAGS="${saved_cppflags}"
414 if test "${HAS_OPENH323:-unset}" != "unset" ; then
415 OPENH323DIR="${HOME}/openh323"
417 saved_cppflags="${CPPFLAGS}"
418 CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
419 AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
420 CPPFLAGS="${saved_cppflags}"
421 if test "${HAS_OPENH323:-unset}" != "unset" ; then
422 OPENH323DIR="/usr/local/share/openh323"
423 OPENH323_INCDIR="/usr/local/include/openh323"
424 if test "x$LIB64" != "x"; then
425 OPENH323_LIBDIR="/usr/local/lib64"
427 OPENH323_LIBDIR="/usr/local/lib"
430 saved_cppflags="${CPPFLAGS}"
431 CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
432 AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
433 CPPFLAGS="${saved_cppflags}"
434 if test "${HAS_OPENH323:-unset}" != "unset" ; then
435 OPENH323DIR="/usr/share/openh323"
436 OPENH323_INCDIR="/usr/include/openh323"
437 if test "x$LIB64" != "x"; then
438 OPENH323_LIBDIR="/usr/lib64"
440 OPENH323_LIBDIR="/usr/lib"
448 if test "${HAS_OPENH323:-unset}" != "unset" ; then
449 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
450 OPENH323_INCDIR="${OPENH323DIR}/include"
452 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
453 OPENH323_LIBDIR="${OPENH323DIR}/lib"
456 OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
457 OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
458 OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
460 AC_SUBST([OPENH323DIR])
461 AC_SUBST([OPENH323_INCDIR])
462 AC_SUBST([OPENH323_LIBDIR])
469 [AST_CHECK_PWLIB_VERSION], [
470 if test "${HAS_$2:-unset}" != "unset"; then
471 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
472 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
473 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
474 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
475 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
476 let $2_REQ=$4*10000+$5*100+$6
478 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
479 if test ${$2_VER} -lt ${$2_REQ}; then
490 [AST_CHECK_PWLIB_BUILD], [
491 if test "${HAS_$2:-unset}" != "unset"; then
492 AC_MSG_CHECKING($1 installation validity)
494 saved_cppflags="${CPPFLAGS}"
496 if test "${$2_LIB:-unset}" != "unset"; then
497 LIBS="${LIBS} ${$2_LIB} $7"
499 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
501 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
506 [AC_LANG_PROGRAM([$4],[$5])],
518 CPPFLAGS="${saved_cppflags}"
520 if test "${ac_cv_lib_$2}" = "yes"; then
521 if test "${$2_LIB:-undef}" = "undef"; then
522 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
523 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
525 $2_LIB="-l${PLATFORM_$2}"
528 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
529 $2_INCLUDE="-I${$2_INCDIR}"
532 AC_DEFINE([HAVE_$2], 1, [$3])
538 [AST_CHECK_OPENH323_BUILD], [
539 if test "${HAS_OPENH323:-unset}" != "unset"; then
540 AC_MSG_CHECKING(OpenH323 build option)
542 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
543 for pfx in $prefixes; do
544 files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
546 if test -n "$files"; then
548 if test -f $f -a ! -L $f; then
549 libfile=`basename $f`
554 if test -n "$libfile"; then
559 if test "${libfile:-unset}" != "unset"; then
560 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
562 case "${OPENH323_SUFFIX}" in
564 OPENH323_BUILD="notrace";;
566 OPENH323_BUILD="opt";;
568 OPENH323_BUILD="debug";;
570 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
571 notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@ @:>@*=@<:@ @:>@*//'"`
572 if test "x$notrace" = "x"; then
575 if test "$notrace" -ne 0; then
576 OPENH323_BUILD="notrace"
580 OPENH323_LIB="-l${OPENH323_PREFIX}"
582 OPENH323_BUILD="notrace"
586 AC_MSG_RESULT(${OPENH323_BUILD})
588 AC_SUBST([OPENH323_SUFFIX])
589 AC_SUBST([OPENH323_BUILD])
596 AN_FUNCTION([fork], [AST_FUNC_FORK])
597 AN_FUNCTION([vfork], [AST_FUNC_FORK])
598 AC_DEFUN([AST_FUNC_FORK],
599 [AC_REQUIRE([AC_TYPE_PID_T])dnl
600 AC_CHECK_HEADERS(vfork.h)
601 AC_CHECK_FUNCS(fork vfork)
602 if test "x$ac_cv_func_fork" = xyes; then
605 ac_cv_func_fork_works=$ac_cv_func_fork
607 if test "x$ac_cv_func_fork_works" = xcross; then
609 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* )
610 # Override, as these systems have only a dummy fork() stub
611 ac_cv_func_fork_works=no
614 ac_cv_func_fork_works=yes
617 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
619 ac_cv_func_vfork_works=$ac_cv_func_vfork
620 if test "x$ac_cv_func_vfork" = xyes; then
623 if test "x$ac_cv_func_fork_works" = xcross; then
624 ac_cv_func_vfork_works=$ac_cv_func_vfork
625 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
628 if test "x$ac_cv_func_vfork_works" = xyes; then
629 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
631 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
633 if test "x$ac_cv_func_fork_works" = xyes; then
634 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
641 AC_DEFUN([_AST_FUNC_FORK],
642 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
644 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
646 /* By Ruediger Kuhlmann. */
649 [ac_cv_func_fork_works=yes],
650 [ac_cv_func_fork_works=no],
651 [ac_cv_func_fork_works=cross])])]
656 # find the pathname to the GNU or non-GNU linker
657 AC_DEFUN([AST_PROG_LD],
658 [AC_ARG_WITH([gnu-ld],
659 [AC_HELP_STRING([--with-gnu-ld],
660 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
661 [test "$withval" = no || with_gnu_ld=yes],
663 AC_REQUIRE([AST_PROG_SED])dnl
664 AC_REQUIRE([AC_PROG_CC])dnl
665 AC_REQUIRE([AC_CANONICAL_HOST])dnl
666 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
668 if test "$GCC" = yes; then
669 # Check if gcc -print-prog-name=ld gives a path.
670 AC_MSG_CHECKING([for ld used by $CC])
673 # gcc leaves a trailing carriage return which upsets mingw
674 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
676 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
679 # Accept absolute paths.
680 [[\\/]]* | ?:[[\\/]]*)
681 re_direlt='/[[^/]][[^/]]*/\.\./'
682 # Canonicalize the pathname of ld
683 ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
684 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
685 ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
687 test -z "$LD" && LD="$ac_prog"
690 # If it fails, then pretend we aren't using GCC.
694 # If it is relative, then search for the first ld in PATH.
698 elif test "$with_gnu_ld" = yes; then
699 AC_MSG_CHECKING([for GNU ld])
701 AC_MSG_CHECKING([for non-GNU ld])
703 AC_CACHE_VAL(lt_cv_path_LD,
704 [if test -z "$LD"; then
705 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
706 for ac_dir in $PATH; do
708 test -z "$ac_dir" && ac_dir=.
709 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
710 lt_cv_path_LD="$ac_dir/$ac_prog"
711 # Check to see if the program is GNU ld. I'd rather use --version,
712 # but apparently some variants of GNU ld only accept -v.
713 # Break only if it was the GNU/non-GNU ld that we prefer.
714 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
715 *GNU* | *'with BFD'*)
716 test "$with_gnu_ld" != no && break
719 test "$with_gnu_ld" != yes && break
726 lt_cv_path_LD="$LD" # Let the user override the test with a path.
729 if test -n "$LD"; then
734 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
741 AC_DEFUN([AST_PROG_LD_GNU],
742 [AC_REQUIRE([AST_PROG_EGREP])dnl
743 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
744 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
745 case `$LD -v 2>&1 </dev/null` in
746 *GNU* | *'with BFD'*)
747 lt_cv_prog_gnu_ld=yes
753 with_gnu_ld=$lt_cv_prog_gnu_ld
758 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
759 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
760 [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
761 then ac_cv_prog_egrep='grep -E'
762 else ac_cv_prog_egrep='egrep'
764 EGREP=$ac_cv_prog_egrep
766 ])]) # AST_PROG_EGREP
770 # Check for a fully functional sed program that truncates
771 # as few characters as possible. Prefer GNU sed if found.
772 AC_DEFUN([AST_PROG_SED],
773 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
774 [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
775 dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
776 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
777 for ac_i in 1 2 3 4 5 6 7; do
778 ac_script="$ac_script$as_nl$ac_script"
780 echo "$ac_script" | sed 99q >conftest.sed
781 $as_unset ac_script || ac_script=
782 _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
783 [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
784 ["$ac_path_SED" -f conftest.sed])])])
785 SED="$ac_cv_path_SED"
790 dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
792 dnl @summary figure out how to build C programs using POSIX threads
794 dnl This macro figures out how to build C programs using POSIX threads.
795 dnl It sets the PTHREAD_LIBS output variable to the threads library and
796 dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
797 dnl C compiler flags that are needed. (The user can also force certain
798 dnl compiler flags/libs to be tested by setting these environment
801 dnl Also sets PTHREAD_CC to any special C compiler that is needed for
802 dnl multi-threaded programs (defaults to the value of CC otherwise).
803 dnl (This is necessary on AIX to use the special cc_r compiler alias.)
805 dnl NOTE: You are assumed to not only compile your program with these
806 dnl flags, but also link it with them as well. e.g. you should link
807 dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
810 dnl If you are only building threads programs, you may wish to use
811 dnl these variables in your default LIBS, CFLAGS, and CC:
813 dnl LIBS="$PTHREAD_LIBS $LIBS"
814 dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
817 dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
818 dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
819 dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
821 dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
822 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
823 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
824 dnl default action will define HAVE_PTHREAD.
826 dnl Please let the authors know if this macro fails on any platform, or
827 dnl if you have any other suggestions or comments. This macro was based
828 dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
829 dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
830 dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
831 dnl We are also grateful for the helpful feedback of numerous users.
833 dnl @category InstalledPackages
834 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
835 dnl @version 2006-05-29
836 dnl @license GPLWithACException
838 AC_DEFUN([ACX_PTHREAD], [
839 AC_REQUIRE([AC_CANONICAL_HOST])
844 # We used to check for pthread.h first, but this fails if pthread.h
845 # requires special compiler flags (e.g. on True64 or Sequent).
846 # It gets checked for in the link test anyway.
848 # First of all, check if the user has set any of the PTHREAD_LIBS,
849 # etcetera environment variables, and if threads linking works using
851 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
852 save_CFLAGS="$CFLAGS"
853 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
855 LIBS="$PTHREAD_LIBS $LIBS"
856 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
857 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
858 AC_MSG_RESULT($acx_pthread_ok)
859 if test x"$acx_pthread_ok" = xno; then
864 CFLAGS="$save_CFLAGS"
867 # We must check for the threads library under a number of different
868 # names; the ordering is very important because some systems
869 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
870 # libraries is broken (non-POSIX).
872 # Create a list of thread flags to try. Items starting with a "-" are
873 # C compiler flags, and other items are library names, except for "none"
874 # which indicates that we try without any flags at all, and "pthread-config"
875 # which is a program returning the flags for the Pth emulation library.
877 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
879 # The ordering *is* (sometimes) important. Some notes on the
880 # individual items follow:
882 # pthreads: AIX (must check this before -lpthread)
883 # none: in case threads are in libc; should be tried before -Kthread and
884 # other compiler flags to prevent continual compiler warnings
885 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
886 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
887 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
888 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
889 # -pthreads: Solaris/gcc
890 # -mthreads: Mingw32/gcc, Lynx/gcc
891 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
892 # doesn't hurt to check since this sometimes defines pthreads too;
893 # also defines -D_REENTRANT)
894 # ... -mt is also the pthreads flag for HP/aCC
895 # pthread: Linux, etcetera
896 # --thread-safe: KAI C++
897 # pthread-config: use pthread-config program (for GNU Pth library)
899 case "${host_cpu}-${host_os}" in
902 # On Solaris (at least, for some versions), libc contains stubbed
903 # (non-functional) versions of the pthreads routines, so link-based
904 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
905 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
906 # a function called by this macro, so we could check for that, but
907 # who knows whether they'll stub that too in a future libc.) So,
908 # we'll just look for -pthreads and -lpthread first:
910 acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
914 if test x"$acx_pthread_ok" = xno; then
915 for flag in $acx_pthread_flags; do
919 AC_MSG_CHECKING([whether pthreads work without any flags])
923 AC_MSG_CHECKING([whether pthreads work with $flag])
924 PTHREAD_CFLAGS="$flag"
928 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
929 if test x"$acx_pthread_config" = xno; then continue; fi
930 PTHREAD_CFLAGS="`pthread-config --cflags`"
931 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
935 AC_MSG_CHECKING([for the pthreads library -l$flag])
936 PTHREAD_LIBS="-l$flag"
941 save_CFLAGS="$CFLAGS"
942 LIBS="$PTHREAD_LIBS $LIBS"
943 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
945 # Check for various functions. We must include pthread.h,
946 # since some functions may be macros. (On the Sequent, we
947 # need a special flag -Kthread to make this header compile.)
948 # We check for pthread_join because it is in -lpthread on IRIX
949 # while pthread_create is in libc. We check for pthread_attr_init
950 # due to DEC craziness with -lpthreads. We check for
951 # pthread_cleanup_push because it is one of the few pthread
952 # functions on Solaris that doesn't have a non-functional libc stub.
953 # We try pthread_create on general principles.
954 AC_TRY_LINK([#include <pthread.h>],
955 [pthread_t th; pthread_join(th, 0);
956 pthread_attr_init(0); pthread_cleanup_push(0, 0);
957 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
958 [acx_pthread_ok=yes])
961 CFLAGS="$save_CFLAGS"
963 AC_MSG_RESULT($acx_pthread_ok)
964 if test "x$acx_pthread_ok" = xyes; then
973 # Various other checks:
974 if test "x$acx_pthread_ok" = xyes; then
976 LIBS="$PTHREAD_LIBS $LIBS"
977 save_CFLAGS="$CFLAGS"
978 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
980 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
981 AC_MSG_CHECKING([for joinable pthread attribute])
983 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
984 AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
985 [attr_name=$attr; break])
987 AC_MSG_RESULT($attr_name)
988 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
989 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
990 [Define to necessary symbol if this constant
991 uses a non-standard name on your system.])
994 AC_MSG_CHECKING([if more special flags are required for pthreads])
996 case "${host_cpu}-${host_os}" in
997 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
998 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
1000 AC_MSG_RESULT(${flag})
1001 if test "x$flag" != xno; then
1002 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1006 CFLAGS="$save_CFLAGS"
1008 # More AIX lossage: must compile with xlc_r or cc_r
1009 if test x"$GCC" != xyes; then
1010 AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
1018 AC_SUBST(PTHREAD_LIBS)
1019 AC_SUBST(PTHREAD_CFLAGS)
1020 AC_SUBST(PTHREAD_CC)
1022 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
1023 if test x"$acx_pthread_ok" = xyes; then
1024 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])