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 saved_cppflags="${CPPFLAGS}"
62 CPPFLAGS="${CPPFLAGS} -I${$1_DIR}/include"
63 if test "x$4" != "x" ; then
64 AC_CHECK_HEADER([${$1_DIR}/include/$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
66 CPPFLAGS="${saved_cppflags}"
68 if test "x$4" != "x" ; then
69 AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
72 if test "x${$1_HEADER_FOUND}" = "x0" ; then
73 if test ! -z "${$1_MANDATORY}" ;
76 AC_MSG_NOTICE([*** It appears that you do not have the $2 development package installed.])
77 AC_MSG_NOTICE([*** Please install it to include ${$1_DESCRIP} support, or re-run configure])
78 AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
86 AC_DEFINE_UNQUOTED([HAVE_$1], 1, [Define to indicate the ${$1_DESCRIP} library])
88 elif test ! -z "${$1_MANDATORY}";
91 AC_MSG_NOTICE([*** The ${$1_DESCRIP} installation on this system appears to be broken.])
92 AC_MSG_NOTICE([*** Either correct the installation, or run configure])
93 AC_MSG_NOTICE([*** without explicitly specifying --with-${$1_OPTION}])
101 [AST_CHECK_GNU_MAKE], [AC_CACHE_CHECK(for GNU make, GNU_MAKE,
102 GNU_MAKE='Not Found' ;
103 GNU_MAKE_VERSION_MAJOR=0 ;
104 GNU_MAKE_VERSION_MINOR=0 ;
105 for a in make gmake gnumake ; do
106 if test -z "$a" ; then continue ; fi ;
107 if ( sh -c "$a --version" 2> /dev/null | grep GNU 2>&1 > /dev/null ) ; then
109 GNU_MAKE_VERSION_MAJOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f3 -d' ' | cut -f1 -d'.'`
110 GNU_MAKE_VERSION_MINOR=`$GNU_MAKE --version | grep "GNU Make" | cut -f2 -d'.' | cut -c1-2`
115 if test "x$GNU_MAKE" = "xNot Found" ; then
116 AC_MSG_ERROR( *** Please install GNU make. It is required to build Asterisk!)
127 if test "${PWLIBDIR:-unset}" != "unset" ; then
128 AC_CHECK_FILE(${PWLIBDIR}/version.h, HAS_PWLIB=1, )
130 if test "${HAS_PWLIB:-unset}" = "unset" ; then
131 if test "${OPENH323DIR:-unset}" != "unset"; then
132 AC_CHECK_FILE(${OPENH323DIR}/../pwlib/version.h, HAS_PWLIB=1, )
134 if test "${HAS_PWLIB:-unset}" != "unset" ; then
135 PWLIBDIR="${OPENH323DIR}/../pwlib"
137 AC_CHECK_FILE(${HOME}/pwlib/include/ptlib.h, HAS_PWLIB=1, )
138 if test "${HAS_PWLIB:-unset}" != "unset" ; then
139 PWLIBDIR="${HOME}/pwlib"
141 AC_CHECK_FILE(/usr/local/include/ptlib.h, HAS_PWLIB=1, )
142 if test "${HAS_PWLIB:-unset}" != "unset" ; then
143 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/bin)
144 if test "${PTLIB_CONFIG:-unset}" = "unset" ; then
145 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/local/share/pwlib/make)
147 PWLIB_INCDIR="/usr/local/include"
148 PWLIB_LIBDIR="/usr/local/lib"
150 AC_CHECK_FILE(/usr/include/ptlib.h, HAS_PWLIB=1, )
151 if test "${HAS_PWLIB:-unset}" != "unset" ; then
152 AC_PATH_PROG(PTLIB_CONFIG, ptlib-config, , /usr/share/pwlib/make)
153 PWLIB_INCDIR="/usr/include"
154 PWLIB_LIBDIR="/usr/lib"
161 #if test "${HAS_PWLIB:-unset}" = "unset" ; then
162 # echo "Cannot find pwlib - please install or set PWLIBDIR and try again"
166 if test "${HAS_PWLIB:-unset}" != "unset" ; then
167 if test "${PWLIBDIR:-unset}" = "unset" ; then
168 if test "${PTLIB_CONFIG:-unset}" != "unset" ; then
169 PWLIBDIR=`$PTLIB_CONFIG --prefix`
171 echo "Cannot find ptlib-config - please install and try again"
176 if test "x$PWLIBDIR" = "x/usr" -o "x$PWLIBDIR" = "x/usr/"; then
177 PWLIBDIR="/usr/share/pwlib"
178 PWLIB_INCDIR="/usr/include"
179 PWLIB_LIBDIR="/usr/lib"
181 if test "x$PWLIBDIR" = "x/usr/local" -o "x$PWLIBDIR" = "x/usr/"; then
182 PWLIBDIR="/usr/local/share/pwlib"
183 PWLIB_INCDIR="/usr/local/include"
184 PWLIB_LIBDIR="/usr/local/lib"
187 if test "${PWLIB_INCDIR:-unset}" = "unset"; then
188 PWLIB_INCDIR="${PWLIBDIR}/include"
190 if test "${PWLIB_LIBDIR:-unset}" = "unset"; then
191 PWLIB_LIBDIR="${PWLIBDIR}/lib"
195 AC_SUBST([PWLIB_INCDIR])
196 AC_SUBST([PWLIB_LIBDIR])
202 [AST_CHECK_OPENH323_PLATFORM], [
205 linux*) PWLIB_OSTYPE=linux ;
207 freebsd* ) PWLIB_OSTYPE=FreeBSD ;
209 openbsd* ) PWLIB_OSTYPE=OpenBSD ;
210 ENDLDLIBS="-lossaudio" ;
212 netbsd* ) PWLIB_OSTYPE=NetBSD ;
213 ENDLDLIBS="-lossaudio" ;
215 solaris* | sunos* ) PWLIB_OSTYPE=solaris ;
217 darwin* ) PWLIB_OSTYPE=Darwin ;
219 beos*) PWLIB_OSTYPE=beos ;
220 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
222 cygwin*) PWLIB_OSTYPE=cygwin ;
224 mingw*) PWLIB_OSTYPE=mingw ;
225 STDCCFLAGS="$STDCCFLAGS -mms-bitfields" ;
226 ENDLDLIBS="-lwinmm -lwsock32 -lsnmpapi -lmpr -lcomdlg32 -lgdi32 -lavicap32" ;
228 * ) PWLIB_OSTYPE="$host_os" ;
229 AC_MSG_WARN("OS $PWLIB_OSTYPE not recognized - proceed with caution!") ;
235 x86 | i686 | i586 | i486 | i386 ) PWLIB_MACHTYPE=x86
238 x86_64) PWLIB_MACHTYPE=x86_64 ;
243 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) PWLIB_MACHTYPE=alpha ;
247 sparc ) PWLIB_MACHTYPE=sparc ;
250 powerpc ) PWLIB_MACHTYPE=ppc ;
253 ppc ) PWLIB_MACHTYPE=ppc ;
256 powerpc64 ) PWLIB_MACHTYPE=ppc64 ;
261 ppc64 ) PWLIB_MACHTYPE=ppc64 ;
266 ia64) PWLIB_MACHTYPE=ia64 ;
270 s390x) PWLIB_MACHTYPE=s390x ;
275 s390) PWLIB_MACHTYPE=s390 ;
278 * ) PWLIB_MACHTYPE="$host_cpu";
279 AC_MSG_WARN("CPU $PWLIB_MACHTYPE not recognized - proceed with caution!") ;;
282 PWLIB_PLATFORM="${PWLIB_OSTYPE}_${PWLIB_MACHTYPE}"
284 AC_SUBST([PWLIB_PLATFORM])
289 [AST_CHECK_OPENH323], [
292 if test "${OPENH323DIR:-unset}" != "unset" ; then
293 AC_CHECK_FILE(${OPENH323DIR}/version.h, HAS_OPENH323=1, )
295 if test "${HAS_OPENH323:-unset}" = "unset" ; then
296 AC_CHECK_FILE(${PWLIBDIR}/../openh323/version.h, OPENH323DIR="${PWLIBDIR}/../openh323"; HAS_OPENH323=1, )
297 if test "${HAS_OPENH323:-unset}" != "unset" ; then
298 OPENH323DIR="${PWLIBDIR}/../openh323"
299 AC_CHECK_FILE(${OPENH323DIR}/include/h323.h, , OPENH323_INCDIR="${PWLIB_INCDIR}/openh323"; OPENH323_LIBDIR="${PWLIB_LIBDIR}")
301 AC_CHECK_FILE(${HOME}/openh323/include/h323.h, HAS_OPENH323=1, )
302 if test "${HAS_OPENH323:-unset}" != "unset" ; then
303 OPENH323DIR="${HOME}/openh323"
305 AC_CHECK_FILE(/usr/local/include/openh323/h323.h, HAS_OPENH323=1, )
306 if test "${HAS_OPENH323:-unset}" != "unset" ; then
307 OPENH323DIR="/usr/local/share/openh323"
308 OPENH323_INCDIR="/usr/local/include/openh323"
309 OPENH323_LIBDIR="/usr/local/lib"
311 AC_CHECK_FILE(/usr/include/openh323/h323.h, HAS_OPENH323=1, )
312 if test "${HAS_OPENH323:-unset}" != "unset" ; then
313 OPENH323DIR="/usr/share/openh323"
314 OPENH323_INCDIR="/usr/include/openh323"
315 OPENH323_LIBDIR="/usr/lib"
322 if test "${HAS_OPENH323:-unset}" != "unset" ; then
323 if test "${OPENH323_INCDIR:-unset}" = "unset"; then
324 OPENH323_INCDIR="${OPENH323DIR}/include"
326 if test "${OPENH323_LIBDIR:-unset}" = "unset"; then
327 OPENH323_LIBDIR="${OPENH323DIR}/lib"
330 AC_SUBST([OPENH323DIR])
331 AC_SUBST([OPENH323_INCDIR])
332 AC_SUBST([OPENH323_LIBDIR])
338 [AST_CHECK_PWLIB_VERSION], [
339 if test "${HAS_$2:-unset}" != "unset"; then
340 $2_VERSION=`grep "$2_VERSION" ${$2_INCDIR}/$3 | cut -f2 -d ' ' | sed -e 's/"//g'`
341 $2_MAJOR_VERSION=`echo ${$2_VERSION} | cut -f1 -d.`
342 $2_MINOR_VERSION=`echo ${$2_VERSION} | cut -f2 -d.`
343 $2_BUILD_NUMBER=`echo ${$2_VERSION} | cut -f3 -d.`
344 let $2_VER=${$2_MAJOR_VERSION}*10000+${$2_MINOR_VERSION}*100+${$2_BUILD_NUMBER}
345 let $2_REQ=$4*10000+$5*100+$6
347 AC_MSG_CHECKING(if $1 version ${$2_VERSION} is compatible with chan_h323)
348 if test ${$2_VER} -lt ${$2_REQ}; then
359 [AST_CHECK_PWLIB_BUILD], [
360 if test "${HAS_$2:-unset}" != "unset"; then
361 AC_MSG_CHECKING($1 installation validity)
363 saved_cppflags="${CPPFLAGS}"
365 LIBS="${LIBS} -L${$2_LIBDIR} -l${PLATFORM_$2} $7"
366 CPPFLAGS="${CPPFLAGS} -I${$2_INCDIR} $6"
371 [AC_LANG_PROGRAM([$4],[$5])],
383 CPPFLAGS="${saved_cppflags}"
385 if test "${ac_cv_lib_$2}" = "yes"; then
386 if test "${$2_LIBDIR}" != "" -a "${$2_LIBDIR}" != "/usr/lib"; then
387 $2_LIB="-L${$2_LIBDIR} -l${PLATFORM_$2}"
389 $2_LIB="-l${PLATFORM_$2}"
391 if test "${$2_INCDIR}" != "" -a "${$2_INCDIR}" != "/usr/include"; then
392 $2_INCLUDE="-I${$2_INCDIR}"
395 AC_DEFINE([HAVE_$2], 1, [$3])
401 [AST_CHECK_OPENH323_BUILD], [
402 if test "${HAS_OPENH323:-unset}" != "unset"; then
403 AC_MSG_CHECKING(OpenH323 build option)
405 files=`ls -l ${OPENH323_LIBDIR}/libh323_${PWLIB_PLATFORM}_*.so*`
407 if test -n "$files"; then
409 if test -f $f -a ! -L $f; then
410 libfile=`basename $f`
415 if test "${libfile:-unset}" != "unset"; then
416 OPENH323_SUFFIX=`eval "echo ${libfile} | sed -e 's/libh323_${PWLIB_PLATFORM}_\(@<:@^.@:>@*\)\..*/\1/'"`
418 case "${OPENH323_SUFFIX}" in
420 OPENH323_BUILD="notrace";;
422 OPENH323_BUILD="opt";;
424 OPENH323_BUILD="debug";;
426 OPENH323_BUILD="notrace";;
428 AC_MSG_RESULT(${OPENH323_BUILD})
430 AC_SUBST([OPENH323_SUFFIX])
431 AC_SUBST([OPENH323_BUILD])
438 AN_FUNCTION([fork], [AST_FUNC_FORK])
439 AN_FUNCTION([vfork], [AST_FUNC_FORK])
440 AC_DEFUN([AST_FUNC_FORK],
441 [AC_REQUIRE([AC_TYPE_PID_T])dnl
442 AC_CHECK_HEADERS(vfork.h)
443 AC_CHECK_FUNCS(fork vfork)
444 if test "x$ac_cv_func_fork" = xyes; then
447 ac_cv_func_fork_works=$ac_cv_func_fork
449 if test "x$ac_cv_func_fork_works" = xcross; then
451 *-*-amigaos* | *-*-msdosdjgpp* | *-*-uclinux* )
452 # Override, as these systems have only a dummy fork() stub
453 ac_cv_func_fork_works=no
456 ac_cv_func_fork_works=yes
459 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
461 ac_cv_func_vfork_works=$ac_cv_func_vfork
462 if test "x$ac_cv_func_vfork" = xyes; then
465 if test "x$ac_cv_func_fork_works" = xcross; then
466 ac_cv_func_vfork_works=$ac_cv_func_vfork
467 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
470 if test "x$ac_cv_func_vfork_works" = xyes; then
471 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
473 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
475 if test "x$ac_cv_func_fork_works" = xyes; then
476 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
483 AC_DEFUN([_AST_FUNC_FORK],
484 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
486 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
488 /* By Ruediger Kuhlmann. */
491 [ac_cv_func_fork_works=yes],
492 [ac_cv_func_fork_works=no],
493 [ac_cv_func_fork_works=cross])])]
498 # find the pathname to the GNU or non-GNU linker
499 AC_DEFUN([AST_PROG_LD],
500 [AC_ARG_WITH([gnu-ld],
501 [AC_HELP_STRING([--with-gnu-ld],
502 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
503 [test "$withval" = no || with_gnu_ld=yes],
505 AC_REQUIRE([AST_PROG_SED])dnl
506 AC_REQUIRE([AC_PROG_CC])dnl
507 AC_REQUIRE([AC_CANONICAL_HOST])dnl
508 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
510 if test "$GCC" = yes; then
511 # Check if gcc -print-prog-name=ld gives a path.
512 AC_MSG_CHECKING([for ld used by $CC])
515 # gcc leaves a trailing carriage return which upsets mingw
516 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
518 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
521 # Accept absolute paths.
522 [[\\/]]* | ?:[[\\/]]*)
523 re_direlt='/[[^/]][[^/]]*/\.\./'
524 # Canonicalize the pathname of ld
525 ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
526 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
527 ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
529 test -z "$LD" && LD="$ac_prog"
532 # If it fails, then pretend we aren't using GCC.
536 # If it is relative, then search for the first ld in PATH.
540 elif test "$with_gnu_ld" = yes; then
541 AC_MSG_CHECKING([for GNU ld])
543 AC_MSG_CHECKING([for non-GNU ld])
545 AC_CACHE_VAL(lt_cv_path_LD,
546 [if test -z "$LD"; then
547 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
548 for ac_dir in $PATH; do
550 test -z "$ac_dir" && ac_dir=.
551 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
552 lt_cv_path_LD="$ac_dir/$ac_prog"
553 # Check to see if the program is GNU ld. I'd rather use --version,
554 # but apparently some variants of GNU ld only accept -v.
555 # Break only if it was the GNU/non-GNU ld that we prefer.
556 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
557 *GNU* | *'with BFD'*)
558 test "$with_gnu_ld" != no && break
561 test "$with_gnu_ld" != yes && break
568 lt_cv_path_LD="$LD" # Let the user override the test with a path.
571 if test -n "$LD"; then
576 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
583 AC_DEFUN([AST_PROG_LD_GNU],
584 [AC_REQUIRE([AST_PROG_EGREP])dnl
585 AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
586 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
587 case `$LD -v 2>&1 </dev/null` in
588 *GNU* | *'with BFD'*)
589 lt_cv_prog_gnu_ld=yes
595 with_gnu_ld=$lt_cv_prog_gnu_ld
600 m4_ifndef([AST_PROG_EGREP], [AC_DEFUN([AST_PROG_EGREP],
601 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
602 [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
603 then ac_cv_prog_egrep='grep -E'
604 else ac_cv_prog_egrep='egrep'
606 EGREP=$ac_cv_prog_egrep
608 ])]) # AST_PROG_EGREP
612 # Check for a fully functional sed program that truncates
613 # as few characters as possible. Prefer GNU sed if found.
614 AC_DEFUN([AST_PROG_SED],
615 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
616 [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
617 dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
618 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
619 for ac_i in 1 2 3 4 5 6 7; do
620 ac_script="$ac_script$as_nl$ac_script"
622 echo "$ac_script" | sed 99q >conftest.sed
623 $as_unset ac_script || ac_script=
624 _AC_PATH_PROG_FEATURE_CHECK(SED, [sed gsed],
625 [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
626 ["$ac_path_SED" -f conftest.sed])])])
627 SED="$ac_cv_path_SED"