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})
92 if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
96 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
98 elif test ! -z "${$1_MANDATORY}";
101 AC_MSG_NOTICE(*** The ${$1_DESCRIP} installation on this system appears to be broken.)
102 AC_MSG_NOTICE(*** Either correct the installation, or run configure)
103 AC_MSG_NOTICE(*** without explicitly specifying --with-${$1_OPTION})
111 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
112 GNU_MAKE='Not Found' ;
113 GNU_MAKE_VERSION_MAJOR=0 ;
114 GNU_MAKE_VERSION_MINOR=0 ;
115 for a in make gmake gnumake ; do
116 if test -z "$a" ; then continue ; fi ;
117 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
119 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
120 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
125 if test "x$GNU_MAKE" = "xNot Found" ; then
126 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
137 if test "${PWLIBDIR:-unset}" != "unset" ; then
138 AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
140 if test "${HAS_PWLIB:-unset}" = "unset" ; then
141 if test "${OPENH323DIR:-unset}" != "unset"; then
142 AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
144 if test "${HAS_PWLIB:-unset}" != "unset" ; then
145 PWLIBDIR="${OPENH323DIR}/../pwlib"
147 AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
148 if test "${HAS_PWLIB:-unset}" != "unset" ; then
149 PWLIBDIR="${HOME}/pwlib"
151 AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
152 if test "${HAS_PWLIB:-unset}" != "unset" ; then
153 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
154 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
155 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
157 PWLIB_INCDIR="/usr/local/include"
158 if test "x$LIB64" != "x"; then
159 PWLIB_LIBDIR="/usr/local/lib64"
161 PWLIB_LIBDIR="/usr/local/lib"
164 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
165 if test "${HAS_PWLIB:-unset}" != "unset" ; then
166 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
167 PWLIB_INCDIR="/usr/include"
168 if test "x$LIB64" != "x"; then
169 PWLIB_LIBDIR="/usr/lib64"
171 PWLIB_LIBDIR="/usr/lib"
179 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
180 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
184 if test "${HAS_PWLIB:-unset}" != "unset" ; then
185 if test "${PWLIBDIR:-unset}" = "unset" ; then
186 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
187 PWLIBDIR=`$PTLIB_CONFIG --prefix`
189 echo "Cannot find ptlib-config - please install and try again"
194 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
195 PWLIBDIR="/usr/share/pwlib"
196 PWLIB_INCDIR="/usr/include"
197 if test "x$LIB64" != "x"; then
198 PWLIB_LIBDIR="/usr/lib64"
200 PWLIB_LIBDIR="/usr/lib"
203 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
204 PWLIBDIR="/usr/local/share/pwlib"
205 PWLIB_INCDIR="/usr/local/include"
206 if test "x$LIB64" != "x"; then
207 PWLIB_LIBDIR="/usr/local/lib64"
209 PWLIB_LIBDIR="/usr/local/lib"
213 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
214 PWLIB_INCDIR="${PWLIBDIR}/include"
216 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
217 PWLIB_LIBDIR="${PWLIBDIR}/lib"
221 AC_SUBST([PWLIB_INCDIR])
222 AC_SUBST([PWLIB_LIBDIR])
228 [AST_CHECK_OPENH323_PLATFORM], [
231 linux*) PWLIB_OSTYPE=linux ;
233 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
235 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
236 ENDLDLIBS="-lossaudio" ;
238 netbsd* ) PWLIB_OSTYPE=NetBSD ;
239 ENDLDLIBS="-lossaudio" ;
241 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
243 darwin* ) PWLIB_OSTYPE=Darwin ;
245 beos*) PWLIB_OSTYPE=beos ;
246 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
248 cygwin*) PWLIB_OSTYPE=cygwin ;
250 mingw*) PWLIB_OSTYPE=mingw ;
251 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
252 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
254 * ) PWLIB_OSTYPE="$host_os" ;
255 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
261 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
264 x86_64) PWLIB_MACHTYPE=x86_64 ;
269 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
273 sparc ) PWLIB_MACHTYPE=sparc ;
276 powerpc ) PWLIB_MACHTYPE=ppc ;
279 ppc ) PWLIB_MACHTYPE=ppc ;
282 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
287 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
292 ia64) PWLIB_MACHTYPE=ia64 ;
296 s390x) PWLIB_MACHTYPE=s390x ;
301 s390) PWLIB_MACHTYPE=s390 ;
304 * ) PWLIB_MACHTYPE="$host_cpu";
305 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
308 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
310 AC_SUBST([PWLIB_PLATFORM])
315 [AST_CHECK_OPENH323], [
318 if test "${OPENH323DIR:-unset}" != "unset" ; then
319 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
321 if test "${HAS_OPENH323:-unset}" = "unset" ; then
322 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
323 if test "${HAS_OPENH323:-unset}" != "unset" ; then
324 OPENH323DIR="${PWLIBDIR}/../openh323"
325 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
327 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
328 if test "${HAS_OPENH323:-unset}" != "unset" ; then
329 OPENH323DIR="${HOME}/openh323"
331 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
332 if test "${HAS_OPENH323:-unset}" != "unset" ; then
333 OPENH323DIR="/usr/local/share/openh323"
334 OPENH323_INCDIR="/usr/local/include/openh323"
335 if test "x$LIB64" != "x"; then
336 OPENH323_LIBDIR="/usr/local/lib64"
338 OPENH323_LIBDIR="/usr/local/lib"
341 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
342 if test "${HAS_OPENH323:-unset}" != "unset" ; then
343 OPENH323DIR="/usr/share/openh323"
344 OPENH323_INCDIR="/usr/include/openh323"
345 if test "x$LIB64" != "x"; then
346 OPENH323_LIBDIR="/usr/lib64"
348 OPENH323_LIBDIR="/usr/lib"
356 if test "${HAS_OPENH323:-unset}" != "unset" ; then
357 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
358 OPENH323_INCDIR="${OPENH323DIR}/include"
360 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
361 OPENH323_LIBDIR="${OPENH323DIR}/lib"
364 AC_SUBST([OPENH323DIR])
365 AC_SUBST([OPENH323_INCDIR])
366 AC_SUBST([OPENH323_LIBDIR])
372 [AST_CHECK_PWLIB_VERSION], [
373 if test "${HAS_$2:-unset}" != "unset"; then
374 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
375 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
376 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
377 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
378 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
379 let $2_REQ=$4*10000+$5*100+$6
381 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
382 if test ${$2_VER} -lt ${$2_REQ}; then
393 [AST_CHECK_PWLIB_BUILD], [
394 if test "${HAS_$2:-unset}" != "unset"; then
395 AC_MSG_CHECKING($1 installation validity)
397 saved_cppflags="${CPPFLAGS}"
399 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
400 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
405 [AC_LANG_PROGRAM([$4],[$5])],
417 CPPFLAGS="${saved_cppflags}"
419 if test "${ac_cv_lib_$2}" = "yes"; then
420 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
421 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
423 $2_LIB="-l${PLATFORM_$2}"
425 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
426 $2_INCLUDE="-I${$2_INCDIR}"
429 AC_DEFINE([HAVE_$2], 1, [$3])
435 [AST_CHECK_OPENH323_BUILD], [
436 if test "${HAS_OPENH323:-unset}" != "unset"; then
437 AC_MSG_CHECKING(OpenH323 build option)
439 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
441 if test -n "$files"; then
443 if test -f $f -a ! -L $f; then
444 libfile=`basename $f`
449 if test "${libfile:-unset}" != "unset"; then
450 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
452 case "${OPENH323_SUFFIX}" in
454 OPENH323_BUILD="notrace";;
456 OPENH323_BUILD="opt";;
458 OPENH323_BUILD="debug";;
460 OPENH323_BUILD="notrace";;
462 AC_MSG_RESULT(${OPENH323_BUILD})
464 AC_SUBST([OPENH323_SUFFIX])
465 AC_SUBST([OPENH323_BUILD])
472 AN_FUNCTION([fork], [AST_FUNC_FORK])
473 AN_FUNCTION([vfork], [AST_FUNC_FORK])
474 AC_DEFUN([AST_FUNC_FORK],
475 [AC_REQUIRE([AC_TYPE_PID_T])dnl
476 AC_CHECK_HEADERS(vfork.h)
477 AC_CHECK_FUNCS(fork vfork)
478 if test "x$ac_cv_func_fork" = xyes; then
481 ac_cv_func_fork_works=$ac_cv_func_fork
483 if test "x$ac_cv_func_fork_works" = xcross; then
485 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
486 # Override, as these systems have only a dummy fork() stub
487 ac_cv_func_fork_works=no
490 ac_cv_func_fork_works=yes
493 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
495 ac_cv_func_vfork_works=$ac_cv_func_vfork
496 if test "x$ac_cv_func_vfork" = xyes; then
499 if test "x$ac_cv_func_fork_works" = xcross; then
500 ac_cv_func_vfork_works=$ac_cv_func_vfork
501 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
504 if test "x$ac_cv_func_vfork_works" = xyes; then
505 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
507 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
509 if test "x$ac_cv_func_fork_works" = xyes; then
510 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
517 AC_DEFUN([_AST_FUNC_FORK],
518 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
520 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
522 /* By Ruediger Kuhlmann. */
525 [ac_cv_func_fork_works=yes],
526 [ac_cv_func_fork_works=no],
527 [ac_cv_func_fork_works=cross])])]