1 # AST_GCC_ATTRIBUTE([attribute name])
3 AC_DEFUN([AST_GCC_ATTRIBUTE],
5 AC_MSG_CHECKING(for compiler 'attribute $1' support)
7 AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
10 AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
14 # AST_EXT_LIB_SETUP([package symbol name], [package friendly name], [package option name], [additional help text])
16 AC_DEFUN([AST_EXT_LIB_SETUP],
20 AC_ARG_WITH([$3], AC_HELP_STRING([--with-$3=PATH],[use $2 files in PATH $4]),[
26 ac_mandatory_list="${ac_mandatory_list} $1"
30 ac_mandatory_list="${ac_mandatory_list} $1"
36 AC_SUBST([$1_INCLUDE])
40 # Check whether any of the mandatory modules are not present, and
41 # print error messages in case.
43 AC_DEFUN([AST_CHECK_MANDATORY],
45 AC_MSG_CHECKING([for mandatory modules: ${ac_mandatory_list}])
47 for i in ${ac_mandatory_list}; do
49 if test "x${a}" = "x1" ; then continue; fi
50 if test ${err} = "0" ; then AC_MSG_RESULT(fail) ; fi
52 eval "a=\${${i}_OPTION}"
54 AC_MSG_NOTICE(*** The $i installation appears to be missing or broken.)
55 AC_MSG_NOTICE(*** Either correct the installation, or run configure)
56 AC_MSG_NOTICE(*** including --without-${a}.)
59 if test $err = 1 ; then exit 1; fi
63 #-- The following two tests are only performed if PBX_$1 != 1,
64 # so you can use multiple tests and stop at the first matching one.
65 # On success, set PBX_$1 = 1, and also #define HAVE_$1 1
66 # and #define HAVE_$1_VERSION ${last_argument} so you can tell which
68 # They should be called after AST_EXT_LIB_SETUP($1, ...)
70 # Check if a given macro is defined in a certain header.
72 # AST_C_DEFINE_CHECK([package symbol name], [macro name], [header file], [version])
73 AC_DEFUN([AST_C_DEFINE_CHECK],
75 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
76 AC_MSG_CHECKING([for $2 in $3])
77 saved_cppflags="${CPPFLAGS}"
78 if test "x${$1_DIR}" != "x"; then
79 $1_INCLUDE= "-I${$1_DIR}/include"
81 CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
84 [ AC_LANG_PROGRAM( [#include <$3>], [int foo = $2;]) ],
87 AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
88 AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
92 CPPFLAGS="${saved_cppflags}"
97 # Check for existence of a given package ($1), either looking up a function
98 # in a library, or, if no function is supplied, only check for the
99 # existence of the header files.
101 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data], [version])
102 AC_DEFUN([AST_EXT_LIB_CHECK],
104 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
106 if test "x${$1_DIR}" != "x"; then
107 if test -d ${$1_DIR}/lib; then
108 pbxlibdir="-L${$1_DIR}/lib"
110 pbxlibdir="-L${$1_DIR}"
114 if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
117 AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
120 if test "${AST_$1_FOUND}" = "yes"; then
123 if test "x${$1_DIR}" != "x"; then
124 $1_LIB="${pbxlibdir} ${$1_LIB}"
125 $1_INCLUDE="-I${$1_DIR}/include"
126 if test "x$4" != "x" ; then
127 AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
130 if test "x$4" != "x" ; then
131 AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
134 if test "x${$1_HEADER_FOUND}" = "x0" ; then
138 if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
142 # XXX don't know how to evaluate the description (third argument) in AC_DEFINE_UNQUOTED
143 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define this to indicate the ${$1_DESCRIP} library])
144 AC_DEFINE_UNQUOTED([HAVE_$1_VERSION], [$6], [Define to indicate the ${$1_DESCRIP} library version])
152 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
153 GNU_MAKE='Not Found' ;
154 GNU_MAKE_VERSION_MAJOR=0 ;
155 GNU_MAKE_VERSION_MINOR=0 ;
156 for a in make gmake gnumake ; do
157 if test -z "$a" ; then continue ; fi ;
158 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
160 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
161 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
166 if test "x$GNU_MAKE" = "xNot Found" ; then
167 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
178 if test "${PWLIBDIR:-unset}" != "unset" ; then
179 AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
181 if test "${HAS_PWLIB:-unset}" = "unset" ; then
182 if test "${OPENH323DIR:-unset}" != "unset"; then
183 AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
185 if test "${HAS_PWLIB:-unset}" != "unset" ; then
186 PWLIBDIR="${OPENH323DIR}/../pwlib"
188 AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
189 if test "${HAS_PWLIB:-unset}" != "unset" ; then
190 PWLIBDIR="${HOME}/pwlib"
192 AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
193 if test "${HAS_PWLIB:-unset}" != "unset" ; then
194 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
195 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
196 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
198 PWLIB_INCDIR="/usr/local/include"
199 if test "x$LIB64" != "x"; then
200 PWLIB_LIBDIR="/usr/local/lib64"
202 PWLIB_LIBDIR="/usr/local/lib"
205 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
206 if test "${HAS_PWLIB:-unset}" != "unset" ; then
207 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
208 PWLIB_INCDIR="/usr/include"
209 if test "x$LIB64" != "x"; then
210 PWLIB_LIBDIR="/usr/lib64"
212 PWLIB_LIBDIR="/usr/lib"
220 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
221 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
225 if test "${HAS_PWLIB:-unset}" != "unset" ; then
226 if test "${PWLIBDIR:-unset}" = "unset" ; then
227 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
228 PWLIBDIR=`$PTLIB_CONFIG --prefix`
230 echo "Cannot find ptlib-config - please install and try again"
235 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
236 PWLIBDIR="/usr/share/pwlib"
237 PWLIB_INCDIR="/usr/include"
238 if test "x$LIB64" != "x"; then
239 PWLIB_LIBDIR="/usr/lib64"
241 PWLIB_LIBDIR="/usr/lib"
244 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
245 PWLIBDIR="/usr/local/share/pwlib"
246 PWLIB_INCDIR="/usr/local/include"
247 if test "x$LIB64" != "x"; then
248 PWLIB_LIBDIR="/usr/local/lib64"
250 PWLIB_LIBDIR="/usr/local/lib"
254 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
255 PWLIB_INCDIR="${PWLIBDIR}/include"
257 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
258 PWLIB_LIBDIR="${PWLIBDIR}/lib"
262 AC_SUBST([PWLIB_INCDIR])
263 AC_SUBST([PWLIB_LIBDIR])
269 [AST_CHECK_OPENH323_PLATFORM], [
272 linux*) PWLIB_OSTYPE=linux ;
274 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
276 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
277 ENDLDLIBS="-lossaudio" ;
279 netbsd* ) PWLIB_OSTYPE=NetBSD ;
280 ENDLDLIBS="-lossaudio" ;
282 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
284 darwin* ) PWLIB_OSTYPE=Darwin ;
286 beos*) PWLIB_OSTYPE=beos ;
287 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
289 cygwin*) PWLIB_OSTYPE=cygwin ;
291 mingw*) PWLIB_OSTYPE=mingw ;
292 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
293 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
295 * ) PWLIB_OSTYPE="$host_os" ;
296 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
302 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
305 x86_64) PWLIB_MACHTYPE=x86_64 ;
310 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
314 sparc ) PWLIB_MACHTYPE=sparc ;
317 powerpc ) PWLIB_MACHTYPE=ppc ;
320 ppc ) PWLIB_MACHTYPE=ppc ;
323 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
328 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
333 ia64) PWLIB_MACHTYPE=ia64 ;
337 s390x) PWLIB_MACHTYPE=s390x ;
342 s390) PWLIB_MACHTYPE=s390 ;
345 * ) PWLIB_MACHTYPE="$host_cpu";
346 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
349 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
351 AC_SUBST([PWLIB_PLATFORM])
356 [AST_CHECK_OPENH323], [
359 if test "${OPENH323DIR:-unset}" != "unset" ; then
360 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
362 if test "${HAS_OPENH323:-unset}" = "unset" ; then
363 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
364 if test "${HAS_OPENH323:-unset}" != "unset" ; then
365 OPENH323DIR="${PWLIBDIR}/../openh323"
366 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
368 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
369 if test "${HAS_OPENH323:-unset}" != "unset" ; then
370 OPENH323DIR="${HOME}/openh323"
372 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
373 if test "${HAS_OPENH323:-unset}" != "unset" ; then
374 OPENH323DIR="/usr/local/share/openh323"
375 OPENH323_INCDIR="/usr/local/include/openh323"
376 if test "x$LIB64" != "x"; then
377 OPENH323_LIBDIR="/usr/local/lib64"
379 OPENH323_LIBDIR="/usr/local/lib"
382 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
383 if test "${HAS_OPENH323:-unset}" != "unset" ; then
384 OPENH323DIR="/usr/share/openh323"
385 OPENH323_INCDIR="/usr/include/openh323"
386 if test "x$LIB64" != "x"; then
387 OPENH323_LIBDIR="/usr/lib64"
389 OPENH323_LIBDIR="/usr/lib"
397 if test "${HAS_OPENH323:-unset}" != "unset" ; then
398 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
399 OPENH323_INCDIR="${OPENH323DIR}/include"
401 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
402 OPENH323_LIBDIR="${OPENH323DIR}/lib"
405 AC_SUBST([OPENH323DIR])
406 AC_SUBST([OPENH323_INCDIR])
407 AC_SUBST([OPENH323_LIBDIR])
413 [AST_CHECK_PWLIB_VERSION], [
414 if test "${HAS_$2:-unset}" != "unset"; then
415 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
416 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
417 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
418 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
419 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
420 let $2_REQ=$4*10000+$5*100+$6
422 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
423 if test ${$2_VER} -lt ${$2_REQ}; then
434 [AST_CHECK_PWLIB_BUILD], [
435 if test "${HAS_$2:-unset}" != "unset"; then
436 AC_MSG_CHECKING($1 installation validity)
438 saved_cppflags="${CPPFLAGS}"
440 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
441 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
446 [AC_LANG_PROGRAM([$4],[$5])],
458 CPPFLAGS="${saved_cppflags}"
460 if test "${ac_cv_lib_$2}" = "yes"; then
461 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
462 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
464 $2_LIB="-l${PLATFORM_$2}"
466 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
467 $2_INCLUDE="-I${$2_INCDIR}"
470 AC_DEFINE([HAVE_$2], 1, [$3])
476 [AST_CHECK_OPENH323_BUILD], [
477 if test "${HAS_OPENH323:-unset}" != "unset"; then
478 AC_MSG_CHECKING(OpenH323 build option)
480 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
482 if test -n "$files"; then
484 if test -f $f -a ! -L $f; then
485 libfile=`basename $f`
490 if test "${libfile:-unset}" != "unset"; then
491 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
493 case "${OPENH323_SUFFIX}" in
495 OPENH323_BUILD="notrace";;
497 OPENH323_BUILD="opt";;
499 OPENH323_BUILD="debug";;
501 OPENH323_BUILD="notrace";;
503 AC_MSG_RESULT(${OPENH323_BUILD})
505 AC_SUBST([OPENH323_SUFFIX])
506 AC_SUBST([OPENH323_BUILD])
513 AN_FUNCTION([fork], [AST_FUNC_FORK])
514 AN_FUNCTION([vfork], [AST_FUNC_FORK])
515 AC_DEFUN([AST_FUNC_FORK],
516 [AC_REQUIRE([AC_TYPE_PID_T])dnl
517 AC_CHECK_HEADERS(vfork.h)
518 AC_CHECK_FUNCS(fork vfork)
519 if test "x$ac_cv_func_fork" = xyes; then
522 ac_cv_func_fork_works=$ac_cv_func_fork
524 if test "x$ac_cv_func_fork_works" = xcross; then
526 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
527 # Override, as these systems have only a dummy fork() stub
528 ac_cv_func_fork_works=no
531 ac_cv_func_fork_works=yes
534 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
536 ac_cv_func_vfork_works=$ac_cv_func_vfork
537 if test "x$ac_cv_func_vfork" = xyes; then
540 if test "x$ac_cv_func_fork_works" = xcross; then
541 ac_cv_func_vfork_works=$ac_cv_func_vfork
542 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
545 if test "x$ac_cv_func_vfork_works" = xyes; then
546 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
548 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
550 if test "x$ac_cv_func_fork_works" = xyes; then
551 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
558 AC_DEFUN([_AST_FUNC_FORK],
559 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
561 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
563 /* By Ruediger Kuhlmann. */
566 [ac_cv_func_fork_works=yes],
567 [ac_cv_func_fork_works=no],
568 [ac_cv_func_fork_works=cross])])]