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 International Components for Unicode (ICU)
239 AC_CHECK_HEADERS( unicode/utypes.h )
240 if test $ac_cv_header_unicode_utypes_h = yes ; then
241 dnl OL_ICULIBS="-licui18n -licuuc -licudata"
242 OL_ICULIBS="-licuuc -licudata"
244 AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [
246 LIBS="$OL_ICULIBS $LIBS"
247 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
248 #include <unicode/utypes.h>
250 (void) u_errorName(0);
251 ]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no])
255 if test $ol_cv_lib_icu != no ; then
257 AC_DEFINE(HAVE_ICU,1,[define if you actually have ICU])
262 dnl ====================================================================
263 dnl Berkeley DB macros
265 dnl --------------------------------------------------------------------
267 AC_DEFUN([OL_BERKELEY_DB_TRY],
268 [if test $ol_cv_lib_db = no ; then
269 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
271 ol_DB_LIB=ifelse($2,,,$2)
273 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
275 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
282 #ifndef DB_VERSION_MAJOR
283 # define DB_VERSION_MAJOR 1
287 #define NULL ((void*)0)
290 #if DB_VERSION_MAJOR > 1
293 int major, minor, patch;
295 version = db_version( &major, &minor, &patch );
297 if( major != DB_VERSION_MAJOR ||
298 minor < DB_VERSION_MINOR )
300 printf("Berkeley DB version mismatch\n"
301 "\theader: %s\n\tlibrary: %s\n",
302 DB_VERSION_STRING, version);
308 #if DB_VERSION_MAJOR > 2
309 db_env_create( NULL, 0 );
310 #elif DB_VERSION_MAJOR > 1
313 (void) dbopen( NULL, 0, 0, 0, NULL);
315 ]])],[$1=yes],[$1=no])
320 if test $$1 = yes ; then
321 ol_cv_lib_db=ifelse($2,,yes,$2)
326 dnl --------------------------------------------------------------------
327 dnl Try to locate appropriate library
328 AC_DEFUN([OL_BERKELEY_DB_LINK],
330 OL_BERKELEY_DB_TRY(ol_cv_db_none)
331 OL_BERKELEY_DB_TRY(ol_cv_db_db44,[-ldb44])
332 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-44])
333 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_4,[-ldb-4.4])
334 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_4,[-ldb-4-4])
335 OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
336 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
337 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
338 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
339 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
340 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
341 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
342 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
343 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
344 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
345 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
346 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
347 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
348 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
349 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
350 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
351 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
352 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
353 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
354 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
355 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
358 dnl --------------------------------------------------------------------
359 dnl Check if Berkeley DB version
360 AC_DEFUN([OL_BERKELEY_DB_VERSION],
361 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
363 LIBS="$LTHREAD_LIBS $LIBS"
364 if test $ol_cv_lib_db != yes ; then
365 LIBS="$ol_cv_lib_db $LIBS"
368 AC_RUN_IFELSE([AC_LANG_SOURCE([[
374 #ifndef DB_VERSION_MAJOR
375 # define DB_VERSION_MAJOR 1
378 #define NULL ((void *)0)
382 #if DB_VERSION_MAJOR > 1
384 int major, minor, patch;
386 version = db_version( &major, &minor, &patch );
388 if( major != DB_VERSION_MAJOR ||
389 minor != DB_VERSION_MINOR ||
390 patch != DB_VERSION_PATCH )
392 printf("Berkeley DB version mismatch\n"
393 "\theader: %s\n\tlibrary: %s\n",
394 DB_VERSION_STRING, version);
400 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
405 if test $ol_cv_berkeley_db_version = no ; then
406 AC_MSG_ERROR([Berkeley DB version mismatch])
410 dnl --------------------------------------------------------------------
411 dnl Check if Berkeley DB supports DB_THREAD
412 AC_DEFUN([OL_BERKELEY_DB_THREAD],
413 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
415 LIBS="$LTHREAD_LIBS $LIBS"
416 if test $ol_cv_lib_db != yes ; then
417 LIBS="$ol_cv_lib_db $LIBS"
420 AC_RUN_IFELSE([AC_LANG_SOURCE([[
427 #define NULL ((void *)0)
432 u_int32_t flags = DB_CREATE |
438 #if DB_VERSION_MAJOR > 2
441 rc = db_env_create( &env, 0 );
443 flags |= DB_INIT_MPOOL;
444 #ifdef DB_MPOOL_PRIVATE
445 flags |= DB_MPOOL_PRIVATE;
449 printf("BerkeleyDB: %s\n", db_strerror(rc) );
453 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
454 rc = env->open( env, NULL, flags, 0 );
456 rc = env->open( env, NULL, NULL, flags, 0 );
460 rc = env->close( env, 0 );
464 printf("BerkeleyDB: %s\n", db_strerror(rc) );
470 memset( &env, '\0', sizeof(env) );
472 rc = db_appinit( NULL, NULL, &env, flags );
478 unlink("__db_mpool.share");
479 unlink("__db_lock.share");
483 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
488 if test $ol_cv_berkeley_db_thread != no ; then
489 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
490 [define if Berkeley DB has DB_THREAD support])
494 dnl --------------------------------------------------------------------
496 AC_DEFUN([OL_BERKELEY_DB],
497 [ol_cv_berkeley_db=no
498 AC_CHECK_HEADERS(db.h)
499 if test $ac_cv_header_db_h = yes; then
501 if test "$ol_cv_lib_db" != no ; then
502 ol_cv_berkeley_db=yes
503 OL_BERKELEY_DB_VERSION
504 OL_BERKELEY_DB_THREAD
508 dnl --------------------------------------------------------------------
509 dnl Check for version compatility with back-bdb
510 AC_DEFUN([OL_BDB_COMPAT],
511 [AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[
512 AC_EGREP_CPP(__db_version_compat,[
515 /* this check could be improved */
516 #ifndef DB_VERSION_MAJOR
517 # define DB_VERSION_MAJOR 1
519 #ifndef DB_VERSION_MINOR
520 # define DB_VERSION_MINOR 0
523 /* require 4.2 or later */
524 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
527 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
530 dnl --------------------------------------------------------------------
531 dnl Find old Berkeley DB 1.85/1.86
532 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
533 [AC_CHECK_HEADERS(db_185.h db.h)
534 if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
535 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
536 AC_EGREP_CPP(__db_version_1,[
543 /* this check could be improved */
544 #ifndef DB_VERSION_MAJOR
545 # define DB_VERSION_MAJOR 1
548 #if DB_VERSION_MAJOR == 1
551 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
553 if test $ol_cv_header_db1 = yes ; then
555 if test "$ol_cv_lib_db" != no ; then
556 ol_cv_berkeley_db=yes
562 dnl ====================================================================
563 dnl Check if GDBM library exists
564 dnl Check for gdbm_open in standard libraries or -lgdbm
566 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
567 dnl 'yes' implies gdbm_open is in $LIBS
570 dnl AC_CHECK_FUNC(gdbm_open)
571 dnl AC_CHECK_LIB(gdbm,gdbm_open)
573 AC_DEFUN([OL_LIB_GDBM],
574 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
576 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
577 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
583 dnl --------------------------------------------------------------------
584 dnl Check if GDBM exists
586 dnl defines ol_cv_gdbm to 'yes' or 'no'
590 dnl AC_CHECK_HEADERS(gdbm.h)
593 [AC_REQUIRE([OL_LIB_GDBM])
594 AC_CHECK_HEADERS(gdbm.h)
595 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
596 if test $ol_cv_lib_gdbm = no || test $ac_cv_header_gdbm_h = no ; then
602 if test $ol_cv_gdbm = yes ; then
603 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
607 dnl ====================================================================
608 dnl Check if MDBM library exists
609 dnl Check for mdbm_open in standard libraries or -lmdbm
611 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
612 dnl 'yes' implies mdbm_open is in $LIBS
615 dnl AC_CHECK_FUNC(mdbm_set_chain)
616 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
618 AC_DEFUN([OL_LIB_MDBM],
619 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
621 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
622 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
628 dnl --------------------------------------------------------------------
629 dnl Check if MDBM exists
631 dnl defines ol_cv_mdbm to 'yes' or 'no'
635 dnl AC_CHECK_HEADERS(mdbm.h)
638 [AC_REQUIRE([OL_LIB_MDBM])
639 AC_CHECK_HEADERS(mdbm.h)
640 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
641 if test $ol_cv_lib_mdbm = no || test $ac_cv_header_mdbm_h = no ; then
647 if test $ol_cv_mdbm = yes ; then
648 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
652 dnl ====================================================================
653 dnl Check if NDBM library exists
654 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
656 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
657 dnl 'yes' implies ndbm_open is in $LIBS
660 dnl AC_CHECK_FUNC(dbm_open)
661 dnl AC_CHECK_LIB(ndbm,dbm_open)
662 dnl AC_CHECK_LIB(dbm,dbm_open)
665 dnl should also check SVR4 case: dbm_open() in -lucb but that
666 dnl would requiring dealing with -L/usr/ucblib
668 AC_DEFUN([OL_LIB_NDBM],
669 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
671 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
672 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
673 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
674 [ol_cv_lib_ndbm=no])dnl
681 dnl --------------------------------------------------------------------
682 dnl Check if NDBM exists
684 dnl defines ol_cv_ndbm to 'yes' or 'no'
688 dnl AC_CHECK_HEADERS(ndbm.h)
691 dnl Doesn't handle SVR4 case (see above)
694 [AC_REQUIRE([OL_LIB_NDBM])
695 AC_CHECK_HEADERS(ndbm.h)
696 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
697 if test $ol_cv_lib_ndbm = no || test $ac_cv_header_ndbm_h = no ; then
703 if test $ol_cv_ndbm = yes ; then
704 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
708 dnl ====================================================================
709 dnl Check POSIX Thread version
711 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
712 dnl version of the POSIX.4a Draft that is implemented.
713 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
714 dnl Existence of pthread.h should be tested separately.
717 dnl pthread_detach() was dropped in Draft 8, it is present
718 dnl in every other version
719 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
720 dnl PTHREAD_CREATE_JOINABLE after that
721 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
722 dnl Draft 6-10 has _init, Draft 4-5 has _create.
723 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
724 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
725 dnl interesting to us because we don't try to statically
726 dnl initialize mutexes. 5-10 has it.
728 dnl Draft 9 and 10 are equivalent for our purposes.
730 AC_DEFUN([OL_POSIX_THREAD_VERSION],
731 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
733 # include <pthread.h>
735 int i = PTHREAD_CREATE_JOINABLE;
737 AC_EGREP_HEADER(pthread_detach,pthread.h,
738 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
739 AC_EGREP_CPP(draft7,[
740 # include <pthread.h>
741 # ifdef PTHREAD_CREATE_UNDETACHED
744 ], ol_cv_pthread_version=7, [
745 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
746 ol_cv_pthread_version=6, [
747 AC_EGREP_CPP(draft5,[
748 # include <pthread.h>
749 #ifdef PTHREAD_MUTEX_INITIALIZER
752 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
756 dnl --------------------------------------------------------------------
757 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
758 /* pthread test headers */
760 #if HAVE_PTHREADS < 7
764 #define NULL (void*)0
770 return (void *) (p == NULL);
773 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
774 /* pthread test function */
775 #ifndef PTHREAD_CREATE_DETACHED
776 #define PTHREAD_CREATE_DETACHED 1
780 int detach = PTHREAD_CREATE_DETACHED;
782 #if HAVE_PTHREADS > 4
786 status = pthread_attr_init(&attr);
787 if( status ) return status;
789 #if HAVE_PTHREADS < 7
790 status = pthread_attr_setdetachstate(&attr, &detach);
791 if( status < 0 ) status = errno;
793 status = pthread_attr_setdetachstate(&attr, detach);
795 if( status ) return status;
796 status = pthread_create( &t, &attr, task, NULL );
797 #if HAVE_PTHREADS < 7
798 if( status < 0 ) status = errno;
800 if( status ) return status;
802 /* Draft 4 pthreads */
803 status = pthread_create( &t, pthread_attr_default, task, NULL );
804 if( status ) return errno;
806 /* give thread a chance to complete */
807 /* it should remain joinable and hence detachable */
810 status = pthread_detach( &t );
811 if( status ) return errno;
814 #ifdef HAVE_LINUX_THREADS
815 pthread_kill_other_threads_np();
821 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
822 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
828 OL_PTHREAD_TEST_FUNCTION
831 dnl --------------------------------------------------------------------
832 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
833 if test "$ol_link_threads" = no ; then
835 AC_CACHE_CHECK([for pthread link with $1], [$2], [
840 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
843 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
844 OL_PTHREAD_TEST_FUNCTION)],
851 if test $$2 = yes ; then
852 ol_link_pthreads="$1"
853 ol_link_threads=posix
858 dnl ====================================================================
859 dnl Check GNU Pth pthread 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_GNU_PTH_PTHREAD_H], [
867 AC_CACHE_CHECK([for GNU Pth pthread.h],
868 [ol_cv_header_gnu_pth_pthread_h],
869 [AC_EGREP_CPP(__gnu_pth__,
870 [#include <pthread.h>
871 #ifdef _POSIX_THREAD_IS_GNU_PTH
875 [ol_cv_header_gnu_pth_pthread_h=yes],
876 [ol_cv_header_gnu_pth_pthread_h=no])
879 dnl ====================================================================
880 dnl Check for NT Threads
881 AC_DEFUN([OL_NT_THREADS], [
882 AC_CHECK_FUNC(_beginthread)
884 if test $ac_cv_func__beginthread = yes ; then
885 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
889 dnl ====================================================================
890 dnl Check LinuxThreads Header
892 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
893 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
894 dnl doesn't exists. Existance of pthread.h should separately
897 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
898 AC_CACHE_CHECK([for LinuxThreads pthread.h],
899 [ol_cv_header_linux_threads],
900 [AC_EGREP_CPP(pthread_kill_other_threads_np,
901 [#include <pthread.h>],
902 [ol_cv_header_linux_threads=yes],
903 [ol_cv_header_linux_threads=no])
905 if test $ol_cv_header_linux_threads = yes; then
906 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
909 dnl --------------------------------------------------------------------
910 dnl Check LinuxThreads Implementation
912 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
913 dnl 'no' implies pthreads implementation is not LinuxThreads.
915 AC_DEFUN([OL_SYS_LINUX_THREADS], [
916 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
917 AC_CACHE_CHECK([for LinuxThreads implementation],
918 [ol_cv_sys_linux_threads],
919 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
922 dnl --------------------------------------------------------------------
923 dnl Check LinuxThreads consistency
924 AC_DEFUN([OL_LINUX_THREADS], [
925 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
926 AC_REQUIRE([OL_SYS_LINUX_THREADS])
927 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
928 if test $ol_cv_header_linux_threads = yes &&
929 test $ol_cv_sys_linux_threads = yes; then
930 ol_cv_linux_threads=yes
931 elif test $ol_cv_header_linux_threads = no &&
932 test $ol_cv_sys_linux_threads = no; then
933 ol_cv_linux_threads=no
935 ol_cv_linux_threads=error
940 dnl ====================================================================
941 dnl Check for POSIX Regex
942 AC_DEFUN([OL_POSIX_REGEX], [
943 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
944 AC_RUN_IFELSE([AC_LANG_SOURCE([[
945 #include <sys/types.h>
947 static char *pattern, *string;
955 if(regcomp(&re, pattern, 0)) {
959 string = "ALL MATCH";
961 rc = regexec(&re, string, 0, (void*)0, 0);
966 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
969 dnl ====================================================================
970 dnl Check if toupper() requires islower() to be called first
971 AC_DEFUN([OL_C_UPPER_LOWER],
972 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
973 AC_RUN_IFELSE([AC_LANG_SOURCE([[
977 if ('C' == toupper('C'))
981 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
982 if test $ol_cv_c_upper_lower != no ; then
983 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
987 dnl ====================================================================
988 dnl Error string checks
990 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
991 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
992 dnl Reported by Keith Bostic.
993 AC_DEFUN([OL_SYS_ERRLIST],
994 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
995 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
997 #include <sys/types.h>
1001 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
1002 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
1004 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
1005 if test $ol_cv_dcl_sys_errlist = no ; then
1006 AC_DEFINE(DECL_SYS_ERRLIST,1,
1007 [define if sys_errlist is not declared in stdio.h or errno.h])
1009 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
1010 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])])
1012 if test $ol_cv_have_sys_errlist = yes ; then
1013 AC_DEFINE(HAVE_SYS_ERRLIST,1,
1014 [define if you actually have sys_errlist in your libs])
1017 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
1018 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
1019 AC_EGREP_CPP(strerror_r,[#include <string.h>],
1020 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
1022 if test $ol_decl_strerror_r = yes ; then
1023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
1025 char x = *strerror_r (0, buf, sizeof buf);
1026 char *p = strerror_r (0, buf, sizeof buf);
1027 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
1029 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1033 strerror_r( 1, buf, sizeof buf );
1034 exit( buf[0] == 0 );
1036 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
1039 if test $ol_cv_nonposix_strerror_r = yes ; then
1040 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1041 [define if strerror_r returns char* instead of int])
1045 AC_DEFUN([OL_STRERROR],
1046 [OL_SYS_ERRLIST dnl TEMPORARY
1047 AC_CHECK_FUNCS(strerror strerror_r)
1048 ol_cv_func_strerror_r=no
1049 if test "${ac_cv_func_strerror_r}" = yes ; then
1050 OL_NONPOSIX_STRERROR_R
1051 elif test "${ac_cv_func_strerror}" = no ; then
1055 dnl ====================================================================
1056 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1057 dnl "int x; int *volatile a = &x; *a = 0;"
1058 dnl -- borrowed from PDKSH
1059 AC_DEFUN([OL_C_VOLATILE],
1060 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1061 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
1062 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1063 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
1064 if test $ol_cv_c_volatile = yes; then
1067 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1071 dnl ====================================================================
1072 dnl Look for fetch(3)
1073 AC_DEFUN([OL_LIB_FETCH],
1075 LIBS="-lfetch -lcom_err $LIBS"
1076 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1077 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1078 #include <sys/param.h>
1080 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
1082 if test $ol_cv_lib_fetch != no ; then
1083 ol_link_fetch="-lfetch -lcom_err"
1084 AC_DEFINE(HAVE_FETCH,1,
1085 [define if you actually have FreeBSD fetch(3)])
1089 dnl ====================================================================
1090 dnl Define inet_aton is available
1091 AC_DEFUN([OL_FUNC_INET_ATON],
1092 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1093 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1094 #ifdef HAVE_SYS_TYPES_H
1095 # include <sys/types.h>
1097 #ifdef HAVE_SYS_SOCKET_H
1098 # include <sys/socket.h>
1099 # ifdef HAVE_SYS_SELECT_H
1100 # include <sys/select.h>
1102 # include <netinet/in.h>
1103 # ifdef HAVE_ARPA_INET_H
1104 # include <arpa/inet.h>
1107 ]], [[struct in_addr in;
1108 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
1109 if test $ol_cv_func_inet_aton != no; then
1110 AC_DEFINE(HAVE_INET_ATON, 1,
1111 [define to you inet_aton(3) is available])
1115 dnl ====================================================================
1116 dnl check no of arguments for ctime_r
1117 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
1118 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1119 [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])
1121 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])
1123 if test $ol_cv_func_ctime_r_nargs3 = yes &&
1124 test $ol_cv_func_ctime_r_nargs2 = no ; then
1126 ol_cv_func_ctime_r_nargs=3
1128 elif test $ol_cv_func_ctime_r_nargs3 = no &&
1129 test $ol_cv_func_ctime_r_nargs2 = yes ; then
1131 ol_cv_func_ctime_r_nargs=2
1134 ol_cv_func_ctime_r_nargs=0
1138 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1139 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1140 [set to the number of arguments ctime_r() expects])
1144 dnl --------------------------------------------------------------------
1145 dnl check return type of ctime_r()
1146 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1147 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1148 [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"])
1150 if test $ol_cv_func_ctime_r_type = "int" ; then
1151 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1154 dnl ====================================================================
1155 dnl check no of arguments for gethostbyname_r
1156 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1157 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1158 ol_cv_func_gethostbyname_r_nargs,
1159 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1160 #include <sys/socket.h>
1161 #include <netinet/in.h>
1163 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1164 int bufsize=BUFSIZE;int h_errno;
1165 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1166 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1169 #include <sys/socket.h>
1170 #include <netinet/in.h>
1172 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1173 char buffer[BUFSIZE];
1174 int bufsize=BUFSIZE;int h_errno;
1175 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1176 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1178 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1179 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1181 ol_cv_func_gethostbyname_r_nargs=5
1183 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1184 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1186 ol_cv_func_gethostbyname_r_nargs=6
1189 ol_cv_func_gethostbyname_r_nargs=0
1192 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1193 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1194 $ol_cv_func_gethostbyname_r_nargs,
1195 [set to the number of arguments gethostbyname_r() expects])
1199 dnl check no of arguments for gethostbyaddr_r
1200 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1201 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1202 [ol_cv_func_gethostbyaddr_r_nargs],
1203 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1204 #include <sys/socket.h>
1205 #include <netinet/in.h>
1207 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1209 size_t alen=sizeof(struct in_addr);
1210 int bufsize=BUFSIZE;int h_errno;
1211 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1212 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1214 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1215 #include <sys/socket.h>
1216 #include <netinet/in.h>
1218 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1219 struct hostent *rhent; char buffer[BUFSIZE];
1221 size_t alen=sizeof(struct in_addr);
1222 int bufsize=BUFSIZE;int h_errno;
1223 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1224 alen, AF_INET, &hent, buffer, bufsize,
1225 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1227 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1228 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1230 ol_cv_func_gethostbyaddr_r_nargs=7
1232 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1233 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1235 ol_cv_func_gethostbyaddr_r_nargs=8
1238 ol_cv_func_gethostbyaddr_r_nargs=0
1241 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1242 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1243 $ol_cv_func_gethostbyaddr_r_nargs,
1244 [set to the number of arguments gethostbyaddr_r() expects])
1248 dnl --------------------------------------------------------------------
1249 dnl Check for Cyrus SASL version compatility
1250 AC_DEFUN([OL_SASL_COMPAT],
1251 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1252 AC_EGREP_CPP(__sasl_compat,[
1253 #ifdef HAVE_SASL_SASL_H
1254 #include <sasl/sasl.h>
1259 /* Require 2.1.15+ */
1260 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1261 char *__sasl_compat = "2.2+ or better okay (we guess)";
1262 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1263 && SASL_VERSION_STEP >=15
1264 char *__sasl_compat = "2.1.15+ or better okay";
1266 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1268 dnl ====================================================================
1269 dnl check for SSL compatibility
1270 AC_DEFUN([OL_SSL_COMPAT],
1271 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)], [ol_cv_ssl_crl_compat],[
1272 AC_EGREP_CPP(__ssl_compat,[
1273 #ifdef HAVE_OPENSSL_SSL_H
1274 #include <openssl/ssl.h>
1279 /* Require 0.9.7d+ */
1280 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1281 char *__ssl_compat = "0.9.7d";
1283 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])