1 dnl OpenLDAP Autoconf Macros
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 dnl Copyright 1998-2008 The OpenLDAP Foundation.
6 dnl All rights reserved.
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted only as authorized by the OpenLDAP
12 dnl A copy of this license is available in the file LICENSE in the
13 dnl top-level directory of the distribution or, alternatively, at
14 dnl <http://www.OpenLDAP.org/license.html>.
16 dnl --------------------------------------------------------------------
17 dnl Restricted form of AC_ARG_ENABLE that limits user options
21 dnl $3 = default value (auto). "--" means do not set it by default
22 dnl $4 = allowed values (auto yes no)
23 dnl $5 = overridden default
24 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
25 pushdef([ol_DefVal],ifelse($3,,auto,$3))
26 AC_ARG_ENABLE($1,ifelse($4,,[$2],[$2] translit([$4],[ ],[|])) ifelse($3,--,,@<:@ol_DefVal@:>@),[
28 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
29 if test "$enableval" = "$ol_val" ; then
33 if test "$ol_arg" = "invalid" ; then
34 AC_MSG_ERROR(bad value $enableval for --enable-$1)
36 ol_enable_$1="$ol_arg"
38 [ ol_enable_$1=ifelse($5,,ol_DefVal,[${]$5[:-]ol_DefVal[}])]]))dnl
39 dnl AC_MSG_RESULT([OpenLDAP -enable-$1 $ol_enable_$1])
44 dnl --------------------------------------------------------------------
45 dnl Restricted form of AC_ARG_WITH that limits user options
49 dnl $3 = default value (no)
50 dnl $4 = allowed values (yes or no)
51 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
52 AC_ARG_WITH($1,[$2 @<:@]ifelse($3,,yes,$3)@:>@,[
54 for ol_val in ifelse($4,,[yes no],[$4]) ; do
55 if test "$withval" = "$ol_val" ; then
59 if test "$ol_arg" = "invalid" ; then
60 AC_MSG_ERROR(bad value $withval for --with-$1)
64 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
65 dnl AC_MSG_RESULT([OpenLDAP --with-$1 $ol_with_$1])
68 dnl ====================================================================
69 dnl Check for dependency generation flag
70 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
73 if test -z "${MKDEP}"; then
75 if test -z "${MKDEP_FLAGS}"; then
76 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
78 for flag in "-M" "-xM"; do
79 cat > conftest.c <<EOF
82 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
83 | grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
85 if test ! -f conftest."${ac_object}" ; then
87 OL_MKDEP_FLAGS="$flag"
94 test "$ol_cv_mkdep" = no && OL_MKDEP=":"
97 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
102 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
105 AC_SUBST(OL_MKDEP_FLAGS)
108 dnl ====================================================================
109 dnl Check if system uses EBCDIC instead of ASCII
110 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
111 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
112 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
114 #include <__ASCII__/generate_error.h>
116 ]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])])
117 if test $ol_cv_cpp_ebcdic = yes ; then
118 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
122 dnl --------------------------------------------------------------------
123 dnl OpenLDAP version of STDC header check w/ EBCDIC support
124 AC_DEFUN([OL_HEADER_STDC],
126 AC_REQUIRE([OL_CPP_EBCDIC])dnl
127 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
128 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
131 #include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no])
133 if test $ol_cv_header_stdc = yes; then
134 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
135 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
138 if test $ol_cv_header_stdc = yes; then
139 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
140 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
143 if test $ol_cv_header_stdc = yes; then
144 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
145 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h>
147 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
148 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
150 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
151 || ('j' <= (c) && (c) <= 'r') \
152 || ('s' <= (c) && (c) <= 'z'))
153 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
155 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
156 int main () { int i; for (i = 0; i < 256; i++)
157 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
159 ]])],[],[ol_cv_header_stdc=no],[:])
161 if test $ol_cv_header_stdc = yes; then
162 AC_DEFINE(STDC_HEADERS)
164 ac_cv_header_stdc=disable
167 dnl ====================================================================
168 dnl DNS resolver macros
169 AC_DEFUN([OL_RESOLVER_TRY],
170 [if test $ol_cv_lib_resolver = no ; then
171 AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1],
173 ol_RESOLVER_LIB=ifelse($2,,,$2)
175 LIBS="$ol_RESOLVER_LIB $LIBS"
177 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
178 #ifdef HAVE_SYS_TYPES_H
179 # include <sys/types.h>
181 #include <netinet/in.h>
182 #ifdef HAVE_ARPA_NAMESER_H
183 # include <arpa/nameser.h>
190 char *request = NULL;
191 unsigned char reply[64*1024];
192 unsigned char host[64*1024];
196 /* Bind 8/9 interface */
197 len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply));
199 /* Bind 4 interface */
203 len = res_query(request, C_IN, T_SRV, reply, sizeof(reply));
207 /* Bind 8/9 interface */
209 #elif defined(HFIXEDSZ)
210 /* Bind 4 interface w/ HFIXEDSZ */
213 /* Bind 4 interface w/o HFIXEDSZ */
216 status = dn_expand( reply, reply+len, p, host, sizeof(host));
217 }]])],[$1=yes],[$1=no])
222 if test $$1 = yes ; then
223 ol_cv_lib_resolver=ifelse($2,,yes,$2)
227 dnl --------------------------------------------------------------------
228 dnl Try to locate appropriate library
229 AC_DEFUN([OL_RESOLVER_LINK],
230 [ol_cv_lib_resolver=no
231 OL_RESOLVER_TRY(ol_cv_resolver_none)
232 OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv])
233 OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind])
236 dnl ====================================================================
237 dnl International Components for Unicode (ICU)
240 AC_CHECK_HEADERS( unicode/utypes.h )
241 if test $ac_cv_header_unicode_utypes_h = yes ; then
242 dnl OL_ICULIBS="-licui18n -licuuc -licudata"
243 OL_ICULIBS="-licuuc -licudata"
245 AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [
247 LIBS="$OL_ICULIBS $LIBS"
248 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
249 #include <unicode/utypes.h>
251 (void) u_errorName(0);
252 ]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no])
256 if test $ol_cv_lib_icu != no ; then
258 AC_DEFINE(HAVE_ICU,1,[define if you actually have ICU])
263 dnl ====================================================================
264 dnl Berkeley DB macros
266 dnl --------------------------------------------------------------------
268 AC_DEFUN([OL_BERKELEY_DB_TRY],
269 [if test $ol_cv_lib_db = no ; then
270 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
272 ol_DB_LIB=ifelse($2,,,$2)
274 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
276 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
283 #ifndef DB_VERSION_MAJOR
284 # define DB_VERSION_MAJOR 1
288 #define NULL ((void*)0)
291 #if DB_VERSION_MAJOR > 2
292 db_env_create( NULL, 0 );
293 #elif DB_VERSION_MAJOR > 1
296 (void) dbopen( NULL, 0, 0, 0, NULL);
298 ]])],[$1=yes],[$1=no])
303 if test $$1 = yes ; then
304 ol_cv_lib_db=ifelse($2,,yes,$2)
309 dnl --------------------------------------------------------------------
310 dnl Get major and minor version from <db.h>
311 AC_DEFUN([OL_BDB_HEADER_VERSION],
312 [AC_CACHE_CHECK([for Berkeley DB major version in db.h], [ol_cv_bdb_major],[
315 #ifndef DB_VERSION_MAJOR
316 # define DB_VERSION_MAJOR 1
318 __db_version DB_VERSION_MAJOR
320 set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
323 case $ol_cv_bdb_major in [[1-9]]*) : ;; *)
324 AC_MSG_ERROR([Unknown Berkeley DB major version in db.h]) ;;
327 dnl Determine minor version
328 AC_CACHE_CHECK([for Berkeley DB minor version in db.h], [ol_cv_bdb_minor],[
331 #ifndef DB_VERSION_MINOR
332 # define DB_VERSION_MINOR 0
334 __db_version DB_VERSION_MINOR
336 set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
339 case $ol_cv_bdb_minor in [[0-9]]*) : ;; *)
340 AC_MSG_ERROR([Unknown Berkeley DB minor version in db.h]) ;;
344 dnl --------------------------------------------------------------------
345 dnl Try to locate appropriate library
346 AC_DEFUN([OL_BERKELEY_DB_LINK],
349 if test $ol_cv_bdb_major = 4 ; then
350 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor])
351 OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor])
352 OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor])
353 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor])
354 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
355 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
356 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
358 OL_BERKELEY_DB_TRY(ol_cv_db_none)
361 dnl --------------------------------------------------------------------
362 dnl Check if Berkeley DB version
363 AC_DEFUN([OL_BERKELEY_DB_VERSION],
364 [AC_CACHE_CHECK([for Berkeley DB library and header version match], [ol_cv_berkeley_db_version], [
366 LIBS="$LTHREAD_LIBS $LIBS"
367 if test $ol_cv_lib_db != yes ; then
368 LIBS="$ol_cv_lib_db $LIBS"
371 AC_RUN_IFELSE([AC_LANG_SOURCE([[
377 #ifndef DB_VERSION_MAJOR
378 # define DB_VERSION_MAJOR 1
381 #define NULL ((void *)0)
385 #if DB_VERSION_MAJOR > 1
387 int major, minor, patch;
389 version = db_version( &major, &minor, &patch );
391 if( major != DB_VERSION_MAJOR ||
392 minor != DB_VERSION_MINOR ||
393 patch != DB_VERSION_PATCH )
395 printf("Berkeley DB version mismatch\n"
396 "\theader: %s\n\tlibrary: %s\n",
397 DB_VERSION_STRING, version);
403 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
408 if test $ol_cv_berkeley_db_version = no ; then
409 AC_MSG_ERROR([Berkeley DB version mismatch])
413 dnl --------------------------------------------------------------------
414 dnl Check if Berkeley DB supports DB_THREAD
415 AC_DEFUN([OL_BERKELEY_DB_THREAD],
416 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
418 LIBS="$LTHREAD_LIBS $LIBS"
419 if test $ol_cv_lib_db != yes ; then
420 LIBS="$ol_cv_lib_db $LIBS"
423 AC_RUN_IFELSE([AC_LANG_SOURCE([[
430 #define NULL ((void *)0)
435 u_int32_t flags = DB_CREATE |
441 #if DB_VERSION_MAJOR > 2
444 rc = db_env_create( &env, 0 );
446 flags |= DB_INIT_MPOOL;
447 #ifdef DB_MPOOL_PRIVATE
448 flags |= DB_MPOOL_PRIVATE;
452 printf("BerkeleyDB: %s\n", db_strerror(rc) );
456 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
457 rc = (env->open)( env, NULL, flags, 0 );
459 rc = (env->open)( env, NULL, NULL, flags, 0 );
463 rc = env->close( env, 0 );
467 printf("BerkeleyDB: %s\n", db_strerror(rc) );
473 memset( &env, '\0', sizeof(env) );
475 rc = db_appinit( NULL, NULL, &env, flags );
481 unlink("__db_mpool.share");
482 unlink("__db_lock.share");
486 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
491 if test $ol_cv_berkeley_db_thread != no ; then
492 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
493 [define if Berkeley DB has DB_THREAD support])
497 dnl --------------------------------------------------------------------
499 AC_DEFUN([OL_BERKELEY_DB],
500 [ol_cv_berkeley_db=no
501 AC_CHECK_HEADERS(db.h)
502 if test $ac_cv_header_db_h = yes; then
503 OL_BDB_HEADER_VERSION
506 if test $ol_cv_bdb_compat != yes ; then
507 AC_MSG_ERROR([BerkeleyDB version incompatible with BDB/HDB backends])
511 if test "$ol_cv_lib_db" != no ; then
512 ol_cv_berkeley_db=yes
513 OL_BERKELEY_DB_VERSION
514 OL_BERKELEY_DB_THREAD
518 dnl --------------------------------------------------------------------
519 dnl Check for version compatility with back-bdb
520 AC_DEFUN([OL_BDB_COMPAT],
521 [AC_CACHE_CHECK([if Berkeley DB version supported by BDB/HDB backends], [ol_cv_bdb_compat],[
522 AC_EGREP_CPP(__db_version_compat,[
525 /* this check could be improved */
526 #ifndef DB_VERSION_MAJOR
527 # define DB_VERSION_MAJOR 1
529 #ifndef DB_VERSION_MINOR
530 # define DB_VERSION_MINOR 0
533 #define DB_VERSION_MM ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR)
535 /* require 4.4 or later */
536 #if DB_VERSION_MM >= 0x0404
539 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
543 dnl ====================================================================
544 dnl Check POSIX Thread version
546 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
547 dnl version of the POSIX.4a Draft that is implemented.
548 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
549 dnl Existence of pthread.h should be tested separately.
552 dnl pthread_detach() was dropped in Draft 8, it is present
553 dnl in every other version
554 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
555 dnl PTHREAD_CREATE_JOINABLE after that
556 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
557 dnl Draft 6-10 has _init, Draft 4-5 has _create.
558 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
559 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
560 dnl interesting to us because we don't try to statically
561 dnl initialize mutexes. 5-10 has it.
563 dnl Draft 9 and 10 are equivalent for our purposes.
565 AC_DEFUN([OL_POSIX_THREAD_VERSION],
566 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
568 # include <pthread.h>
570 int i = PTHREAD_CREATE_JOINABLE;
572 AC_EGREP_HEADER(pthread_detach,pthread.h,
573 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
574 AC_EGREP_CPP(draft7,[
575 # include <pthread.h>
576 # ifdef PTHREAD_CREATE_UNDETACHED
579 ], ol_cv_pthread_version=7, [
580 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
581 ol_cv_pthread_version=6, [
582 AC_EGREP_CPP(draft5,[
583 # include <pthread.h>
584 #ifdef PTHREAD_MUTEX_INITIALIZER
587 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
591 dnl --------------------------------------------------------------------
592 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
593 /* pthread test headers */
595 #if HAVE_PTHREADS < 7
599 #define NULL (void*)0
605 return (void *) (p == NULL);
608 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
609 /* pthread test function */
610 #ifndef PTHREAD_CREATE_DETACHED
611 #define PTHREAD_CREATE_DETACHED 1
615 int detach = PTHREAD_CREATE_DETACHED;
617 #if HAVE_PTHREADS > 4
621 status = pthread_attr_init(&attr);
622 if( status ) return status;
624 #if HAVE_PTHREADS < 7
625 status = pthread_attr_setdetachstate(&attr, &detach);
626 if( status < 0 ) status = errno;
628 status = pthread_attr_setdetachstate(&attr, detach);
630 if( status ) return status;
631 status = pthread_create( &t, &attr, task, NULL );
632 #if HAVE_PTHREADS < 7
633 if( status < 0 ) status = errno;
635 if( status ) return status;
637 /* Draft 4 pthreads */
638 status = pthread_create( &t, pthread_attr_default, task, NULL );
639 if( status ) return errno;
641 /* give thread a chance to complete */
642 /* it should remain joinable and hence detachable */
645 status = pthread_detach( &t );
646 if( status ) return errno;
649 #ifdef HAVE_LINUX_THREADS
650 pthread_kill_other_threads_np();
656 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
657 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
663 OL_PTHREAD_TEST_FUNCTION
666 dnl --------------------------------------------------------------------
667 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
668 if test "$ol_link_threads" = no ; then
670 AC_CACHE_CHECK([for pthread link with $1], [$2], [
675 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
678 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
679 OL_PTHREAD_TEST_FUNCTION)],
686 if test $$2 = yes ; then
687 ol_link_pthreads="$1"
688 ol_link_threads=posix
693 dnl ====================================================================
694 dnl Check GNU Pth pthread Header
696 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
697 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
698 dnl doesn't exists. Existance of pthread.h should separately
701 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
702 AC_CACHE_CHECK([for GNU Pth pthread.h],
703 [ol_cv_header_gnu_pth_pthread_h],
704 [AC_EGREP_CPP(__gnu_pth__,
705 [#include <pthread.h>
706 #ifdef _POSIX_THREAD_IS_GNU_PTH
710 [ol_cv_header_gnu_pth_pthread_h=yes],
711 [ol_cv_header_gnu_pth_pthread_h=no])
714 dnl ====================================================================
715 dnl Check for NT Threads
716 AC_DEFUN([OL_NT_THREADS], [
717 AC_CHECK_FUNC(_beginthread)
719 if test $ac_cv_func__beginthread = yes ; then
720 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
724 dnl ====================================================================
725 dnl Check LinuxThreads Header
727 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
728 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
729 dnl doesn't exists. Existance of pthread.h should separately
732 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
733 AC_CACHE_CHECK([for LinuxThreads pthread.h],
734 [ol_cv_header_linux_threads],
735 [AC_EGREP_CPP(pthread_kill_other_threads_np,
736 [#include <pthread.h>],
737 [ol_cv_header_linux_threads=yes],
738 [ol_cv_header_linux_threads=no])
740 if test $ol_cv_header_linux_threads = yes; then
741 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
744 dnl --------------------------------------------------------------------
745 dnl Check LinuxThreads Implementation
747 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
748 dnl 'no' implies pthreads implementation is not LinuxThreads.
750 AC_DEFUN([OL_SYS_LINUX_THREADS], [
751 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
752 AC_CACHE_CHECK([for LinuxThreads implementation],
753 [ol_cv_sys_linux_threads],
754 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
757 dnl --------------------------------------------------------------------
758 dnl Check LinuxThreads consistency
759 AC_DEFUN([OL_LINUX_THREADS], [
760 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
761 AC_REQUIRE([OL_SYS_LINUX_THREADS])
762 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
763 if test $ol_cv_header_linux_threads = yes &&
764 test $ol_cv_sys_linux_threads = yes; then
765 ol_cv_linux_threads=yes
766 elif test $ol_cv_header_linux_threads = no &&
767 test $ol_cv_sys_linux_threads = no; then
768 ol_cv_linux_threads=no
770 ol_cv_linux_threads=error
775 dnl ====================================================================
776 dnl Check for POSIX Regex
777 AC_DEFUN([OL_POSIX_REGEX], [
778 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
779 AC_RUN_IFELSE([AC_LANG_SOURCE([[
780 #include <sys/types.h>
782 static char *pattern, *string;
790 if(regcomp(&re, pattern, 0)) {
794 string = "ALL MATCH";
796 rc = regexec(&re, string, 0, (void*)0, 0);
801 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
804 dnl ====================================================================
805 dnl Check if toupper() requires islower() to be called first
806 AC_DEFUN([OL_C_UPPER_LOWER],
807 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
808 AC_RUN_IFELSE([AC_LANG_SOURCE([[
812 if ('C' == toupper('C'))
816 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
817 if test $ol_cv_c_upper_lower != no ; then
818 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
822 dnl ====================================================================
823 dnl Error string checks
825 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
826 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
827 dnl Reported by Keith Bostic.
828 AC_DEFUN([OL_SYS_ERRLIST],
829 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
830 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
832 #include <sys/types.h>
836 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
837 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
839 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
840 if test $ol_cv_dcl_sys_errlist = no ; then
841 AC_DEFINE(DECL_SYS_ERRLIST,1,
842 [define if sys_errlist is not declared in stdio.h or errno.h])
844 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
845 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])])
847 if test $ol_cv_have_sys_errlist = yes ; then
848 AC_DEFINE(HAVE_SYS_ERRLIST,1,
849 [define if you actually have sys_errlist in your libs])
852 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
853 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
854 AC_EGREP_CPP(strerror_r,[#include <string.h>],
855 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
857 if test $ol_decl_strerror_r = yes ; then
858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
860 char x = *strerror_r (0, buf, sizeof buf);
861 char *p = strerror_r (0, buf, sizeof buf);
862 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
864 AC_RUN_IFELSE([AC_LANG_SOURCE([[
868 strerror_r( 1, buf, sizeof buf );
871 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
874 if test $ol_cv_nonposix_strerror_r = yes ; then
875 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
876 [define if strerror_r returns char* instead of int])
880 AC_DEFUN([OL_STRERROR],
881 [OL_SYS_ERRLIST dnl TEMPORARY
882 AC_CHECK_FUNCS(strerror strerror_r)
883 ol_cv_func_strerror_r=no
884 if test "${ac_cv_func_strerror_r}" = yes ; then
885 OL_NONPOSIX_STRERROR_R
886 elif test "${ac_cv_func_strerror}" = no ; then
890 dnl ====================================================================
891 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
892 dnl "int x; int *volatile a = &x; *a = 0;"
893 dnl -- borrowed from PDKSH
894 AC_DEFUN([OL_C_VOLATILE],
895 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
896 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
897 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
898 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
899 if test $ol_cv_c_volatile = yes; then
902 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
906 dnl ====================================================================
907 dnl Look for fetch(3)
908 AC_DEFUN([OL_LIB_FETCH],
910 LIBS="-lfetch -lcom_err $LIBS"
911 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
912 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
913 #include <sys/param.h>
915 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
917 if test $ol_cv_lib_fetch != no ; then
918 ol_link_fetch="-lfetch -lcom_err"
919 AC_DEFINE(HAVE_FETCH,1,
920 [define if you actually have FreeBSD fetch(3)])
924 dnl ====================================================================
925 dnl Define inet_aton is available
926 AC_DEFUN([OL_FUNC_INET_ATON],
927 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
928 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
929 #ifdef HAVE_SYS_TYPES_H
930 # include <sys/types.h>
932 #ifdef HAVE_SYS_SOCKET_H
933 # include <sys/socket.h>
934 # ifdef HAVE_SYS_SELECT_H
935 # include <sys/select.h>
937 # include <netinet/in.h>
938 # ifdef HAVE_ARPA_INET_H
939 # include <arpa/inet.h>
942 ]], [[struct in_addr in;
943 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
944 if test $ol_cv_func_inet_aton != no; then
945 AC_DEFINE(HAVE_INET_ATON, 1,
946 [define to you inet_aton(3) is available])
950 dnl ====================================================================
951 dnl check no of arguments for ctime_r
952 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
953 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
954 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer,32);]])],[ol_cv_func_ctime_r_nargs3=yes],[ol_cv_func_ctime_r_nargs3=no])
956 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer);]])],[ol_cv_func_ctime_r_nargs2=yes],[ol_cv_func_ctime_r_nargs2=no])
958 if test $ol_cv_func_ctime_r_nargs3 = yes &&
959 test $ol_cv_func_ctime_r_nargs2 = no ; then
961 ol_cv_func_ctime_r_nargs=3
963 elif test $ol_cv_func_ctime_r_nargs3 = no &&
964 test $ol_cv_func_ctime_r_nargs2 = yes ; then
966 ol_cv_func_ctime_r_nargs=2
969 ol_cv_func_ctime_r_nargs=0
973 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
974 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
975 [set to the number of arguments ctime_r() expects])
979 dnl --------------------------------------------------------------------
980 dnl check return type of ctime_r()
981 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
982 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
983 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[extern int (ctime_r)();]])],[ol_cv_func_ctime_r_type="int"],[ol_cv_func_ctime_r_type="charp"])
985 if test $ol_cv_func_ctime_r_type = "int" ; then
986 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
989 dnl ====================================================================
990 dnl check no of arguments for gethostbyname_r
991 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
992 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
993 ol_cv_func_gethostbyname_r_nargs,
994 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
995 #include <sys/socket.h>
996 #include <netinet/in.h>
998 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
999 int bufsize=BUFSIZE;int h_errno;
1000 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1001 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1003 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1004 #include <sys/socket.h>
1005 #include <netinet/in.h>
1007 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1008 char buffer[BUFSIZE];
1009 int bufsize=BUFSIZE;int h_errno;
1010 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1011 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1013 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1014 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1016 ol_cv_func_gethostbyname_r_nargs=5
1018 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1019 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1021 ol_cv_func_gethostbyname_r_nargs=6
1024 ol_cv_func_gethostbyname_r_nargs=0
1027 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1028 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1029 $ol_cv_func_gethostbyname_r_nargs,
1030 [set to the number of arguments gethostbyname_r() expects])
1034 dnl check no of arguments for gethostbyaddr_r
1035 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1036 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1037 [ol_cv_func_gethostbyaddr_r_nargs],
1038 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1039 #include <sys/socket.h>
1040 #include <netinet/in.h>
1042 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1044 size_t alen=sizeof(struct in_addr);
1045 int bufsize=BUFSIZE;int h_errno;
1046 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1047 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1049 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1050 #include <sys/socket.h>
1051 #include <netinet/in.h>
1053 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1054 struct hostent *rhent; char buffer[BUFSIZE];
1056 size_t alen=sizeof(struct in_addr);
1057 int bufsize=BUFSIZE;int h_errno;
1058 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1059 alen, AF_INET, &hent, buffer, bufsize,
1060 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1062 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1063 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1065 ol_cv_func_gethostbyaddr_r_nargs=7
1067 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1068 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1070 ol_cv_func_gethostbyaddr_r_nargs=8
1073 ol_cv_func_gethostbyaddr_r_nargs=0
1076 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1077 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1078 $ol_cv_func_gethostbyaddr_r_nargs,
1079 [set to the number of arguments gethostbyaddr_r() expects])
1083 dnl --------------------------------------------------------------------
1084 dnl Check for Cyrus SASL version compatility
1085 AC_DEFUN([OL_SASL_COMPAT],
1086 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1087 AC_EGREP_CPP(__sasl_compat,[
1088 #ifdef HAVE_SASL_SASL_H
1089 #include <sasl/sasl.h>
1094 /* Require 2.1.15+ */
1095 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1096 char *__sasl_compat = "2.2+ or better okay (we guess)";
1097 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1098 && SASL_VERSION_STEP >=15
1099 char *__sasl_compat = "2.1.15+ or better okay";
1101 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1103 dnl ====================================================================
1104 dnl check for SSL compatibility
1105 AC_DEFUN([OL_SSL_COMPAT],
1106 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1107 [ol_cv_ssl_crl_compat],[
1108 AC_EGREP_CPP(__ssl_compat,[
1109 #ifdef HAVE_OPENSSL_SSL_H
1110 #include <openssl/ssl.h>
1113 /* Require 0.9.7d+ */
1114 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1115 char *__ssl_compat = "0.9.7d";
1117 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])