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 Unix semaphores
409 dnl posix semaphore support in darwin/macosx is broken
410 if test ${OSTYPE} != Darwin ; then
411 AC_TRY_COMPILE([#include <semaphore.h>],
412 [sem_t *s; sem_init(s, 0, 0);], P_HAS_SEMAPHORES=1)
413 AC_MSG_CHECKING(if Unix semaphores are available)
414 if test "${P_HAS_SEMAPHORES}x" != "x" ; then
415 AC_DEFINE(P_HAS_SEMAPHORES)
419 AC_MSG_WARN(This host does not support semaphores which are essential)
420 AC_MSG_WARN(to implement 'critical sections'. This feature was added)
421 AC_MSG_WARN(in PWLib 1.7.0 and improves the stability of multithreaded)
422 AC_MSG_WARN(programs. This feature has been disabled for this host)
426 dnl ########################################################################
427 dnl check for pthreads library
429 dnl MSWIN_DISPLAY semaphore,Semaphore Support
430 dnl MSWIN_DEFINE semaphore,P_HAS_SEMAPHORES
432 dnl Linux, Mac OS X use libpthread and -lpthread
433 dnl FreeBSD uses the -pthread compiler option and uses libc_r
435 AC_CHECK_LIB(pthread, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
436 if test ${HAS_PTHREADS} = yes ; then
437 ENDLDLIBS="$ENDLDLIBS -lpthread"
438 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT"
441 AC_CHECK_LIB(c_r, pthread_create, HAS_PTHREADS=yes, HAS_PTHREADS=no)
442 if test ${HAS_PTHREADS} = yes ; then
443 ENDLDLIBS="$ENDLDLIBS -pthread"
444 STDCCFLAGS="$STDCCFLAGS -D_REENTRANT -pthread"
449 if test ${HAS_PTHREADS} != yes ; then
450 AC_MSG_ERROR(must have pthreads!)
453 dnl ########################################################################
454 dnl check for XPG6 compliant pthreads (timed spinlocks)
456 if test ${HAS_PTHREADS} = yes ; then
457 AC_CHECK_LIB(pthread, pthread_mutex_timedlock, HAS_PTHREADS_XPG6=yes, HAS_PTHREADS_XPG6=no)
458 if test ${HAS_PTHREADS_XPG6} = yes ; then
459 AC_DEFINE(P_PTHREADS_XPG6, 1, "XPG6 compliant pthreads found")
462 AC_CHECK_LIB(pthread, sem_timedwait, HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
463 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
464 AC_MSG_CHECKING(if sem_timedwait is compilable)
465 AC_TRY_COMPILE([#include <semaphore.h>],
466 [sem_t *s; const struct timespec * t; sem_timedwait(s, t);], HAS_SEMAPHORES_XPG6=yes, HAS_SEMAPHORES_XPG6=no)
467 if test ${HAS_SEMAPHORES_XPG6} = yes ; then
468 AC_DEFINE(P_HAS_SEMAPHORES_XPG6, 1, "Supports XPG6 Semaphores")
476 dnl ########################################################################
477 dnl check for recursive mutexes
478 P_HAS_RECURSIVE_MUTEX=0
479 AC_MSG_CHECKING(if recursive mutexes are available)
480 AC_TRY_COMPILE([#include <pthread.h>],
481 [pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);], P_HAS_RECURSIVE_MUTEX=1)
482 if test ${P_HAS_RECURSIVE_MUTEX} = 1 ; then
487 AC_DEFINE_UNQUOTED(P_HAS_RECURSIVE_MUTEX, ${P_HAS_RECURSIVE_MUTEX})
490 dnl ########################################################################
491 dnl check for regex library
493 dnl yes this test needs to be outside the if below
494 dnl because autoconf needs to initialise stuff. without this
495 dnl all sorts of strange things happen
496 AC_CHECK_HEADERS(regex.h, HAS_REGEX=yes)
498 AC_ARG_ENABLE(internalregex,
499 [ --enable-internalregex force internal regex library],
500 internalregex=$enableval)
501 if test "$internalregex" = "yes" ; then
502 AC_MSG_NOTICE(Forcing use of internal regex library)
504 if test "$HAS_REGEX" = "yes" ; then
505 AC_CHECK_FUNC(regcomp, HAS_REGEX=yes)
506 if test "$HAS_REGEX" = "yes" ; then
507 AC_SUBST(HAS_REGEX, 1)
508 AC_DEFINE(P_REGEX, 1, "Regex library found")
514 dnl ########################################################################
515 dnl check for dynamic library code (dlopen and friends)
517 dnl MSWIN DLL Support,,P_DYNALINK
522 if test ${OSTYPE} = beos ; then
524 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in BeOS")
525 elif test ${OSTYPE} = Darwin ; then
527 AC_DEFINE(P_DYNALINK, 1, "dlopen implemented inside pwlib in Darwin")
529 AC_CHECK_HEADERS(dlfcn.h, HAS_DLFCN=yes, HAS_DLFCN=no)
530 if test "$HAS_DLFCN" = yes ; then
531 AC_MSG_CHECKING(if dlopen is available)
532 AC_TRY_COMPILE([#include <dlfcn.h>],
533 [void * p = dlopen("lib", 0);], HAS_DLOPEN=yes, HAS_DLOPEN=no)
534 if test "$HAS_DLOPEN" = no ; then
539 AC_DEFINE(P_DYNALINK, 1, "dlopen found")
540 AC_CHECK_LIB(dl,dlopen,HAS_LIBDL=yes, HAS_LIBDL=no)
545 dnl #########################################################################
546 dnl check to see if plugins enabled
547 dnl MSWIN Plugin Support,,P_HAS_PLUGINS
549 AC_MSG_CHECKING(if plugins support needs to be compiled)
550 AC_ARG_ENABLE(plugins,
551 [ --enable-plugins enable plugins' support in PWLIB],
555 if test "${plugins}" = "no" ; then
557 elif test "${P_DYNALINK:-unset}" = "unset" ; then
558 AC_MSG_RESULT(plugins disabled as dlopen not available)
560 AC_MSG_RESULT(plugins enabled)
562 AC_DEFINE(P_HAS_PLUGINS, 1, "plugins enabled")
565 AC_SUBST(HAS_PLUGINS)
567 if test "x$LIB64" != "x" ; then
568 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib64/pwlib"], [Default plugin directory])
570 AC_DEFINE_UNQUOTED([P_DEFAULT_PLUGIN_DIR], ["${INSTALLPREFIX}/lib/pwlib"], [Default plugin directory])
573 dnl ########################################################################
574 dnl look for DNS resolver code (must be done before OpenLDAP)
575 dnl on some systems, the resolver is in libc
576 dnl but needs resolv.h included which defines res_search as __res_search
578 dnl MSWIN_DISPLAY resolver,DNS Resolver
579 dnl MSWIN_CHECK_FILE resolver,include\windns.h,P_DNS=1
580 dnl MSWIN_DIR_SYMBOL resolver,DNS_DIR
581 dnl MSWIN_CHECK_DIR resolver,\Program Files\Microsoft SDK\
583 AC_ARG_ENABLE(resolver,
584 [ --disable-resolver disable DNS resolver support in PWLIB],
587 if test "$resolver" = "no" ; then
590 AC_CHECK_FUNC(res_search, HAVE_RESOLVER=1)
591 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
594 AC_MSG_CHECKING([for res_search in -lresolv])
597 #include <netinet/in.h>
599 int main(int argc,char **argv){
600 res_search (NULL, 0, 0, NULL, 0);
602 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
604 RESOLVER_LIBS="-lresolv"
606 AC_SEARCH_LIBS(__res_search, resolv, HAVE_RESOLVER=1)
610 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
611 AC_DEFINE(P_DNS, 1, "resolver libraries found")
615 dnl ########################################################################
618 dnl MSWIN_DISPLAY sasl,Cyrus SASL
619 dnl MSWIN_CHECK_FILE sasl,include\sasl.h,P_SASL=1
620 dnl MSWIN_DIR_SYMBOL sasl,SASL_DIR
621 dnl MSWIN_CHECK_DIR sasl,\cyrus-sasl\
624 [ --disable-sasl disable SASL support in PWLIB],
627 if test "$sasl" = "no" ; then
628 AC_MSG_NOTICE(SASL disabled)
631 dnl Not all Unices have SASL installed as a separate library (Solaris)
632 AC_CHECK_LIB(sasl2, sasl_version, HAS_SASL2=1, HAS_SASL2=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
633 if test "${HAS_SASL2}x" = "x" ; then
634 dnl Some older Linux boxes have libsasl instead of libsasl2
635 AC_CHECK_LIB(sasl, sasl_client_auth, HAS_SASL=1, HAS_SASL=,$LDFLAGS -llber -lldap -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENDLAPSYSLIBS)
638 dnl we need to track down the correct sasl.h
639 AC_MSG_CHECKING([if <sasl.h> works])
640 AC_COMPILE_IFELSE([[#include <sasl.h>
641 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],HAS_INCLUDE_SASL_H=1)
642 if test "${HAS_INCLUDE_SASL_H}x" != "x" ; then
647 AC_MSG_CHECKING([if <sasl/sasl.h> works])
648 AC_COMPILE_IFELSE([[#include <sasl/sasl.h>
649 int main(int argc,char **argv){ int v = SASL_LOG_PASS; }]],P_HAS_SASL_SASL_H=1)
650 if test "${P_HAS_SASL_SASL_H}x" != "x" ; then
653 AC_DEFINE(P_HAS_SASL_SASL_H)
659 if test "${HAS_SASL2}x" != "x" ; then
661 ENDLDLIBS="$ENDLDLIBS -lsasl2"
663 AC_SUBST(HAS_SASL2, 1)
664 elif test "${HAS_SASL}x" != "x" ; then
666 ENDLDLIBS="$ENDLDLIBS -lsasl"
668 AC_SUBST(HAS_SASL, 1)
675 dnl ########################################################################
676 dnl look for OpenLDAP (requires SASL)
678 dnl MSWIN_DISPLAY openldap,Open LDAP
679 dnl MSWIN_CHECK_FILE openldap,include\ldap.h|OpenLDAP,P_LDAP=1
680 dnl MSWIN_DIR_SYMBOL openldap,LDAP_DIR
681 dnl MSWIN_CHECK_DIR openldap,..\openldap\
682 dnl MSWIN_CHECK_DIR openldap,..\external\openldap\
683 dnl MSWIN_CHECK_DIR openldap,\openldap\
684 dnl MSWIN_CHECK_DIR openldap,c:\openldap\
686 AC_ARG_ENABLE(openldap,
687 [ --disable-openldap disable OpenLDAP support in PWLIB],
690 if test "$openldap" = "no" ; then
691 AC_SUBST(HAS_OPENLDAP, 0)
694 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
695 AC_CHECK_HEADERS(ldap.h, HAS_OPENLDAP=1)
697 dnl posix4 is required by libldap_r on Solaris
698 if test "${OSTYPE:-unknown}" = "solaris"; then
699 OPENLDAPSYSLIBS=-lposix4
702 dnl check also for lldap_r presence (required for thread safe OpenLDAP?)
703 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
704 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
706 AC_CHECK_FILE(/usr/local/include/ldap.h, HAS_OPENLDAP=1)
707 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
708 OPENLDAPINCLUDEDIR=/usr/local/include
709 OPENLDAPLIBDIR=/usr/local/lib
710 AC_CHECK_LIB(ldap, ldap_open, HAS_OPENLDAP=1, HAS_OPENLDAP=,-L/usr/local/lib -llber -lldap_r $RESOLVER_LIBS $ENDLDLIBS $OPENLDAPSYSLIBS)
715 if test "${HAS_OPENLDAP:-unset}" != "unset" ; then
716 AC_SUBST(HAS_OPENLDAP, 1)
717 AC_DEFINE(P_LDAP, 1, "OpenLDAP found")
718 ENDLDLIBS="-lldap -lldap_r -llber $ENDLDLIBS"
719 if test "${OPENLDAPINCLUDEDIR}unset" != "unset" ; then
720 STDCCFLAGS="$STDCCFLAGS -I${OPENLDAPINCLUDEDIR}"
722 if test "${OPENLDAPLIBDIR}unset" != "unset" ; then
723 LDFLAGS="$LDFLAGS -L${OPENLDAPLIBDIR}"
729 dnl ########################################################################
731 dnl check for environment variable, then assume standard system install
732 dnl this process is made incredibly more complex by the fact that RedHad 9
733 dnl is completely fscked. The default OpenSSL installation requires Kerberos,
734 dnl even when Kerberos is not installed, requiring an explicit #define to
736 dnl As if that is not enough, autoconf gets very confused if configure.in
737 dnl contains a AC_CHECK_HEADER directive that never gets used. So we have
738 dnl to ensure that it is always called
740 dnl MSWIN_DISPLAY openssl,Open SSL
741 dnl MSWIN_CHECK_FILE openssl,inc32\openssl\ssl.h,P_SSL=1
742 dnl MSWIN_DIR_SYMBOL openssl,SSL_DIR
743 dnl MSWIN_CHECK_DIR openssl,..\openssl\
744 dnl MSWIN_CHECK_DIR openssl,..\external\openssl\
745 dnl MSWIN_CHECK_DIR openssl,\openssl\
746 dnl MSWIN_CHECK_DIR openssl,c:\openssl\
748 AC_ARG_ENABLE(openssl,
749 [ --disable-openssl disable OpenSSL support in PWLIB],
752 if test "$openssl" = "no" ; then
754 AC_SUBST(HAS_OPENSSL, 0)
757 dnl check to see OPENSSLDIR is set
758 dnl if it is, we assume it correct - no further checking required
759 if test ${OPENSSLDIR:-unset} != "unset" ; then
760 AC_MSG_CHECKING([for ${OPENSSLDIR}/include/openssl/ssl.h])
761 if test -e ${OPENSSLDIR}/include/openssl/ssl.h ; then
764 SSLINCLUDEDIR="${OPENSSLDIR}/include"
765 SSLLIBDIR="${OPENSSLDIR}/lib"
772 dnl if OPENSSLDIR is not set, then check to see if OpenSSL
773 dnl is installed in the standard system dirs. And also see if
774 dnl if it works using crazy RedHat checks
775 if test "${SSLHDR:-unset}" = "unset" ; then
776 AC_CHECK_HEADERS(openssl/ssl.h,SSLHDR=1)
777 if test "${SSLHDR:-unset}" = "unset" ; then
778 AC_MSG_CHECKING([if openssl/ssl.h works with OPENSSL_NO_KRB5])
779 AC_COMPILE_IFELSE([[#define OPENSSL_NO_KRB5
780 #include <openssl/ssl.h>
781 int main(int argc,char **argv){}]],SSLHDR=1)
782 if test ${SSLHDR:-unset} != "unset" ; then
784 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
785 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
786 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
793 dnl if we have not found OpenSSL so far, then look for it in
794 dnl several standard places, and check for crazy RedHat install too
795 if test "${SSLHDR:-unset}" = "unset" ; then
797 for openssl_dir in /usr/local/openssl /usr/local/ssl ; do
798 AC_MSG_CHECKING([for OpenSSL in $openssl_dir])
799 if test ! -f ${openssl_dir}/include/openssl/ssl.h ; then
802 AC_LANG_CONFTEST([[#include "${openssl_dir}/include/openssl/ssl.h"
803 int main(int argc,char **argv){ return 0; }]])
804 $CXX $CXXFLAGS -I${openssl_dir}/include -c conftest.cc > /dev/null 2>&1
805 if test $? = 0 ; then
809 SSLINCLUDEDIR="${openssl_dir}/include"
810 SSLLIBDIR="${openssl_dir}/lib"
814 AC_MSG_CHECKING([if ${openssl_dir}/include/openssl/ssl.h works with OPENSSL_NO_KRB5...])
815 AC_LANG_CONFTEST([[#define OPENSSL_NO_KRB5
816 #include "${openssl_dir}/include/openssl/ssl.h"
817 int main(int argc,char **argv){}]])
818 $CXX $CXXFLAGS -I${openssl_dir}/openssl/include -c conftest.cc > /dev/null 2>&1
819 if test $? = 0 ; then
822 SSLCCFLAGS=" -DOPENSSL_NO_KRB5"
823 SSLINCLUDEDIR="${openssl_dir}/include"
824 SSLLIBDIR="${openssl_dir}/lib"
825 P_STATIC_LDFLAGS="$P_STATIC_LDFLAGS -L/usr/kerberos/lib"
826 P_STATIC_ENDLDLIBS="-lkrb5 -lk5crypto -lcom_err"
836 if test ${SSLHDR:-unset} != "unset" ; then
837 AC_SUBST(HAS_OPENSSL, 1)
838 AC_DEFINE(P_SSL, 1, "OpenSSL found")
839 if test ${SSLINCLUDEDIR:-unset} != "unset" ; then
840 STDCCFLAGS="$STDCCFLAGS -I${SSLINCLUDEDIR}"
842 if test ${SSLLIBDIR:-unset} != "unset" ; then
843 LDFLAGS="$LDFLAGS -L${SSLLIBDIR}"
845 STDCCFLAGS="${STDCCFLAGS}${SSLCCFLAGS}"
846 ENDLDLIBS="$ENDLDLIBS -lssl -lcrypto"
850 AC_SUBST(P_STATIC_ENDLDLIBS)
851 AC_SUBST(P_STATIC_LDFLAGS)
853 dnl ########################################################################
854 dnl look for expat XML parser
856 dnl MSWIN_DISPLAY expat,Expat XML
857 dnl MSWIN_CHECK_FILE expat,lib\expat.h,P_EXPAT=1
858 dnl MSWIN_DIR_SYMBOL expat,EXPAT_DIR
859 dnl MSWIN_CHECK_DIR expat,..\expat\
860 dnl MSWIN_CHECK_DIR expat,..\external\expat\
861 dnl MSWIN_CHECK_DIR expat,\expat
862 dnl MSWIN_CHECK_DIR expat,c:\expat\
865 [ --disable-expat disable XML support in PWLIB],
868 if test "$expat" = "no" ; then
869 AC_SUBST(HAS_EXPAT, 0)
870 AC_DEFINE(P_EXPAT, 0)
873 AC_CHECK_HEADERS(expat.h, HAS_EXPAT=1)
874 if test "${HAS_EXPAT:-unset}" != "unset" ; then
875 AC_CHECK_LIB(expat, XML_ParserCreate, HAS_EXPAT=1, HAS_EXPAT=)
877 AC_CHECK_FILE(/usr/local/include/expat.h, HAS_EXPAT=1)
878 if test "${HAS_EXPAT:-unset}" != "unset" ; then
879 EXPATINCLUDEDIR=/usr/local/include
880 EXPATLIBDIR=/usr/local/lib
884 if test "${HAS_EXPAT:-unset}" != "unset" ; then
885 AC_SUBST(HAS_EXPAT, 1)
886 AC_DEFINE(P_EXPAT, 1, "expat found")
887 if test ${EXPATINCLUDEDIR:-unset} != "unset" ; then
888 STDCCFLAGS="$STDCCFLAGS -I${EXPATINCLUDEDIR}"
890 if test ${EXPATLIBDIR:-unset} != "unset" ; then
891 LDFLAGS="$LDFLAGS -L${EXPATLIBDIR}"
893 ENDLDLIBS="$ENDLDLIBS -lexpat"
898 dnl ########################################################################
901 dnl MSWIN_DISPLAY sapi,Speech API
902 dnl MSWIN_CHECK_FILE sapi,include\sphelper.h,P_SAPI=1
903 dnl MSWIN_DIR_SYMBOL sapi,SAPI_DIR
904 dnl MSWIN_CHECK_DIR sapi,\Program Files\Microsoft Speech SDK 5.1\
907 dnl ########################################################################
908 dnl look for IPV6 functions
910 dnl MSWIN_DISPLAY ipv6,IPv6 Support
911 dnl MSWIN_CHECK_FILE ipv6,ws2tcpip.h|sin6_scope_id,P_HAS_IPV6=1
912 dnl MSWIN_DIR_SYMBOL ipv6,IPV6_DIR
913 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft Visual Studio\VC98\Include\
914 dnl MSWIN_CHECK_DIR ipv6,\Program Files\Microsoft SDK\include\
917 [ --disable-ipv6 disable IPV6 support in PWLIB],
920 if test "$ipv6" = "no" ; then
921 AC_DEFINE(P_HAS_IPV6, 0)
922 AC_SUBST(HAS_IPV6, 0)
924 AC_CACHE_CHECK([for IPv6 Support], HAS_IPV6,
925 [AC_TRY_COMPILE([#include <sys/types.h>
926 #include <netinet/in.h>],
927 [struct sockaddr_in6 s; s.sin6_scope_id = 0;], HAS_IPV6=yes, HAS_IPV6=no)])
929 if test $HAS_IPV6 = yes ; then
930 AC_DEFINE(P_HAS_IPV6, 1, "IPV6 enabled")
934 dnl ########################################################################
935 dnl look for QoS functions
937 dnl MSWIN_DISPLAY qos,QoS Support
938 dnl MSWIN_CHECK_FILE qos,qossp.h|QOS_DESTADDR,P_HAS_QOS=1
939 dnl MSWIN_DIR_SYMBOL qos,QOS_DIR
940 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft Visual Studio\VC98\Include\
941 dnl MSWIN_CHECK_DIR qos,\Program Files\Microsoft SDK\include\
944 [ --disable-qos disable QOS support in PWLIB],
947 if test "$qos" = "no" ; then
948 AC_DEFINE([P_HAS_QOS], [0], [No QOS])
950 AC_DEFINE([P_HAS_QOS], [1], [Have QOS])
954 dnl ########################################################################
955 dnl look for SDL, but only if we have pthreads
957 dnl MSWIN_DISPLAY libsdl,Simple DirectMedia Layer
958 dnl MSWIN_CHECK_FILE libsdl,include\SDL_video.h,P_SDL=1
959 dnl MSWIN_CHECK_FILE libsdl,lib\SDL.lib,P_SDL_LIBDIR="lib"
960 dnl MSWIN_DIR_SYMBOL libsdl,SDL_DIR
961 dnl MSWIN_CHECK_DIR libsdl,..\sdl\
962 dnl MSWIN_CHECK_DIR libsdl,..\external\sdl\
963 dnl MSWIN_CHECK_DIR libsdl,\sdl\
964 dnl MSWIN_CHECK_DIR libsdl,c:\sdl\
967 [ --disable-sdl disable SDL support in PWLIB],
970 if test "$sdl" = "no" ; then
975 if test "${SDLLIB:-unset}" = "unset" ; then
980 AC_CHECK_HEADERS(SDL/SDL.h, HAS_SDL=1)
981 if test "${HAS_SDL:-unset}" != "unset" ; then
982 if test "${X11LIBDIR:-unset}" == "unset" ; then
983 X11LIBDIR=/usr/X11R6/lib
985 AC_CHECK_LIB(SDL, SDL_CreateYUVOverlay, HAS_SDL=1, HAS_SDL=, -L${X11LIBDIR} -lpthread -lX11 -lXext -laa)
988 dnl freeBSD SDL check
989 if test "${HAS_SDL:-unset}" = "unset" ; then
990 AC_CHECK_FILE(/usr/local/include/SDL11/SDL.h, HAS_SDL=1)
991 if test "${HAS_SDL:-unset}" != "unset" ; then
996 if test "${HAS_SDL:-unset}" != "unset" ; then
998 AC_DEFINE(P_SDL, 1, "SDL found")
999 if test ${SDLINCLUDEDIR:-unset} != "unset" ; then
1000 STDCCFLAGS="$STDCCFLAGS -I${SDLINCLUDEDIR}"
1002 if test ${SDLLIBDIR:-unset} != "unset" ; then
1003 LDFLAGS="$LDFLAGS -L${SDLLIBDIR}"
1005 ENDLDLIBS="$ENDLDLIBS -l${SDLLIB}"
1010 dnl ########################################################################
1011 dnl check for video capture support.
1012 dnl videodev.h on linux
1013 dnl machine/ioctl_meteor on FreeBSD
1014 dnl i386/ioctl_meteor on OpenBSD
1015 dnl dev/ic/bt8xx on NetBSD
1017 AC_ARG_ENABLE(video,
1018 [ --disable-video disable non-plugin video device support in PWLIB],
1022 if test "$HAS_PLUGINS" = "0" ; then
1023 if test "$video" != "no" ; then
1024 AC_CHECK_HEADER(linux/videodev.h, HAS_VIDEO_CAPTURE=1)
1025 dnl AC_CHECK_HEADER(machine/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1026 dnl AC_CHECK_HEADER(i386/ioctl_meteor.h, HAS_VIDEO_CAPTURE=1)
1027 dnl AC_CHECK_HEADER(dev/ic/bt8xx.h, HAS_VIDEO_CAPTURE=1)
1028 if test "${HAS_VIDEO_CAPTURE}" = "0" ; then
1029 AC_MSG_NOTICE(No Video Capture support)
1030 AC_DEFINE([NO_VIDEO_CAPTURE], [], [No video capture])
1034 AC_SUBST(HAS_VIDEO_CAPTURE)
1036 dnl ########################################################################
1037 dnl check for various functions
1038 AC_ARG_ENABLE(alsa, [ --enable-alsa disable non-plugin ALSA audio support],enable_alsa=$enableval)
1041 if test "$HAS_PLUGINS" = "0" ; then
1042 if test "$enable_alsa" != "no" ; then
1043 AC_CHECK_HEADER(alsa/asoundlib.h, HAS_ALSA=1)
1044 AC_MSG_CHECKING(for ALSA sound support)
1045 if test "${HAS_ALSA}" = "1"; then
1047 ENDLDLIBS="$ENDLDLIBS -lasound"
1055 dnl ########################################################################
1056 dnl check for various functions
1057 dnl According to Andre Schulze <as8@rncmm2.urz.tu-dresden.de>
1058 dnl Solaris swab should not be used
1059 if test "$OSTYPE" = "solaris" ; then
1062 AC_CHECK_FUNC(swab,USE_SYSTEM_SWAB=1)
1064 if test "x$ac_cv_func_swab" = "xyes" ; then
1065 AC_DEFINE([USE_SYSTEM_SWAB], [], [Use system swab()])
1068 dnl ########################################################################
1069 dnl look for MEMORY_CHECK enabled.
1071 dnl MSWIN_DISPLAY memcheck,Memory check switch read
1073 AC_ARG_ENABLE(memcheck,
1074 [ --enable-memcheck enable leak testing code (off by default)],
1075 memcheck=$enableval)
1077 if test "$memcheck" = "yes" ; then
1078 AC_DEFINE(PMEMORY_CHECK, 1)
1079 AC_MSG_NOTICE(Memory checking enabled)
1083 dnl ########################################################################
1084 dnl output make directives
1086 dnl resolver needs to be at the end
1087 if test "${HAVE_RESOLVER:-unset}" != "unset" ; then
1088 if test "${RESOLVER_LIBS:-unset}" != "unset" ; then
1089 ENDLDLIBS="$ENDLDLIBS $RESOLVER_LIBS"
1093 dnl dl needs to be at the end
1094 if test "${OSTYPE}" != "Darwin" ; then
1095 if test ${HAS_LIBDL} = yes ; then
1096 ENDLDLIBS="$ENDLDLIBS -ldl"
1100 AC_SUBST(STDCCFLAGS)
1101 AC_SUBST(STDCXXFLAGS)
1102 AC_SUBST(OPTSTDCCFLAGS)
1107 AC_CONFIG_FILES(make/ptbuildopts.mak)
1108 AC_CONFIG_FILES([make/ptlib-config], [chmod a+x make/ptlib-config])
1109 AC_CONFIG_FILES(Makefile)
1111 dnl ########################################################################
1112 dnl output header file
1113 #AC_CONFIG_FILES(include/ptbuildopts.h.in)
1114 AC_CONFIG_HEADERS(include/ptbuildopts.h)