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