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";
102 STDCCFLAGS="$STDCCFLAGS -DP_USE_PRAGMA"
107 OSRELEASE=`uname -r` ;
108 STDCCFLAGS="$STDCCFLAGS -D__BEOS__"
111 * ) OSTYPE="$target_os" ;
112 OS_TAG="P_UNKNOWN_OS" ;
113 OSRELEASE="\"${OSTYPE}_`uname -r`\"" ;
114 AC_MSG_WARN("OS $target_os not recognized - proceed with caution!") ;
120 case "$target_cpu" in
121 x86 | i686 | i586 | i486 | i386 ) MACHTYPE=x86
124 x86_64) MACHTYPE=x86_64 ;
129 alpha | alphaev56 | alphaev6 | alphaev67 | alphaev7) MACHTYPE=alpha ;
133 sparc ) MACHTYPE=sparc ;
136 powerpc ) MACHTYPE=ppc ;
142 powerpc64 ) MACHTYPE=ppc64 ;
147 ppc64 ) MACHTYPE=ppc64 ;
152 ia64) MACHTYPE=ia64 ;
156 s390x) MACHTYPE=s390x ;
161 s390) MACHTYPE=s390 ;
164 * ) MACHTYPE=$target_cpu ;
165 AC_MSG_WARN("CPU $target_cpu not recognized - proceed with caution!") ;;
168 AC_MSG_NOTICE(OSTYPE set to $OSTYPE);
169 AC_MSG_NOTICE(OSRELEASE set to $OSRELEASE);
170 AC_MSG_NOTICE(MACHTYPE set to $MACHTYPE);
172 AC_SUBST(MACHTYPE, $MACHTYPE)
173 AC_SUBST(OSTYPE, $OSTYPE)
174 AC_SUBST(OSRELEASE, $OSRELEASE)
175 AC_SUBST(TARGETDIR, $TARGETDIR)
177 AC_DEFINE_UNQUOTED($OS_TAG, $OSRELEASE)
179 AC_DEFINE([PHAS_TEMPLATES], [1], [Templates found])
181 if test "x$P_64BIT" != "x" ; then
182 AC_DEFINE([P_64BIT], [1], [64bit architecture])
185 dnl BeOS has it;s own threading system
186 if test ${OSTYPE} != beos ; then
187 AC_DEFINE(P_PTHREADS, 1, "PThreads found")
190 dnl ########################################################################
191 dnl set the shared library extension, if not already set
193 if test "x${SHAREDLIBEXT}" = "x" ; then
196 AC_SUBST(SHAREDLIBEXT, $SHAREDLIBEXT)
197 AC_DEFINE([P_SHAREDLIBEXT], [$SHAREDLIBEXT], [shared library extension])
199 dnl ########################################################################
200 dnl check the endianness
202 dnl MSWIN_DISPLAY byteorder,Byte Order
203 dnl MSWIN_DEFINE byteorder,PBYTE_ORDER=PLITTLE_ENDIAN
206 if test ${ac_cv_c_bigendian} = yes ; then
207 PBYTE_ORDER=PBIG_ENDIAN
209 PBYTE_ORDER=PLITTLE_ENDIAN
212 AC_DEFINE_UNQUOTED(PBYTE_ORDER, $PBYTE_ORDER, "byte order")
214 dnl ########################################################################
215 dnl look for compile flags
218 AC_MSG_CHECKING(if linker accepts -felide-constructors)
219 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
220 $CXX $CXXFLAGS -felide-constructors conftest.cc > /dev/null 2>&1
221 if test $? = 0 ; then
223 STDCXXFLAGS="$STDCXXFLAGS -felide-constructors"
228 AC_MSG_CHECKING(if linker accepts -Wreorder)
229 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
230 $STDCXX $CXXFLAGS -Wreorder conftest.cc > /dev/null 2>&1
231 if test $? = 0 ; then
233 STDCXXFLAGS="$STDCXXFLAGS -Wreorder"
238 # AC_MSG_CHECKING(if linker accepts -Woverloaded-virtual)
239 # AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
240 # $CXX $CFLAGS -Woverloaded-virtual conftest.cc > /dev/null 2>&1
241 # if test $? = 0 ; then
243 # STDCCFLAGS="$STDCCFLAGS -Woverloaded-virtual"
248 AC_MSG_CHECKING(if compiler uses RTTI by default)
251 int main(int ac,char **av)
256 virtual void fred() { }
264 A * p = dynamic_cast<A *>(&t);
267 ]],DEFAULT_RTTI=1, DEFAULT_RTTI=0)
268 if test "$DEFAULT_RTTI" = "1" ; then
272 STDCXXFLAGS="$STDCCFLAGS -rtti"
277 dnl Remove --gc-sections as the linker crashes when linking
278 dnl static executables with this option
279 dnl AC_MSG_CHECKING(if linker accepts --gc-sections)
280 dnl C_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
281 dnl CXX $CFLAGS -Wl,--gc-sections conftest.cc > /dev/null 2>&1
282 dnl if test $? = 0 ; then
286 dnl AC_MSG_RESULT(yes)
288 AC_MSG_CHECKING(if compiler accepts -ffunction-sections)
289 AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
290 $CXX $CFLAGS -ffunction-sections -c conftest.cc > /dev/null 2>&1
291 if test $? = 0 ; then
293 STDCCFLAGS="$STDCCFLAGS -ffunction-sections"
299 dnl remove data-sections as not only does is case the linker to
300 dnl crash on some platforms, but seems to be broken w.r.t
301 dnl closure of templates with static member functions
302 dnl see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8249
304 dnl AC_MSG_CHECKING(if compiler accepts -fdata-sections)
305 dnl AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
306 dnl $CXX $CFLAGS -fdata-sections -c conftest.cc > /dev/null 2>&1
307 dnl if test $? = 0 ; then
308 dnl AC_MSG_RESULT(yes)
309 dnl STDCCFLAGS="$STDCCFLAGS -fdata-sections"
312 dnl AC_MSG_RESULT(no)
315 dnl as much as this flag would help, there is no known linker
316 dnl that can handle pwlib when it has been compiled with it
317 dnl AC_MSG_CHECKING(if compiler accepts -fvtable-gc)
318 dnl AC_LANG_CONFTEST([[int main(int ac,char **av) { return 0; }]])
319 dnl $CXX $CFLAGS -fvtable-gc -c conftest.cc > /dev/null 2>&1
320 dnl if test $? = 0 ; then
321 dnl AC_MSG_RESULT(yes)
322 dnl STDCCFLAGS="$STDCCFLAGS -fvtable-gc"
325 dnl AC_MSG_RESULT(no)
328 if test $GCSECTIONS = 1; then
329 if test "${OSTYPE}" != "Darwin" ; then
330 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -Wl,--gc-sections"
338 dnl ########################################################################
339 dnl check for long double
342 if test $ac_cv_c_long_double != yes ; then
343 AC_DEFINE([PNO_LONG_DOUBLE], [], [No long double])
346 dnl ########################################################################
347 dnl check for number of parms to readdir
348 AC_MSG_CHECKING(if readdir_r has 2 parms)
349 AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS
350 #include <dirent.h>],
351 [DIR *s; struct dirent * e; readdir_r(s, e);], P_HAS_POSIX_READDIR_R=2, P_HAS_POSIX_READDIR_R=0)
352 if test ${P_HAS_POSIX_READDIR_R} = 2 ; then
356 AC_MSG_CHECKING(if readdir_r has 3 parms)
357 AC_TRY_COMPILE([#include <dirent.h>],
358 [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)
359 if test ${P_HAS_POSIX_READDIR_R} = 3 ; then
365 AC_DEFINE_UNQUOTED(P_HAS_POSIX_READDIR_R, ${P_HAS_POSIX_READDIR_R})
367 dnl ########################################################################
368 dnl check for streams types
371 AC_MSG_CHECKING(if using STL streams)
372 AC_TRY_COMPILE([#include <iostream>],
373 [int v = (int)std::ios_base::seekdir();], P_HAS_STL_STREAMS=1)
374 if test ${P_HAS_STL_STREAMS} = 1 ; then
379 AC_DEFINE_UNQUOTED(P_HAS_STL_STREAMS, ${P_HAS_STL_STREAMS})
381 dnl ########################################################################
382 dnl see if using GNU glibc++, because then we have atomic integer operations
385 P_NEEDS_GNU_CXX_NAMESPACE=0
386 AC_MSG_CHECKING(if atomic integer available)
387 AC_TRY_COMPILE([#include <bits/atomicity.h>],
388 [_Atomic_word val;], P_HAS_ATOMIC_INT=1)
389 if test ${P_HAS_ATOMIC_INT} = 1 ; then
391 AC_MSG_CHECKING(if __exchange_and_add is in __gnu_cxx namespace)
392 AC_TRY_COMPILE([#include <bits/atomicity.h>],
393 [_Atomic_word val; __gnu_cxx::__exchange_and_add(&val, 1)], P_NEEDS_GNU_CXX_NAMESPACE=1)
394 if test ${P_NEEDS_GNU_CXX_NAMESPACE} = 1 ; then
402 AC_DEFINE_UNQUOTED(P_HAS_ATOMIC_INT, ${P_HAS_ATOMIC_INT})
403 AC_DEFINE_UNQUOTED(P_NEEDS_GNU_CXX_NAMESPACE, ${P_NEEDS_GNU_CXX_NAMESPACE})
406 dnl ########################################################################
407 dnl check for select_large_fdset (Solaris)
409 if test "${OSTYPE:-unknown}" = "solaris"; then
410 AC_MSG_CHECKING(checking for FD_SETSIZE)
411 _FD_SYSTEM_FILE=/etc/system
412 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -c1`
413 if test "$_FD_SETSIZE" = "#"; then
416 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -f2 -d'='`
417 if test "x$_FD_SETSIZE" = "x"; then
420 STDCCFLAGS="$STDCCFLAGS -DFD_SETSIZE=$_FD_SETSIZE"
423 AC_MSG_RESULT($_FD_SETSIZE)
426 dnl ########################################################################
427 dnl check for Unix semaphores
429 dnl posix semaphore support in darwin/macosx is broken
430 if test ${OSTYPE} != Darwin ; then
431 AC_TRY_COMPILE([#include <semaphore.h>],
432 [sem_t *s; sem_init(s, 0, 0);], P_HAS_SEMAPHORES=1)
433 AC_MSG_CHECKING(if Unix semaphores are available)
434 if test "${P_HAS_SEMAPHORES}x" != "x" ; then
435 AC_DEFINE(P_HAS_SEMAPHORES)
439 AC_MSG_WARN(This host does not support semaphores which are essential)
440 AC_MSG_WARN(to implement 'critical sections'. This feature was added)
441 AC_MSG_WARN(in PWLib 1.7.0 and improves the stability of multithreaded)
442 AC_MSG_WARN(programs. This feature has been disabled for this host)
446 dnl ########################################################################
447 dnl check for pthreads library
449 dnl MSWIN_DISPLAY semaphore,Semaphore Support
450 dnl MSWIN_DEFINE semaphore,P_HAS_SEMAPHORES
452 dnl Linux, Mac OS X use libpthread and -lpthread
453 dnl FreeBSD uses the -pthread compiler option and uses libc_r
455 AC_CHECK_LIB(pthread, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
456 if test ${HAS_PTHREADS} = yes ; then
457 ENDLDLIBS="$ENDLDLIBS -lpthread"
458 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT"
461 AC_CHECK_LIB(c_r, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
462 if test ${HAS_PTHREADS} = yes ; then
463 ENDLDLIBS="$ENDLDLIBS -pthread"
464 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT -pthread"
469 if test ${HAS_PTHREADS} != yes ; then
470 AC_MSG_ERROR(must have pthreads!)
473 dnl ########################################################################
474 dnl check for XPG6 compliant pthreads (timed spinlocks)
476 if test ${HAS_PTHREADS} = yes ; then
477 AC_CHECK_LIB(pthread, pthread_mutex_timedlock, HAS_PTHREADS_XPG6=yes, HAS_PTHREADS_XPG6=no)
478 if test ${HAS_PTHREADS_XPG6} = yes ; then
479 AC_DEFINE(P_PTHREADS_XPG6, 1, "XPG6 compliant pthreads found")
482 AC_CHECK_LIB(pthread, sem_timedwait, HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
483 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
484 AC_MSG_CHECKING(if sem_timedwait is compilable)
485 AC_TRY_COMPILE([#include <semaphore.h>],
486 [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
487 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
488 AC_DEFINE(P_HAS_SEMAPHORES_XPG6, 1, "Supports XPG6 Semaphores")
496 dnl ########################################################################
497 dnl check for recursive mutexes
498 P_HAS_RECURSIVE_MUTEX=0
499 AC_MSG_CHECKING(if recursive mutexes are available)
500 AC_TRY_COMPILE([#include <pthread.h>],
501 [pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);], P_HAS_RECURSIVE_MUTEX=1)
502 if test ${P_HAS_RECURSIVE_MUTEX} = 1 ; then
507 AC_DEFINE_UNQUOTED(P_HAS_RECURSIVE_MUTEX, ${P_HAS_RECURSIVE_MUTEX})
510 dnl ########################################################################
511 dnl check for regex library
513 dnl yes this test needs to be outside the if below
514 dnl because autoconf needs to initialise stuff. without this
515 dnl all sorts of strange things happen
516 AC_CHECK_HEADERS(regex.h, HAS_REGEX=yes)
518 AC_ARG_ENABLE(internalregex,
519 [ --enable-internalregex force internal regex library],
520 internalregex=$enableval)
521 if test "$internalregex" = "yes" ; then
522 AC_MSG_NOTICE(Forcing use of internal regex library)
524 if test "$HAS_REGEX" = "yes" ; then
525 AC_CHECK_FUNC(regcomp, HAS_REGEX=yes)
526 if test "$HAS_REGEX" = "yes" ; then
527 AC_SUBST(HAS_REGEX, 1)
528 AC_DEFINE(P_REGEX, 1, "Regex library found")
534 dnl ########################################################################
535 dnl check for dynamic library code (dlopen and friends)
537 dnl MSWIN DLL Support,,P_DYNALINK
542 if test ${OSTYPE} = beos ; then
544 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in BeOS")
545 elif test ${OSTYPE} = Darwin ; then
547 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in Darwin")
549 AC_CHECK_HEADERS(dlfcn.h, HAS_DLFCN=yes, HAS_DLFCN=no)
550 if test "$HAS_DLFCN" = yes ; then
551 AC_MSG_CHECKING(if dlopen is available)
552 AC_TRY_COMPILE([#include <dlfcn.h>],
553 [void * p = dlopen("lib", 0);], HAS_DLOPEN=yes, HAS_DLOPEN=no)
554 if test "$HAS_DLOPEN" = no ; then
559 AC_DEFINE(P_DYNALINK, 1, "dlopen found")
560 AC_CHECK_LIB(dl,dlopen,HAS_LIBDL=yes, HAS_LIBDL=no)
565 dnl #########################################################################
566 dnl check to see if plugins enabled
567 dnl MSWIN Plugin Support,,P_HAS_PLUGINS
569 AC_MSG_CHECKING(if plugins support needs to be compiled)
570 AC_ARG_ENABLE(plugins,
571 [ --enable-plugins enable plugins' support in PWLIB],
575 if test "${plugins}" = "no" ; then
577 elif test "${P_DYNALINK:-unset}" = "unset" ; then
578 AC_MSG_RESULT(plugins disabled as dlopen not available)
580 AC_MSG_RESULT(plugins enabled)
582 AC_DEFINE(P_HAS_PLUGINS, 1, "plugins enabled")
585 AC_SUBST(HAS_PLUGINS)
587 if test "x$LIB64" != "x" ; then
588 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib64/pwlib"], [Default plugin directory])
590 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib/pwlib"], [Default plugin directory])
593 dnl ########################################################################
594 dnl look for DNS resolver code (must be done before OpenLDAP)
595 dnl on some systems, the resolver is in libc
596 dnl but needs resolv.h included which defines res_search as __res_search
598 dnl MSWIN_DISPLAY resolver,DNS Resolver
599 dnl MSWIN_CHECK_FILE resolver,include\windns.h,P_DNS=1
600 dnl MSWIN_DIR_SYMBOL resolver,DNS_DIR
601 dnl MSWIN_CHECK_DIR resolver,\Program Files\Microsoft SDK\
603 AC_ARG_ENABLE(resolver,
604 [ --disable-resolver disable DNS resolver support in PWLIB],
607 if test "$resolver" = "no" ; then
610 AC_CHECK_FUNC(res_search, HAVE_RESOLVER=1)
611 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
614 AC_MSG_CHECKING([for res_search in -lresolv])
617 #include <netinet/in.h>
619 int main(int argc,char **argv){
620 res_search (NULL, 0, 0, NULL, 0);
622 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
624 RESOLVER_LIBS="-lresolv"
626 AC_SEARCH_LIBS(__res_search, resolv, HAVE_RESOLVER=1)
630 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
631 AC_DEFINE(P_DNS, 1, "resolver libraries found")
635 dnl ########################################################################
638 dnl MSWIN_DISPLAY sasl,Cyrus SASL
639 dnl MSWIN_CHECK_FILE sasl,include\sasl.h,P_SASL=1
640 dnl MSWIN_DIR_SYMBOL sasl,SASL_DIR
641 dnl MSWIN_CHECK_DIR sasl,..\cyrus-sasl\
642 dnl MSWIN_CHECK_DIR sasl,..\external\cyrus-sasl\
643 dnl MSWIN_CHECK_DIR sasl,\cyrus-sasl\
644 dnl MSWIN_CHECK_DIR sasl,c:\cyrus-sasl\
647 [ --disable-sasl disable SASL support in PWLIB],
650 if test "$sasl" = "no" ; then
651 AC_MSG_NOTICE(SASL disabled)
654 dnl Not all Unices have SASL installed as a separate library (Solaris)
655 AC_CHECK_LIB(sasl2, sasl_version, HAS_SASL2=1, HAS_SASL2=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
656 if test "${HAS_SASL2}x" = "x" ; then
657 dnl Some older Linux boxes have libsasl instead of libsasl2
658 AC_CHECK_LIB(sasl, sasl_client_auth, HAS_SASL=1, HAS_SASL=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
661 dnl we need to track down the correct sasl.h
662 AC_MSG_CHECKING([if <sasl.h> works])
663 AC_COMPILE_IFELSE([[#include <sasl.h>
664 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],HAS_INCLUDE_SASL_H=1)
665 if test "${HAS_INCLUDE_SASL_H}x" != "x" ; then
670 AC_MSG_CHECKING([if <sasl/sasl.h> works])
671 AC_COMPILE_IFELSE([[#include <sasl/sasl.h>
672 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],P_HAS_SASL_SASL_H=1)
673 if test "${P_HAS_SASL_SASL_H}x" != "x" ; then
676 AC_DEFINE(P_HAS_SASL_SASL_H)
682 if test "${HAS_SASL2}x" != "x" ; then
684 ENDLDLIBS="$ENDLDLIBS -lsasl2"
686 AC_SUBST(HAS_SASL2, 1)
687 elif test "${HAS_SASL}x" != "x" ; then
689 ENDLDLIBS="$ENDLDLIBS -lsasl"
691 AC_SUBST(HAS_SASL, 1)
698 dnl ########################################################################
699 dnl look for OpenLDAP (requires SASL)
701 dnl MSWIN_DISPLAY openldap,Open LDAP
702 dnl MSWIN_CHECK_FILE openldap,include\ldap.h|OpenLDAP,P_LDAP=1
703 dnl MSWIN_DIR_SYMBOL openldap,LDAP_DIR
704 dnl MSWIN_CHECK_DIR openldap,..\openldap\
705 dnl MSWIN_CHECK_DIR openldap,..\external\openldap\
706 dnl MSWIN_CHECK_DIR openldap,\openldap\
707 dnl MSWIN_CHECK_DIR openldap,c:\openldap\
709 AC_ARG_ENABLE(openldap,
710 [ --disable-openldap disable OpenLDAP support in PWLIB],
713 if test "$openldap" = "no" ; then
714 AC_SUBST(HAS_OPENLDAP, 0)
717 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
718 AC_CHECK_HEADERS(ldap.h, HAS_OPENLDAP=1)
720 dnl posix4 is required by libldap_r on Solaris
721 if test "${OSTYPE:-unknown}" = "solaris"; then
722 OPENLDAPSYSLIBS=-lposix4
725 dnl check also for lldap_r presence (required for thread safe OpenLDAP?)
726 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
727 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
729 AC_CHECK_FILE(/usr/local/include/ldap.h, HAS_OPENLDAP=1)
730 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
731 OPENLDAPINCLUDEDIR=/usr/local/include
732 OPENLDAPLIBDIR=/usr/local/lib
733 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-L/usr/local/lib -llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
738 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
739 AC_SUBST(HAS_OPENLDAP, 1)
740 AC_DEFINE(P_LDAP, 1, "OpenLDAP found")
741 ENDLDLIBS="-lldap -lldap_r -llber $ENDLDLIBS"
742 if test "${OPENLDAPINCLUDEDIR}unset" != "unset" ; then
743 STDCCFLAGS="$STDCCFLAGS -I${OPENLDAPINCLUDEDIR}"
745 if test "${OPENLDAPLIBDIR}unset" != "unset" ; then
746 LDFLAGS="$LDFLAGS -L${OPENLDAPLIBDIR}"
752 dnl ########################################################################
754 dnl check for environment variable, then assume standard system install
755 dnl this process is made incredibly more complex by the fact that RedHad 9
756 dnl is completely fscked. The default OpenSSL installation requires Kerberos,
757 dnl even when Kerberos is not installed, requiring an explicit #define to
759 dnl As if that is not enough, autoconf gets very confused if configure.in
760 dnl contains a AC_CHECK_HEADER directive that never gets used. So we have
761 dnl to ensure that it is always called
763 dnl MSWIN_DISPLAY openssl,Open SSL
764 dnl MSWIN_CHECK_FILE openssl,inc32\openssl\ssl.h,P_SSL=1
765 dnl MSWIN_DIR_SYMBOL openssl,SSL_DIR
766 dnl MSWIN_CHECK_DIR openssl,..\openssl\
767 dnl MSWIN_CHECK_DIR openssl,..\external\openssl\
768 dnl MSWIN_CHECK_DIR openssl,\openssl\
769 dnl MSWIN_CHECK_DIR openssl,c:\openssl\
771 AC_ARG_ENABLE(openssl,
772 [ --disable-openssl disable OpenSSL support in PWLIB],
775 if test "$openssl" = "no" ; then
777 AC_SUBST(HAS_OPENSSL, 0)
780 dnl check to see OPENSSLDIR is set
781 dnl if it is, we assume it correct - no further checking required
782 if test ${OPENSSLDIR:-unset} != "unset" ; then
783 AC_MSG_CHECKING([for ${OPENSSLDIR}/include/openssl/ssl.h])
784 if test -e ${OPENSSLDIR}/include/openssl/ssl.h ; then
787 SSLINCLUDEDIR="${OPENSSLDIR}/include"
788 SSLLIBDIR="${OPENSSLDIR}/lib"
795 dnl if OPENSSLDIR is not set, then check to see if OpenSSL
796 dnl is installed in the standard system dirs. And also see if
797 dnl if it works using crazy RedHat checks
798 if test "${SSLHDR:-unset}" = "unset" ; then
799 AC_CHECK_HEADERS(openssl/ssl.h,SSLHDR=1)
800 if test "${SSLHDR:-unset}" != "unset" ; then
801 AC_MSG_CHECKING([if openssl/ssl.h works with OPENSSL_NO_KRB5])
802 AC_COMPILE_IFELSE([[#define OPENSSL_NO_KRB5
803 #include <openssl/ssl.h>
804 int main(int argc,char **argv){}]],SSLHDR=1)
805 if test ${SSLHDR:-unset} != "unset" ; then
807 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
808 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
809 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
816 dnl if we have not found OpenSSL so far, then look for it in
817 dnl several standard places, and check for crazy RedHat install too
818 if test "${SSLHDR:-unset}" = "unset" ; then
820 for openssl_dir in /usr/local/openssl /usr/local/ssl ; do
821 AC_MSG_CHECKING([for OpenSSL in $openssl_dir])
822 if test ! -f ${openssl_dir}/include/openssl/ssl.h ; then
825 AC_LANG_CONFTEST([[#include "${openssl_dir}/include/openssl/ssl.h"
826 int main(int argc,char **argv){ return 0; }]])
827 $CXX $CXXFLAGS -I${openssl_dir}/include -c conftest.cc > /dev/null 2>&1
828 if test $? = 0 ; then
832 SSLINCLUDEDIR="${openssl_dir}/include"
833 SSLLIBDIR="${openssl_dir}/lib"
837 AC_MSG_CHECKING([if ${openssl_dir}/include/openssl/ssl.h works with OPENSSL_NO_KRB5...])
838 AC_LANG_CONFTEST([[#define OPENSSL_NO_KRB5
839 #include "${openssl_dir}/include/openssl/ssl.h"
840 int main(int argc,char **argv){}]])
841 $CXX $CXXFLAGS -I${openssl_dir}/openssl/include -c conftest.cc > /dev/null 2>&1
842 if test $? = 0 ; then
845 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
846 SSLINCLUDEDIR="${openssl_dir}/include"
847 SSLLIBDIR="${openssl_dir}/lib"
848 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
849 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
859 if test ${SSLHDR:-unset} != "unset" ; then
860 AC_SUBST(HAS_OPENSSL, 1)
861 AC_DEFINE(P_SSL, 1, "OpenSSL found")
862 if test ${SSLINCLUDEDIR:-unset} != "unset" ; then
863 STDCCFLAGS="$STDCCFLAGS -I${SSLINCLUDEDIR}"
865 if test ${SSLLIBDIR:-unset} != "unset" ; then
866 LDFLAGS="$LDFLAGS -L${SSLLIBDIR}"
868 STDCCFLAGS="${STDCCFLAGS}${SSLCCFLAGS}"
869 ENDLDLIBS="$ENDLDLIBS -lssl -lcrypto"
873 AC_SUBST(P_STATIC_ENDLDLIBS)
874 AC_SUBST(P_STATIC_LDFLAGS)
876 dnl ########################################################################
877 dnl look for expat XML parser
879 dnl MSWIN_DISPLAY expat,Expat XML
880 dnl MSWIN_CHECK_FILE expat,lib\expat.h,P_EXPAT=1
881 dnl MSWIN_DIR_SYMBOL expat,EXPAT_DIR
882 dnl MSWIN_CHECK_DIR expat,..\expat\
883 dnl MSWIN_CHECK_DIR expat,..\external\expat\
884 dnl MSWIN_CHECK_DIR expat,\expat
885 dnl MSWIN_CHECK_DIR expat,c:\expat\
888 [ --disable-expat disable XML support in PWLIB],
891 if test "$expat" = "no" ; then
892 AC_SUBST(HAS_EXPAT, 0)
893 AC_DEFINE(P_EXPAT, 0)
896 AC_CHECK_HEADERS(expat.h, HAS_EXPAT=1)
897 if test "${HAS_EXPAT:-unset}" != "unset" ; then
898 AC_CHECK_LIB(expat, XML_ParserCreate, HAS_EXPAT=1, HAS_EXPAT=)
900 AC_CHECK_FILE(/usr/local/include/expat.h, HAS_EXPAT=1)
901 if test "${HAS_EXPAT:-unset}" != "unset" ; then
902 EXPATINCLUDEDIR=/usr/local/include
903 EXPATLIBDIR=/usr/local/lib
907 if test "${HAS_EXPAT:-unset}" != "unset" ; then
908 AC_SUBST(HAS_EXPAT, 1)
909 AC_DEFINE(P_EXPAT, 1, "expat found")
910 if test ${EXPATINCLUDEDIR:-unset} != "unset" ; then
911 STDCCFLAGS="$STDCCFLAGS -I${EXPATINCLUDEDIR}"
913 if test ${EXPATLIBDIR:-unset} != "unset" ; then
914 LDFLAGS="$LDFLAGS -L${EXPATLIBDIR}"
916 ENDLDLIBS="$ENDLDLIBS -lexpat"
921 dnl ########################################################################
924 dnl MSWIN_DISPLAY sapi,Speech API
925 dnl MSWIN_CHECK_FILE sapi,include\sphelper.h,P_SAPI=1
926 dnl MSWIN_DIR_SYMBOL sapi,SAPI_DIR
927 dnl MSWIN_CHECK_DIR sapi,\Program Files\Microsoft Speech SDK 5.1\
930 dnl ########################################################################
931 dnl look for IPV6 functions
933 dnl MSWIN_DISPLAY ipv6,IPv6 Support
934 dnl MSWIN_CHECK_FILE ipv6,ws2tcpip.h|sin6_scope_id,P_HAS_IPV6=1
935 dnl MSWIN_DIR_SYMBOL ipv6,IPV6_DIR
936 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft Visual Studio\VC98\Include\
937 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft SDK\include\
940 [ --disable-ipv6 disable IPV6 support in PWLIB],
943 if test "$ipv6" = "no" ; then
944 AC_DEFINE(P_HAS_IPV6, 0)
945 AC_SUBST(HAS_IPV6, 0)
947 AC_CACHE_CHECK([for IPv6 Support], HAS_IPV6,
948 [AC_TRY_COMPILE([#include <sys/types.h>
949 #include <netinet/in.h>],
950 [struct sockaddr_in6 s; s.sin6_scope_id = 0;], HAS_IPV6=yes, HAS_IPV6=no)])
952 if test $HAS_IPV6 = yes ; then
953 AC_DEFINE(P_HAS_IPV6, 1, "IPV6 enabled")
957 dnl ########################################################################
958 dnl look for QoS functions
960 dnl MSWIN_DISPLAY qos,QoS Support
961 dnl MSWIN_CHECK_FILE qos,qossp.h|QOS_DESTADDR,P_HAS_QOS=1
962 dnl MSWIN_DIR_SYMBOL qos,QOS_DIR
963 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft Visual Studio\VC98\Include\
964 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft SDK\include\
967 [ --disable-qos disable QOS support in PWLIB],
970 if test "$qos" = "no" ; then
971 AC_DEFINE([P_HAS_QOS], [0], [No QOS])
973 AC_DEFINE([P_HAS_QOS], [1], [Have QOS])
977 dnl ########################################################################
978 dnl look for SDL, but only if we have pthreads
980 dnl MSWIN_DISPLAY libsdl,Simple DirectMedia Layer
981 dnl MSWIN_CHECK_FILE libsdl,include\SDL_video.h,P_SDL=1
982 dnl MSWIN_CHECK_FILE libsdl,lib\SDL.lib,P_SDL_LIBDIR="lib"
983 dnl MSWIN_DIR_SYMBOL libsdl,SDL_DIR
984 dnl MSWIN_CHECK_DIR libsdl,..\sdl\
985 dnl MSWIN_CHECK_DIR libsdl,..\external\sdl\
986 dnl MSWIN_CHECK_DIR libsdl,\sdl\
987 dnl MSWIN_CHECK_DIR libsdl,c:\sdl\
990 [ --disable-sdl disable SDL support in PWLIB],
993 if test "$sdl" = "no" ; then
998 if test "${SDLLIB:-unset}" = "unset" ; then
1003 AC_CHECK_HEADERS(SDL/SDL.h, HAS_SDL=1)
1004 if test "${HAS_SDL:-unset}" != "unset" ; then
1005 if test "${X11LIBDIR:-unset}" == "unset" ; then
1006 X11LIBDIR=/usr/X11R6/lib
1008 AC_CHECK_LIB(SDL, SDL_CreateYUVOverlay, HAS_SDL=1, HAS_SDL=, -L${X11LIBDIR} -lpthread -lX11 -lXext -laa)
1011 dnl freeBSD SDL check
1012 if test "${HAS_SDL:-unset}" = "unset" ; then
1013 AC_CHECK_FILE(/usr/local/include/SDL11/SDL.h, HAS_SDL=1)
1014 if test "${HAS_SDL:-unset}" != "unset" ; then
1019 if test "${HAS_SDL:-unset}" != "unset" ; then
1020 AC_SUBST(HAS_SDL, 1)
1021 AC_DEFINE(P_SDL, 1, "SDL found")
1022 if test ${SDLINCLUDEDIR:-unset} != "unset" ; then
1023 STDCCFLAGS="$STDCCFLAGS -I${SDLINCLUDEDIR}"
1025 if test ${SDLLIBDIR:-unset} != "unset" ; then
1026 LDFLAGS="$LDFLAGS -L${SDLLIBDIR}"
1028 ENDLDLIBS="$ENDLDLIBS -l${SDLLIB}"
1033 dnl ########################################################################
1034 dnl check for video capture support.
1035 dnl videodev.h on linux
1036 dnl machine/ioctl_meteor on FreeBSD
1037 dnl i386/ioctl_meteor on OpenBSD
1038 dnl dev/ic/bt8xx on NetBSD
1040 AC_ARG_ENABLE(video,
1041 [ --disable-video disable non-plugin video device support in PWLIB],
1045 if test "$HAS_PLUGINS" = "0" ; then
1046 if test "$video" != "no" ; then
1047 AC_CHECK_HEADER(linux/videodev.h, HAS_VIDEO_CAPTURE=1)
1048 dnl AC_CHECK_HEADER(machine/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1049 dnl AC_CHECK_HEADER(i386/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1050 dnl AC_CHECK_HEADER(dev/ic/bt8xx.h, HAS_VIDEO_CAPTURE=1)
1051 if test "${HAS_VIDEO_CAPTURE}" = "0" ; then
1052 AC_MSG_NOTICE(No Video Capture support)
1053 AC_DEFINE([NO_VIDEO_CAPTURE], [], [No video capture])
1057 AC_SUBST(HAS_VIDEO_CAPTURE)
1059 dnl ########################################################################
1060 dnl check for various functions
1061 AC_ARG_ENABLE(alsa, [ --enable-alsa disable non-plugin ALSA audio support],enable_alsa=$enableval)
1064 if test "$HAS_PLUGINS" = "0" ; then
1065 if test "$enable_alsa" != "no" ; then
1066 AC_CHECK_HEADER(alsa/asoundlib.h, HAS_ALSA=1)
1067 AC_MSG_CHECKING(for ALSA sound support)
1068 if test "${HAS_ALSA}" = "1"; then
1070 ENDLDLIBS="$ENDLDLIBS -lasound"
1078 dnl ########################################################################
1079 dnl check for various functions
1080 dnl According to Andre Schulze <as8@rncmm2.urz.tu-dresden.de>
1081 dnl Solaris swab should not be used
1082 if test "$OSTYPE" = "solaris" ; then
1085 AC_CHECK_FUNC(swab,USE_SYSTEM_SWAB=1)
1087 if test "x$ac_cv_func_swab" = "xyes" ; then
1088 AC_DEFINE([USE_SYSTEM_SWAB], [], [Use system swab()])
1091 dnl ########################################################################
1092 dnl look for MEMORY_CHECK enabled.
1094 dnl MSWIN_DISPLAY memcheck,Memory check switch read
1096 AC_ARG_ENABLE(memcheck,
1097 [ --enable-memcheck enable leak testing code (off by default)],
1098 memcheck=$enableval)
1100 if test "$memcheck" = "yes" ; then
1101 AC_DEFINE(PMEMORY_CHECK, 1)
1102 AC_MSG_NOTICE(Memory checking enabled)
1106 dnl ########################################################################
1107 dnl output make directives
1109 dnl resolver needs to be at the end
1110 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
1111 if test "${RESOLVER_LIBS:-unset}" != "unset" ; then
1112 ENDLDLIBS="$ENDLDLIBS $RESOLVER_LIBS"
1116 dnl dl needs to be at the end
1117 if test "${OSTYPE}" != "Darwin" ; then
1118 if test ${HAS_LIBDL} = yes ; then
1119 ENDLDLIBS="$ENDLDLIBS -ldl"
1123 AC_SUBST(STDCCFLAGS)
1124 AC_SUBST(STDCXXFLAGS)
1125 AC_SUBST(OPTSTDCCFLAGS)
1130 AC_CONFIG_FILES(make/ptbuildopts.mak)
1131 AC_CONFIG_FILES([make/ptlib-config], [chmod a+x make/ptlib-config])
1132 AC_CONFIG_FILES(Makefile)
1134 dnl ########################################################################
1135 dnl output header file
1136 #AC_CONFIG_FILES(include/ptbuildopts.h.in)
1137 AC_CONFIG_HEADERS(include/ptbuildopts.h)