Fix a typo in the non-DEBUG_THREADS version of the recently added DEADLOCK_AVOIDANCE()
[asterisk-bristuff.git] / acinclude.m4
blob106688b69f8961dd7464751add9e4b809f7221a7
1 # AST_GCC_ATTRIBUTE([attribute name])
3 AC_DEFUN([AST_GCC_ATTRIBUTE],
5 AC_MSG_CHECKING(for compiler 'attribute $1' support)
6 saved_CFLAGS="$CFLAGS"
7 CFLAGS="$CFLAGS -Werror"
8 AC_COMPILE_IFELSE(
9         AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
10                         []),
11         AC_MSG_RESULT(yes)
12         AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
13         AC_MSG_RESULT(no))
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],
22 $1_DESCRIP="$2"
23 $1_OPTION="$3"
24 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
25 case ${withval} in
26      n|no)
27      USE_$1=no
28      ;;
29      y|ye|yes)
30      $1_MANDATORY="yes"
31      ;;
32      *)
33      $1_DIR="${withval}"
34      $1_MANDATORY="yes"
35      ;;
36 esac
38 PBX_$1=0
39 AC_SUBST([$1_LIB])
40 AC_SUBST([$1_INCLUDE])
41 AC_SUBST([$1_DIR])
42 AC_SUBST([PBX_$1])
45 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data])
47 AC_DEFUN([AST_EXT_LIB_CHECK],
49 if test "${USE_$1}" != "no"; then
50    pbxlibdir=""
51    if test "x${$1_DIR}" != "x"; then
52       if test -d ${$1_DIR}/lib; then
53          pbxlibdir="-L${$1_DIR}/lib"
54       else
55          pbxlibdir="-L${$1_DIR}"
56       fi
57    fi
58    AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
60    if test "${AST_$1_FOUND}" = "yes"; then
61       $1_LIB="-l$2 $5"
62       $1_HEADER_FOUND="1"
63       if test "x${$1_DIR}" != "x"; then
64          $1_LIB="${pbxlibdir} ${$1_LIB}"
65          $1_INCLUDE="-I${$1_DIR}/include"
66          saved_cppflags="${CPPFLAGS}"
67          CPPFLAGS="${CPPFLAGS} -I${$1_DIR}/include"
68          if test "x$4" != "x" ; then
69             AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
70          fi
71          CPPFLAGS="${saved_cppflags}"
72       else
73          if test "x$4" != "x" ; then
74             AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
75          fi
76       fi
77       if test "x${$1_HEADER_FOUND}" = "x0" ; then
78          if test -n "${$1_MANDATORY}" ;
79          then
80             AC_MSG_NOTICE([***])
81             AC_MSG_NOTICE([*** It appears that you do not have the $2 development package installed.])
82             AC_MSG_NOTICE([*** Please install it to include ${$1_DESCRIP} support, or re-run configure])
83             AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
84             exit 1
85          fi
86          $1_LIB=""
87          $1_INCLUDE=""
88          PBX_$1=0
89       else
90          PBX_$1=1
91          AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
92       fi
93    elif test -n "${$1_MANDATORY}";
94    then
95       AC_MSG_NOTICE([***])
96       AC_MSG_NOTICE([*** The ${$1_DESCRIP} installation on this system appears to be broken.])
97       AC_MSG_NOTICE([*** Either correct the installation, or run configure])
98       AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
99       exit 1
100    fi
104 # The next three functions check for the availability of a given package.
105 # AST_C_DEFINE_CHECK looks for the presence of a #define in a header file,
106 # AST_C_COMPILE_CHECK can be used for testing for various items in header files,
107 # AST_EXT_LIB_CHECK looks for a symbol in a given library, or at least
108 #   for the presence of a header file.
109 # AST_EXT_TOOL_CHECK looks for a symbol in using $1-config to determine CFLAGS and LIBS
111 # They are only run if PBX_$1 != 1 (where $1 is the package),
112 # so you can call them multiple times and stop at the first matching one.
113 # On success, they both set PBX_$1 = 1, set $1_INCLUDE and $1_LIB as applicable,
114 # and also #define HAVE_$1 1 and #define HAVE_$1_VERSION ${last_argument}
115 # in autoconfig.h so you can tell which test succeeded.
116 # They should be called after AST_EXT_LIB_SETUP($1, ...)
118 # Check if a given macro is defined in a certain header.
120 # AST_C_DEFINE_CHECK([package], [macro name], [header file], [version])
121 AC_DEFUN([AST_C_DEFINE_CHECK],
123     if test "x${PBX_$1}" != "x1"; then
124     AC_MSG_CHECKING([for $2 in $3])
125     saved_cppflags="${CPPFLAGS}"
126     if test "x${$1_DIR}" != "x"; then
127         $1_INCLUDE="-I${$1_DIR}/include"
128     fi
129     CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
131     AC_COMPILE_IFELSE(
132         [ AC_LANG_PROGRAM( [#include <$3>],
133                    [#if defined($2)
134                 int foo = 0;
135                     #else
136                     int foo = bar;
137                     #endif
138                 0
139                    ])],
140         [   AC_MSG_RESULT(yes)
141         PBX_$1=1
142         AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
143         AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
144         ],
145         [   AC_MSG_RESULT(no) ] 
146     )
147     CPPFLAGS="${saved_cppflags}"
148     fi
149     AC_SUBST(PBX_$1)
152 # AST_C_COMPILE_CHECK can be used for testing for various items in header files
154 # AST_C_COMPILE_CHECK([package], [expression], [header file], [version])
155 AC_DEFUN([AST_C_COMPILE_CHECK],
157     if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
158         AC_MSG_CHECKING([if "$2" compiles using $3])
159         saved_cppflags="${CPPFLAGS}"
160         if test "x${$1_DIR}" != "x"; then
161             $1_INCLUDE="-I${$1_DIR}/include"
162         fi
163         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
165         AC_COMPILE_IFELSE(
166             [ AC_LANG_PROGRAM( [#include <$3>],
167                                [ $2; ]
168                                )],
169             [   AC_MSG_RESULT(yes)
170                 PBX_$1=1
171                 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
172                 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
173             ],
174             [       AC_MSG_RESULT(no) ] 
175         )
176         CPPFLAGS="${saved_cppflags}"
177     fi
180 AC_DEFUN(
181 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
182    GNU_MAKE='Not Found' ;
183    GNU_MAKE_VERSION_MAJOR=0 ;
184    GNU_MAKE_VERSION_MINOR=0 ;
185    for a in make gmake gnumake ; do
186       if test -z "$a" ; then continue ; fi ;
187       if ( sh -c "$a --version" 2> /dev/null | grep GNU  2>&1 > /dev/null ) ;  then
188          GNU_MAKE=$a ;
189          GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
190          GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
191          break;
192       fi
193    done ;
194 ) ;
195 if test  "x$GNU_MAKE" = "xNot Found"  ; then
196    AC_MSG_ERROR( *** Please install GNU make.  It is required to build Asterisk!)
197    exit 1
199 AC_SUBST([GNU_MAKE])
203 AC_DEFUN(
204 [AST_CHECK_PWLIB], [
205 PWLIB_INCDIR=
206 PWLIB_LIBDIR=
207 AC_LANG_PUSH([C++])
208 if test "${PWLIBDIR:-unset}" != "unset" ; then
209   AC_CHECK_HEADER(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
211 if test "${HAS_PWLIB:-unset}" = "unset" ; then
212   if test "${OPENH323DIR:-unset}" != "unset"; then
213     AC_CHECK_HEADER(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
214   fi
215   if test "${HAS_PWLIB:-unset}" != "unset" ; then
216     PWLIBDIR="${OPENH323DIR}/../pwlib"
217   else
218     AC_CHECK_HEADER(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
219     if test "${HAS_PWLIB:-unset}" != "unset" ; then
220       PWLIBDIR="${HOME}/pwlib"
221     else
222       AC_CHECK_HEADER(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
223       if test "${HAS_PWLIB:-unset}" != "unset" ; then
224         AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
225         if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
226           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
227         fi
228         PWLIB_INCDIR="/usr/local/include"
229         PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
230         if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
231           if test "x$LIB64" != "x"; then
232             PWLIB_LIBDIR="/usr/local/lib64"
233           else
234             PWLIB_LIBDIR="/usr/local/lib"
235           fi
236         fi
237         PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
238         PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
239       else
240         AC_CHECK_HEADER(/usr/include/ptlib.h, HAS_PWLIB=1, )
241         if test "${HAS_PWLIB:-unset}" != "unset" ; then
242           AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
243           PWLIB_INCDIR="/usr/include"
244           PWLIB_LIBDIR=`${PTLIB_CONFIG} --pwlibdir`
245           if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
246             if test "x$LIB64" != "x"; then
247               PWLIB_LIBDIR="/usr/lib64"
248             else
249               PWLIB_LIBDIR="/usr/lib"
250             fi
251           fi
252           PWLIB_LIB=`${PTLIB_CONFIG} --ldflags --libs`
253           PWLIB_LIB="-L${PWLIB_LIBDIR} `echo ${PWLIB_LIB}`"
254         fi
255       fi
256     fi
257   fi
260 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
261 #  echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
262 #  exit
265 if test "${HAS_PWLIB:-unset}" != "unset" ; then
266   if test "${PWLIBDIR:-unset}" = "unset" ; then
267     if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
268       PWLIBDIR=`$PTLIB_CONFIG --prefix`
269     else
270       echo "Cannot find ptlib-config - please install and try again"
271       exit
272     fi
273   fi
275   if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
276     PWLIBDIR="/usr/share/pwlib"
277     PWLIB_INCDIR="/usr/include"
278     if test "x$LIB64" != "x"; then
279       PWLIB_LIBDIR="/usr/lib64"
280     else
281       PWLIB_LIBDIR="/usr/lib"
282     fi
283   fi
284   if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
285     PWLIBDIR="/usr/local/share/pwlib"
286     PWLIB_INCDIR="/usr/local/include"
287     if test "x$LIB64" != "x"; then
288       PWLIB_LIBDIR="/usr/local/lib64"
289     else
290       PWLIB_LIBDIR="/usr/local/lib"
291     fi
292   fi
294   if test "${PWLIB_INCDIR:-unset}" = "unset"; then
295     PWLIB_INCDIR="${PWLIBDIR}/include"
296   fi
297   if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
298     PWLIB_LIBDIR="${PWLIBDIR}/lib"
299   fi
301   AC_SUBST([PWLIBDIR])
302   AC_SUBST([PWLIB_INCDIR])
303   AC_SUBST([PWLIB_LIBDIR])
305   AC_LANG_POP([C++])
309 AC_DEFUN(
310 [AST_CHECK_OPENH323_PLATFORM], [
311 PWLIB_OSTYPE=
312 case "$host_os" in
313   linux*)          PWLIB_OSTYPE=linux ;
314                 ;;
315   freebsd* )       PWLIB_OSTYPE=FreeBSD ;
316                 ;;
317   openbsd* )       PWLIB_OSTYPE=OpenBSD ;
318                                    ENDLDLIBS="-lossaudio" ;
319                 ;;
320   netbsd* )        PWLIB_OSTYPE=NetBSD ;
321                                    ENDLDLIBS="-lossaudio" ;
322                 ;;
323   solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
324                 ;;
325   darwin* )            PWLIB_OSTYPE=Darwin ;
326                 ;;
327   beos*)           PWLIB_OSTYPE=beos ;
328                    STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
329                 ;;
330   cygwin*)         PWLIB_OSTYPE=cygwin ;
331                 ;;
332   mingw*)              PWLIB_OSTYPE=mingw ;
333                            STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
334                            ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
335                 ;;
336   * )                  PWLIB_OSTYPE="$host_os" ;
337                            AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
338                 ;;
339 esac
341 PWLIB_MACHTYPE=
342 case "$host_cpu" in
343    x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
344                    ;;
346    x86_64)         PWLIB_MACHTYPE=x86_64 ;
347                    P_64BIT=1 ;
348                    LIB64=1 ;
349                    ;;
351    alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
352                    P_64BIT=1 ;
353                    ;;
355    sparc )         PWLIB_MACHTYPE=sparc ;
356                    ;;
358    powerpc )       PWLIB_MACHTYPE=ppc ;
359                    ;;
361    ppc )           PWLIB_MACHTYPE=ppc ;
362                    ;;
364    powerpc64 )     PWLIB_MACHTYPE=ppc64 ;
365                    P_64BIT=1 ;
366                    LIB64=1 ;
367                    ;;
369    ppc64 )         PWLIB_MACHTYPE=ppc64 ;
370                    P_64BIT=1 ;
371                    LIB64=1 ;
372                    ;;
374    ia64)           PWLIB_MACHTYPE=ia64 ;
375                    P_64BIT=1 ;
376                    ;;
378    s390x)          PWLIB_MACHTYPE=s390x ;
379                    P_64BIT=1 ;
380                    LIB64=1 ;
381                    ;;
383    s390)           PWLIB_MACHTYPE=s390 ;
384                    ;;
386    * )             PWLIB_MACHTYPE="$host_cpu";
387                    AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
388 esac
390 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
392 AC_SUBST([PWLIB_PLATFORM])
396 AC_DEFUN(
397 [AST_CHECK_OPENH323], [
398 OPENH323_INCDIR=
399 OPENH323_LIBDIR=
400 AC_LANG_PUSH([C++])
401 if test "${OPENH323DIR:-unset}" != "unset" ; then
402   AC_CHECK_HEADER(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
404 if test "${HAS_OPENH323:-unset}" = "unset" ; then
405   AC_CHECK_HEADER(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
406   if test "${HAS_OPENH323:-unset}" != "unset" ; then
407     OPENH323DIR="${PWLIBDIR}/../openh323"
408     saved_cppflags="${CPPFLAGS}"
409     CPPFLAGS="${CPPFLAGS} -I${PWLIB_INCDIR}/openh323 -I${PWLIB_INCDIR}"
410     AC_CHECK_HEADER(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}", [#include <ptlib.h>])
411     CPPFLAGS="${saved_cppflags}"
412   else
413     saved_cppflags="${CPPFLAGS}"
414     CPPFLAGS="${CPPFLAGS} -I${HOME}/openh323/include -I${PWLIB_INCDIR}"
415     AC_CHECK_HEADER(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
416     CPPFLAGS="${saved_cppflags}"
417     if test "${HAS_OPENH323:-unset}" != "unset" ; then
418       OPENH323DIR="${HOME}/openh323"
419     else
420       saved_cppflags="${CPPFLAGS}"
421       CPPFLAGS="${CPPFLAGS} -I/usr/local/include/openh323 -I${PWLIB_INCDIR}"
422       AC_CHECK_HEADER(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
423       CPPFLAGS="${saved_cppflags}"
424       if test "${HAS_OPENH323:-unset}" != "unset" ; then
425         OPENH323DIR="/usr/local/share/openh323"
426         OPENH323_INCDIR="/usr/local/include/openh323"
427         if test "x$LIB64" != "x"; then
428           OPENH323_LIBDIR="/usr/local/lib64"
429         else
430           OPENH323_LIBDIR="/usr/local/lib"
431         fi
432       else
433         saved_cppflags="${CPPFLAGS}"
434         CPPFLAGS="${CPPFLAGS} -I/usr/include/openh323 -I${PWLIB_INCDIR}"
435         AC_CHECK_HEADER(/usr/include/openh323/h323.h, HAS_OPENH323=1, , [#include <ptlib.h>])
436         CPPFLAGS="${saved_cppflags}"
437         if test "${HAS_OPENH323:-unset}" != "unset" ; then
438           OPENH323DIR="/usr/share/openh323"
439           OPENH323_INCDIR="/usr/include/openh323"
440           if test "x$LIB64" != "x"; then
441             OPENH323_LIBDIR="/usr/lib64"
442           else
443             OPENH323_LIBDIR="/usr/lib"
444           fi
445         fi
446       fi
447     fi
448   fi
451 if test "${HAS_OPENH323:-unset}" != "unset" ; then
452   if test "${OPENH323_INCDIR:-unset}" = "unset"; then
453     OPENH323_INCDIR="${OPENH323DIR}/include"
454   fi
455   if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
456     OPENH323_LIBDIR="${OPENH323DIR}/lib"
457   fi
459   OPENH323_LIBDIR="`cd ${OPENH323_LIBDIR}; pwd`"
460   OPENH323_INCDIR="`cd ${OPENH323_INCDIR}; pwd`"
461   OPENH323DIR="`cd ${OPENH323DIR}; pwd`"
463   AC_SUBST([OPENH323DIR])
464   AC_SUBST([OPENH323_INCDIR])
465   AC_SUBST([OPENH323_LIBDIR])
467   AC_LANG_POP([C++])
471 AC_DEFUN(
472 [AST_CHECK_PWLIB_VERSION], [
473         if test "${HAS_$2:-unset}" != "unset"; then
474                 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
475                 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
476                 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
477                 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
478                 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
479                 let $2_REQ=$4*10000+$5*100+$6
481                 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
482                 if test ${$2_VER} -lt ${$2_REQ}; then
483                         AC_MSG_RESULT(no)
484                         unset HAS_$2
485                 else
486                         AC_MSG_RESULT(yes)
487                 fi
488         fi
492 AC_DEFUN(
493 [AST_CHECK_PWLIB_BUILD], [
494         if test "${HAS_$2:-unset}" != "unset"; then
495            AC_MSG_CHECKING($1 installation validity)
497            saved_cppflags="${CPPFLAGS}"
498            saved_libs="${LIBS}"
499            if test "${$2_LIB:-unset}" != "unset"; then
500               LIBS="${LIBS} ${$2_LIB} $7"
501            else
502               LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
503            fi
504            CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
506            AC_LANG_PUSH([C++])
508            AC_LINK_IFELSE(
509                 [AC_LANG_PROGRAM([$4],[$5])],
510                 [       AC_MSG_RESULT(yes) 
511                         ac_cv_lib_$2="yes" 
512                 ],
513                 [       AC_MSG_RESULT(no) 
514                         ac_cv_lib_$2="no" 
515                 ]
516                 )
518            AC_LANG_POP([C++])
520            LIBS="${saved_libs}"
521            CPPFLAGS="${saved_cppflags}"
523            if test "${ac_cv_lib_$2}" = "yes"; then
524               if test "${$2_LIB:-undef}" = "undef"; then
525                  if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
526                     $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
527                  else
528                     $2_LIB="-l${PLATFORM_$2}"
529                  fi
530               fi
531               if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
532                  $2_INCLUDE="-I${$2_INCDIR}"
533               fi
534                   PBX_$2=1
535                   AC_DEFINE([HAVE_$2], 1, [$3])
536            fi
537         fi
540 AC_DEFUN(
541 [AST_CHECK_OPENH323_BUILD], [
542         if test "${HAS_OPENH323:-unset}" != "unset"; then
543                 AC_MSG_CHECKING(OpenH323 build option)
544                 OPENH323_SUFFIX=
545                 prefixes="h323_${PWLIB_PLATFORM}_ h323_ openh323"
546                 for pfx in $prefixes; do
547                         files=`ls -l ${OPENH323_LIBDIR}/lib${pfx}*.so* 2>/dev/null`
548                         libfile=
549                         if test -n "$files"; then
550                                 for f in $files; do
551                                         if test -f $f -a ! -L $f; then
552                                                 libfile=`basename $f`
553                                                 break;
554                                         fi
555                                 done
556                         fi
557                         if test -n "$libfile"; then
558                                 OPENH323_PREFIX=$pfx
559                                 break;
560                         fi
561                 done
562                 if test "${libfile:-unset}" != "unset"; then
563                         OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/lib${OPENH323_PREFIX}\(@<:@^.@:>@*\)\..*/\1/'"`
564                 fi
565                 case "${OPENH323_SUFFIX}" in
566                         n)
567                                 OPENH323_BUILD="notrace";;
568                         r)
569                                 OPENH323_BUILD="opt";;
570                         d)
571                                 OPENH323_BUILD="debug";;
572                         *)
573                                 if test "${OPENH323_PREFIX:-undef}" = "openh323"; then
574                                         notrace=`eval "grep NOTRACE ${OPENH323DIR}/openh323u.mak | grep = | sed -e 's/@<:@A-Z0-9_@:>@*@<:@      @:>@*=@<:@      @:>@*//'"`
575                                         if test "x$notrace" = "x"; then
576                                                 notrace="0"
577                                         fi
578                                         if test "$notrace" -ne 0; then
579                                                 OPENH323_BUILD="notrace"
580                                         else
581                                                 OPENH323_BUILD="opt"
582                                         fi
583                                         OPENH323_LIB="-l${OPENH323_PREFIX}"
584                                 else
585                                         OPENH323_BUILD="notrace"
586                                 fi
587                                 ;;
588                 esac
589                 AC_MSG_RESULT(${OPENH323_BUILD})
591                 AC_SUBST([OPENH323_SUFFIX])
592                 AC_SUBST([OPENH323_BUILD])
593         fi
597 # AST_FUNC_FORK
598 # -------------
599 AN_FUNCTION([fork],  [AST_FUNC_FORK])
600 AN_FUNCTION([vfork], [AST_FUNC_FORK])
601 AC_DEFUN([AST_FUNC_FORK],
602 [AC_REQUIRE([AC_TYPE_PID_T])dnl
603 AC_CHECK_HEADERS(vfork.h)
604 AC_CHECK_FUNCS(fork vfork)
605 if test "x$ac_cv_func_fork" = xyes; then
606   _AST_FUNC_FORK
607 else
608   ac_cv_func_fork_works=$ac_cv_func_fork
610 if test "x$ac_cv_func_fork_works" = xcross; then
611   case $host in
612     *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* | *-*-linux-uclibc* )
613       # Override, as these systems have only a dummy fork() stub
614       ac_cv_func_fork_works=no
615       ;;
616     *)
617       ac_cv_func_fork_works=yes
618       ;;
619   esac
620   AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
622 ac_cv_func_vfork_works=$ac_cv_func_vfork
623 if test "x$ac_cv_func_vfork" = xyes; then
624   _AC_FUNC_VFORK
626 if test "x$ac_cv_func_fork_works" = xcross; then
627   ac_cv_func_vfork_works=$ac_cv_func_vfork
628   AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
631 if test "x$ac_cv_func_vfork_works" = xyes; then
632   AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
633 else
634   AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
636 if test "x$ac_cv_func_fork_works" = xyes; then
637   AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
639 ])# AST_FUNC_FORK
642 # _AST_FUNC_FORK
643 # -------------
644 AC_DEFUN([_AST_FUNC_FORK],
645   [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
646     [AC_RUN_IFELSE(
647       [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
648         [
649           /* By Ruediger Kuhlmann. */
650           return fork () < 0;
651         ])],
652       [ac_cv_func_fork_works=yes],
653       [ac_cv_func_fork_works=no],
654       [ac_cv_func_fork_works=cross])])]
655 )# _AST_FUNC_FORK
657 # AST_PROG_LD
658 # ----------
659 # find the pathname to the GNU or non-GNU linker
660 AC_DEFUN([AST_PROG_LD],
661 [AC_ARG_WITH([gnu-ld],
662     [AC_HELP_STRING([--with-gnu-ld],
663         [assume the C compiler uses GNU ld @<:@default=no@:>@])],
664     [test "$withval" = no || with_gnu_ld=yes],
665     [with_gnu_ld=no])
666 AC_REQUIRE([AST_PROG_SED])dnl
667 AC_REQUIRE([AC_PROG_CC])dnl
668 AC_REQUIRE([AC_CANONICAL_HOST])dnl
669 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
670 ac_prog=ld
671 if test "$GCC" = yes; then
672   # Check if gcc -print-prog-name=ld gives a path.
673   AC_MSG_CHECKING([for ld used by $CC])
674   case $host in
675   *-*-mingw*)
676     # gcc leaves a trailing carriage return which upsets mingw
677     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
678   *)
679     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
680   esac
681   case $ac_prog in
682     # Accept absolute paths.
683     [[\\/]]* | ?:[[\\/]]*)
684       re_direlt='/[[^/]][[^/]]*/\.\./'
685       # Canonicalize the pathname of ld
686       ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
687       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
688         ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
689       done
690       test -z "$LD" && LD="$ac_prog"
691       ;;
692   "")
693     # If it fails, then pretend we aren't using GCC.
694     ac_prog=ld
695     ;;
696   *)
697     # If it is relative, then search for the first ld in PATH.
698     with_gnu_ld=unknown
699     ;;
700   esac
701 elif test "$with_gnu_ld" = yes; then
702   AC_MSG_CHECKING([for GNU ld])
703 else
704   AC_MSG_CHECKING([for non-GNU ld])
706 AC_CACHE_VAL(lt_cv_path_LD,
707 [if test -z "$LD"; then
708   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
709   for ac_dir in $PATH; do
710     IFS="$lt_save_ifs"
711     test -z "$ac_dir" && ac_dir=.
712     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
713       lt_cv_path_LD="$ac_dir/$ac_prog"
714       # Check to see if the program is GNU ld.  I'd rather use --version,
715       # but apparently some variants of GNU ld only accept -v.
716       # Break only if it was the GNU/non-GNU ld that we prefer.
717       case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
718       *GNU* | *'with BFD'*)
719         test "$with_gnu_ld" != no && break
720         ;;
721       *)
722         test "$with_gnu_ld" != yes && break
723         ;;
724       esac
725     fi
726   done
727   IFS="$lt_save_ifs"
728 else
729   lt_cv_path_LD="$LD" # Let the user override the test with a path.
730 fi])
731 LD="$lt_cv_path_LD"
732 if test -n "$LD"; then
733   AC_MSG_RESULT($LD)
734 else
735   AC_MSG_RESULT(no)
737 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
738 AST_PROG_LD_GNU
739 ])# AST_PROG_LD
742 # AST_PROG_LD_GNU
743 # --------------
744 AC_DEFUN([AST_PROG_LD_GNU],
745 [AC_REQUIRE([AST_PROG_EGREP])dnl
746 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
747 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
748 case `$LD -v 2>&1 </dev/null` in
749 *GNU* | *'with BFD'*)
750   lt_cv_prog_gnu_ld=yes
751   ;;
753   lt_cv_prog_gnu_ld=no
754   ;;
755 esac])
756 with_gnu_ld=$lt_cv_prog_gnu_ld
757 ])# AST_PROG_LD_GNU
759 # AST_PROG_EGREP
760 # -------------
761 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
762 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
763    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
764     then ac_cv_prog_egrep='grep -E'
765     else ac_cv_prog_egrep='egrep'
766     fi])
767  EGREP=$ac_cv_prog_egrep
768  AC_SUBST([EGREP])
769 ])]) # AST_PROG_EGREP
771 # AST_PROG_SED
772 # -----------
773 # Check for a fully functional sed program that truncates
774 # as few characters as possible.  Prefer GNU sed if found.
775 AC_DEFUN([AST_PROG_SED],
776 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
777     [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
778      dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
779      ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
780      for ac_i in 1 2 3 4 5 6 7; do
781        ac_script="$ac_script$as_nl$ac_script"
782      done
783      echo "$ac_script" | sed 99q >conftest.sed
784      $as_unset ac_script || ac_script=
785      _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
786         [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
787                 ["$ac_path_SED" -f conftest.sed])])])
788  SED="$ac_cv_path_SED"
789  AC_SUBST([SED])dnl
790  rm -f conftest.sed
791 ])# AST_PROG_SED
793 dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
795 dnl @summary figure out how to build C programs using POSIX threads
797 dnl This macro figures out how to build C programs using POSIX threads.
798 dnl It sets the PTHREAD_LIBS output variable to the threads library and
799 dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
800 dnl C compiler flags that are needed. (The user can also force certain
801 dnl compiler flags/libs to be tested by setting these environment
802 dnl variables.)
804 dnl Also sets PTHREAD_CC to any special C compiler that is needed for
805 dnl multi-threaded programs (defaults to the value of CC otherwise).
806 dnl (This is necessary on AIX to use the special cc_r compiler alias.)
808 dnl NOTE: You are assumed to not only compile your program with these
809 dnl flags, but also link it with them as well. e.g. you should link
810 dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
811 dnl $LIBS
813 dnl If you are only building threads programs, you may wish to use
814 dnl these variables in your default LIBS, CFLAGS, and CC:
816 dnl        LIBS="$PTHREAD_LIBS $LIBS"
817 dnl        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
818 dnl        CC="$PTHREAD_CC"
820 dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
821 dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
822 dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
824 dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
825 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
826 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
827 dnl default action will define HAVE_PTHREAD.
829 dnl Please let the authors know if this macro fails on any platform, or
830 dnl if you have any other suggestions or comments. This macro was based
831 dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
832 dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
833 dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
834 dnl We are also grateful for the helpful feedback of numerous users.
836 dnl @category InstalledPackages
837 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
838 dnl @version 2006-05-29
839 dnl @license GPLWithACException
841 AC_DEFUN([ACX_PTHREAD], [
842 AC_REQUIRE([AC_CANONICAL_HOST])
843 AC_LANG_SAVE
844 AC_LANG_C
845 acx_pthread_ok=no
847 # We used to check for pthread.h first, but this fails if pthread.h
848 # requires special compiler flags (e.g. on True64 or Sequent).
849 # It gets checked for in the link test anyway.
851 # First of all, check if the user has set any of the PTHREAD_LIBS,
852 # etcetera environment variables, and if threads linking works using
853 # them:
854 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
855         save_CFLAGS="$CFLAGS"
856         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
857         save_LIBS="$LIBS"
858         LIBS="$PTHREAD_LIBS $LIBS"
859         AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
860         AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
861         AC_MSG_RESULT($acx_pthread_ok)
862         if test x"$acx_pthread_ok" = xno; then
863                 PTHREAD_LIBS=""
864                 PTHREAD_CFLAGS=""
865         fi
866         LIBS="$save_LIBS"
867         CFLAGS="$save_CFLAGS"
870 # We must check for the threads library under a number of different
871 # names; the ordering is very important because some systems
872 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
873 # libraries is broken (non-POSIX).
875 # Create a list of thread flags to try.  Items starting with a "-" are
876 # C compiler flags, and other items are library names, except for "none"
877 # which indicates that we try without any flags at all, and "pthread-config"
878 # which is a program returning the flags for the Pth emulation library.
880 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
882 # The ordering *is* (sometimes) important.  Some notes on the
883 # individual items follow:
885 # pthreads: AIX (must check this before -lpthread)
886 # none: in case threads are in libc; should be tried before -Kthread and
887 #       other compiler flags to prevent continual compiler warnings
888 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
889 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
890 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
891 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
892 # -pthreads: Solaris/gcc
893 # -mthreads: Mingw32/gcc, Lynx/gcc
894 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
895 #      doesn't hurt to check since this sometimes defines pthreads too;
896 #      also defines -D_REENTRANT)
897 #      ... -mt is also the pthreads flag for HP/aCC
898 # pthread: Linux, etcetera
899 # --thread-safe: KAI C++
900 # pthread-config: use pthread-config program (for GNU Pth library)
902 case "${host_cpu}-${host_os}" in
903         *solaris*)
905         # On Solaris (at least, for some versions), libc contains stubbed
906         # (non-functional) versions of the pthreads routines, so link-based
907         # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
908         # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
909         # a function called by this macro, so we could check for that, but
910         # who knows whether they'll stub that too in a future libc.)  So,
911         # we'll just look for -pthreads and -lpthread first:
913         acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
914         ;;
915 esac
917 if test x"$acx_pthread_ok" = xno; then
918 for flag in $acx_pthread_flags; do
920         case $flag in
921                 none)
922                 AC_MSG_CHECKING([whether pthreads work without any flags])
923                 ;;
925                 -*)
926                 AC_MSG_CHECKING([whether pthreads work with $flag])
927                 PTHREAD_CFLAGS="$flag"
928                 ;;
930                 pthread-config)
931                 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
932                 if test x"$acx_pthread_config" = xno; then continue; fi
933                 PTHREAD_CFLAGS="`pthread-config --cflags`"
934                 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
935                 ;;
937                 *)
938                 AC_MSG_CHECKING([for the pthreads library -l$flag])
939                 PTHREAD_LIBS="-l$flag"
940                 ;;
941         esac
943         save_LIBS="$LIBS"
944         save_CFLAGS="$CFLAGS"
945         LIBS="$PTHREAD_LIBS $LIBS"
946         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
948         # Check for various functions.  We must include pthread.h,
949         # since some functions may be macros.  (On the Sequent, we
950         # need a special flag -Kthread to make this header compile.)
951         # We check for pthread_join because it is in -lpthread on IRIX
952         # while pthread_create is in libc.  We check for pthread_attr_init
953         # due to DEC craziness with -lpthreads.  We check for
954         # pthread_cleanup_push because it is one of the few pthread
955         # functions on Solaris that doesn't have a non-functional libc stub.
956         # We try pthread_create on general principles.
957         AC_TRY_LINK([#include <pthread.h>],
958                     [pthread_t th; pthread_join(th, 0);
959                      pthread_attr_init(0); pthread_cleanup_push(0, 0);
960                      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
961                     [acx_pthread_ok=yes])
963         LIBS="$save_LIBS"
964         CFLAGS="$save_CFLAGS"
966         AC_MSG_RESULT($acx_pthread_ok)
967         if test "x$acx_pthread_ok" = xyes; then
968                 break;
969         fi
971         PTHREAD_LIBS=""
972         PTHREAD_CFLAGS=""
973 done
976 # Various other checks:
977 if test "x$acx_pthread_ok" = xyes; then
978         save_LIBS="$LIBS"
979         LIBS="$PTHREAD_LIBS $LIBS"
980         save_CFLAGS="$CFLAGS"
981         CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
983         # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
984         AC_MSG_CHECKING([for joinable pthread attribute])
985         attr_name=unknown
986         for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
987             AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
988                         [attr_name=$attr; break])
989         done
990         AC_MSG_RESULT($attr_name)
991         if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
992             AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
993                                [Define to necessary symbol if this constant
994                                 uses a non-standard name on your system.])
995         fi
997         AC_MSG_CHECKING([if more special flags are required for pthreads])
998         flag=no
999         case "${host_cpu}-${host_os}" in
1000             *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
1001             *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
1002         esac
1003         AC_MSG_RESULT(${flag})
1004         if test "x$flag" != xno; then
1005             PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1006         fi
1008         LIBS="$save_LIBS"
1009         CFLAGS="$save_CFLAGS"
1011         # More AIX lossage: must compile with xlc_r or cc_r
1012         if test x"$GCC" != xyes; then
1013           AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
1014         else
1015           PTHREAD_CC=$CC
1016         fi
1017 else
1018         PTHREAD_CC="$CC"
1021 AC_SUBST(PTHREAD_LIBS)
1022 AC_SUBST(PTHREAD_CFLAGS)
1023 AC_SUBST(PTHREAD_CC)
1025 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
1026 if test x"$acx_pthread_ok" = xyes; then
1027         ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
1028         :
1029 else
1030         acx_pthread_ok=no
1031         $2
1033 AC_LANG_RESTORE
1034 ])dnl ACX_PTHREAD