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