1 AC_INIT(include/ptlib.h)
3 AC_CONFIG_SUBDIRS(plugins)
9 dnl ########################################################################
10 dnl set the PWLIB directory to the current directory
14 dnl set the pwlib installation dir for pwlib-config
17 dnl ########################################################################
18 dnl set the PREFIX accordingly
19 if test "x$prefix" = "xNONE"; then
20 INSTALLPREFIX="/usr/local"
22 INSTALLPREFIX="${prefix}"
25 AC_SUBST(INSTALLPREFIX)
28 dnl ########################################################################
29 dnl set LIBDIR accordingly
34 dnl ########################################################################
35 dnl extract the PWLIB version
36 MAJOR_VERSION=`cat ${PWLIBDIR}/version.h | grep MAJOR_VERSION | cut -f3 -d' '`
37 MINOR_VERSION=`cat ${PWLIBDIR}/version.h | grep MINOR_VERSION | cut -f3 -d' '`
38 BUILD_NUMBER=`cat ${PWLIBDIR}/version.h | grep BUILD_NUMBER | cut -f3 -d' '`
39 PWLIB_VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_NUMBER}"
40 AC_SUBST(MAJOR_VERSION)
41 AC_SUBST(MINOR_VERSION)
42 AC_SUBST(BUILD_NUMBER)
43 AC_SUBST(PWLIB_VERSION)
44 AC_SUBST(MAJOR_VERSION, $MAJOR_VERSION)
45 AC_SUBST(MINOR_VERSION, $MINOR_VERSION)
46 AC_SUBST(BUILD_NUMBER, $BUILD_NUMBER)
48 AC_MSG_NOTICE(PTLib version is ${PWLIB_VERSION});
50 AC_DEFINE_UNQUOTED([PWLIB_MAJOR], [$MAJOR_VERSION], [Major version])
51 AC_DEFINE_UNQUOTED([PWLIB_MINOR], [$MINOR_VERSION], [Minor version])
52 AC_DEFINE_UNQUOTED([PWLIB_BUILD], [$BUILD_NUMBER], [Build number])
53 AC_DEFINE_UNQUOTED([PWLIB_VERSION], ["$PWLIB_VERSION"], [pwlib version])
55 dnl ########################################################################
56 dnl set the OSTYPE and MACHTYPE
64 linux*) OSTYPE=linux ;
65 OSRELEASE="\"`uname -r`\"";
67 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
70 freebsd* ) OSTYPE=FreeBSD ;
72 if test "x$OSRELEASE" = "x"; then
73 OSRELEASE="`sysctl -n kern.osreldate`" ;
75 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
78 openbsd* ) OSTYPE=OpenBSD ;
80 OSRELEASE="`sysctl -n kern.osrevision`" ;
81 ENDLDLIBS="-lossaudio" ;
82 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
85 netbsd* ) OSTYPE=NetBSD ;
87 OSRELEASE="`/sbin/sysctl -n kern.osrevision`" ;
88 ENDLDLIBS="-lossaudio" ;
89 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
92 solaris* | sunos* ) OSTYPE=solaris ;
94 OSRELEASE=`uname -r | sed "s/5\.//g"` ;
95 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
98 darwin* ) OSTYPE=Darwin ;
100 OSRELEASE="`uname -r | sed 's/\.//g'`" ;
101 SHAREDLIBEXT="dylib";
106 OSRELEASE=`uname -r` ;
107 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
110 * ) OSTYPE="$target_os" ;
111 OS_TAG="P_UNKNOWN_OS" ;
112 OSRELEASE="\"${OSTYPE}_`uname -r`\"" ;
113 AC_MSG_WARN("OS $target_os not recognized - proceed with caution!") ;
119 case "$target_cpu" in
120 x86 | i686 | i586 | i486 | i386 ) MACHTYPE=x86
123 x86_64) MACHTYPE=x86_64 ;
128 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) MACHTYPE=alpha ;
132 sparc ) MACHTYPE=sparc ;
135 powerpc ) MACHTYPE=ppc ;
141 powerpc64 ) MACHTYPE=ppc64 ;
146 ppc64 ) MACHTYPE=ppc64 ;
151 ia64) MACHTYPE=ia64 ;
155 s390x) MACHTYPE=s390x ;
160 s390) MACHTYPE=s390 ;
163 * ) MACHTYPE=$target_cpu ;
164 AC_MSG_WARN("CPU $target_cpu not recognized - proceed with caution!") ;;
167 AC_MSG_NOTICE(OSTYPE set to $OSTYPE);
168 AC_MSG_NOTICE(OSRELEASE set to $OSRELEASE);
169 AC_MSG_NOTICE(MACHTYPE set to $MACHTYPE);
171 AC_SUBST(MACHTYPE, $MACHTYPE)
172 AC_SUBST(OSTYPE, $OSTYPE)
173 AC_SUBST(OSRELEASE, $OSRELEASE)
174 AC_SUBST(TARGETDIR, $TARGETDIR)
176 AC_DEFINE_UNQUOTED($OS_TAG, $OSRELEASE)
178 AC_DEFINE([PHAS_TEMPLATES], [1], [Templates found])
180 if test "x$P_64BIT" != "x" ; then
181 AC_DEFINE([P_64BIT], [1], [64bit architecture])
184 dnl BeOS has it;s own threading system
185 if test ${OSTYPE} != beos ; then
186 AC_DEFINE(P_PTHREADS, 1, "PThreads found")
189 dnl ########################################################################
190 dnl set the shared library extension, if not already set
192 if test "x${SHAREDLIBEXT}" = "x" ; then
195 AC_SUBST(SHAREDLIBEXT, $SHAREDLIBEXT)
196 AC_DEFINE([P_SHAREDLIBEXT], [$SHAREDLIBEXT], [shared library extension])
198 dnl ########################################################################
199 dnl check the endianness
201 dnl MSWIN_DISPLAY byteorder,Byte Order
202 dnl MSWIN_DEFINE byteorder,PBYTE_ORDER=PLITTLE_ENDIAN
205 if test ${ac_cv_c_bigendian} = yes ; then
206 PBYTE_ORDER=PBIG_ENDIAN
208 PBYTE_ORDER=PLITTLE_ENDIAN
211 AC_DEFINE_UNQUOTED(PBYTE_ORDER, $PBYTE_ORDER, "byte order")
213 dnl ########################################################################
214 dnl look for compile flags
217 AC_MSG_CHECKING(if linker accepts -felide-constructors)
218 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
219 $CXX $CXXFLAGS -felide-constructors conftest.cc > /dev/null 2>&1
220 if test $? = 0 ; then
222 STDCXXFLAGS="$STDCXXFLAGS -felide-constructors"
227 AC_MSG_CHECKING(if linker accepts -Wreorder)
228 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
229 $STDCXX $CXXFLAGS -Wreorder conftest.cc > /dev/null 2>&1
230 if test $? = 0 ; then
232 STDCXXFLAGS="$STDCXXFLAGS -Wreorder"
237 # AC_MSG_CHECKING(if linker accepts -Woverloaded-virtual)
238 # AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
239 # $CXX $CFLAGS -Woverloaded-virtual conftest.cc > /dev/null 2>&1
240 # if test $? = 0 ; then
242 # STDCCFLAGS="$STDCCFLAGS -Woverloaded-virtual"
247 AC_MSG_CHECKING(if compiler uses RTTI by default)
250 int main(int ac,char **av)
255 virtual void fred() { }
263 A * p = dynamic_cast<A *>(&t);
266 ]],DEFAULT_RTTI=1, DEFAULT_RTTI=0)
267 if test "$DEFAULT_RTTI" = "1" ; then
271 STDCXXFLAGS="$STDCCFLAGS -rtti"
276 dnl Remove --gc-sections as the linker crashes when linking
277 dnl static executables with this option
278 dnl AC_MSG_CHECKING(if linker accepts --gc-sections)
279 dnl C_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
280 dnl CXX $CFLAGS -Wl,--gc-sections conftest.cc > /dev/null 2>&1
281 dnl if test $? = 0 ; then
285 dnl AC_MSG_RESULT(yes)
287 AC_MSG_CHECKING(if compiler accepts -ffunction-sections)
288 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
289 $CXX $CFLAGS -ffunction-sections -c conftest.cc > /dev/null 2>&1
290 if test $? = 0 ; then
292 STDCCFLAGS="$STDCCFLAGS -ffunction-sections"
298 dnl remove data-sections as not only does is case the linker to
299 dnl crash on some platforms, but seems to be broken w.r.t
300 dnl closure of templates with static member functions
301 dnl see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8249
303 dnl AC_MSG_CHECKING(if compiler accepts -fdata-sections)
304 dnl AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
305 dnl $CXX $CFLAGS -fdata-sections -c conftest.cc > /dev/null 2>&1
306 dnl if test $? = 0 ; then
307 dnl AC_MSG_RESULT(yes)
308 dnl STDCCFLAGS="$STDCCFLAGS -fdata-sections"
311 dnl AC_MSG_RESULT(no)
314 dnl as much as this flag would help, there is no known linker
315 dnl that can handle pwlib when it has been compiled with it
316 dnl AC_MSG_CHECKING(if compiler accepts -fvtable-gc)
317 dnl AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
318 dnl $CXX $CFLAGS -fvtable-gc -c conftest.cc > /dev/null 2>&1
319 dnl if test $? = 0 ; then
320 dnl AC_MSG_RESULT(yes)
321 dnl STDCCFLAGS="$STDCCFLAGS -fvtable-gc"
324 dnl AC_MSG_RESULT(no)
327 if test $GCSECTIONS = 1; then
328 if test "${OSTYPE}" != "Darwin" ; then
329 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -Wl,--gc-sections"
337 dnl ########################################################################
338 dnl check for long double
341 if test $ac_cv_c_long_double != yes ; then
342 AC_DEFINE([PNO_LONG_DOUBLE], [], [No long double])
343 elif test ${OSTYPE} = Darwin ; then
344 STDCCFLAGS="$STDCCFLAGS -Wno-long-double"
347 dnl ########################################################################
348 dnl check for number of parms to readdir
349 AC_MSG_CHECKING(if readdir_r has 2 parms)
350 AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS
351 #include <dirent.h>],
352 [DIR *s; struct dirent * e; readdir_r(s, e);], P_HAS_POSIX_READDIR_R=2, P_HAS_POSIX_READDIR_R=0)
353 if test ${P_HAS_POSIX_READDIR_R} = 2 ; then
357 AC_MSG_CHECKING(if readdir_r has 3 parms)
358 AC_TRY_COMPILE([#include <dirent.h>],
359 [DIR *s; struct dirent * e; struct dirent * p; readdir_r(s, e, &p);], P_HAS_POSIX_READDIR_R=3, P_HAS_POSIX_READDIR_R=0)
360 if test ${P_HAS_POSIX_READDIR_R} = 3 ; then
366 AC_DEFINE_UNQUOTED(P_HAS_POSIX_READDIR_R, ${P_HAS_POSIX_READDIR_R})
368 dnl ########################################################################
369 dnl check for recvmsg
372 AC_MSG_CHECKING(for recvmsg)
373 AC_TRY_COMPILE([#include <sys/types.h>
374 #include <sys/socket.h>],
375 [struct msghdr *msg; recvmsg(0, msg, 0);], P_HAS_RECVMSG=1)
376 if test "${P_HAS_RECVMSG}" = "1" ; then
381 AC_DEFINE_UNQUOTED(P_HAS_RECVMSG, ${P_HAS_RECVMSG})
383 dnl ########################################################################
384 dnl check for streams types
387 AC_MSG_CHECKING(if using STL streams)
388 AC_TRY_COMPILE([#include <iostream>],
389 [int v = (int)std::ios_base::seekdir();], P_HAS_STL_STREAMS=1)
390 if test "${P_HAS_STL_STREAMS}" = 1 ; then
395 AC_DEFINE_UNQUOTED(P_HAS_STL_STREAMS, ${P_HAS_STL_STREAMS})
397 dnl ########################################################################
398 dnl see if using GNU glibc++, because then we have atomic integer operations
401 P_NEEDS_GNU_CXX_NAMESPACE=0
402 AC_MSG_CHECKING(if atomic integer available)
403 AC_TRY_COMPILE([#include <bits/atomicity.h>],
404 [_Atomic_word val;], P_HAS_ATOMIC_INT=1)
405 if test ${P_HAS_ATOMIC_INT} = 1 ; then
407 AC_MSG_CHECKING(if __exchange_and_add is in __gnu_cxx namespace)
408 AC_TRY_COMPILE([#include <bits/atomicity.h>],
409 [_Atomic_word val; __gnu_cxx::__exchange_and_add(&val, 1)], P_NEEDS_GNU_CXX_NAMESPACE=1)
410 if test ${P_NEEDS_GNU_CXX_NAMESPACE} = 1 ; then
418 AC_DEFINE_UNQUOTED(P_HAS_ATOMIC_INT, ${P_HAS_ATOMIC_INT})
419 AC_DEFINE_UNQUOTED(P_NEEDS_GNU_CXX_NAMESPACE, ${P_NEEDS_GNU_CXX_NAMESPACE})
422 dnl ########################################################################
423 dnl check for select_large_fdset (Solaris)
425 if test "${OSTYPE:-unknown}" = "solaris"; then
426 AC_MSG_CHECKING(checking for FD_SETSIZE)
427 _FD_SYSTEM_FILE=/etc/system
428 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -c1`
429 if test "$_FD_SETSIZE" = "#"; then
432 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -f2 -d'='`
433 if test "x$_FD_SETSIZE" = "x"; then
436 STDCCFLAGS="$STDCCFLAGS -DFD_SETSIZE=$_FD_SETSIZE"
439 AC_MSG_RESULT($_FD_SETSIZE)
442 dnl ########################################################################
443 dnl check for Unix semaphores
445 dnl posix semaphore support in darwin/macosx is broken
446 if test ${OSTYPE} != Darwin ; then
447 AC_TRY_COMPILE([#include <semaphore.h>],
448 [sem_t *s; sem_init(s, 0, 0);], P_HAS_SEMAPHORES=1)
449 AC_MSG_CHECKING(if Unix semaphores are available)
450 if test "${P_HAS_SEMAPHORES}x" != "x" ; then
451 AC_DEFINE(P_HAS_SEMAPHORES)
455 AC_MSG_WARN(This host does not support semaphores which are essential)
456 AC_MSG_WARN(to implement 'critical sections'. This feature was added)
457 AC_MSG_WARN(in PWLib 1.7.0 and improves the stability of multithreaded)
458 AC_MSG_WARN(programs. This feature has been disabled for this host)
462 dnl ########################################################################
463 dnl check for pthreads library
465 dnl MSWIN_DISPLAY semaphore,Semaphore Support
466 dnl MSWIN_DEFINE semaphore,P_HAS_SEMAPHORES
468 dnl Linux, Mac OS X use libpthread and -lpthread
469 dnl FreeBSD uses the -pthread compiler option and uses libc_r
471 AC_CHECK_LIB(pthread, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
472 if test ${HAS_PTHREADS} = yes ; then
473 ENDLDLIBS="$ENDLDLIBS -lpthread"
474 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT"
477 AC_CHECK_LIB(c_r, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
478 if test ${HAS_PTHREADS} = yes ; then
479 ENDLDLIBS="$ENDLDLIBS -pthread"
480 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT -pthread"
485 if test ${HAS_PTHREADS} != yes ; then
486 AC_MSG_ERROR(must have pthreads!)
489 dnl ########################################################################
490 dnl check for XPG6 compliant pthreads (timed spinlocks)
492 if test ${HAS_PTHREADS} = yes ; then
493 AC_MSG_CHECKING(if pthread_mutex_timedlock is available)
494 AC_TRY_COMPILE([#include <pthread.h>],
495 [pthread_mutex_timedlock(NULL, NULL);], HAS_PTHREADS_XPG6=yes, HAS_PTHREADS_XPG6=no)
496 if test ${HAS_PTHREADS_XPG6} = yes ; then
498 AC_DEFINE(P_PTHREADS_XPG6, 1, "XPG6 compliant pthreads found")
503 AC_CHECK_LIB(pthread, sem_timedwait, HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
504 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
505 AC_MSG_CHECKING(if sem_timedwait is compilable)
506 AC_TRY_COMPILE([#include <semaphore.h>],
507 [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
508 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
509 AC_DEFINE(P_HAS_SEMAPHORES_XPG6, 1, "Supports XPG6 Semaphores")
517 dnl ########################################################################
518 dnl check for recursive mutexes
519 P_HAS_RECURSIVE_MUTEX=0
520 AC_MSG_CHECKING(if recursive mutexes are available)
521 AC_TRY_COMPILE([#include <pthread.h>],
522 [pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);], P_HAS_RECURSIVE_MUTEX=1)
523 if test ${P_HAS_RECURSIVE_MUTEX} = 1 ; then
528 AC_DEFINE_UNQUOTED(P_HAS_RECURSIVE_MUTEX, ${P_HAS_RECURSIVE_MUTEX})
531 dnl ########################################################################
532 dnl check for regex library
534 dnl yes this test needs to be outside the if below
535 dnl because autoconf needs to initialise stuff. without this
536 dnl all sorts of strange things happen
537 AC_CHECK_HEADERS(regex.h, HAS_REGEX=yes)
539 AC_ARG_ENABLE(internalregex,
540 [ --enable-internalregex force internal regex library],
541 internalregex=$enableval)
542 if test "$internalregex" = "yes" ; then
543 AC_MSG_NOTICE(Forcing use of internal regex library)
545 if test "$HAS_REGEX" = "yes" ; then
546 AC_CHECK_FUNC(regcomp, HAS_REGEX=yes)
547 if test "$HAS_REGEX" = "yes" ; then
548 AC_SUBST(HAS_REGEX, 1)
549 AC_DEFINE(P_REGEX, 1, "Regex library found")
555 dnl ########################################################################
556 dnl check for dynamic library code (dlopen and friends)
558 dnl MSWIN DLL Support,,P_DYNALINK
563 if test ${OSTYPE} = beos ; then
565 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in BeOS")
566 elif test ${OSTYPE} = Darwin ; then
568 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in Darwin")
570 AC_CHECK_HEADERS(dlfcn.h, HAS_DLFCN=yes, HAS_DLFCN=no)
571 if test "$HAS_DLFCN" = yes ; then
572 AC_MSG_CHECKING(if dlopen is available)
573 AC_TRY_COMPILE([#include <dlfcn.h>],
574 [void * p = dlopen("lib", 0);], HAS_DLOPEN=yes, HAS_DLOPEN=no)
575 if test "$HAS_DLOPEN" = no ; then
580 AC_DEFINE(P_DYNALINK, 1, "dlopen found")
581 AC_CHECK_LIB(dl,dlopen,HAS_LIBDL=yes, HAS_LIBDL=no)
586 dnl #########################################################################
587 dnl check to see if plugins enabled
588 dnl MSWIN Plugin Support,,P_HAS_PLUGINS
590 AC_MSG_CHECKING(if plugins support needs to be compiled)
591 AC_ARG_ENABLE(plugins,
592 [ --enable-plugins enable plugins' support in PWLIB],
596 if test "${plugins}" = "no" ; then
598 elif test "${P_DYNALINK:-unset}" = "unset" ; then
599 AC_MSG_RESULT(plugins disabled as dlopen not available)
601 AC_MSG_RESULT(plugins enabled)
603 AC_DEFINE(P_HAS_PLUGINS, 1, "plugins enabled")
606 AC_SUBST(HAS_PLUGINS)
608 if test "x$LIB64" != "x" ; then
609 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib64/pwlib"], [Default plugin directory])
611 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib/pwlib"], [Default plugin directory])
614 dnl ########################################################################
615 dnl look for DNS resolver code (must be done before OpenLDAP)
616 dnl on some systems, the resolver is in libc
617 dnl but needs resolv.h included which defines res_search as __res_search
619 dnl MSWIN_DISPLAY resolver,DNS Resolver
620 dnl MSWIN_CHECK_FILE resolver,include\windns.h,P_DNS=1
621 dnl MSWIN_DIR_SYMBOL resolver,DNS_DIR
622 dnl MSWIN_CHECK_DIR resolver,\Program Files\Microsoft SDK\
624 AC_ARG_ENABLE(resolver,
625 [ --disable-resolver disable DNS resolver support in PWLIB],
628 if test "$resolver" = "no" ; then
631 AC_CHECK_FUNC(res_search, HAVE_RESOLVER=1)
632 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
635 AC_MSG_CHECKING([for res_search in -lresolv])
638 #include <netinet/in.h>
640 int main(int argc,char **argv){
641 res_search (NULL, 0, 0, NULL, 0);
643 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
645 RESOLVER_LIBS="-lresolv"
647 AC_SEARCH_LIBS(__res_search, resolv, HAVE_RESOLVER=1)
651 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
652 AC_DEFINE(P_DNS, 1, "resolver libraries found")
656 dnl ########################################################################
659 dnl MSWIN_DISPLAY sasl,Cyrus SASL
660 dnl MSWIN_CHECK_FILE sasl,include\sasl.h,P_SASL=1
661 dnl MSWIN_DIR_SYMBOL sasl,SASL_DIR
662 dnl MSWIN_CHECK_DIR sasl,..\cyrus-sasl\
663 dnl MSWIN_CHECK_DIR sasl,..\external\cyrus-sasl\
664 dnl MSWIN_CHECK_DIR sasl,\cyrus-sasl\
665 dnl MSWIN_CHECK_DIR sasl,c:\cyrus-sasl\
668 [ --disable-sasl disable SASL support in PWLIB],
671 if test "$sasl" = "no" ; then
672 AC_MSG_NOTICE(SASL disabled)
675 dnl Not all Unices have SASL installed as a separate library (Solaris)
676 AC_CHECK_LIB(sasl2, sasl_version, HAS_SASL2=1, HAS_SASL2=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
677 if test "${HAS_SASL2}x" = "x" ; then
678 dnl Some older Linux boxes have libsasl instead of libsasl2
679 AC_CHECK_LIB(sasl, sasl_client_auth, HAS_SASL=1, HAS_SASL=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
682 dnl we need to track down the correct sasl.h
683 AC_MSG_CHECKING([if <sasl.h> works])
684 AC_COMPILE_IFELSE([[#include <sasl.h>
685 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],HAS_INCLUDE_SASL_H=1)
686 if test "${HAS_INCLUDE_SASL_H}x" != "x" ; then
691 AC_MSG_CHECKING([if <sasl/sasl.h> works])
692 AC_COMPILE_IFELSE([[#include <sasl/sasl.h>
693 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],P_HAS_SASL_SASL_H=1)
694 if test "${P_HAS_SASL_SASL_H}x" != "x" ; then
697 AC_DEFINE(P_HAS_SASL_SASL_H)
703 if test "${HAS_SASL2}x" != "x" ; then
705 ENDLDLIBS="$ENDLDLIBS -lsasl2"
707 AC_SUBST(HAS_SASL2, 1)
708 elif test "${HAS_SASL}x" != "x" ; then
710 ENDLDLIBS="$ENDLDLIBS -lsasl"
712 AC_SUBST(HAS_SASL, 1)
719 dnl ########################################################################
720 dnl look for OpenLDAP (requires SASL)
722 dnl MSWIN_DISPLAY openldap,Open LDAP
723 dnl MSWIN_CHECK_FILE openldap,include\ldap.h|OpenLDAP,P_LDAP=1
724 dnl MSWIN_DIR_SYMBOL openldap,LDAP_DIR
725 dnl MSWIN_CHECK_DIR openldap,..\openldap\
726 dnl MSWIN_CHECK_DIR openldap,..\external\openldap\
727 dnl MSWIN_CHECK_DIR openldap,\openldap\
728 dnl MSWIN_CHECK_DIR openldap,c:\openldap\
730 AC_ARG_ENABLE(openldap,
731 [ --disable-openldap disable OpenLDAP support in PWLIB],
734 if test "$openldap" = "no" ; then
735 AC_SUBST(HAS_OPENLDAP, 0)
738 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
739 AC_CHECK_HEADERS(ldap.h, HAS_OPENLDAP=1)
741 dnl posix4 is required by libldap_r on Solaris
742 if test "${OSTYPE:-unknown}" = "solaris"; then
743 OPENLDAPSYSLIBS=-lposix4
746 dnl check also for lldap_r presence (required for thread safe OpenLDAP?)
747 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
748 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
750 AC_CHECK_FILE(/usr/local/include/ldap.h, HAS_OPENLDAP=1)
751 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
752 OPENLDAPINCLUDEDIR=/usr/local/include
753 OPENLDAPLIBDIR=/usr/local/lib
754 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-L/usr/local/lib -llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
759 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
760 AC_SUBST(HAS_OPENLDAP, 1)
761 AC_DEFINE(P_LDAP, 1, "OpenLDAP found")
762 ENDLDLIBS="-lldap -lldap_r -llber $ENDLDLIBS"
763 if test "${OPENLDAPINCLUDEDIR}unset" != "unset" ; then
764 STDCCFLAGS="$STDCCFLAGS -I${OPENLDAPINCLUDEDIR}"
766 if test "${OPENLDAPLIBDIR}unset" != "unset" ; then
767 LDFLAGS="$LDFLAGS -L${OPENLDAPLIBDIR}"
773 dnl ########################################################################
775 dnl check for environment variable, then assume standard system install
776 dnl this process is made incredibly more complex by the fact that RedHad 9
777 dnl is completely fscked. The default OpenSSL installation requires Kerberos,
778 dnl even when Kerberos is not installed, requiring an explicit #define to
780 dnl As if that is not enough, autoconf gets very confused if configure.in
781 dnl contains a AC_CHECK_HEADER directive that never gets used. So we have
782 dnl to ensure that it is always called
784 dnl MSWIN_DISPLAY openssl,Open SSL
785 dnl MSWIN_CHECK_FILE openssl,inc32\openssl\ssl.h,P_SSL=1
786 dnl MSWIN_DIR_SYMBOL openssl,SSL_DIR
787 dnl MSWIN_CHECK_DIR openssl,..\openssl\
788 dnl MSWIN_CHECK_DIR openssl,..\external\openssl\
789 dnl MSWIN_CHECK_DIR openssl,\openssl\
790 dnl MSWIN_CHECK_DIR openssl,c:\openssl\
792 AC_ARG_ENABLE(openssl,
793 [ --disable-openssl disable OpenSSL support in PWLIB],
796 if test "$openssl" = "no" ; then
798 AC_SUBST(HAS_OPENSSL, 0)
801 dnl check to see OPENSSLDIR is set
802 dnl if it is, we assume it correct - no further checking required
803 if test ${OPENSSLDIR:-unset} != "unset" ; then
804 AC_MSG_CHECKING([for ${OPENSSLDIR}/include/openssl/ssl.h])
805 if test -e ${OPENSSLDIR}/include/openssl/ssl.h ; then
808 SSLINCLUDEDIR="${OPENSSLDIR}/include"
809 SSLLIBDIR="${OPENSSLDIR}/lib"
816 dnl if OPENSSLDIR is not set, then check to see if OpenSSL
817 dnl is installed in the standard system dirs. And also see if
818 dnl if it works using crazy RedHat checks
819 if test "${SSLHDR:-unset}" = "unset" ; then
820 AC_CHECK_HEADERS(openssl/ssl.h,SSLHDR=1)
821 if test "${SSLHDR:-unset}" = "unset" ; then
822 AC_MSG_CHECKING([if openssl/ssl.h works with OPENSSL_NO_KRB5])
823 AC_COMPILE_IFELSE([[#define OPENSSL_NO_KRB5
824 #include <openssl/ssl.h>
825 int main(int argc,char **argv){}]],SSLHDR=1)
826 if test "${SSLHDR:-unset}" != "unset" ; then
828 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
829 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
830 if test ${OSTYPE} = linux ; then
831 dnl Linux static libs
832 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
840 dnl if we have not found OpenSSL so far, then look for it in
841 dnl several standard places, and check for crazy RedHat install too
842 if test "${SSLHDR:-unset}" = "unset" ; then
844 for openssl_dir in /usr/local/openssl /usr/local/ssl ; do
845 AC_MSG_CHECKING([for OpenSSL in $openssl_dir])
846 if test ! -f ${openssl_dir}/include/openssl/ssl.h ; then
849 AC_LANG_CONFTEST([[#include "${openssl_dir}/include/openssl/ssl.h"
850 int main(int argc,char **argv){ return 0; }]])
851 $CXX $CXXFLAGS -I${openssl_dir}/include -c conftest.cc > /dev/null 2>&1
852 if test $? = 0 ; then
856 SSLINCLUDEDIR="${openssl_dir}/include"
857 SSLLIBDIR="${openssl_dir}/lib"
861 AC_MSG_CHECKING([if ${openssl_dir}/include/openssl/ssl.h works with OPENSSL_NO_KRB5...])
862 AC_LANG_CONFTEST([[#define OPENSSL_NO_KRB5
863 #include "${openssl_dir}/include/openssl/ssl.h"
864 int main(int argc,char **argv){}]])
865 $CXX $CXXFLAGS -I${openssl_dir}/openssl/include -c conftest.cc > /dev/null 2>&1
866 if test $? = 0 ; then
869 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
870 SSLINCLUDEDIR="${openssl_dir}/include"
871 SSLLIBDIR="${openssl_dir}/lib"
872 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
873 if test ${OSTYPE} = linux ; then
874 dnl Linux static libs
875 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
886 if test ${SSLHDR:-unset} != "unset" ; then
887 AC_SUBST(HAS_OPENSSL, 1)
888 AC_DEFINE(P_SSL, 1, "OpenSSL found")
889 if test ${SSLINCLUDEDIR:-unset} != "unset" ; then
890 STDCCFLAGS="$STDCCFLAGS -I${SSLINCLUDEDIR}"
892 if test ${SSLLIBDIR:-unset} != "unset" ; then
893 LDFLAGS="$LDFLAGS -L${SSLLIBDIR}"
895 STDCCFLAGS="${STDCCFLAGS}${SSLCCFLAGS}"
896 ENDLDLIBS="$ENDLDLIBS -lssl -lcrypto"
900 AC_SUBST(P_STATIC_ENDLDLIBS)
901 AC_SUBST(P_STATIC_LDFLAGS)
903 dnl ########################################################################
904 dnl look for expat XML parser
906 dnl MSWIN_DISPLAY expat,Expat XML
907 dnl MSWIN_CHECK_FILE expat,lib\expat.h,P_EXPAT=1
908 dnl MSWIN_DIR_SYMBOL expat,EXPAT_DIR
909 dnl MSWIN_CHECK_DIR expat,..\expat\
910 dnl MSWIN_CHECK_DIR expat,..\external\expat\
911 dnl MSWIN_CHECK_DIR expat,\expat
912 dnl MSWIN_CHECK_DIR expat,c:\expat\
915 [ --disable-expat disable XML support in PWLIB],
918 if test "$expat" = "no" ; then
919 AC_SUBST(HAS_EXPAT, 0)
920 AC_DEFINE(P_EXPAT, 0)
923 AC_CHECK_HEADERS(expat.h, HAS_EXPAT=1)
924 if test "${HAS_EXPAT:-unset}" != "unset" ; then
925 AC_CHECK_LIB(expat, XML_ParserCreate, HAS_EXPAT=1, HAS_EXPAT=)
927 AC_CHECK_FILE(/usr/local/include/expat.h, HAS_EXPAT=1)
928 if test "${HAS_EXPAT:-unset}" != "unset" ; then
929 EXPATINCLUDEDIR=/usr/local/include
930 EXPATLIBDIR=/usr/local/lib
934 if test "${HAS_EXPAT:-unset}" != "unset" ; then
935 AC_SUBST(HAS_EXPAT, 1)
936 AC_DEFINE(P_EXPAT, 1, "expat found")
937 if test ${EXPATINCLUDEDIR:-unset} != "unset" ; then
938 STDCCFLAGS="$STDCCFLAGS -I${EXPATINCLUDEDIR}"
940 if test ${EXPATLIBDIR:-unset} != "unset" ; then
941 LDFLAGS="$LDFLAGS -L${EXPATLIBDIR}"
943 ENDLDLIBS="$ENDLDLIBS -lexpat"
948 dnl ########################################################################
951 dnl MSWIN_DISPLAY sapi,Speech API
952 dnl MSWIN_CHECK_FILE sapi,include\sphelper.h,P_SAPI=1
953 dnl MSWIN_DIR_SYMBOL sapi,SAPI_DIR
954 dnl MSWIN_CHECK_DIR sapi,\Program Files\Microsoft Speech SDK 5.1\
957 dnl ########################################################################
958 dnl look for IPV6 functions
960 dnl MSWIN_DISPLAY ipv6,IPv6 Support
961 dnl MSWIN_CHECK_FILE ipv6,ws2tcpip.h|sin6_scope_id,P_HAS_IPV6=1
962 dnl MSWIN_DIR_SYMBOL ipv6,IPV6_DIR
963 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft Visual Studio\VC98\Include\
964 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft SDK\include\
967 [ --disable-ipv6 disable IPV6 support in PWLIB],
970 if test "$ipv6" = "no" ; then
971 AC_DEFINE(P_HAS_IPV6, 0)
972 AC_SUBST(HAS_IPV6, 0)
974 AC_MSG_CHECKING(for IPv6 support)
975 AC_TRY_COMPILE([#include <sys/types.h>
976 #include <netinet/in.h>],
977 [struct sockaddr_in6 s; s.sin6_scope_id = 0;], HAS_IPV6=yes, HAS_IPV6=no)
978 if test $HAS_IPV6 = no ; then
981 AC_TRY_COMPILE([#include <sys/socket.h>
983 [getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);], HAS_IPV6=yes, HAS_IPV6=no)
984 if test $HAS_IPV6 = no ; then
988 AC_DEFINE(P_HAS_IPV6, 1, "IPV6 enabled")
993 dnl ########################################################################
994 dnl look for QoS functions
996 dnl MSWIN_DISPLAY qos,QoS Support
997 dnl MSWIN_CHECK_FILE qos,qossp.h|QOS_DESTADDR,P_HAS_QOS=1
998 dnl MSWIN_DIR_SYMBOL qos,QOS_DIR
999 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft Visual Studio\VC98\Include\
1000 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft SDK\include\
1003 [ --disable-qos disable QOS support in PWLIB],
1006 if test "$qos" = "no" ; then
1007 AC_DEFINE([P_HAS_QOS], [0], [No QOS])
1009 AC_DEFINE([P_HAS_QOS], [1], [Have QOS])
1013 dnl ########################################################################
1014 dnl look for SDL, but only if we have pthreads
1016 dnl MSWIN_DISPLAY libsdl,Simple DirectMedia Layer
1017 dnl MSWIN_CHECK_FILE libsdl,include\SDL_video.h,P_SDL=1
1018 dnl MSWIN_CHECK_FILE libsdl,lib\SDL.lib,P_SDL_LIBDIR="lib"
1019 dnl MSWIN_DIR_SYMBOL libsdl,SDL_DIR
1020 dnl MSWIN_CHECK_DIR libsdl,..\sdl\
1021 dnl MSWIN_CHECK_DIR libsdl,..\external\sdl\
1022 dnl MSWIN_CHECK_DIR libsdl,\sdl\
1023 dnl MSWIN_CHECK_DIR libsdl,c:\sdl\
1026 [ --disable-sdl disable SDL support in PWLIB],
1029 if test "$sdl" = "no" ; then
1030 AC_SUBST(HAS_SDL, 0)
1034 if test "${SDLLIB:-unset}" = "unset" ; then
1039 AC_CHECK_HEADERS(SDL/SDL.h, HAS_SDL=1)
1040 if test "${HAS_SDL:-unset}" != "unset" ; then
1041 if test "${X11LIBDIR:-unset}" == "unset" ; then
1042 X11LIBDIR=/usr/X11R6/lib
1044 AC_CHECK_LIB(SDL, SDL_CreateYUVOverlay, HAS_SDL=1, HAS_SDL=, -L${X11LIBDIR} -lpthread -lX11 -lXext -laa)
1047 dnl freeBSD SDL check
1048 if test "${HAS_SDL:-unset}" = "unset" ; then
1049 AC_CHECK_FILE(/usr/local/include/SDL11/SDL.h, HAS_SDL=1)
1050 if test "${HAS_SDL:-unset}" != "unset" ; then
1055 if test "${HAS_SDL:-unset}" != "unset" ; then
1056 AC_SUBST(HAS_SDL, 1)
1057 AC_DEFINE(P_SDL, 1, "SDL found")
1058 if test ${SDLINCLUDEDIR:-unset} != "unset" ; then
1059 STDCCFLAGS="$STDCCFLAGS -I${SDLINCLUDEDIR}"
1061 if test ${SDLLIBDIR:-unset} != "unset" ; then
1062 LDFLAGS="$LDFLAGS -L${SDLLIBDIR}"
1064 ENDLDLIBS="$ENDLDLIBS -l${SDLLIB}"
1069 dnl ########################################################################
1070 dnl check for video capture support.
1071 dnl videodev.h on linux
1072 dnl machine/ioctl_meteor on FreeBSD
1073 dnl i386/ioctl_meteor on OpenBSD
1074 dnl dev/ic/bt8xx on NetBSD
1076 AC_ARG_ENABLE(video,
1077 [ --disable-video disable non-plugin video device support in PWLIB],
1081 if test "$HAS_PLUGINS" = "0" ; then
1082 if test "$video" != "no" ; then
1083 AC_CHECK_HEADER(linux/videodev.h, HAS_VIDEO_CAPTURE=1)
1084 dnl AC_CHECK_HEADER(machine/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1085 dnl AC_CHECK_HEADER(i386/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1086 dnl AC_CHECK_HEADER(dev/ic/bt8xx.h, HAS_VIDEO_CAPTURE=1)
1087 if test "${HAS_VIDEO_CAPTURE}" = "0" ; then
1088 AC_MSG_NOTICE(No Video Capture support)
1089 AC_DEFINE([NO_VIDEO_CAPTURE], [], [No video capture])
1093 AC_SUBST(HAS_VIDEO_CAPTURE)
1095 dnl ########################################################################
1096 dnl check for various functions
1097 AC_ARG_ENABLE(alsa, [ --enable-alsa disable non-plugin ALSA audio support],enable_alsa=$enableval)
1100 if test "$HAS_PLUGINS" = "0" ; then
1101 if test "$enable_alsa" != "no" ; then
1102 AC_CHECK_HEADER(alsa/asoundlib.h, HAS_ALSA=1)
1103 AC_MSG_CHECKING(for ALSA sound support)
1104 if test "${HAS_ALSA}" = "1"; then
1106 ENDLDLIBS="$ENDLDLIBS -lasound"
1114 dnl ########################################################################
1115 dnl check for various functions
1116 dnl According to Andre Schulze <as8@rncmm2.urz.tu-dresden.de>
1117 dnl Solaris swab should not be used
1118 if test "$OSTYPE" = "solaris" ; then
1121 AC_CHECK_FUNC(swab,USE_SYSTEM_SWAB=1)
1123 if test "x$ac_cv_func_swab" = "xyes" ; then
1124 AC_DEFINE([USE_SYSTEM_SWAB], [], [Use system swab()])
1127 dnl ########################################################################
1128 dnl look for MEMORY_CHECK enabled.
1130 AC_ARG_ENABLE(memcheck,
1131 [ --enable-memcheck enable leak testing code (off by default)],
1132 memcheck=$enableval)
1134 if test "$memcheck" = "yes" ; then
1135 AC_DEFINE(PMEMORY_CHECK, 1)
1136 AC_MSG_NOTICE(Memory checking enabled)
1140 dnl ########################################################################
1141 dnl output make directives
1143 dnl resolver needs to be at the end
1144 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
1145 if test "${RESOLVER_LIBS:-unset}" != "unset" ; then
1146 ENDLDLIBS="$ENDLDLIBS $RESOLVER_LIBS"
1150 dnl dl needs to be at the end
1151 if test "${OSTYPE}" != "Darwin" ; then
1152 if test ${HAS_LIBDL} = yes ; then
1153 ENDLDLIBS="$ENDLDLIBS -ldl"
1157 AC_SUBST(STDCCFLAGS)
1158 AC_SUBST(STDCXXFLAGS)
1159 AC_SUBST(OPTSTDCCFLAGS)
1164 AC_CONFIG_FILES(make/ptbuildopts.mak)
1165 AC_CONFIG_FILES([make/ptlib-config], [chmod a+x make/ptlib-config])
1166 AC_CONFIG_FILES(Makefile)
1168 dnl ########################################################################
1169 dnl output header file
1170 #AC_CONFIG_FILES(include/ptbuildopts.h.in)
1171 AC_CONFIG_HEADERS(include/ptbuildopts.h)