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]),[
36 AC_SUBST([$1_INCLUDE])
40 # Check for existence of a given package ($1), looking up a function
41 # in a library, or, if no function is supplied, only check for the
42 # existence of the header files.
43 # Only check if PBX_$1 != 1, and set PBX_$1=1 and HAVE_$1 if found.
44 # Should be called after AST_EXT_LIB_SETUP($1, ...)
46 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data])
48 AC_DEFUN([AST_EXT_LIB_CHECK],
50 if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
52 if test "x${$1_DIR}" != "x"; then
53 if test -d ${$1_DIR}/lib; then
54 pbxlibdir="-L${$1_DIR}/lib"
56 pbxlibdir="-L${$1_DIR}"
60 if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
63 AC_CHECK_LIB([$2], [${pbxfuncname}], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
66 if test "${AST_$1_FOUND}" = "yes"; then
69 if test "x${$1_DIR}" != "x"; then
70 $1_LIB="${pbxlibdir} ${$1_LIB}"
71 $1_INCLUDE="-I${$1_DIR}/include"
72 if test "x$4" != "x" ; then
73 AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
76 if test "x$4" != "x" ; then
77 AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
80 if test "x${$1_HEADER_FOUND}" = "x0" ; then
81 if test ! -z "${$1_MANDATORY}" ;
84 AC_MSG_NOTICE( *** It appears that you do not have the $2 development package installed.)
85 AC_MSG_NOTICE( *** Please install it to include ${$1_DESCRIP} support, or re-run configure)
86 AC_MSG_NOTICE( *** without explicitly specifying --with-${$1_OPTION})
94 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
96 elif test ! -z "${$1_MANDATORY}";
99 AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
100 AC_MSG_NOTICE(*** Either correct the installation, or run configure)
101 AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
109 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
110 GNU_MAKE='Not Found' ;
111 GNU_MAKE_VERSION_MAJOR=0 ;
112 GNU_MAKE_VERSION_MINOR=0 ;
113 for a in make gmake gnumake ; do
114 if test -z "$a" ; then continue ; fi ;
115 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
117 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
118 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
123 if test "x$GNU_MAKE" = "xNot Found" ; then
124 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
135 if test "${PWLIBDIR:-unset}" != "unset" ; then
136 AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
138 if test "${HAS_PWLIB:-unset}" = "unset" ; then
139 if test "${OPENH323DIR:-unset}" != "unset"; then
140 AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
142 if test "${HAS_PWLIB:-unset}" != "unset" ; then
143 PWLIBDIR="${OPENH323DIR}/../pwlib"
145 AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
146 if test "${HAS_PWLIB:-unset}" != "unset" ; then
147 PWLIBDIR="${HOME}/pwlib"
149 AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
150 if test "${HAS_PWLIB:-unset}" != "unset" ; then
151 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
152 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
153 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
155 PWLIB_INCDIR="/usr/local/include"
156 if test "x$LIB64" != "x"; then
157 PWLIB_LIBDIR="/usr/local/lib64"
159 PWLIB_LIBDIR="/usr/local/lib"
162 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
163 if test "${HAS_PWLIB:-unset}" != "unset" ; then
164 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
165 PWLIB_INCDIR="/usr/include"
166 if test "x$LIB64" != "x"; then
167 PWLIB_LIBDIR="/usr/lib64"
169 PWLIB_LIBDIR="/usr/lib"
177 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
178 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
182 if test "${HAS_PWLIB:-unset}" != "unset" ; then
183 if test "${PWLIBDIR:-unset}" = "unset" ; then
184 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
185 PWLIBDIR=`$PTLIB_CONFIG --prefix`
187 echo "Cannot find ptlib-config - please install and try again"
192 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
193 PWLIBDIR="/usr/share/pwlib"
194 PWLIB_INCDIR="/usr/include"
195 if test "x$LIB64" != "x"; then
196 PWLIB_LIBDIR="/usr/lib64"
198 PWLIB_LIBDIR="/usr/lib"
201 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
202 PWLIBDIR="/usr/local/share/pwlib"
203 PWLIB_INCDIR="/usr/local/include"
204 if test "x$LIB64" != "x"; then
205 PWLIB_LIBDIR="/usr/local/lib64"
207 PWLIB_LIBDIR="/usr/local/lib"
211 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
212 PWLIB_INCDIR="${PWLIBDIR}/include"
214 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
215 PWLIB_LIBDIR="${PWLIBDIR}/lib"
219 AC_SUBST([PWLIB_INCDIR])
220 AC_SUBST([PWLIB_LIBDIR])
226 [AST_CHECK_OPENH323_PLATFORM], [
229 linux*) PWLIB_OSTYPE=linux ;
231 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
233 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
234 ENDLDLIBS="-lossaudio" ;
236 netbsd* ) PWLIB_OSTYPE=NetBSD ;
237 ENDLDLIBS="-lossaudio" ;
239 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
241 darwin* ) PWLIB_OSTYPE=Darwin ;
243 beos*) PWLIB_OSTYPE=beos ;
244 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
246 cygwin*) PWLIB_OSTYPE=cygwin ;
248 mingw*) PWLIB_OSTYPE=mingw ;
249 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
250 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
252 * ) PWLIB_OSTYPE="$host_os" ;
253 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
259 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
262 x86_64) PWLIB_MACHTYPE=x86_64 ;
267 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
271 sparc ) PWLIB_MACHTYPE=sparc ;
274 powerpc ) PWLIB_MACHTYPE=ppc ;
277 ppc ) PWLIB_MACHTYPE=ppc ;
280 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
285 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
290 ia64) PWLIB_MACHTYPE=ia64 ;
294 s390x) PWLIB_MACHTYPE=s390x ;
299 s390) PWLIB_MACHTYPE=s390 ;
302 * ) PWLIB_MACHTYPE="$host_cpu";
303 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
306 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
308 AC_SUBST([PWLIB_PLATFORM])
313 [AST_CHECK_OPENH323], [
316 if test "${OPENH323DIR:-unset}" != "unset" ; then
317 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
319 if test "${HAS_OPENH323:-unset}" = "unset" ; then
320 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
321 if test "${HAS_OPENH323:-unset}" != "unset" ; then
322 OPENH323DIR="${PWLIBDIR}/../openh323"
323 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
325 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
326 if test "${HAS_OPENH323:-unset}" != "unset" ; then
327 OPENH323DIR="${HOME}/openh323"
329 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
330 if test "${HAS_OPENH323:-unset}" != "unset" ; then
331 OPENH323DIR="/usr/local/share/openh323"
332 OPENH323_INCDIR="/usr/local/include/openh323"
333 if test "x$LIB64" != "x"; then
334 OPENH323_LIBDIR="/usr/local/lib64"
336 OPENH323_LIBDIR="/usr/local/lib"
339 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
340 if test "${HAS_OPENH323:-unset}" != "unset" ; then
341 OPENH323DIR="/usr/share/openh323"
342 OPENH323_INCDIR="/usr/include/openh323"
343 if test "x$LIB64" != "x"; then
344 OPENH323_LIBDIR="/usr/lib64"
346 OPENH323_LIBDIR="/usr/lib"
354 if test "${HAS_OPENH323:-unset}" != "unset" ; then
355 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
356 OPENH323_INCDIR="${OPENH323DIR}/include"
358 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
359 OPENH323_LIBDIR="${OPENH323DIR}/lib"
362 AC_SUBST([OPENH323DIR])
363 AC_SUBST([OPENH323_INCDIR])
364 AC_SUBST([OPENH323_LIBDIR])
370 [AST_CHECK_PWLIB_VERSION], [
371 if test "${HAS_$2:-unset}" != "unset"; then
372 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
373 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
374 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
375 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
376 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
377 let $2_REQ=$4*10000+$5*100+$6
379 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
380 if test ${$2_VER} -lt ${$2_REQ}; then
391 [AST_CHECK_PWLIB_BUILD], [
392 if test "${HAS_$2:-unset}" != "unset"; then
393 AC_MSG_CHECKING($1 installation validity)
395 saved_cppflags="${CPPFLAGS}"
397 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
398 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
403 [AC_LANG_PROGRAM([$4],[$5])],
415 CPPFLAGS="${saved_cppflags}"
417 if test "${ac_cv_lib_$2}" = "yes"; then
418 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
419 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
421 $2_LIB="-l${PLATFORM_$2}"
423 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
424 $2_INCLUDE="-I${$2_INCDIR}"
427 AC_DEFINE([HAVE_$2], 1, [$3])
433 [AST_CHECK_OPENH323_BUILD], [
434 if test "${HAS_OPENH323:-unset}" != "unset"; then
435 AC_MSG_CHECKING(OpenH323 build option)
437 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
439 if test -n "$files"; then
441 if test -f $f -a ! -L $f; then
442 libfile=`basename $f`
447 if test "${libfile:-unset}" != "unset"; then
448 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
450 case "${OPENH323_SUFFIX}" in
452 OPENH323_BUILD="notrace";;
454 OPENH323_BUILD="opt";;
456 OPENH323_BUILD="debug";;
458 OPENH323_BUILD="notrace";;
460 AC_MSG_RESULT(${OPENH323_BUILD})
462 AC_SUBST([OPENH323_SUFFIX])
463 AC_SUBST([OPENH323_BUILD])
470 AN_FUNCTION([fork], [AST_FUNC_FORK])
471 AN_FUNCTION([vfork], [AST_FUNC_FORK])
472 AC_DEFUN([AST_FUNC_FORK],
473 [AC_REQUIRE([AC_TYPE_PID_T])dnl
474 AC_CHECK_HEADERS(vfork.h)
475 AC_CHECK_FUNCS(fork vfork)
476 if test "x$ac_cv_func_fork" = xyes; then
479 ac_cv_func_fork_works=$ac_cv_func_fork
481 if test "x$ac_cv_func_fork_works" = xcross; then
483 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
484 # Override, as these systems have only a dummy fork() stub
485 ac_cv_func_fork_works=no
488 ac_cv_func_fork_works=yes
491 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
493 ac_cv_func_vfork_works=$ac_cv_func_vfork
494 if test "x$ac_cv_func_vfork" = xyes; then
497 if test "x$ac_cv_func_fork_works" = xcross; then
498 ac_cv_func_vfork_works=$ac_cv_func_vfork
499 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
502 if test "x$ac_cv_func_vfork_works" = xyes; then
503 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
505 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
507 if test "x$ac_cv_func_fork_works" = xyes; then
508 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
515 AC_DEFUN([_AST_FUNC_FORK],
516 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
518 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
520 /* By Ruediger Kuhlmann. */
523 [ac_cv_func_fork_works=yes],
524 [ac_cv_func_fork_works=no],
525 [ac_cv_func_fork_works=cross])])]