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 # AST_EXT_LIB_CHECK([package symbol name], [package library name], [function to check], [package header], [additional LIB data])
42 AC_DEFUN([AST_EXT_LIB_CHECK],
44 if test "${USE_$1}" != "no"; then
46 if test "x${$1_DIR}" != "x"; then
47 if test -d ${$1_DIR}/lib; then
48 pbxlibdir="-L${$1_DIR}/lib"
50 pbxlibdir="-L${$1_DIR}"
53 AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], ${pbxlibdir} $5)
55 if test "${AST_$1_FOUND}" = "yes"; then
58 if test "x${$1_DIR}" != "x"; then
59 $1_LIB="${pbxlibdir} ${$1_LIB}"
60 $1_INCLUDE="-I${$1_DIR}/include"
61 if test "x$4" != "x" ; then
62 AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
65 if test "x$4" != "x" ; then
66 AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0] )
69 if test "x${$1_HEADER_FOUND}" = "x0" ; then
70 if test ! -z "${$1_MANDATORY}" ;
73 AC_MSG_NOTICE( *** It appears that you do not have the $2 development package installed.)
74 AC_MSG_NOTICE( *** Please install it to include ${$1_DESCRIP} support, or re-run configure)
75 AC_MSG_NOTICE( *** without explicitly specifying --with-${$1_OPTION})
83 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
85 elif test ! -z "${$1_MANDATORY}";
88 AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
89 AC_MSG_NOTICE(*** Either correct the installation, or run configure)
90 AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
98 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
99 GNU_MAKE='Not Found' ;
100 GNU_MAKE_VERSION_MAJOR=0 ;
101 GNU_MAKE_VERSION_MINOR=0 ;
102 for a in make gmake gnumake ; do
103 if test -z "$a" ; then continue ; fi ;
104 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
106 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
107 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
112 if test "x$GNU_MAKE" = "xNot Found" ; then
113 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
124 if test "${PWLIBDIR:-unset}" != "unset" ; then
125 AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
127 if test "${HAS_PWLIB:-unset}" = "unset" ; then
128 if test "${OPENH323DIR:-unset}" != "unset"; then
129 AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
131 if test "${HAS_PWLIB:-unset}" != "unset" ; then
132 PWLIBDIR="${OPENH323DIR}/../pwlib"
134 AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
135 if test "${HAS_PWLIB:-unset}" != "unset" ; then
136 PWLIBDIR="${HOME}/pwlib"
138 AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
139 if test "${HAS_PWLIB:-unset}" != "unset" ; then
140 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
141 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
142 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
144 PWLIB_INCDIR="/usr/local/include"
145 if test "x$LIB64" != "x"; then
146 PWLIB_LIBDIR="/usr/local/lib64"
148 PWLIB_LIBDIR="/usr/local/lib"
151 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
152 if test "${HAS_PWLIB:-unset}" != "unset" ; then
153 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
154 PWLIB_INCDIR="/usr/include"
155 if test "x$LIB64" != "x"; then
156 PWLIB_LIBDIR="/usr/lib64"
158 PWLIB_LIBDIR="/usr/lib"
166 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
167 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
171 if test "${HAS_PWLIB:-unset}" != "unset" ; then
172 if test "${PWLIBDIR:-unset}" = "unset" ; then
173 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
174 PWLIBDIR=`$PTLIB_CONFIG --prefix`
176 echo "Cannot find ptlib-config - please install and try again"
181 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
182 PWLIBDIR="/usr/share/pwlib"
183 PWLIB_INCDIR="/usr/include"
184 if test "x$LIB64" != "x"; then
185 PWLIB_LIBDIR="/usr/lib64"
187 PWLIB_LIBDIR="/usr/lib"
190 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
191 PWLIBDIR="/usr/local/share/pwlib"
192 PWLIB_INCDIR="/usr/local/include"
193 if test "x$LIB64" != "x"; then
194 PWLIB_LIBDIR="/usr/local/lib64"
196 PWLIB_LIBDIR="/usr/local/lib"
200 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
201 PWLIB_INCDIR="${PWLIBDIR}/include"
203 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
204 PWLIB_LIBDIR="${PWLIBDIR}/lib"
208 AC_SUBST([PWLIB_INCDIR])
209 AC_SUBST([PWLIB_LIBDIR])
215 [AST_CHECK_OPENH323_PLATFORM], [
218 linux*) PWLIB_OSTYPE=linux ;
220 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
222 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
223 ENDLDLIBS="-lossaudio" ;
225 netbsd* ) PWLIB_OSTYPE=NetBSD ;
226 ENDLDLIBS="-lossaudio" ;
228 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
230 darwin* ) PWLIB_OSTYPE=Darwin ;
232 beos*) PWLIB_OSTYPE=beos ;
233 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
235 cygwin*) PWLIB_OSTYPE=cygwin ;
237 mingw*) PWLIB_OSTYPE=mingw ;
238 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
239 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
241 * ) PWLIB_OSTYPE="$host_os" ;
242 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
248 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
251 x86_64) PWLIB_MACHTYPE=x86_64 ;
256 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
260 sparc ) PWLIB_MACHTYPE=sparc ;
263 powerpc ) PWLIB_MACHTYPE=ppc ;
266 ppc ) PWLIB_MACHTYPE=ppc ;
269 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
274 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
279 ia64) PWLIB_MACHTYPE=ia64 ;
283 s390x) PWLIB_MACHTYPE=s390x ;
288 s390) PWLIB_MACHTYPE=s390 ;
291 * ) PWLIB_MACHTYPE="$host_cpu";
292 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
295 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
297 AC_SUBST([PWLIB_PLATFORM])
302 [AST_CHECK_OPENH323], [
305 if test "${OPENH323DIR:-unset}" != "unset" ; then
306 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
308 if test "${HAS_OPENH323:-unset}" = "unset" ; then
309 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
310 if test "${HAS_OPENH323:-unset}" != "unset" ; then
311 OPENH323DIR="${PWLIBDIR}/../openh323"
312 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
314 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
315 if test "${HAS_OPENH323:-unset}" != "unset" ; then
316 OPENH323DIR="${HOME}/openh323"
318 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
319 if test "${HAS_OPENH323:-unset}" != "unset" ; then
320 OPENH323DIR="/usr/local/share/openh323"
321 OPENH323_INCDIR="/usr/local/include/openh323"
322 if test "x$LIB64" != "x"; then
323 OPENH323_LIBDIR="/usr/local/lib64"
325 OPENH323_LIBDIR="/usr/local/lib"
328 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
329 if test "${HAS_OPENH323:-unset}" != "unset" ; then
330 OPENH323DIR="/usr/share/openh323"
331 OPENH323_INCDIR="/usr/include/openh323"
332 if test "x$LIB64" != "x"; then
333 OPENH323_LIBDIR="/usr/lib64"
335 OPENH323_LIBDIR="/usr/lib"
343 if test "${HAS_OPENH323:-unset}" != "unset" ; then
344 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
345 OPENH323_INCDIR="${OPENH323DIR}/include"
347 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
348 OPENH323_LIBDIR="${OPENH323DIR}/lib"
351 AC_SUBST([OPENH323DIR])
352 AC_SUBST([OPENH323_INCDIR])
353 AC_SUBST([OPENH323_LIBDIR])
359 [AST_CHECK_PWLIB_VERSION], [
360 if test "${HAS_$2:-unset}" != "unset"; then
361 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
362 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
363 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
364 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
365 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
366 let $2_REQ=$4*10000+$5*100+$6
368 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
369 if test ${$2_VER} -lt ${$2_REQ}; then
380 [AST_CHECK_PWLIB_BUILD], [
381 if test "${HAS_$2:-unset}" != "unset"; then
382 AC_MSG_CHECKING($1 installation validity)
384 saved_cppflags="${CPPFLAGS}"
386 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
387 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
392 [AC_LANG_PROGRAM([$4],[$5])],
404 CPPFLAGS="${saved_cppflags}"
406 if test "${ac_cv_lib_$2}" = "yes"; then
407 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
408 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
410 $2_LIB="-l${PLATFORM_$2}"
412 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
413 $2_INCLUDE="-I${$2_INCDIR}"
416 AC_DEFINE([HAVE_$2], 1, [$3])
422 [AST_CHECK_OPENH323_BUILD], [
423 if test "${HAS_OPENH323:-unset}" != "unset"; then
424 AC_MSG_CHECKING(OpenH323 build option)
426 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
428 if test -n "$files"; then
430 if test -f $f -a ! -L $f; then
431 libfile=`basename $f`
436 if test "${libfile:-unset}" != "unset"; then
437 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
439 case "${OPENH323_SUFFIX}" in
441 OPENH323_BUILD="notrace";;
443 OPENH323_BUILD="opt";;
445 OPENH323_BUILD="debug";;
447 OPENH323_BUILD="notrace";;
449 AC_MSG_RESULT(${OPENH323_BUILD})
451 AC_SUBST([OPENH323_SUFFIX])
452 AC_SUBST([OPENH323_BUILD])
459 AN_FUNCTION([fork], [AST_FUNC_FORK])
460 AN_FUNCTION([vfork], [AST_FUNC_FORK])
461 AC_DEFUN([AST_FUNC_FORK],
462 [AC_REQUIRE([AC_TYPE_PID_T])dnl
463 AC_CHECK_HEADERS(vfork.h)
464 AC_CHECK_FUNCS(fork vfork)
465 if test "x$ac_cv_func_fork" = xyes; then
468 ac_cv_func_fork_works=$ac_cv_func_fork
470 if test "x$ac_cv_func_fork_works" = xcross; then
472 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
473 # Override, as these systems have only a dummy fork() stub
474 ac_cv_func_fork_works=no
477 ac_cv_func_fork_works=yes
480 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
482 ac_cv_func_vfork_works=$ac_cv_func_vfork
483 if test "x$ac_cv_func_vfork" = xyes; then
486 if test "x$ac_cv_func_fork_works" = xcross; then
487 ac_cv_func_vfork_works=$ac_cv_func_vfork
488 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
491 if test "x$ac_cv_func_vfork_works" = xyes; then
492 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
494 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
496 if test "x$ac_cv_func_fork_works" = xyes; then
497 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
504 AC_DEFUN([_AST_FUNC_FORK],
505 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
507 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
509 /* By Ruediger Kuhlmann. */
512 [ac_cv_func_fork_works=yes],
513 [ac_cv_func_fork_works=no],
514 [ac_cv_func_fork_works=cross])])]