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])
345 if test ${OSTYPE} = Darwin ; then
346 STDCCFLAGS="$STDCCFLAGS -Wno-long-double"
349 dnl ########################################################################
350 dnl check for number of parms to readdir
351 AC_MSG_CHECKING(if readdir_r has 2 parms)
352 AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS
353 #include <dirent.h>],
354 [DIR *s; struct dirent * e; readdir_r(s, e);], P_HAS_POSIX_READDIR_R=2, P_HAS_POSIX_READDIR_R=0)
355 if test ${P_HAS_POSIX_READDIR_R} = 2 ; then
359 AC_MSG_CHECKING(if readdir_r has 3 parms)
360 AC_TRY_COMPILE([#include <dirent.h>],
361 [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)
362 if test ${P_HAS_POSIX_READDIR_R} = 3 ; then
368 AC_DEFINE_UNQUOTED(P_HAS_POSIX_READDIR_R, ${P_HAS_POSIX_READDIR_R})
370 dnl ########################################################################
371 dnl check for recvmsg
374 AC_MSG_CHECKING(for recvmsg)
375 AC_TRY_COMPILE([#include <sys/types.h>
376 #include <sys/socket.h>
377 #include <netinet/in.h>],
378 [int t = SOL_IP; t = IP_PKTINFO; struct msghdr *msg; recvmsg(0, msg, 0);], P_HAS_RECVMSG=1)
379 if test "${P_HAS_RECVMSG}" = "1" ; then
384 AC_DEFINE_UNQUOTED(P_HAS_RECVMSG, ${P_HAS_RECVMSG})
386 dnl ########################################################################
387 dnl check for streams types
390 AC_MSG_CHECKING(if using STL streams)
391 AC_TRY_COMPILE([#include <iostream>],
392 [int v = (int)std::ios_base::seekdir();], P_HAS_STL_STREAMS=1)
393 if test "${P_HAS_STL_STREAMS}" = 1 ; then
398 AC_DEFINE_UNQUOTED(P_HAS_STL_STREAMS, ${P_HAS_STL_STREAMS})
400 dnl ########################################################################
401 dnl see if using GNU glibc++, because then we have atomic integer operations
404 P_NEEDS_GNU_CXX_NAMESPACE=0
405 AC_MSG_CHECKING(if atomic integer available)
406 AC_TRY_COMPILE([#include <bits/atomicity.h>],
407 [_Atomic_word val;], P_HAS_ATOMIC_INT=1)
408 if test ${P_HAS_ATOMIC_INT} = 1 ; then
410 AC_MSG_CHECKING(if __exchange_and_add is in __gnu_cxx namespace)
411 AC_TRY_COMPILE([#include <bits/atomicity.h>],
412 [_Atomic_word val; __gnu_cxx::__exchange_and_add(&val, 1)], P_NEEDS_GNU_CXX_NAMESPACE=1)
413 if test ${P_NEEDS_GNU_CXX_NAMESPACE} = 1 ; then
421 AC_DEFINE_UNQUOTED(P_HAS_ATOMIC_INT, ${P_HAS_ATOMIC_INT})
422 AC_DEFINE_UNQUOTED(P_NEEDS_GNU_CXX_NAMESPACE, ${P_NEEDS_GNU_CXX_NAMESPACE})
425 dnl ########################################################################
426 dnl check for select_large_fdset (Solaris)
428 if test "${OSTYPE:-unknown}" = "solaris"; then
429 AC_MSG_CHECKING(checking for FD_SETSIZE)
430 _FD_SYSTEM_FILE=/etc/system
431 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -c1`
432 if test "$_FD_SETSIZE" = "#"; then
435 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -f2 -d'='`
436 if test "x$_FD_SETSIZE" = "x"; then
439 STDCCFLAGS="$STDCCFLAGS -DFD_SETSIZE=$_FD_SETSIZE"
442 AC_MSG_RESULT($_FD_SETSIZE)
445 dnl ########################################################################
446 dnl check for Unix semaphores
448 dnl posix semaphore support in darwin/macosx is broken
449 if test ${OSTYPE} != Darwin ; then
450 AC_TRY_COMPILE([#include <semaphore.h>],
451 [sem_t *s; sem_init(s, 0, 0);], P_HAS_SEMAPHORES=1)
452 AC_MSG_CHECKING(if Unix semaphores are available)
453 if test "${P_HAS_SEMAPHORES}x" != "x" ; then
454 AC_DEFINE(P_HAS_SEMAPHORES)
458 AC_MSG_WARN(This host does not support semaphores which are essential)
459 AC_MSG_WARN(to implement 'critical sections'. This feature was added)
460 AC_MSG_WARN(in PWLib 1.7.0 and improves the stability of multithreaded)
461 AC_MSG_WARN(programs. This feature has been disabled for this host)
465 dnl ########################################################################
466 dnl check for pthreads library
468 dnl MSWIN_DISPLAY semaphore,Semaphore Support
469 dnl MSWIN_DEFINE semaphore,P_HAS_SEMAPHORES
471 dnl Linux, Mac OS X use libpthread and -lpthread
472 dnl FreeBSD uses the -pthread compiler option and uses libc_r
474 AC_CHECK_LIB(pthread, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
475 if test ${HAS_PTHREADS} = yes ; then
476 ENDLDLIBS="$ENDLDLIBS -lpthread"
477 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT"
480 AC_CHECK_LIB(c_r, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
481 if test ${HAS_PTHREADS} = yes ; then
482 ENDLDLIBS="$ENDLDLIBS -pthread"
483 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT -pthread"
488 if test ${HAS_PTHREADS} != yes ; then
489 AC_MSG_ERROR(must have pthreads!)
492 dnl ########################################################################
493 dnl check for XPG6 compliant pthreads (timed spinlocks)
495 if test ${HAS_PTHREADS} = yes ; then
496 AC_MSG_CHECKING(if pthread_mutex_timedlock is available)
497 AC_TRY_COMPILE([#include <pthread.h>],
498 [pthread_mutex_timedlock(NULL, NULL);], HAS_PTHREADS_XPG6=yes, HAS_PTHREADS_XPG6=no)
499 if test ${HAS_PTHREADS_XPG6} = yes ; then
501 AC_DEFINE(P_PTHREADS_XPG6, 1, "XPG6 compliant pthreads found")
506 AC_CHECK_LIB(pthread, sem_timedwait, HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
507 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
508 AC_MSG_CHECKING(if sem_timedwait is compilable)
509 AC_TRY_COMPILE([#include <semaphore.h>],
510 [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
511 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
512 AC_DEFINE(P_HAS_SEMAPHORES_XPG6, 1, "Supports XPG6 Semaphores")
520 dnl ########################################################################
521 dnl check for recursive mutexes
522 P_HAS_RECURSIVE_MUTEX=0
523 AC_MSG_CHECKING(if recursive mutexes are available)
524 AC_TRY_COMPILE([#include <pthread.h>],
525 [pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);], P_HAS_RECURSIVE_MUTEX=1)
526 if test ${P_HAS_RECURSIVE_MUTEX} = 1 ; then
531 AC_DEFINE_UNQUOTED(P_HAS_RECURSIVE_MUTEX, ${P_HAS_RECURSIVE_MUTEX})
534 dnl ########################################################################
535 dnl check for regex library
537 dnl yes this test needs to be outside the if below
538 dnl because autoconf needs to initialise stuff. without this
539 dnl all sorts of strange things happen
540 AC_CHECK_HEADERS(regex.h, HAS_REGEX=yes)
542 AC_ARG_ENABLE(internalregex,
543 [ --enable-internalregex force internal regex library],
544 internalregex=$enableval)
545 if test "$internalregex" = "yes" ; then
546 AC_MSG_NOTICE(Forcing use of internal regex library)
548 if test "$HAS_REGEX" = "yes" ; then
549 AC_CHECK_FUNC(regcomp, HAS_REGEX=yes)
550 if test "$HAS_REGEX" = "yes" ; then
551 AC_SUBST(HAS_REGEX, 1)
552 AC_DEFINE(P_REGEX, 1, "Regex library found")
558 dnl ########################################################################
559 dnl check for dynamic library code (dlopen and friends)
561 dnl MSWIN DLL Support,,P_DYNALINK
566 if test ${OSTYPE} = beos ; then
568 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in BeOS")
569 elif test ${OSTYPE} = Darwin ; then
571 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in Darwin")
573 AC_CHECK_HEADERS(dlfcn.h, HAS_DLFCN=yes, HAS_DLFCN=no)
574 if test "$HAS_DLFCN" = yes ; then
575 AC_MSG_CHECKING(if dlopen is available)
576 AC_TRY_COMPILE([#include <dlfcn.h>],
577 [void * p = dlopen("lib", 0);], HAS_DLOPEN=yes, HAS_DLOPEN=no)
578 if test "$HAS_DLOPEN" = no ; then
583 AC_DEFINE(P_DYNALINK, 1, "dlopen found")
584 AC_CHECK_LIB(dl,dlopen,HAS_LIBDL=yes, HAS_LIBDL=no)
589 dnl #########################################################################
590 dnl check to see if plugins enabled
591 dnl MSWIN Plugin Support,,P_HAS_PLUGINS
593 AC_MSG_CHECKING(if plugins support needs to be compiled)
594 AC_ARG_ENABLE(plugins,
595 [ --enable-plugins enable plugins' support in PWLIB],
599 if test "${plugins}" = "no" ; then
601 elif test "${P_DYNALINK:-unset}" = "unset" ; then
602 AC_MSG_RESULT(plugins disabled as dlopen not available)
604 AC_MSG_RESULT(plugins enabled)
606 AC_DEFINE(P_HAS_PLUGINS, 1, "plugins enabled")
609 AC_SUBST(HAS_PLUGINS)
611 if test "x$LIB64" != "x" ; then
612 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib64/pwlib"], [Default plugin directory])
614 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib/pwlib"], [Default plugin directory])
617 dnl ########################################################################
618 dnl look for DNS resolver code (must be done before OpenLDAP)
619 dnl on some systems, the resolver is in libc
620 dnl but needs resolv.h included which defines res_search as __res_search
622 dnl MSWIN_DISPLAY resolver,DNS Resolver
623 dnl MSWIN_CHECK_FILE resolver,include\windns.h,P_DNS=1
624 dnl MSWIN_DIR_SYMBOL resolver,DNS_DIR
625 dnl MSWIN_CHECK_DIR resolver,\Program Files\Microsoft SDK\
627 AC_ARG_ENABLE(resolver,
628 [ --disable-resolver disable DNS resolver support in PWLIB],
631 if test "$resolver" = "no" ; then
634 AC_CHECK_FUNC(res_search, HAVE_RESOLVER=1)
635 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
638 AC_MSG_CHECKING([for res_search in -lresolv])
641 #include <netinet/in.h>
643 int main(int argc,char **argv){
644 res_search (NULL, 0, 0, NULL, 0);
646 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
648 RESOLVER_LIBS="-lresolv"
650 AC_SEARCH_LIBS(__res_search, resolv, HAVE_RESOLVER=1)
654 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
655 AC_DEFINE(P_DNS, 1, "resolver libraries found")
659 dnl ########################################################################
662 dnl MSWIN_DISPLAY sasl,Cyrus SASL
663 dnl MSWIN_CHECK_FILE sasl,include\sasl.h,P_SASL=1
664 dnl MSWIN_DIR_SYMBOL sasl,SASL_DIR
665 dnl MSWIN_CHECK_DIR sasl,..\cyrus-sasl\
666 dnl MSWIN_CHECK_DIR sasl,..\external\cyrus-sasl\
667 dnl MSWIN_CHECK_DIR sasl,\cyrus-sasl\
668 dnl MSWIN_CHECK_DIR sasl,c:\cyrus-sasl\
671 [ --disable-sasl disable SASL support in PWLIB],
674 if test "$sasl" = "no" ; then
675 AC_MSG_NOTICE(SASL disabled)
678 dnl Not all Unices have SASL installed as a separate library (Solaris)
679 AC_CHECK_LIB(sasl2, sasl_version, HAS_SASL2=1, HAS_SASL2=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
680 if test "${HAS_SASL2}x" = "x" ; then
681 dnl Some older Linux boxes have libsasl instead of libsasl2
682 AC_CHECK_LIB(sasl, sasl_client_auth, HAS_SASL=1, HAS_SASL=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
685 dnl we need to track down the correct sasl.h
686 AC_MSG_CHECKING([if <sasl.h> works])
687 AC_COMPILE_IFELSE([[#include <sasl.h>
688 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],HAS_INCLUDE_SASL_H=1)
689 if test "${HAS_INCLUDE_SASL_H}x" != "x" ; then
694 AC_MSG_CHECKING([if <sasl/sasl.h> works])
695 AC_COMPILE_IFELSE([[#include <sasl/sasl.h>
696 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],P_HAS_SASL_SASL_H=1)
697 if test "${P_HAS_SASL_SASL_H}x" != "x" ; then
700 AC_DEFINE(P_HAS_SASL_SASL_H)
706 if test "${HAS_SASL2}x" != "x" ; then
708 ENDLDLIBS="$ENDLDLIBS -lsasl2"
710 AC_SUBST(HAS_SASL2, 1)
711 elif test "${HAS_SASL}x" != "x" ; then
713 ENDLDLIBS="$ENDLDLIBS -lsasl"
715 AC_SUBST(HAS_SASL, 1)
722 dnl ########################################################################
723 dnl look for OpenLDAP (requires SASL)
725 dnl MSWIN_DISPLAY openldap,Open LDAP
726 dnl MSWIN_CHECK_FILE openldap,include\ldap.h|OpenLDAP,P_LDAP=1
727 dnl MSWIN_DIR_SYMBOL openldap,LDAP_DIR
728 dnl MSWIN_CHECK_DIR openldap,..\openldap\
729 dnl MSWIN_CHECK_DIR openldap,..\external\openldap\
730 dnl MSWIN_CHECK_DIR openldap,\openldap\
731 dnl MSWIN_CHECK_DIR openldap,c:\openldap\
733 AC_ARG_ENABLE(openldap,
734 [ --disable-openldap disable OpenLDAP support in PWLIB],
737 if test "$openldap" = "no" ; then
738 AC_SUBST(HAS_OPENLDAP, 0)
741 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
742 AC_CHECK_HEADERS(ldap.h, HAS_OPENLDAP=1)
744 dnl posix4 is required by libldap_r on Solaris
745 if test "${OSTYPE:-unknown}" = "solaris"; then
746 OPENLDAPSYSLIBS=-lposix4
749 dnl check also for lldap_r presence (required for thread safe OpenLDAP?)
750 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
751 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
753 AC_CHECK_FILE(/usr/local/include/ldap.h, HAS_OPENLDAP=1)
754 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
755 OPENLDAPINCLUDEDIR=/usr/local/include
756 OPENLDAPLIBDIR=/usr/local/lib
757 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-L/usr/local/lib -llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
762 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
763 AC_SUBST(HAS_OPENLDAP, 1)
764 AC_DEFINE(P_LDAP, 1, "OpenLDAP found")
765 ENDLDLIBS="-lldap -lldap_r -llber $ENDLDLIBS"
766 if test "${OPENLDAPINCLUDEDIR}unset" != "unset" ; then
767 STDCCFLAGS="$STDCCFLAGS -I${OPENLDAPINCLUDEDIR}"
769 if test "${OPENLDAPLIBDIR}unset" != "unset" ; then
770 LDFLAGS="$LDFLAGS -L${OPENLDAPLIBDIR}"
776 dnl ########################################################################
778 dnl check for environment variable, then assume standard system install
779 dnl this process is made incredibly more complex by the fact that RedHad 9
780 dnl is completely fscked. The default OpenSSL installation requires Kerberos,
781 dnl even when Kerberos is not installed, requiring an explicit #define to
783 dnl As if that is not enough, autoconf gets very confused if configure.in
784 dnl contains a AC_CHECK_HEADER directive that never gets used. So we have
785 dnl to ensure that it is always called
787 dnl MSWIN_DISPLAY openssl,Open SSL
788 dnl MSWIN_CHECK_FILE openssl,inc32\openssl\ssl.h,P_SSL=1
789 dnl MSWIN_DIR_SYMBOL openssl,SSL_DIR
790 dnl MSWIN_CHECK_DIR openssl,..\openssl\
791 dnl MSWIN_CHECK_DIR openssl,..\external\openssl\
792 dnl MSWIN_CHECK_DIR openssl,\openssl\
793 dnl MSWIN_CHECK_DIR openssl,c:\openssl\
795 AC_ARG_ENABLE(openssl,
796 [ --disable-openssl disable OpenSSL support in PWLIB],
799 if test "$openssl" = "no" ; then
801 AC_SUBST(HAS_OPENSSL, 0)
804 dnl check to see OPENSSLDIR is set
805 dnl if it is, we assume it correct - no further checking required
806 if test ${OPENSSLDIR:-unset} != "unset" ; then
807 AC_MSG_CHECKING([for ${OPENSSLDIR}/include/openssl/ssl.h])
808 if test -e ${OPENSSLDIR}/include/openssl/ssl.h ; then
811 SSLINCLUDEDIR="${OPENSSLDIR}/include"
812 SSLLIBDIR="${OPENSSLDIR}/lib"
819 dnl if OPENSSLDIR is not set, then check to see if OpenSSL
820 dnl is installed in the standard system dirs. And also see if
821 dnl if it works using crazy RedHat checks
822 if test "${SSLHDR:-unset}" = "unset" ; then
823 AC_CHECK_HEADERS(openssl/ssl.h,SSLHDR=1)
824 if test "${SSLHDR:-unset}" = "unset" ; then
825 AC_MSG_CHECKING([if openssl/ssl.h works with OPENSSL_NO_KRB5])
826 AC_COMPILE_IFELSE([[#define OPENSSL_NO_KRB5
827 #include <openssl/ssl.h>
828 int main(int argc,char **argv){}]],SSLHDR=1)
829 if test "${SSLHDR:-unset}" != "unset" ; then
831 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
832 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
833 if test ${OSTYPE} = linux ; then
834 dnl Linux static libs
835 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
843 dnl if we have not found OpenSSL so far, then look for it in
844 dnl several standard places, and check for crazy RedHat install too
845 if test "${SSLHDR:-unset}" = "unset" ; then
847 for openssl_dir in /usr/local/openssl /usr/local/ssl ; do
848 AC_MSG_CHECKING([for OpenSSL in $openssl_dir])
849 if test ! -f ${openssl_dir}/include/openssl/ssl.h ; then
852 AC_LANG_CONFTEST([[#include "${openssl_dir}/include/openssl/ssl.h"
853 int main(int argc,char **argv){ return 0; }]])
854 $CXX $CXXFLAGS -I${openssl_dir}/include -c conftest.cc > /dev/null 2>&1
855 if test $? = 0 ; then
859 SSLINCLUDEDIR="${openssl_dir}/include"
860 SSLLIBDIR="${openssl_dir}/lib"
864 AC_MSG_CHECKING([if ${openssl_dir}/include/openssl/ssl.h works with OPENSSL_NO_KRB5...])
865 AC_LANG_CONFTEST([[#define OPENSSL_NO_KRB5
866 #include "${openssl_dir}/include/openssl/ssl.h"
867 int main(int argc,char **argv){}]])
868 $CXX $CXXFLAGS -I${openssl_dir}/openssl/include -c conftest.cc > /dev/null 2>&1
869 if test $? = 0 ; then
872 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
873 SSLINCLUDEDIR="${openssl_dir}/include"
874 SSLLIBDIR="${openssl_dir}/lib"
875 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
876 if test ${OSTYPE} = linux ; then
877 dnl Linux static libs
878 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
889 if test ${SSLHDR:-unset} != "unset" ; then
890 AC_SUBST(HAS_OPENSSL, 1)
891 AC_DEFINE(P_SSL, 1, "OpenSSL found")
892 if test ${SSLINCLUDEDIR:-unset} != "unset" ; then
893 STDCCFLAGS="$STDCCFLAGS -I${SSLINCLUDEDIR}"
895 if test ${SSLLIBDIR:-unset} != "unset" ; then
896 LDFLAGS="$LDFLAGS -L${SSLLIBDIR}"
898 STDCCFLAGS="${STDCCFLAGS}${SSLCCFLAGS}"
899 ENDLDLIBS="$ENDLDLIBS -lssl -lcrypto"
903 AC_SUBST(P_STATIC_ENDLDLIBS)
904 AC_SUBST(P_STATIC_LDFLAGS)
906 dnl ########################################################################
907 dnl look for expat XML parser
909 dnl MSWIN_DISPLAY expat,Expat XML
910 dnl MSWIN_CHECK_FILE expat,lib\expat.h,P_EXPAT=1
911 dnl MSWIN_DIR_SYMBOL expat,EXPAT_DIR
912 dnl MSWIN_CHECK_DIR expat,..\expat\
913 dnl MSWIN_CHECK_DIR expat,..\external\expat\
914 dnl MSWIN_CHECK_DIR expat,\expat
915 dnl MSWIN_CHECK_DIR expat,c:\expat\
918 [ --disable-expat disable XML support in PWLIB],
921 if test "$expat" = "no" ; then
922 AC_SUBST(HAS_EXPAT, 0)
923 AC_DEFINE(P_EXPAT, 0)
926 AC_CHECK_HEADERS(expat.h, HAS_EXPAT=1)
927 if test "${HAS_EXPAT:-unset}" != "unset" ; then
928 AC_CHECK_LIB(expat, XML_ParserCreate, HAS_EXPAT=1, HAS_EXPAT=)
930 AC_CHECK_FILE(/usr/local/include/expat.h, HAS_EXPAT=1)
931 if test "${HAS_EXPAT:-unset}" != "unset" ; then
932 EXPATINCLUDEDIR=/usr/local/include
933 EXPATLIBDIR=/usr/local/lib
937 if test "${HAS_EXPAT:-unset}" != "unset" ; then
938 AC_SUBST(HAS_EXPAT, 1)
939 AC_DEFINE(P_EXPAT, 1, "expat found")
940 if test ${EXPATINCLUDEDIR:-unset} != "unset" ; then
941 STDCCFLAGS="$STDCCFLAGS -I${EXPATINCLUDEDIR}"
943 if test ${EXPATLIBDIR:-unset} != "unset" ; then
944 LDFLAGS="$LDFLAGS -L${EXPATLIBDIR}"
946 ENDLDLIBS="$ENDLDLIBS -lexpat"
951 dnl ########################################################################
954 dnl MSWIN_DISPLAY sapi,Speech API
955 dnl MSWIN_CHECK_FILE sapi,include\sphelper.h,P_SAPI=1
956 dnl MSWIN_DIR_SYMBOL sapi,SAPI_DIR
957 dnl MSWIN_CHECK_DIR sapi,\Program Files\Microsoft Speech SDK 5.1\
960 dnl ########################################################################
961 dnl look for IPV6 functions
963 dnl MSWIN_DISPLAY ipv6,IPv6 Support
964 dnl MSWIN_CHECK_FILE ipv6,ws2tcpip.h|sin6_scope_id,P_HAS_IPV6=1
965 dnl MSWIN_DIR_SYMBOL ipv6,IPV6_DIR
966 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft Visual Studio\VC98\Include\
967 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft SDK\include\
970 [ --disable-ipv6 disable IPV6 support in PWLIB],
973 if test "$ipv6" = "no" ; then
974 AC_DEFINE(P_HAS_IPV6, 0)
975 AC_SUBST(HAS_IPV6, 0)
977 AC_MSG_CHECKING(for IPv6 support)
978 AC_TRY_COMPILE([#include <sys/types.h>
979 #include <netinet/in.h>],
980 [struct sockaddr_in6 s; s.sin6_scope_id = 0;], HAS_IPV6=yes, HAS_IPV6=no)
981 if test $HAS_IPV6 = no ; then
984 AC_TRY_COMPILE([#include <sys/socket.h>
986 [getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);], HAS_IPV6=yes, HAS_IPV6=no)
987 if test $HAS_IPV6 = no ; then
991 AC_DEFINE(P_HAS_IPV6, 1, "IPV6 enabled")
996 dnl ########################################################################
997 dnl look for QoS functions
999 dnl MSWIN_DISPLAY qos,QoS Support
1000 dnl MSWIN_CHECK_FILE qos,qossp.h|QOS_DESTADDR,P_HAS_QOS=1
1001 dnl MSWIN_DIR_SYMBOL qos,QOS_DIR
1002 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft Visual Studio\VC98\Include\
1003 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft SDK\include\
1006 [ --disable-qos disable QOS support in PWLIB],
1009 if test "$qos" = "no" ; then
1010 AC_DEFINE([P_HAS_QOS], [0], [No QOS])
1012 AC_DEFINE([P_HAS_QOS], [1], [Have QOS])
1016 dnl ########################################################################
1017 dnl look for SDL, but only if we have pthreads
1019 dnl MSWIN_DISPLAY libsdl,Simple DirectMedia Layer
1020 dnl MSWIN_CHECK_FILE libsdl,include\SDL_video.h,P_SDL=1
1021 dnl MSWIN_CHECK_FILE libsdl,lib\SDL.lib,P_SDL_LIBDIR="lib"
1022 dnl MSWIN_DIR_SYMBOL libsdl,SDL_DIR
1023 dnl MSWIN_CHECK_DIR libsdl,..\sdl\
1024 dnl MSWIN_CHECK_DIR libsdl,..\external\sdl\
1025 dnl MSWIN_CHECK_DIR libsdl,\sdl\
1026 dnl MSWIN_CHECK_DIR libsdl,c:\sdl\
1029 [ --disable-sdl disable SDL support in PWLIB],
1032 if test "$sdl" = "no" ; then
1033 AC_SUBST(HAS_SDL, 0)
1037 if test "${SDLLIB:-unset}" = "unset" ; then
1042 AC_CHECK_HEADERS(SDL/SDL.h, HAS_SDL=1)
1043 if test "${HAS_SDL:-unset}" != "unset" ; then
1044 if test "${X11LIBDIR:-unset}" == "unset" ; then
1045 X11LIBDIR=/usr/X11R6/lib
1047 AC_CHECK_LIB(SDL, SDL_CreateYUVOverlay, HAS_SDL=1, HAS_SDL=, -L${X11LIBDIR} -lpthread -lX11 -lXext -laa)
1050 dnl freeBSD SDL check
1051 if test "${HAS_SDL:-unset}" = "unset" ; then
1052 AC_CHECK_FILE(/usr/local/include/SDL11/SDL.h, HAS_SDL=1)
1053 if test "${HAS_SDL:-unset}" != "unset" ; then
1058 if test "${HAS_SDL:-unset}" != "unset" ; then
1059 AC_SUBST(HAS_SDL, 1)
1060 AC_DEFINE(P_SDL, 1, "SDL found")
1061 if test ${SDLINCLUDEDIR:-unset} != "unset" ; then
1062 STDCCFLAGS="$STDCCFLAGS -I${SDLINCLUDEDIR}"
1064 if test ${SDLLIBDIR:-unset} != "unset" ; then
1065 LDFLAGS="$LDFLAGS -L${SDLLIBDIR}"
1067 ENDLDLIBS="$ENDLDLIBS -l${SDLLIB}"
1072 dnl ########################################################################
1073 dnl check for video capture support.
1074 dnl videodev.h on linux
1075 dnl machine/ioctl_meteor on FreeBSD
1076 dnl i386/ioctl_meteor on OpenBSD
1077 dnl dev/ic/bt8xx on NetBSD
1079 AC_ARG_ENABLE(video,
1080 [ --disable-video disable non-plugin video device support in PWLIB],
1084 if test "$HAS_PLUGINS" = "0" ; then
1085 if test "$video" != "no" ; then
1086 AC_CHECK_HEADER(linux/videodev.h, HAS_VIDEO_CAPTURE=1)
1087 dnl AC_CHECK_HEADER(machine/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1088 dnl AC_CHECK_HEADER(i386/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1089 dnl AC_CHECK_HEADER(dev/ic/bt8xx.h, HAS_VIDEO_CAPTURE=1)
1090 if test "${HAS_VIDEO_CAPTURE}" = "0" ; then
1091 AC_MSG_NOTICE(No Video Capture support)
1092 AC_DEFINE([NO_VIDEO_CAPTURE], [], [No video capture])
1096 AC_SUBST(HAS_VIDEO_CAPTURE)
1098 dnl ########################################################################
1099 dnl enable shared memory video devices (static video plugin)
1101 AC_ARG_ENABLE(shm_video,
1102 [ --enable-shm-video enable shared memory video devices (off by default)],
1103 shm_video=$enableval)
1105 USE_SHM_VIDEO_DEVICES=0
1106 if test "$shm_video" = "yes" ; then
1107 USE_SHM_VIDEO_DEVICES=1
1108 AC_MSG_NOTICE(Shared memory video devices enabled)
1110 AC_SUBST(USE_SHM_VIDEO_DEVICES)
1112 dnl ########################################################################
1113 dnl check for various functions
1114 AC_ARG_ENABLE(alsa, [ --enable-alsa disable non-plugin ALSA audio support],enable_alsa=$enableval)
1117 if test "$HAS_PLUGINS" = "0" ; then
1118 if test "$enable_alsa" != "no" ; then
1119 AC_CHECK_HEADER(alsa/asoundlib.h, HAS_ALSA=1)
1120 AC_MSG_CHECKING(for ALSA sound support)
1121 if test "${HAS_ALSA}" = "1"; then
1123 ENDLDLIBS="$ENDLDLIBS -lasound"
1131 dnl ########################################################################
1132 dnl check for various functions
1133 dnl According to Andre Schulze <as8@rncmm2.urz.tu-dresden.de>
1134 dnl Solaris swab should not be used
1135 if test "$OSTYPE" = "solaris" ; then
1138 AC_CHECK_FUNC(swab,USE_SYSTEM_SWAB=1)
1140 if test "x$ac_cv_func_swab" = "xyes" ; then
1141 AC_DEFINE([USE_SYSTEM_SWAB], [], [Use system swab()])
1144 dnl ########################################################################
1145 dnl look for MEMORY_CHECK enabled.
1147 AC_ARG_ENABLE(memcheck,
1148 [ --enable-memcheck enable leak testing code (off by default)],
1149 memcheck=$enableval)
1151 if test "$memcheck" = "yes" ; then
1152 AC_DEFINE(PMEMORY_CHECK, 1)
1153 AC_MSG_NOTICE(Memory checking enabled)
1157 dnl ########################################################################
1158 dnl output make directives
1160 dnl resolver needs to be at the end
1161 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
1162 if test "${RESOLVER_LIBS:-unset}" != "unset" ; then
1163 ENDLDLIBS="$ENDLDLIBS $RESOLVER_LIBS"
1167 dnl dl needs to be at the end
1168 if test "${OSTYPE}" != "Darwin" ; then
1169 if test ${HAS_LIBDL} = yes ; then
1170 ENDLDLIBS="$ENDLDLIBS -ldl"
1174 dnl ########################################################################
1175 dnl this reduces the size of all executables and libraries
1177 STDCCFLAGS="$STDCCFLAGS -fno-exceptions"
1179 dnl ########################################################################
1180 dnl final declarations
1182 AC_SUBST(STDCCFLAGS)
1183 AC_SUBST(STDCXXFLAGS)
1184 AC_SUBST(OPTSTDCCFLAGS)
1189 AC_CONFIG_FILES(make/ptbuildopts.mak)
1190 AC_CONFIG_FILES([make/ptlib-config], [chmod a+x make/ptlib-config])
1191 AC_CONFIG_FILES(Makefile)
1193 dnl ########################################################################
1194 dnl output header file
1195 #AC_CONFIG_FILES(include/ptbuildopts.h.in)
1196 AC_CONFIG_HEADERS(include/ptbuildopts.h)