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])
344 elif test ${OSTYPE} = Darwin ; then
345 STDCCFLAGS="$STDCCFLAGS -Wno-long-double"
348 dnl ########################################################################
349 dnl check for number of parms to readdir
350 AC_MSG_CHECKING(if readdir_r has 2 parms)
351 AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS
352 #include <dirent.h>],
353 [DIR *s; struct dirent * e; readdir_r(s, e);], P_HAS_POSIX_READDIR_R=2, P_HAS_POSIX_READDIR_R=0)
354 if test ${P_HAS_POSIX_READDIR_R} = 2 ; then
358 AC_MSG_CHECKING(if readdir_r has 3 parms)
359 AC_TRY_COMPILE([#include <dirent.h>],
360 [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)
361 if test ${P_HAS_POSIX_READDIR_R} = 3 ; then
367 AC_DEFINE_UNQUOTED(P_HAS_POSIX_READDIR_R, ${P_HAS_POSIX_READDIR_R})
369 dnl ########################################################################
370 dnl check for streams types
373 AC_MSG_CHECKING(if using STL streams)
374 AC_TRY_COMPILE([#include <iostream>],
375 [int v = (int)std::ios_base::seekdir();], P_HAS_STL_STREAMS=1)
376 if test ${P_HAS_STL_STREAMS} = 1 ; then
381 AC_DEFINE_UNQUOTED(P_HAS_STL_STREAMS, ${P_HAS_STL_STREAMS})
383 dnl ########################################################################
384 dnl see if using GNU glibc++, because then we have atomic integer operations
387 P_NEEDS_GNU_CXX_NAMESPACE=0
388 AC_MSG_CHECKING(if atomic integer available)
389 AC_TRY_COMPILE([#include <bits/atomicity.h>],
390 [_Atomic_word val;], P_HAS_ATOMIC_INT=1)
391 if test ${P_HAS_ATOMIC_INT} = 1 ; then
393 AC_MSG_CHECKING(if __exchange_and_add is in __gnu_cxx namespace)
394 AC_TRY_COMPILE([#include <bits/atomicity.h>],
395 [_Atomic_word val; __gnu_cxx::__exchange_and_add(&val, 1)], P_NEEDS_GNU_CXX_NAMESPACE=1)
396 if test ${P_NEEDS_GNU_CXX_NAMESPACE} = 1 ; then
404 AC_DEFINE_UNQUOTED(P_HAS_ATOMIC_INT, ${P_HAS_ATOMIC_INT})
405 AC_DEFINE_UNQUOTED(P_NEEDS_GNU_CXX_NAMESPACE, ${P_NEEDS_GNU_CXX_NAMESPACE})
408 dnl ########################################################################
409 dnl check for select_large_fdset (Solaris)
411 if test "${OSTYPE:-unknown}" = "solaris"; then
412 AC_MSG_CHECKING(checking for FD_SETSIZE)
413 _FD_SYSTEM_FILE=/etc/system
414 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -c1`
415 if test "$_FD_SETSIZE" = "#"; then
418 _FD_SETSIZE=`cat $_FD_SYSTEM_FILE | grep rlim_fd_max | cut -f2 -d'='`
419 if test "x$_FD_SETSIZE" = "x"; then
422 STDCCFLAGS="$STDCCFLAGS -DFD_SETSIZE=$_FD_SETSIZE"
425 AC_MSG_RESULT($_FD_SETSIZE)
428 dnl ########################################################################
429 dnl check for Unix semaphores
431 dnl posix semaphore support in darwin/macosx is broken
432 if test ${OSTYPE} != Darwin ; then
433 AC_TRY_COMPILE([#include <semaphore.h>],
434 [sem_t *s; sem_init(s, 0, 0);], P_HAS_SEMAPHORES=1)
435 AC_MSG_CHECKING(if Unix semaphores are available)
436 if test "${P_HAS_SEMAPHORES}x" != "x" ; then
437 AC_DEFINE(P_HAS_SEMAPHORES)
441 AC_MSG_WARN(This host does not support semaphores which are essential)
442 AC_MSG_WARN(to implement 'critical sections'. This feature was added)
443 AC_MSG_WARN(in PWLib 1.7.0 and improves the stability of multithreaded)
444 AC_MSG_WARN(programs. This feature has been disabled for this host)
448 dnl ########################################################################
449 dnl check for pthreads library
451 dnl MSWIN_DISPLAY semaphore,Semaphore Support
452 dnl MSWIN_DEFINE semaphore,P_HAS_SEMAPHORES
454 dnl Linux, Mac OS X use libpthread and -lpthread
455 dnl FreeBSD uses the -pthread compiler option and uses libc_r
457 AC_CHECK_LIB(pthread, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
458 if test ${HAS_PTHREADS} = yes ; then
459 ENDLDLIBS="$ENDLDLIBS -lpthread"
460 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT"
463 AC_CHECK_LIB(c_r, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
464 if test ${HAS_PTHREADS} = yes ; then
465 ENDLDLIBS="$ENDLDLIBS -pthread"
466 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT -pthread"
471 if test ${HAS_PTHREADS} != yes ; then
472 AC_MSG_ERROR(must have pthreads!)
475 dnl ########################################################################
476 dnl check for XPG6 compliant pthreads (timed spinlocks)
478 if test ${HAS_PTHREADS} = yes ; then
479 AC_MSG_CHECKING(if pthread_mutex_timedlock is available)
480 AC_TRY_COMPILE([#include <pthread.h>],
481 [pthread_mutex_timedlock(NULL, NULL);], HAS_PTHREADS_XPG6=yes, HAS_PTHREADS_XPG6=no)
482 if test ${HAS_PTHREADS_XPG6} = yes ; then
484 AC_DEFINE(P_PTHREADS_XPG6, 1, "XPG6 compliant pthreads found")
489 AC_CHECK_LIB(pthread, sem_timedwait, HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
490 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
491 AC_MSG_CHECKING(if sem_timedwait is compilable)
492 AC_TRY_COMPILE([#include <semaphore.h>],
493 [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
494 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
495 AC_DEFINE(P_HAS_SEMAPHORES_XPG6, 1, "Supports XPG6 Semaphores")
503 dnl ########################################################################
504 dnl check for recursive mutexes
505 P_HAS_RECURSIVE_MUTEX=0
506 AC_MSG_CHECKING(if recursive mutexes are available)
507 AC_TRY_COMPILE([#include <pthread.h>],
508 [pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);], P_HAS_RECURSIVE_MUTEX=1)
509 if test ${P_HAS_RECURSIVE_MUTEX} = 1 ; then
514 AC_DEFINE_UNQUOTED(P_HAS_RECURSIVE_MUTEX, ${P_HAS_RECURSIVE_MUTEX})
517 dnl ########################################################################
518 dnl check for regex library
520 dnl yes this test needs to be outside the if below
521 dnl because autoconf needs to initialise stuff. without this
522 dnl all sorts of strange things happen
523 AC_CHECK_HEADERS(regex.h, HAS_REGEX=yes)
525 AC_ARG_ENABLE(internalregex,
526 [ --enable-internalregex force internal regex library],
527 internalregex=$enableval)
528 if test "$internalregex" = "yes" ; then
529 AC_MSG_NOTICE(Forcing use of internal regex library)
531 if test "$HAS_REGEX" = "yes" ; then
532 AC_CHECK_FUNC(regcomp, HAS_REGEX=yes)
533 if test "$HAS_REGEX" = "yes" ; then
534 AC_SUBST(HAS_REGEX, 1)
535 AC_DEFINE(P_REGEX, 1, "Regex library found")
541 dnl ########################################################################
542 dnl check for dynamic library code (dlopen and friends)
544 dnl MSWIN DLL Support,,P_DYNALINK
549 if test ${OSTYPE} = beos ; then
551 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in BeOS")
552 elif test ${OSTYPE} = Darwin ; then
554 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in Darwin")
556 AC_CHECK_HEADERS(dlfcn.h, HAS_DLFCN=yes, HAS_DLFCN=no)
557 if test "$HAS_DLFCN" = yes ; then
558 AC_MSG_CHECKING(if dlopen is available)
559 AC_TRY_COMPILE([#include <dlfcn.h>],
560 [void * p = dlopen("lib", 0);], HAS_DLOPEN=yes, HAS_DLOPEN=no)
561 if test "$HAS_DLOPEN" = no ; then
566 AC_DEFINE(P_DYNALINK, 1, "dlopen found")
567 AC_CHECK_LIB(dl,dlopen,HAS_LIBDL=yes, HAS_LIBDL=no)
572 dnl #########################################################################
573 dnl check to see if plugins enabled
574 dnl MSWIN Plugin Support,,P_HAS_PLUGINS
576 AC_MSG_CHECKING(if plugins support needs to be compiled)
577 AC_ARG_ENABLE(plugins,
578 [ --enable-plugins enable plugins' support in PWLIB],
582 if test "${plugins}" = "no" ; then
584 elif test "${P_DYNALINK:-unset}" = "unset" ; then
585 AC_MSG_RESULT(plugins disabled as dlopen not available)
587 AC_MSG_RESULT(plugins enabled)
589 AC_DEFINE(P_HAS_PLUGINS, 1, "plugins enabled")
592 AC_SUBST(HAS_PLUGINS)
594 if test "x$LIB64" != "x" ; then
595 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib64/pwlib"], [Default plugin directory])
597 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib/pwlib"], [Default plugin directory])
600 dnl ########################################################################
601 dnl look for DNS resolver code (must be done before OpenLDAP)
602 dnl on some systems, the resolver is in libc
603 dnl but needs resolv.h included which defines res_search as __res_search
605 dnl MSWIN_DISPLAY resolver,DNS Resolver
606 dnl MSWIN_CHECK_FILE resolver,include\windns.h,P_DNS=1
607 dnl MSWIN_DIR_SYMBOL resolver,DNS_DIR
608 dnl MSWIN_CHECK_DIR resolver,\Program Files\Microsoft SDK\
610 AC_ARG_ENABLE(resolver,
611 [ --disable-resolver disable DNS resolver support in PWLIB],
614 if test "$resolver" = "no" ; then
617 AC_CHECK_FUNC(res_search, HAVE_RESOLVER=1)
618 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
621 AC_MSG_CHECKING([for res_search in -lresolv])
624 #include <netinet/in.h>
626 int main(int argc,char **argv){
627 res_search (NULL, 0, 0, NULL, 0);
629 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
631 RESOLVER_LIBS="-lresolv"
633 AC_SEARCH_LIBS(__res_search, resolv, HAVE_RESOLVER=1)
637 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
638 AC_DEFINE(P_DNS, 1, "resolver libraries found")
642 dnl ########################################################################
645 dnl MSWIN_DISPLAY sasl,Cyrus SASL
646 dnl MSWIN_CHECK_FILE sasl,include\sasl.h,P_SASL=1
647 dnl MSWIN_DIR_SYMBOL sasl,SASL_DIR
648 dnl MSWIN_CHECK_DIR sasl,..\cyrus-sasl\
649 dnl MSWIN_CHECK_DIR sasl,..\external\cyrus-sasl\
650 dnl MSWIN_CHECK_DIR sasl,\cyrus-sasl\
651 dnl MSWIN_CHECK_DIR sasl,c:\cyrus-sasl\
654 [ --disable-sasl disable SASL support in PWLIB],
657 if test "$sasl" = "no" ; then
658 AC_MSG_NOTICE(SASL disabled)
661 dnl Not all Unices have SASL installed as a separate library (Solaris)
662 AC_CHECK_LIB(sasl2, sasl_version, HAS_SASL2=1, HAS_SASL2=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
663 if test "${HAS_SASL2}x" = "x" ; then
664 dnl Some older Linux boxes have libsasl instead of libsasl2
665 AC_CHECK_LIB(sasl, sasl_client_auth, HAS_SASL=1, HAS_SASL=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
668 dnl we need to track down the correct sasl.h
669 AC_MSG_CHECKING([if <sasl.h> works])
670 AC_COMPILE_IFELSE([[#include <sasl.h>
671 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],HAS_INCLUDE_SASL_H=1)
672 if test "${HAS_INCLUDE_SASL_H}x" != "x" ; then
677 AC_MSG_CHECKING([if <sasl/sasl.h> works])
678 AC_COMPILE_IFELSE([[#include <sasl/sasl.h>
679 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],P_HAS_SASL_SASL_H=1)
680 if test "${P_HAS_SASL_SASL_H}x" != "x" ; then
683 AC_DEFINE(P_HAS_SASL_SASL_H)
689 if test "${HAS_SASL2}x" != "x" ; then
691 ENDLDLIBS="$ENDLDLIBS -lsasl2"
693 AC_SUBST(HAS_SASL2, 1)
694 elif test "${HAS_SASL}x" != "x" ; then
696 ENDLDLIBS="$ENDLDLIBS -lsasl"
698 AC_SUBST(HAS_SASL, 1)
705 dnl ########################################################################
706 dnl look for OpenLDAP (requires SASL)
708 dnl MSWIN_DISPLAY openldap,Open LDAP
709 dnl MSWIN_CHECK_FILE openldap,include\ldap.h|OpenLDAP,P_LDAP=1
710 dnl MSWIN_DIR_SYMBOL openldap,LDAP_DIR
711 dnl MSWIN_CHECK_DIR openldap,..\openldap\
712 dnl MSWIN_CHECK_DIR openldap,..\external\openldap\
713 dnl MSWIN_CHECK_DIR openldap,\openldap\
714 dnl MSWIN_CHECK_DIR openldap,c:\openldap\
716 AC_ARG_ENABLE(openldap,
717 [ --disable-openldap disable OpenLDAP support in PWLIB],
720 if test "$openldap" = "no" ; then
721 AC_SUBST(HAS_OPENLDAP, 0)
724 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
725 AC_CHECK_HEADERS(ldap.h, HAS_OPENLDAP=1)
727 dnl posix4 is required by libldap_r on Solaris
728 if test "${OSTYPE:-unknown}" = "solaris"; then
729 OPENLDAPSYSLIBS=-lposix4
732 dnl check also for lldap_r presence (required for thread safe OpenLDAP?)
733 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
734 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
736 AC_CHECK_FILE(/usr/local/include/ldap.h, HAS_OPENLDAP=1)
737 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
738 OPENLDAPINCLUDEDIR=/usr/local/include
739 OPENLDAPLIBDIR=/usr/local/lib
740 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-L/usr/local/lib -llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
745 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
746 AC_SUBST(HAS_OPENLDAP, 1)
747 AC_DEFINE(P_LDAP, 1, "OpenLDAP found")
748 ENDLDLIBS="-lldap -lldap_r -llber $ENDLDLIBS"
749 if test "${OPENLDAPINCLUDEDIR}unset" != "unset" ; then
750 STDCCFLAGS="$STDCCFLAGS -I${OPENLDAPINCLUDEDIR}"
752 if test "${OPENLDAPLIBDIR}unset" != "unset" ; then
753 LDFLAGS="$LDFLAGS -L${OPENLDAPLIBDIR}"
759 dnl ########################################################################
761 dnl check for environment variable, then assume standard system install
762 dnl this process is made incredibly more complex by the fact that RedHad 9
763 dnl is completely fscked. The default OpenSSL installation requires Kerberos,
764 dnl even when Kerberos is not installed, requiring an explicit #define to
766 dnl As if that is not enough, autoconf gets very confused if configure.in
767 dnl contains a AC_CHECK_HEADER directive that never gets used. So we have
768 dnl to ensure that it is always called
770 dnl MSWIN_DISPLAY openssl,Open SSL
771 dnl MSWIN_CHECK_FILE openssl,inc32\openssl\ssl.h,P_SSL=1
772 dnl MSWIN_DIR_SYMBOL openssl,SSL_DIR
773 dnl MSWIN_CHECK_DIR openssl,..\openssl\
774 dnl MSWIN_CHECK_DIR openssl,..\external\openssl\
775 dnl MSWIN_CHECK_DIR openssl,\openssl\
776 dnl MSWIN_CHECK_DIR openssl,c:\openssl\
778 AC_ARG_ENABLE(openssl,
779 [ --disable-openssl disable OpenSSL support in PWLIB],
782 if test "$openssl" = "no" ; then
784 AC_SUBST(HAS_OPENSSL, 0)
787 dnl check to see OPENSSLDIR is set
788 dnl if it is, we assume it correct - no further checking required
789 if test ${OPENSSLDIR:-unset} != "unset" ; then
790 AC_MSG_CHECKING([for ${OPENSSLDIR}/include/openssl/ssl.h])
791 if test -e ${OPENSSLDIR}/include/openssl/ssl.h ; then
794 SSLINCLUDEDIR="${OPENSSLDIR}/include"
795 SSLLIBDIR="${OPENSSLDIR}/lib"
802 dnl if OPENSSLDIR is not set, then check to see if OpenSSL
803 dnl is installed in the standard system dirs. And also see if
804 dnl if it works using crazy RedHat checks
805 if test "${SSLHDR:-unset}" = "unset" ; then
806 AC_CHECK_HEADERS(openssl/ssl.h,SSLHDR=1)
807 if test "${SSLHDR:-unset}" != "unset" ; then
808 AC_MSG_CHECKING([if openssl/ssl.h works with OPENSSL_NO_KRB5])
809 AC_COMPILE_IFELSE([[#define OPENSSL_NO_KRB5
810 #include <openssl/ssl.h>
811 int main(int argc,char **argv){}]],SSLHDR=1)
812 if test ${SSLHDR:-unset} != "unset" ; then
814 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
815 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
816 if test ${OSTYPE} = linux ; then
817 dnl Linux static libs
818 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
826 dnl if we have not found OpenSSL so far, then look for it in
827 dnl several standard places, and check for crazy RedHat install too
828 if test "${SSLHDR:-unset}" = "unset" ; then
830 for openssl_dir in /usr/local/openssl /usr/local/ssl ; do
831 AC_MSG_CHECKING([for OpenSSL in $openssl_dir])
832 if test ! -f ${openssl_dir}/include/openssl/ssl.h ; then
835 AC_LANG_CONFTEST([[#include "${openssl_dir}/include/openssl/ssl.h"
836 int main(int argc,char **argv){ return 0; }]])
837 $CXX $CXXFLAGS -I${openssl_dir}/include -c conftest.cc > /dev/null 2>&1
838 if test $? = 0 ; then
842 SSLINCLUDEDIR="${openssl_dir}/include"
843 SSLLIBDIR="${openssl_dir}/lib"
847 AC_MSG_CHECKING([if ${openssl_dir}/include/openssl/ssl.h works with OPENSSL_NO_KRB5...])
848 AC_LANG_CONFTEST([[#define OPENSSL_NO_KRB5
849 #include "${openssl_dir}/include/openssl/ssl.h"
850 int main(int argc,char **argv){}]])
851 $CXX $CXXFLAGS -I${openssl_dir}/openssl/include -c conftest.cc > /dev/null 2>&1
852 if test $? = 0 ; then
855 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
856 SSLINCLUDEDIR="${openssl_dir}/include"
857 SSLLIBDIR="${openssl_dir}/lib"
858 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
859 if test ${OSTYPE} = linux ; then
860 dnl Linux static libs
861 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
872 if test ${SSLHDR:-unset} != "unset" ; then
873 AC_SUBST(HAS_OPENSSL, 1)
874 AC_DEFINE(P_SSL, 1, "OpenSSL found")
875 if test ${SSLINCLUDEDIR:-unset} != "unset" ; then
876 STDCCFLAGS="$STDCCFLAGS -I${SSLINCLUDEDIR}"
878 if test ${SSLLIBDIR:-unset} != "unset" ; then
879 LDFLAGS="$LDFLAGS -L${SSLLIBDIR}"
881 STDCCFLAGS="${STDCCFLAGS}${SSLCCFLAGS}"
882 ENDLDLIBS="$ENDLDLIBS -lssl -lcrypto"
886 AC_SUBST(P_STATIC_ENDLDLIBS)
887 AC_SUBST(P_STATIC_LDFLAGS)
889 dnl ########################################################################
890 dnl look for expat XML parser
892 dnl MSWIN_DISPLAY expat,Expat XML
893 dnl MSWIN_CHECK_FILE expat,lib\expat.h,P_EXPAT=1
894 dnl MSWIN_DIR_SYMBOL expat,EXPAT_DIR
895 dnl MSWIN_CHECK_DIR expat,..\expat\
896 dnl MSWIN_CHECK_DIR expat,..\external\expat\
897 dnl MSWIN_CHECK_DIR expat,\expat
898 dnl MSWIN_CHECK_DIR expat,c:\expat\
901 [ --disable-expat disable XML support in PWLIB],
904 if test "$expat" = "no" ; then
905 AC_SUBST(HAS_EXPAT, 0)
906 AC_DEFINE(P_EXPAT, 0)
909 AC_CHECK_HEADERS(expat.h, HAS_EXPAT=1)
910 if test "${HAS_EXPAT:-unset}" != "unset" ; then
911 AC_CHECK_LIB(expat, XML_ParserCreate, HAS_EXPAT=1, HAS_EXPAT=)
913 AC_CHECK_FILE(/usr/local/include/expat.h, HAS_EXPAT=1)
914 if test "${HAS_EXPAT:-unset}" != "unset" ; then
915 EXPATINCLUDEDIR=/usr/local/include
916 EXPATLIBDIR=/usr/local/lib
920 if test "${HAS_EXPAT:-unset}" != "unset" ; then
921 AC_SUBST(HAS_EXPAT, 1)
922 AC_DEFINE(P_EXPAT, 1, "expat found")
923 if test ${EXPATINCLUDEDIR:-unset} != "unset" ; then
924 STDCCFLAGS="$STDCCFLAGS -I${EXPATINCLUDEDIR}"
926 if test ${EXPATLIBDIR:-unset} != "unset" ; then
927 LDFLAGS="$LDFLAGS -L${EXPATLIBDIR}"
929 ENDLDLIBS="$ENDLDLIBS -lexpat"
934 dnl ########################################################################
937 dnl MSWIN_DISPLAY sapi,Speech API
938 dnl MSWIN_CHECK_FILE sapi,include\sphelper.h,P_SAPI=1
939 dnl MSWIN_DIR_SYMBOL sapi,SAPI_DIR
940 dnl MSWIN_CHECK_DIR sapi,\Program Files\Microsoft Speech SDK 5.1\
943 dnl ########################################################################
944 dnl look for IPV6 functions
946 dnl MSWIN_DISPLAY ipv6,IPv6 Support
947 dnl MSWIN_CHECK_FILE ipv6,ws2tcpip.h|sin6_scope_id,P_HAS_IPV6=1
948 dnl MSWIN_DIR_SYMBOL ipv6,IPV6_DIR
949 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft Visual Studio\VC98\Include\
950 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft SDK\include\
953 [ --disable-ipv6 disable IPV6 support in PWLIB],
956 if test "$ipv6" = "no" ; then
957 AC_DEFINE(P_HAS_IPV6, 0)
958 AC_SUBST(HAS_IPV6, 0)
960 AC_MSG_CHECKING(for IPv6 support)
961 AC_TRY_COMPILE([#include <sys/types.h>
962 #include <netinet/in.h>],
963 [struct sockaddr_in6 s; s.sin6_scope_id = 0;], HAS_IPV6=yes, HAS_IPV6=no)
964 if test $HAS_IPV6 = no ; then
967 AC_TRY_COMPILE([#include <sys/socket.h>
969 [getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);], HAS_IPV6=yes, HAS_IPV6=no)
970 if test $HAS_IPV6 = no ; then
974 AC_DEFINE(P_HAS_IPV6, 1, "IPV6 enabled")
979 dnl ########################################################################
980 dnl look for QoS functions
982 dnl MSWIN_DISPLAY qos,QoS Support
983 dnl MSWIN_CHECK_FILE qos,qossp.h|QOS_DESTADDR,P_HAS_QOS=1
984 dnl MSWIN_DIR_SYMBOL qos,QOS_DIR
985 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft Visual Studio\VC98\Include\
986 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft SDK\include\
989 [ --disable-qos disable QOS support in PWLIB],
992 if test "$qos" = "no" ; then
993 AC_DEFINE([P_HAS_QOS], [0], [No QOS])
995 AC_DEFINE([P_HAS_QOS], [1], [Have QOS])
999 dnl ########################################################################
1000 dnl look for SDL, but only if we have pthreads
1002 dnl MSWIN_DISPLAY libsdl,Simple DirectMedia Layer
1003 dnl MSWIN_CHECK_FILE libsdl,include\SDL_video.h,P_SDL=1
1004 dnl MSWIN_CHECK_FILE libsdl,lib\SDL.lib,P_SDL_LIBDIR="lib"
1005 dnl MSWIN_DIR_SYMBOL libsdl,SDL_DIR
1006 dnl MSWIN_CHECK_DIR libsdl,..\sdl\
1007 dnl MSWIN_CHECK_DIR libsdl,..\external\sdl\
1008 dnl MSWIN_CHECK_DIR libsdl,\sdl\
1009 dnl MSWIN_CHECK_DIR libsdl,c:\sdl\
1012 [ --disable-sdl disable SDL support in PWLIB],
1015 if test "$sdl" = "no" ; then
1016 AC_SUBST(HAS_SDL, 0)
1020 if test "${SDLLIB:-unset}" = "unset" ; then
1025 AC_CHECK_HEADERS(SDL/SDL.h, HAS_SDL=1)
1026 if test "${HAS_SDL:-unset}" != "unset" ; then
1027 if test "${X11LIBDIR:-unset}" == "unset" ; then
1028 X11LIBDIR=/usr/X11R6/lib
1030 AC_CHECK_LIB(SDL, SDL_CreateYUVOverlay, HAS_SDL=1, HAS_SDL=, -L${X11LIBDIR} -lpthread -lX11 -lXext -laa)
1033 dnl freeBSD SDL check
1034 if test "${HAS_SDL:-unset}" = "unset" ; then
1035 AC_CHECK_FILE(/usr/local/include/SDL11/SDL.h, HAS_SDL=1)
1036 if test "${HAS_SDL:-unset}" != "unset" ; then
1041 if test "${HAS_SDL:-unset}" != "unset" ; then
1042 AC_SUBST(HAS_SDL, 1)
1043 AC_DEFINE(P_SDL, 1, "SDL found")
1044 if test ${SDLINCLUDEDIR:-unset} != "unset" ; then
1045 STDCCFLAGS="$STDCCFLAGS -I${SDLINCLUDEDIR}"
1047 if test ${SDLLIBDIR:-unset} != "unset" ; then
1048 LDFLAGS="$LDFLAGS -L${SDLLIBDIR}"
1050 ENDLDLIBS="$ENDLDLIBS -l${SDLLIB}"
1055 dnl ########################################################################
1056 dnl check for video capture support.
1057 dnl videodev.h on linux
1058 dnl machine/ioctl_meteor on FreeBSD
1059 dnl i386/ioctl_meteor on OpenBSD
1060 dnl dev/ic/bt8xx on NetBSD
1062 AC_ARG_ENABLE(video,
1063 [ --disable-video disable non-plugin video device support in PWLIB],
1067 if test "$HAS_PLUGINS" = "0" ; then
1068 if test "$video" != "no" ; then
1069 AC_CHECK_HEADER(linux/videodev.h, HAS_VIDEO_CAPTURE=1)
1070 dnl AC_CHECK_HEADER(machine/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1071 dnl AC_CHECK_HEADER(i386/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1072 dnl AC_CHECK_HEADER(dev/ic/bt8xx.h, HAS_VIDEO_CAPTURE=1)
1073 if test "${HAS_VIDEO_CAPTURE}" = "0" ; then
1074 AC_MSG_NOTICE(No Video Capture support)
1075 AC_DEFINE([NO_VIDEO_CAPTURE], [], [No video capture])
1079 AC_SUBST(HAS_VIDEO_CAPTURE)
1081 dnl ########################################################################
1082 dnl check for various functions
1083 AC_ARG_ENABLE(alsa, [ --enable-alsa disable non-plugin ALSA audio support],enable_alsa=$enableval)
1086 if test "$HAS_PLUGINS" = "0" ; then
1087 if test "$enable_alsa" != "no" ; then
1088 AC_CHECK_HEADER(alsa/asoundlib.h, HAS_ALSA=1)
1089 AC_MSG_CHECKING(for ALSA sound support)
1090 if test "${HAS_ALSA}" = "1"; then
1092 ENDLDLIBS="$ENDLDLIBS -lasound"
1100 dnl ########################################################################
1101 dnl check for various functions
1102 dnl According to Andre Schulze <as8@rncmm2.urz.tu-dresden.de>
1103 dnl Solaris swab should not be used
1104 if test "$OSTYPE" = "solaris" ; then
1107 AC_CHECK_FUNC(swab,USE_SYSTEM_SWAB=1)
1109 if test "x$ac_cv_func_swab" = "xyes" ; then
1110 AC_DEFINE([USE_SYSTEM_SWAB], [], [Use system swab()])
1113 dnl ########################################################################
1114 dnl look for MEMORY_CHECK enabled.
1116 AC_ARG_ENABLE(memcheck,
1117 [ --enable-memcheck enable leak testing code (off by default)],
1118 memcheck=$enableval)
1120 if test "$memcheck" = "yes" ; then
1121 AC_DEFINE(PMEMORY_CHECK, 1)
1122 AC_MSG_NOTICE(Memory checking enabled)
1126 dnl ########################################################################
1127 dnl output make directives
1129 dnl resolver needs to be at the end
1130 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
1131 if test "${RESOLVER_LIBS:-unset}" != "unset" ; then
1132 ENDLDLIBS="$ENDLDLIBS $RESOLVER_LIBS"
1136 dnl dl needs to be at the end
1137 if test "${OSTYPE}" != "Darwin" ; then
1138 if test ${HAS_LIBDL} = yes ; then
1139 ENDLDLIBS="$ENDLDLIBS -ldl"
1143 AC_SUBST(STDCCFLAGS)
1144 AC_SUBST(STDCXXFLAGS)
1145 AC_SUBST(OPTSTDCCFLAGS)
1150 AC_CONFIG_FILES(make/ptbuildopts.mak)
1151 AC_CONFIG_FILES([make/ptlib-config], [chmod a+x make/ptlib-config])
1152 AC_CONFIG_FILES(Makefile)
1154 dnl ########################################################################
1155 dnl output header file
1156 #AC_CONFIG_FILES(include/ptbuildopts.h.in)
1157 AC_CONFIG_HEADERS(include/ptbuildopts.h)