1 dnl OpenLDAP Autoconf Macros
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 dnl Copyright 1998-2005 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"
96 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
101 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
104 AC_SUBST(OL_MKDEP_FLAGS)
107 dnl ====================================================================
108 dnl Check if system uses EBCDIC instead of ASCII
109 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
110 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
111 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
113 #include <__ASCII__/generate_error.h>
115 ]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])])
116 if test $ol_cv_cpp_ebcdic = yes ; then
117 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
121 dnl --------------------------------------------------------------------
122 dnl OpenLDAP version of STDC header check w/ EBCDIC support
123 AC_DEFUN([OL_HEADER_STDC],
125 AC_REQUIRE([OL_CPP_EBCDIC])dnl
126 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
127 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
130 #include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no])
132 if test $ol_cv_header_stdc = yes; then
133 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
134 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
137 if test $ol_cv_header_stdc = yes; then
138 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
139 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
142 if test $ol_cv_header_stdc = yes; then
143 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
144 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h>
146 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
147 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
149 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
150 || ('j' <= (c) && (c) <= 'r') \
151 || ('s' <= (c) && (c) <= 'z'))
152 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
154 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
155 int main () { int i; for (i = 0; i < 256; i++)
156 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
158 ]])],[],[ol_cv_header_stdc=no],[:])
160 if test $ol_cv_header_stdc = yes; then
161 AC_DEFINE(STDC_HEADERS)
163 ac_cv_header_stdc=disable
166 dnl ====================================================================
167 dnl DNS resolver macros
168 AC_DEFUN([OL_RESOLVER_TRY],
169 [if test $ol_cv_lib_resolver = no ; then
170 AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1],
172 ol_RESOLVER_LIB=ifelse($2,,,$2)
174 LIBS="$ol_RESOLVER_LIB $LIBS"
176 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
177 #ifdef HAVE_SYS_TYPES_H
178 # include <sys/types.h>
180 #include <netinet/in.h>
181 #ifdef HAVE_ARPA_NAMESER_H
182 # include <arpa/nameser.h>
189 char *request = NULL;
190 unsigned char reply[64*1024];
191 unsigned char host[64*1024];
195 /* Bind 8/9 interface */
196 len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply));
198 /* Bind 4 interface */
202 len = res_query(request, C_IN, T_SRV, reply, sizeof(reply));
206 /* Bind 8/9 interface */
208 #elif defined(HFIXEDSZ)
209 /* Bind 4 interface w/ HFIXEDSZ */
212 /* Bind 4 interface w/o HFIXEDSZ */
215 status = dn_expand( reply, reply+len, p, host, sizeof(host));
216 }]])],[$1=yes],[$1=no])
221 if test $$1 = yes ; then
222 ol_cv_lib_resolver=ifelse($2,,yes,$2)
226 dnl --------------------------------------------------------------------
227 dnl Try to locate appropriate library
228 AC_DEFUN([OL_RESOLVER_LINK],
229 [ol_cv_lib_resolver=no
230 OL_RESOLVER_TRY(ol_cv_resolver_none)
231 OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv])
232 OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind])
235 dnl ====================================================================
236 dnl Berkeley DB macros
238 dnl --------------------------------------------------------------------
240 AC_DEFUN([OL_BERKELEY_DB_TRY],
241 [if test $ol_cv_lib_db = no ; then
242 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
244 ol_DB_LIB=ifelse($2,,,$2)
246 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
248 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
255 #ifndef DB_VERSION_MAJOR
256 # define DB_VERSION_MAJOR 1
260 #define NULL ((void*)0)
263 #if DB_VERSION_MAJOR > 1
266 int major, minor, patch;
268 version = db_version( &major, &minor, &patch );
270 if( major != DB_VERSION_MAJOR ||
271 minor < DB_VERSION_MINOR )
273 printf("Berkeley DB version mismatch\n"
274 "\theader: %s\n\tlibrary: %s\n",
275 DB_VERSION_STRING, version);
281 #if DB_VERSION_MAJOR > 2
282 db_env_create( NULL, 0 );
283 #elif DB_VERSION_MAJOR > 1
286 (void) dbopen( NULL, 0, 0, 0, NULL);
288 ]])],[$1=yes],[$1=no])
293 if test $$1 = yes ; then
294 ol_cv_lib_db=ifelse($2,,yes,$2)
299 dnl --------------------------------------------------------------------
300 dnl Try to locate appropriate library
301 AC_DEFUN([OL_BERKELEY_DB_LINK],
303 OL_BERKELEY_DB_TRY(ol_cv_db_none)
304 OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
305 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
306 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
307 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
308 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
309 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
310 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
311 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
312 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
313 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
314 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
315 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
316 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
317 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
318 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
320 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
321 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
322 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
323 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
324 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
327 dnl --------------------------------------------------------------------
328 dnl Check if Berkeley DB version
329 AC_DEFUN([OL_BERKELEY_DB_VERSION],
330 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
332 LIBS="$LTHREAD_LIBS $LIBS"
333 if test $ol_cv_lib_db != yes ; then
334 LIBS="$ol_cv_lib_db $LIBS"
337 AC_RUN_IFELSE([AC_LANG_SOURCE([[
343 #ifndef DB_VERSION_MAJOR
344 # define DB_VERSION_MAJOR 1
347 #define NULL ((void *)0)
351 #if DB_VERSION_MAJOR > 1
353 int major, minor, patch;
355 version = db_version( &major, &minor, &patch );
357 if( major != DB_VERSION_MAJOR ||
358 minor != DB_VERSION_MINOR ||
359 patch != DB_VERSION_PATCH )
361 printf("Berkeley DB version mismatch\n"
362 "\theader: %s\n\tlibrary: %s\n",
363 DB_VERSION_STRING, version);
369 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
374 if test $ol_cv_berkeley_db_version = no ; then
375 AC_MSG_ERROR([Berkeley DB version mismatch])
379 dnl --------------------------------------------------------------------
380 dnl Check if Berkeley DB supports DB_THREAD
381 AC_DEFUN([OL_BERKELEY_DB_THREAD],
382 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
384 LIBS="$LTHREAD_LIBS $LIBS"
385 if test $ol_cv_lib_db != yes ; then
386 LIBS="$ol_cv_lib_db $LIBS"
389 AC_RUN_IFELSE([AC_LANG_SOURCE([[
396 #define NULL ((void *)0)
401 u_int32_t flags = DB_CREATE |
407 #if DB_VERSION_MAJOR > 2
410 rc = db_env_create( &env, 0 );
412 flags |= DB_INIT_MPOOL;
413 #ifdef DB_MPOOL_PRIVATE
414 flags |= DB_MPOOL_PRIVATE;
418 printf("BerkeleyDB: %s\n", db_strerror(rc) );
422 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
423 rc = env->open( env, NULL, flags, 0 );
425 rc = env->open( env, NULL, NULL, flags, 0 );
429 rc = env->close( env, 0 );
433 printf("BerkeleyDB: %s\n", db_strerror(rc) );
439 memset( &env, '\0', sizeof(env) );
441 rc = db_appinit( NULL, NULL, &env, flags );
447 unlink("__db_mpool.share");
448 unlink("__db_lock.share");
452 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
457 if test $ol_cv_berkeley_db_thread != no ; then
458 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
459 [define if Berkeley DB has DB_THREAD support])
463 dnl --------------------------------------------------------------------
465 AC_DEFUN([OL_BERKELEY_DB],
466 [ol_cv_berkeley_db=no
467 AC_CHECK_HEADERS(db.h)
468 if test $ac_cv_header_db_h = yes; then
470 if test "$ol_cv_lib_db" != no ; then
471 ol_cv_berkeley_db=yes
472 OL_BERKELEY_DB_VERSION
473 OL_BERKELEY_DB_THREAD
477 dnl --------------------------------------------------------------------
478 dnl Check for version compatility with back-bdb
479 AC_DEFUN([OL_BDB_COMPAT],
480 [AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[
481 AC_EGREP_CPP(__db_version_compat,[
484 /* this check could be improved */
485 #ifndef DB_VERSION_MAJOR
486 # define DB_VERSION_MAJOR 1
488 #ifndef DB_VERSION_MINOR
489 # define DB_VERSION_MINOR 0
492 /* require 4.2 or later */
493 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
496 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
499 dnl --------------------------------------------------------------------
500 dnl Find old Berkeley DB 1.85/1.86
501 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
502 [AC_CHECK_HEADERS(db_185.h db.h)
503 if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
504 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
505 AC_EGREP_CPP(__db_version_1,[
512 /* this check could be improved */
513 #ifndef DB_VERSION_MAJOR
514 # define DB_VERSION_MAJOR 1
517 #if DB_VERSION_MAJOR == 1
520 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
522 if test $ol_cv_header_db1 = yes ; then
524 if test "$ol_cv_lib_db" != no ; then
525 ol_cv_berkeley_db=yes
531 dnl ====================================================================
532 dnl Check if GDBM library exists
533 dnl Check for gdbm_open in standard libraries or -lgdbm
535 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
536 dnl 'yes' implies gdbm_open is in $LIBS
539 dnl AC_CHECK_FUNC(gdbm_open)
540 dnl AC_CHECK_LIB(gdbm,gdbm_open)
542 AC_DEFUN([OL_LIB_GDBM],
543 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
545 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
546 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
552 dnl --------------------------------------------------------------------
553 dnl Check if GDBM exists
555 dnl defines ol_cv_gdbm to 'yes' or 'no'
559 dnl AC_CHECK_HEADERS(gdbm.h)
562 [AC_REQUIRE([OL_LIB_GDBM])
563 AC_CHECK_HEADERS(gdbm.h)
564 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
565 if test $ol_cv_lib_gdbm = no || test $ac_cv_header_gdbm_h = no ; then
571 if test $ol_cv_gdbm = yes ; then
572 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
576 dnl ====================================================================
577 dnl Check if MDBM library exists
578 dnl Check for mdbm_open in standard libraries or -lmdbm
580 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
581 dnl 'yes' implies mdbm_open is in $LIBS
584 dnl AC_CHECK_FUNC(mdbm_set_chain)
585 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
587 AC_DEFUN([OL_LIB_MDBM],
588 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
590 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
591 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
597 dnl --------------------------------------------------------------------
598 dnl Check if MDBM exists
600 dnl defines ol_cv_mdbm to 'yes' or 'no'
604 dnl AC_CHECK_HEADERS(mdbm.h)
607 [AC_REQUIRE([OL_LIB_MDBM])
608 AC_CHECK_HEADERS(mdbm.h)
609 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
610 if test $ol_cv_lib_mdbm = no || test $ac_cv_header_mdbm_h = no ; then
616 if test $ol_cv_mdbm = yes ; then
617 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
621 dnl ====================================================================
622 dnl Check if NDBM library exists
623 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
625 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
626 dnl 'yes' implies ndbm_open is in $LIBS
629 dnl AC_CHECK_FUNC(dbm_open)
630 dnl AC_CHECK_LIB(ndbm,dbm_open)
631 dnl AC_CHECK_LIB(dbm,dbm_open)
634 dnl should also check SVR4 case: dbm_open() in -lucb but that
635 dnl would requiring dealing with -L/usr/ucblib
637 AC_DEFUN([OL_LIB_NDBM],
638 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
640 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
641 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
642 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
643 [ol_cv_lib_ndbm=no])dnl
650 dnl --------------------------------------------------------------------
651 dnl Check if NDBM exists
653 dnl defines ol_cv_ndbm to 'yes' or 'no'
657 dnl AC_CHECK_HEADERS(ndbm.h)
660 dnl Doesn't handle SVR4 case (see above)
663 [AC_REQUIRE([OL_LIB_NDBM])
664 AC_CHECK_HEADERS(ndbm.h)
665 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
666 if test $ol_cv_lib_ndbm = no || test $ac_cv_header_ndbm_h = no ; then
672 if test $ol_cv_ndbm = yes ; then
673 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
677 dnl ====================================================================
678 dnl Check POSIX Thread version
680 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
681 dnl version of the POSIX.4a Draft that is implemented.
682 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
683 dnl Existence of pthread.h should be tested separately.
686 dnl pthread_detach() was dropped in Draft 8, it is present
687 dnl in every other version
688 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
689 dnl PTHREAD_CREATE_JOINABLE after that
690 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
691 dnl Draft 6-10 has _init, Draft 4-5 has _create.
692 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
693 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
694 dnl interesting to us because we don't try to statically
695 dnl initialize mutexes. 5-10 has it.
697 dnl Draft 9 and 10 are equivalent for our purposes.
699 AC_DEFUN([OL_POSIX_THREAD_VERSION],
700 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
702 # include <pthread.h>
704 int i = PTHREAD_CREATE_JOINABLE;
706 AC_EGREP_HEADER(pthread_detach,pthread.h,
707 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
708 AC_EGREP_CPP(draft7,[
709 # include <pthread.h>
710 # ifdef PTHREAD_CREATE_UNDETACHED
713 ], ol_cv_pthread_version=7, [
714 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
715 ol_cv_pthread_version=6, [
716 AC_EGREP_CPP(draft5,[
717 # include <pthread.h>
718 #ifdef PTHREAD_MUTEX_INITIALIZER
721 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
725 dnl --------------------------------------------------------------------
726 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
727 /* pthread test headers */
729 #if HAVE_PTHREADS < 7
733 #define NULL (void*)0
739 return (void *) (p == NULL);
742 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
743 /* pthread test function */
744 #ifndef PTHREAD_CREATE_DETACHED
745 #define PTHREAD_CREATE_DETACHED 1
749 int detach = PTHREAD_CREATE_DETACHED;
751 #if HAVE_PTHREADS > 4
755 status = pthread_attr_init(&attr);
756 if( status ) return status;
758 #if HAVE_PTHREADS < 7
759 status = pthread_attr_setdetachstate(&attr, &detach);
760 if( status < 0 ) status = errno;
762 status = pthread_attr_setdetachstate(&attr, detach);
764 if( status ) return status;
765 status = pthread_create( &t, &attr, task, NULL );
766 #if HAVE_PTHREADS < 7
767 if( status < 0 ) status = errno;
769 if( status ) return status;
771 /* Draft 4 pthreads */
772 status = pthread_create( &t, pthread_attr_default, task, NULL );
773 if( status ) return errno;
775 /* give thread a chance to complete */
776 /* it should remain joinable and hence detachable */
779 status = pthread_detach( &t );
780 if( status ) return errno;
783 #ifdef HAVE_LINUX_THREADS
784 pthread_kill_other_threads_np();
790 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
791 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
797 OL_PTHREAD_TEST_FUNCTION
800 dnl --------------------------------------------------------------------
801 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
802 if test "$ol_link_threads" = no ; then
804 AC_CACHE_CHECK([for pthread link with $1], [$2], [
809 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
812 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
813 OL_PTHREAD_TEST_FUNCTION)],
820 if test $$2 = yes ; then
821 ol_link_pthreads="$1"
822 ol_link_threads=posix
827 dnl ====================================================================
828 dnl Check GNU Pth pthread Header
830 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
831 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
832 dnl doesn't exists. Existance of pthread.h should separately
835 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
836 AC_CACHE_CHECK([for GNU Pth pthread.h],
837 [ol_cv_header_gnu_pth_pthread_h],
838 [AC_EGREP_CPP(__gnu_pth__,
839 [#include <pthread.h>
840 #ifdef _POSIX_THREAD_IS_GNU_PTH
844 [ol_cv_header_gnu_pth_pthread_h=yes],
845 [ol_cv_header_gnu_pth_pthread_h=no])
848 dnl ====================================================================
849 dnl Check for NT Threads
850 AC_DEFUN([OL_NT_THREADS], [
851 AC_CHECK_FUNC(_beginthread)
853 if test $ac_cv_func__beginthread = yes ; then
854 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
858 dnl ====================================================================
859 dnl Check LinuxThreads Header
861 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
862 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
863 dnl doesn't exists. Existance of pthread.h should separately
866 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
867 AC_CACHE_CHECK([for LinuxThreads pthread.h],
868 [ol_cv_header_linux_threads],
869 [AC_EGREP_CPP(pthread_kill_other_threads_np,
870 [#include <pthread.h>],
871 [ol_cv_header_linux_threads=yes],
872 [ol_cv_header_linux_threads=no])
874 if test $ol_cv_header_linux_threads = yes; then
875 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
878 dnl --------------------------------------------------------------------
879 dnl Check LinuxThreads Implementation
881 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
882 dnl 'no' implies pthreads implementation is not LinuxThreads.
884 AC_DEFUN([OL_SYS_LINUX_THREADS], [
885 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
886 AC_CACHE_CHECK([for LinuxThreads implementation],
887 [ol_cv_sys_linux_threads],
888 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
891 dnl --------------------------------------------------------------------
892 dnl Check LinuxThreads consistency
893 AC_DEFUN([OL_LINUX_THREADS], [
894 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
895 AC_REQUIRE([OL_SYS_LINUX_THREADS])
896 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
897 if test $ol_cv_header_linux_threads = yes &&
898 test $ol_cv_sys_linux_threads = yes; then
899 ol_cv_linux_threads=yes
900 elif test $ol_cv_header_linux_threads = no &&
901 test $ol_cv_sys_linux_threads = no; then
902 ol_cv_linux_threads=no
904 ol_cv_linux_threads=error
909 dnl ====================================================================
910 dnl Check for POSIX Regex
911 AC_DEFUN([OL_POSIX_REGEX], [
912 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
913 AC_RUN_IFELSE([AC_LANG_SOURCE([[
914 #include <sys/types.h>
916 static char *pattern, *string;
924 if(regcomp(&re, pattern, 0)) {
928 string = "ALL MATCH";
930 rc = regexec(&re, string, 0, (void*)0, 0);
935 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
938 dnl ====================================================================
939 dnl Check if toupper() requires islower() to be called first
940 AC_DEFUN([OL_C_UPPER_LOWER],
941 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
942 AC_RUN_IFELSE([AC_LANG_SOURCE([[
946 if ('C' == toupper('C'))
950 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
951 if test $ol_cv_c_upper_lower != no ; then
952 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
956 dnl ====================================================================
957 dnl Error string checks
959 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
960 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
961 dnl Reported by Keith Bostic.
962 AC_DEFUN([OL_SYS_ERRLIST],
963 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
964 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
966 #include <sys/types.h>
970 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
971 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
973 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
974 if test $ol_cv_dcl_sys_errlist = no ; then
975 AC_DEFINE(DECL_SYS_ERRLIST,1,
976 [define if sys_errlist is not declared in stdio.h or errno.h])
978 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
979 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])])
981 if test $ol_cv_have_sys_errlist = yes ; then
982 AC_DEFINE(HAVE_SYS_ERRLIST,1,
983 [define if you actually have sys_errlist in your libs])
986 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
987 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
988 AC_EGREP_CPP(strerror_r,[#include <string.h>],
989 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
991 if test $ol_decl_strerror_r = yes ; then
992 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
994 char x = *strerror_r (0, buf, sizeof buf);
995 char *p = strerror_r (0, buf, sizeof buf);
996 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
998 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1002 strerror_r( 1, buf, sizeof buf );
1003 exit( buf[0] == 0 );
1005 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
1008 if test $ol_cv_nonposix_strerror_r = yes ; then
1009 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1010 [define if strerror_r returns char* instead of int])
1014 AC_DEFUN([OL_STRERROR],
1015 [OL_SYS_ERRLIST dnl TEMPORARY
1016 AC_CHECK_FUNCS(strerror strerror_r)
1017 ol_cv_func_strerror_r=no
1018 if test "${ac_cv_func_strerror_r}" = yes ; then
1019 OL_NONPOSIX_STRERROR_R
1020 elif test "${ac_cv_func_strerror}" = no ; then
1024 dnl ====================================================================
1025 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1026 dnl "int x; int *volatile a = &x; *a = 0;"
1027 dnl -- borrowed from PDKSH
1028 AC_DEFUN([OL_C_VOLATILE],
1029 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1030 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
1031 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1032 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
1033 if test $ol_cv_c_volatile = yes; then
1036 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1040 dnl ====================================================================
1041 dnl Look for fetch(3)
1042 AC_DEFUN([OL_LIB_FETCH],
1044 LIBS="-lfetch -lcom_err $LIBS"
1045 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1046 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1047 #include <sys/param.h>
1049 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
1051 if test $ol_cv_lib_fetch != no ; then
1052 ol_link_fetch="-lfetch -lcom_err"
1053 AC_DEFINE(HAVE_FETCH,1,
1054 [define if you actually have FreeBSD fetch(3)])
1058 dnl ====================================================================
1059 dnl Define inet_aton is available
1060 AC_DEFUN([OL_FUNC_INET_ATON],
1061 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1062 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1063 #ifdef HAVE_SYS_TYPES_H
1064 # include <sys/types.h>
1066 #ifdef HAVE_SYS_SOCKET_H
1067 # include <sys/socket.h>
1068 # ifdef HAVE_SYS_SELECT_H
1069 # include <sys/select.h>
1071 # include <netinet/in.h>
1072 # ifdef HAVE_ARPA_INET_H
1073 # include <arpa/inet.h>
1076 ]], [[struct in_addr in;
1077 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
1078 if test $ol_cv_func_inet_aton != no; then
1079 AC_DEFINE(HAVE_INET_ATON, 1,
1080 [define to you inet_aton(3) is available])
1084 dnl ====================================================================
1085 dnl check no of arguments for ctime_r
1086 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
1087 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1088 [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])
1090 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])
1092 if test $ol_cv_func_ctime_r_nargs3 = yes &&
1093 test $ol_cv_func_ctime_r_nargs2 = no ; then
1095 ol_cv_func_ctime_r_nargs=3
1097 elif test $ol_cv_func_ctime_r_nargs3 = no &&
1098 test $ol_cv_func_ctime_r_nargs2 = yes ; then
1100 ol_cv_func_ctime_r_nargs=2
1103 ol_cv_func_ctime_r_nargs=0
1107 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1108 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1109 [set to the number of arguments ctime_r() expects])
1113 dnl --------------------------------------------------------------------
1114 dnl check return type of ctime_r()
1115 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1116 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1117 [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"])
1119 if test $ol_cv_func_ctime_r_type = "int" ; then
1120 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1123 dnl ====================================================================
1124 dnl check no of arguments for gethostbyname_r
1125 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1126 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1127 ol_cv_func_gethostbyname_r_nargs,
1128 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1129 #include <sys/socket.h>
1130 #include <netinet/in.h>
1132 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1133 int bufsize=BUFSIZE;int h_errno;
1134 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1135 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1137 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1138 #include <sys/socket.h>
1139 #include <netinet/in.h>
1141 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1142 char buffer[BUFSIZE];
1143 int bufsize=BUFSIZE;int h_errno;
1144 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1145 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1147 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1148 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1150 ol_cv_func_gethostbyname_r_nargs=5
1152 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1153 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1155 ol_cv_func_gethostbyname_r_nargs=6
1158 ol_cv_func_gethostbyname_r_nargs=0
1161 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1162 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1163 $ol_cv_func_gethostbyname_r_nargs,
1164 [set to the number of arguments gethostbyname_r() expects])
1168 dnl check no of arguments for gethostbyaddr_r
1169 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1170 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1171 [ol_cv_func_gethostbyaddr_r_nargs],
1172 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1173 #include <sys/socket.h>
1174 #include <netinet/in.h>
1176 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1178 size_t alen=sizeof(struct in_addr);
1179 int bufsize=BUFSIZE;int h_errno;
1180 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1181 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1183 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1184 #include <sys/socket.h>
1185 #include <netinet/in.h>
1187 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1188 struct hostent *rhent; char buffer[BUFSIZE];
1190 size_t alen=sizeof(struct in_addr);
1191 int bufsize=BUFSIZE;int h_errno;
1192 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1193 alen, AF_INET, &hent, buffer, bufsize,
1194 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1196 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1197 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1199 ol_cv_func_gethostbyaddr_r_nargs=7
1201 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1202 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1204 ol_cv_func_gethostbyaddr_r_nargs=8
1207 ol_cv_func_gethostbyaddr_r_nargs=0
1210 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1211 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1212 $ol_cv_func_gethostbyaddr_r_nargs,
1213 [set to the number of arguments gethostbyaddr_r() expects])
1217 dnl --------------------------------------------------------------------
1218 dnl Check for Cyrus SASL version compatility
1219 AC_DEFUN([OL_SASL_COMPAT],
1220 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1221 AC_EGREP_CPP(__sasl_compat,[
1222 #ifdef HAVE_SASL_SASL_H
1223 #include <sasl/sasl.h>
1228 /* Require 2.1.15+ */
1229 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1230 char *__sasl_compat = "2.2+ or better okay (we guess)";
1231 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1232 && SASL_VERSION_STEP >=15
1233 char *__sasl_compat = "2.1.15+ or better okay";
1235 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1237 dnl ====================================================================
1238 dnl check for SSL compatibility
1239 AC_DEFUN([OL_SSL_COMPAT],
1240 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)], [ol_cv_ssl_crl_compat],[
1241 AC_EGREP_CPP(__ssl_compat,[
1242 #ifdef HAVE_OPENSSL_SSL_H
1243 #include <openssl/ssl.h>
1248 /* Require 0.9.7d+ */
1249 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1250 char *__ssl_compat = "0.9.7d";
1252 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])