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 PWLIB_LIBDIR="/usr/local/lib"
147 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
148 if test "${HAS_PWLIB:-unset}" != "unset" ; then
149 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
150 PWLIB_INCDIR="/usr/include"
151 PWLIB_LIBDIR="/usr/lib"
158 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
159 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
163 if test "${HAS_PWLIB:-unset}" != "unset" ; then
164 if test "${PWLIBDIR:-unset}" = "unset" ; then
165 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
166 PWLIBDIR=`$PTLIB_CONFIG --prefix`
168 echo "Cannot find ptlib-config - please install and try again"
173 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
174 PWLIBDIR="/usr/share/pwlib"
175 PWLIB_INCDIR="/usr/include"
176 PWLIB_LIBDIR="/usr/lib"
178 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
179 PWLIBDIR="/usr/local/share/pwlib"
180 PWLIB_INCDIR="/usr/local/include"
181 PWLIB_LIBDIR="/usr/local/lib"
184 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
185 PWLIB_INCDIR="${PWLIBDIR}/include"
187 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
188 PWLIB_LIBDIR="${PWLIBDIR}/lib"
192 AC_SUBST([PWLIB_INCDIR])
193 AC_SUBST([PWLIB_LIBDIR])
199 [AST_CHECK_OPENH323_PLATFORM], [
202 linux*) PWLIB_OSTYPE=linux ;
204 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
206 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
207 ENDLDLIBS="-lossaudio" ;
209 netbsd* ) PWLIB_OSTYPE=NetBSD ;
210 ENDLDLIBS="-lossaudio" ;
212 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
214 darwin* ) PWLIB_OSTYPE=Darwin ;
216 beos*) PWLIB_OSTYPE=beos ;
217 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
219 cygwin*) PWLIB_OSTYPE=cygwin ;
221 mingw*) PWLIB_OSTYPE=mingw ;
222 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
223 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
225 * ) PWLIB_OSTYPE="$host_os" ;
226 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
232 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
235 x86_64) PWLIB_MACHTYPE=x86_64 ;
240 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
244 sparc ) PWLIB_MACHTYPE=sparc ;
247 powerpc ) PWLIB_MACHTYPE=ppc ;
250 ppc ) PWLIB_MACHTYPE=ppc ;
253 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
258 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
263 ia64) PWLIB_MACHTYPE=ia64 ;
267 s390x) PWLIB_MACHTYPE=s390x ;
272 s390) PWLIB_MACHTYPE=s390 ;
275 * ) PWLIB_MACHTYPE="$host_cpu";
276 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
279 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
281 AC_SUBST([PWLIB_PLATFORM])
286 [AST_CHECK_OPENH323], [
289 if test "${OPENH323DIR:-unset}" != "unset" ; then
290 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
292 if test "${HAS_OPENH323:-unset}" = "unset" ; then
293 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
294 if test "${HAS_OPENH323:-unset}" != "unset" ; then
295 OPENH323DIR="${PWLIBDIR}/../openh323"
296 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
298 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
299 if test "${HAS_OPENH323:-unset}" != "unset" ; then
300 OPENH323DIR="${HOME}/openh323"
302 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
303 if test "${HAS_OPENH323:-unset}" != "unset" ; then
304 OPENH323DIR="/usr/local/share/openh323"
305 OPENH323_INCDIR="/usr/local/include/openh323"
306 OPENH323_LIBDIR="/usr/local/lib"
308 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
309 if test "${HAS_OPENH323:-unset}" != "unset" ; then
310 OPENH323DIR="/usr/share/openh323"
311 OPENH323_INCDIR="/usr/include/openh323"
312 OPENH323_LIBDIR="/usr/lib"
319 if test "${HAS_OPENH323:-unset}" != "unset" ; then
320 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
321 OPENH323_INCDIR="${OPENH323DIR}/include"
323 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
324 OPENH323_LIBDIR="${OPENH323DIR}/lib"
327 AC_SUBST([OPENH323DIR])
328 AC_SUBST([OPENH323_INCDIR])
329 AC_SUBST([OPENH323_LIBDIR])
335 [AST_CHECK_PWLIB_VERSION], [
336 if test "${HAS_$2:-unset}" != "unset"; then
337 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
338 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
339 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
340 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
341 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
342 let $2_REQ=$4*10000+$5*100+$6
344 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
345 if test ${$2_VER} -lt ${$2_REQ}; then
356 [AST_CHECK_PWLIB_BUILD], [
357 if test "${HAS_$2:-unset}" != "unset"; then
358 AC_MSG_CHECKING($1 installation validity)
360 saved_cppflags="${CPPFLAGS}"
362 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
363 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
368 [AC_LANG_PROGRAM([$4],[$5])],
380 CPPFLAGS="${saved_cppflags}"
382 if test "${ac_cv_lib_$2}" = "yes"; then
383 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
384 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
386 $2_LIB="-l${PLATFORM_$2}"
388 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
389 $2_INCLUDE="-I${$2_INCDIR}"
392 AC_DEFINE([HAVE_$2], 1, [$3])
398 [AST_CHECK_OPENH323_BUILD], [
399 if test "${HAS_OPENH323:-unset}" != "unset"; then
400 AC_MSG_CHECKING(OpenH323 build option)
402 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
404 if test -n "$files"; then
406 if test -f $f -a ! -L $f; then
407 libfile=`basename $f`
412 if test "${libfile:-unset}" != "unset"; then
413 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
415 case "${OPENH323_SUFFIX}" in
417 OPENH323_BUILD="notrace";;
419 OPENH323_BUILD="opt";;
421 OPENH323_BUILD="debug";;
423 OPENH323_BUILD="notrace";;
425 AC_MSG_RESULT(${OPENH323_BUILD})
427 AC_SUBST([OPENH323_SUFFIX])
428 AC_SUBST([OPENH323_BUILD])
435 AN_FUNCTION([fork], [AST_FUNC_FORK])
436 AN_FUNCTION([vfork], [AST_FUNC_FORK])
437 AC_DEFUN([AST_FUNC_FORK],
438 [AC_REQUIRE([AC_TYPE_PID_T])dnl
439 AC_CHECK_HEADERS(vfork.h)
440 AC_CHECK_FUNCS(fork vfork)
441 if test "x$ac_cv_func_fork" = xyes; then
444 ac_cv_func_fork_works=$ac_cv_func_fork
446 if test "x$ac_cv_func_fork_works" = xcross; then
448 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
449 # Override, as these systems have only a dummy fork() stub
450 ac_cv_func_fork_works=no
453 ac_cv_func_fork_works=yes
456 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
458 ac_cv_func_vfork_works=$ac_cv_func_vfork
459 if test "x$ac_cv_func_vfork" = xyes; then
462 if test "x$ac_cv_func_fork_works" = xcross; then
463 ac_cv_func_vfork_works=$ac_cv_func_vfork
464 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
467 if test "x$ac_cv_func_vfork_works" = xyes; then
468 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
470 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
472 if test "x$ac_cv_func_fork_works" = xyes; then
473 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
480 AC_DEFUN([_AST_FUNC_FORK],
481 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
483 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
485 /* By Ruediger Kuhlmann. */
488 [ac_cv_func_fork_works=yes],
489 [ac_cv_func_fork_works=no],
490 [ac_cv_func_fork_works=cross])])]
495 # find the pathname to the GNU or non-GNU linker
496 AC_DEFUN([AST_PROG_LD],
497 [AC_ARG_WITH([gnu-ld],
498 [AC_HELP_STRING([--with-gnu-ld],
499 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
500 [test "$withval" = no || with_gnu_ld=yes],
502 AC_REQUIRE([AC_PROG_SED])dnl
503 AC_REQUIRE([AC_PROG_CC])dnl
504 AC_REQUIRE([AC_CANONICAL_HOST])dnl
505 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
507 if test "$GCC" = yes; then
508 # Check if gcc -print-prog-name=ld gives a path.
509 AC_MSG_CHECKING([for ld used by $CC])
512 # gcc leaves a trailing carriage return which upsets mingw
513 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
515 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
518 # Accept absolute paths.
519 [[\\/]]* | ?:[[\\/]]*)
520 re_direlt='/[[^/]][[^/]]*/\.\./'
521 # Canonicalize the pathname of ld
522 ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
523 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
524 ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
526 test -z "$LD" && LD="$ac_prog"
529 # If it fails, then pretend we aren't using GCC.
533 # If it is relative, then search for the first ld in PATH.
537 elif test "$with_gnu_ld" = yes; then
538 AC_MSG_CHECKING([for GNU ld])
540 AC_MSG_CHECKING([for non-GNU ld])
542 AC_CACHE_VAL(lt_cv_path_LD,
543 [if test -z "$LD"; then
544 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
545 for ac_dir in $PATH; do
547 test -z "$ac_dir" && ac_dir=.
548 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
549 lt_cv_path_LD="$ac_dir/$ac_prog"
550 # Check to see if the program is GNU ld. I'd rather use --version,
551 # but apparently some variants of GNU ld only accept -v.
552 # Break only if it was the GNU/non-GNU ld that we prefer.
553 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
554 *GNU* | *'with BFD'*)
555 test "$with_gnu_ld" != no && break
558 test "$with_gnu_ld" != yes && break
565 lt_cv_path_LD="$LD" # Let the user override the test with a path.
568 if test -n "$LD"; then
573 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
580 AC_DEFUN([AST_PROG_LD_GNU],
581 [AC_REQUIRE([AST_PROG_EGREP])dnl
582 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
583 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
584 case `$LD -v 2>&1 </dev/null` in
585 *GNU* | *'with BFD'*)
586 lt_cv_prog_gnu_ld=yes
592 with_gnu_ld=$lt_cv_prog_gnu_ld
597 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
598 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
599 [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
600 then ac_cv_prog_egrep='grep -E'
601 else ac_cv_prog_egrep='egrep'
603 EGREP=$ac_cv_prog_egrep
605 ])]) # AST_PROG_EGREP