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 > 1
294 int major, minor, patch;
296 version = db_version( &major, &minor, &patch );
298 if( major != DB_VERSION_MAJOR ||
299 minor < DB_VERSION_MINOR )
301 printf("Berkeley DB version mismatch\n"
302 "\theader: %s\n\tlibrary: %s\n",
303 DB_VERSION_STRING, version);
309 #if DB_VERSION_MAJOR > 2
310 db_env_create( NULL, 0 );
311 #elif DB_VERSION_MAJOR > 1
314 (void) dbopen( NULL, 0, 0, 0, NULL);
316 ]])],[$1=yes],[$1=no])
321 if test $$1 = yes ; then
322 ol_cv_lib_db=ifelse($2,,yes,$2)
327 dnl --------------------------------------------------------------------
328 dnl Try to locate appropriate library
329 AC_DEFUN([OL_BERKELEY_DB_LINK],
332 dnl Determine major version
333 AC_CACHE_CHECK([for Berkeley DB major version], [ol_cv_bdb_major],[
335 if test $ol_cv_bdb_major = 0 ; then
336 AC_EGREP_CPP(__db_version, [
338 #ifndef DB_VERSION_MAJOR
339 # define DB_VERSION_MAJOR 1
341 #if DB_VERSION_MAJOR == 4
344 ], [ol_cv_bdb_major=4], [:])
346 if test $ol_cv_bdb_major = 0 ; then
347 AC_EGREP_CPP(__db_version, [
349 #ifndef DB_VERSION_MAJOR
350 # define DB_VERSION_MAJOR 1
352 #if DB_VERSION_MAJOR == 3
355 ], [ol_cv_bdb_major=3], [:])
357 if test $ol_cv_bdb_major = 0 ; then
358 AC_EGREP_CPP(__db_version, [
360 #ifndef DB_VERSION_MAJOR
361 # define DB_VERSION_MAJOR 1
363 #if DB_VERSION_MAJOR == 2
366 ], [ol_cv_bdb_major=2], [:])
368 if test $ol_cv_bdb_major = 0 ; then
369 AC_EGREP_CPP(__db_version, [
371 #ifndef DB_VERSION_MAJOR
372 # define DB_VERSION_MAJOR 1
374 #if DB_VERSION_MAJOR == 1
377 ], [ol_cv_bdb_major=1], [:])
380 if test $ol_cv_bdb_major = 0 ; then
381 AC_MSG_ERROR([Unknown Berkeley DB major version])
385 dnl Determine minor version
386 AC_CACHE_CHECK([for Berkeley DB minor version], [ol_cv_bdb_minor],[
388 if test $ol_cv_bdb_minor = 0 ; then
389 AC_EGREP_CPP(__db_version, [
391 #ifndef DB_VERSION_MINOR
392 # define DB_VERSION_MINOR 0
394 #if DB_VERSION_MINOR == 9
397 ], [ol_cv_bdb_minor=9], [:])
399 if test $ol_cv_bdb_minor = 0 ; then
400 AC_EGREP_CPP(__db_version, [
402 #ifndef DB_VERSION_MINOR
403 # define DB_VERSION_MINOR 0
405 #if DB_VERSION_MINOR == 8
408 ], [ol_cv_bdb_minor=8], [:])
410 if test $ol_cv_bdb_minor = 0 ; then
411 AC_EGREP_CPP(__db_version, [
413 #ifndef DB_VERSION_MINOR
414 # define DB_VERSION_MINOR 0
416 #if DB_VERSION_MINOR == 7
419 ], [ol_cv_bdb_minor=7], [:])
421 if test $ol_cv_bdb_minor = 0 ; then
422 AC_EGREP_CPP(__db_version, [
424 #ifndef DB_VERSION_MINOR
425 # define DB_VERSION_MINOR 0
427 #if DB_VERSION_MINOR == 6
430 ], [ol_cv_bdb_minor=6], [:])
432 if test $ol_cv_bdb_minor = 0 ; then
433 AC_EGREP_CPP(__db_version, [
435 #ifndef DB_VERSION_MINOR
436 # define DB_VERSION_MINOR 0
438 #if DB_VERSION_MINOR == 5
441 ], [ol_cv_bdb_minor=5], [:])
443 if test $ol_cv_bdb_minor = 0 ; then
444 AC_EGREP_CPP(__db_version, [
446 #ifndef DB_VERSION_MINOR
447 # define DB_VERSION_MINOR 0
449 #if DB_VERSION_MINOR == 4
452 ], [ol_cv_bdb_minor=4], [:])
454 if test $ol_cv_bdb_minor = 0 ; then
455 AC_EGREP_CPP(__db_version, [
457 #ifndef DB_VERSION_MINOR
458 # define DB_VERSION_MINOR 0
460 #if DB_VERSION_MINOR == 3
463 ], [ol_cv_bdb_minor=3], [:])
465 if test $ol_cv_bdb_minor = 0 ; then
466 AC_EGREP_CPP(__db_version, [
468 #ifndef DB_VERSION_MINOR
469 # define DB_VERSION_MINOR 0
471 #if DB_VERSION_MINOR == 2
474 ], [ol_cv_bdb_minor=2], [:])
476 if test $ol_cv_bdb_minor = 0 ; then
477 AC_EGREP_CPP(__db_version, [
479 #ifndef DB_VERSION_MINOR
480 # define DB_VERSION_MINOR 0
482 #if DB_VERSION_MINOR == 1
485 ], [ol_cv_bdb_minor=1], [:])
489 if test $ol_cv_bdb_major = 4 ; then
490 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor])
491 OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor])
492 OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor])
493 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor])
494 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
495 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
496 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
498 elif test $ol_cv_bdb_major = 3 ; then
499 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
500 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
502 elif test $ol_cv_bdb_major = 2 ; then
503 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
504 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
506 elif test $ol_cv_bdb_major = 1 ; then
507 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
508 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
510 OL_BERKELEY_DB_TRY(ol_cv_db_none)
513 dnl --------------------------------------------------------------------
514 dnl Check if Berkeley DB version
515 AC_DEFUN([OL_BERKELEY_DB_VERSION],
516 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
518 LIBS="$LTHREAD_LIBS $LIBS"
519 if test $ol_cv_lib_db != yes ; then
520 LIBS="$ol_cv_lib_db $LIBS"
523 AC_RUN_IFELSE([AC_LANG_SOURCE([[
529 #ifndef DB_VERSION_MAJOR
530 # define DB_VERSION_MAJOR 1
533 #define NULL ((void *)0)
537 #if DB_VERSION_MAJOR > 1
539 int major, minor, patch;
541 version = db_version( &major, &minor, &patch );
543 if( major != DB_VERSION_MAJOR ||
544 minor != DB_VERSION_MINOR ||
545 patch != DB_VERSION_PATCH )
547 printf("Berkeley DB version mismatch\n"
548 "\theader: %s\n\tlibrary: %s\n",
549 DB_VERSION_STRING, version);
555 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
560 if test $ol_cv_berkeley_db_version = no ; then
561 AC_MSG_ERROR([Berkeley DB version mismatch])
565 dnl --------------------------------------------------------------------
566 dnl Check if Berkeley DB supports DB_THREAD
567 AC_DEFUN([OL_BERKELEY_DB_THREAD],
568 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
570 LIBS="$LTHREAD_LIBS $LIBS"
571 if test $ol_cv_lib_db != yes ; then
572 LIBS="$ol_cv_lib_db $LIBS"
575 AC_RUN_IFELSE([AC_LANG_SOURCE([[
582 #define NULL ((void *)0)
587 u_int32_t flags = DB_CREATE |
593 #if DB_VERSION_MAJOR > 2
596 rc = db_env_create( &env, 0 );
598 flags |= DB_INIT_MPOOL;
599 #ifdef DB_MPOOL_PRIVATE
600 flags |= DB_MPOOL_PRIVATE;
604 printf("BerkeleyDB: %s\n", db_strerror(rc) );
608 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
609 rc = (env->open)( env, NULL, flags, 0 );
611 rc = (env->open)( env, NULL, NULL, flags, 0 );
615 rc = env->close( env, 0 );
619 printf("BerkeleyDB: %s\n", db_strerror(rc) );
625 memset( &env, '\0', sizeof(env) );
627 rc = db_appinit( NULL, NULL, &env, flags );
633 unlink("__db_mpool.share");
634 unlink("__db_lock.share");
638 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
643 if test $ol_cv_berkeley_db_thread != no ; then
644 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
645 [define if Berkeley DB has DB_THREAD support])
649 dnl --------------------------------------------------------------------
651 AC_DEFUN([OL_BERKELEY_DB],
652 [ol_cv_berkeley_db=no
653 AC_CHECK_HEADERS(db.h)
654 if test $ac_cv_header_db_h = yes; then
656 if test "$ol_cv_lib_db" != no ; then
657 ol_cv_berkeley_db=yes
658 OL_BERKELEY_DB_VERSION
659 OL_BERKELEY_DB_THREAD
663 dnl --------------------------------------------------------------------
664 dnl Check for version compatility with back-bdb
665 AC_DEFUN([OL_BDB_COMPAT],
666 [AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[
667 AC_EGREP_CPP(__db_version_compat,[
670 /* this check could be improved */
671 #ifndef DB_VERSION_MAJOR
672 # define DB_VERSION_MAJOR 1
674 #ifndef DB_VERSION_MINOR
675 # define DB_VERSION_MINOR 0
678 #define DB_VERSION_MM ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR)
680 /* require 4.4 or later */
681 #if DB_VERSION_MM >= 0x0404
684 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
687 dnl --------------------------------------------------------------------
688 dnl Find old Berkeley DB 1.85/1.86
689 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
690 [AC_CHECK_HEADERS(db_185.h db.h)
691 if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
692 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
693 AC_EGREP_CPP(__db_version_1,[
700 /* this check could be improved */
701 #ifndef DB_VERSION_MAJOR
702 # define DB_VERSION_MAJOR 1
705 #if DB_VERSION_MAJOR == 1
708 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
710 if test $ol_cv_header_db1 = yes ; then
712 if test "$ol_cv_lib_db" != no ; then
713 ol_cv_berkeley_db=yes
719 dnl ====================================================================
720 dnl Check POSIX Thread version
722 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
723 dnl version of the POSIX.4a Draft that is implemented.
724 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
725 dnl Existence of pthread.h should be tested separately.
728 dnl pthread_detach() was dropped in Draft 8, it is present
729 dnl in every other version
730 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
731 dnl PTHREAD_CREATE_JOINABLE after that
732 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
733 dnl Draft 6-10 has _init, Draft 4-5 has _create.
734 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
735 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
736 dnl interesting to us because we don't try to statically
737 dnl initialize mutexes. 5-10 has it.
739 dnl Draft 9 and 10 are equivalent for our purposes.
741 AC_DEFUN([OL_POSIX_THREAD_VERSION],
742 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
743 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
744 # include <pthread.h>
746 int i = PTHREAD_CREATE_JOINABLE;
748 AC_EGREP_HEADER(pthread_detach,pthread.h,
749 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
750 AC_EGREP_CPP(draft7,[
751 # include <pthread.h>
752 # ifdef PTHREAD_CREATE_UNDETACHED
755 ], ol_cv_pthread_version=7, [
756 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
757 ol_cv_pthread_version=6, [
758 AC_EGREP_CPP(draft5,[
759 # include <pthread.h>
760 #ifdef PTHREAD_MUTEX_INITIALIZER
763 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
767 dnl --------------------------------------------------------------------
768 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
769 /* pthread test headers */
771 #if HAVE_PTHREADS < 7
775 #define NULL (void*)0
781 return (void *) (p == NULL);
784 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
785 /* pthread test function */
786 #ifndef PTHREAD_CREATE_DETACHED
787 #define PTHREAD_CREATE_DETACHED 1
791 int detach = PTHREAD_CREATE_DETACHED;
793 #if HAVE_PTHREADS > 4
797 status = pthread_attr_init(&attr);
798 if( status ) return status;
800 #if HAVE_PTHREADS < 7
801 status = pthread_attr_setdetachstate(&attr, &detach);
802 if( status < 0 ) status = errno;
804 status = pthread_attr_setdetachstate(&attr, detach);
806 if( status ) return status;
807 status = pthread_create( &t, &attr, task, NULL );
808 #if HAVE_PTHREADS < 7
809 if( status < 0 ) status = errno;
811 if( status ) return status;
813 /* Draft 4 pthreads */
814 status = pthread_create( &t, pthread_attr_default, task, NULL );
815 if( status ) return errno;
817 /* give thread a chance to complete */
818 /* it should remain joinable and hence detachable */
821 status = pthread_detach( &t );
822 if( status ) return errno;
825 #ifdef HAVE_LINUX_THREADS
826 pthread_kill_other_threads_np();
832 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
833 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
839 OL_PTHREAD_TEST_FUNCTION
842 dnl --------------------------------------------------------------------
843 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
844 if test "$ol_link_threads" = no ; then
846 AC_CACHE_CHECK([for pthread link with $1], [$2], [
851 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
854 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
855 OL_PTHREAD_TEST_FUNCTION)],
862 if test $$2 = yes ; then
863 ol_link_pthreads="$1"
864 ol_link_threads=posix
869 dnl ====================================================================
870 dnl Check GNU Pth pthread Header
872 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
873 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
874 dnl doesn't exists. Existance of pthread.h should separately
877 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
878 AC_CACHE_CHECK([for GNU Pth pthread.h],
879 [ol_cv_header_gnu_pth_pthread_h],
880 [AC_EGREP_CPP(__gnu_pth__,
881 [#include <pthread.h>
882 #ifdef _POSIX_THREAD_IS_GNU_PTH
886 [ol_cv_header_gnu_pth_pthread_h=yes],
887 [ol_cv_header_gnu_pth_pthread_h=no])
890 dnl ====================================================================
891 dnl Check for NT Threads
892 AC_DEFUN([OL_NT_THREADS], [
893 AC_CHECK_FUNC(_beginthread)
895 if test $ac_cv_func__beginthread = yes ; then
896 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
900 dnl ====================================================================
901 dnl Check LinuxThreads Header
903 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
904 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
905 dnl doesn't exists. Existance of pthread.h should separately
908 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
909 AC_CACHE_CHECK([for LinuxThreads pthread.h],
910 [ol_cv_header_linux_threads],
911 [AC_EGREP_CPP(pthread_kill_other_threads_np,
912 [#include <pthread.h>],
913 [ol_cv_header_linux_threads=yes],
914 [ol_cv_header_linux_threads=no])
916 if test $ol_cv_header_linux_threads = yes; then
917 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
920 dnl --------------------------------------------------------------------
921 dnl Check LinuxThreads Implementation
923 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
924 dnl 'no' implies pthreads implementation is not LinuxThreads.
926 AC_DEFUN([OL_SYS_LINUX_THREADS], [
927 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
928 AC_CACHE_CHECK([for LinuxThreads implementation],
929 [ol_cv_sys_linux_threads],
930 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
933 dnl --------------------------------------------------------------------
934 dnl Check LinuxThreads consistency
935 AC_DEFUN([OL_LINUX_THREADS], [
936 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
937 AC_REQUIRE([OL_SYS_LINUX_THREADS])
938 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
939 if test $ol_cv_header_linux_threads = yes &&
940 test $ol_cv_sys_linux_threads = yes; then
941 ol_cv_linux_threads=yes
942 elif test $ol_cv_header_linux_threads = no &&
943 test $ol_cv_sys_linux_threads = no; then
944 ol_cv_linux_threads=no
946 ol_cv_linux_threads=error
951 dnl ====================================================================
952 dnl Check for POSIX Regex
953 AC_DEFUN([OL_POSIX_REGEX], [
954 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
955 AC_RUN_IFELSE([AC_LANG_SOURCE([[
956 #include <sys/types.h>
958 static char *pattern, *string;
966 if(regcomp(&re, pattern, 0)) {
970 string = "ALL MATCH";
972 rc = regexec(&re, string, 0, (void*)0, 0);
977 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
980 dnl ====================================================================
981 dnl Check if toupper() requires islower() to be called first
982 AC_DEFUN([OL_C_UPPER_LOWER],
983 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
984 AC_RUN_IFELSE([AC_LANG_SOURCE([[
988 if ('C' == toupper('C'))
992 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
993 if test $ol_cv_c_upper_lower != no ; then
994 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
998 dnl ====================================================================
999 dnl Error string checks
1001 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
1002 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
1003 dnl Reported by Keith Bostic.
1004 AC_DEFUN([OL_SYS_ERRLIST],
1005 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
1006 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1008 #include <sys/types.h>
1012 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
1013 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
1015 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
1016 if test $ol_cv_dcl_sys_errlist = no ; then
1017 AC_DEFINE(DECL_SYS_ERRLIST,1,
1018 [define if sys_errlist is not declared in stdio.h or errno.h])
1020 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
1021 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])])
1023 if test $ol_cv_have_sys_errlist = yes ; then
1024 AC_DEFINE(HAVE_SYS_ERRLIST,1,
1025 [define if you actually have sys_errlist in your libs])
1028 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
1029 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
1030 AC_EGREP_CPP(strerror_r,[#include <string.h>],
1031 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
1033 if test $ol_decl_strerror_r = yes ; then
1034 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
1036 char x = *strerror_r (0, buf, sizeof buf);
1037 char *p = strerror_r (0, buf, sizeof buf);
1038 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
1040 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1044 strerror_r( 1, buf, sizeof buf );
1045 exit( buf[0] == 0 );
1047 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
1050 if test $ol_cv_nonposix_strerror_r = yes ; then
1051 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1052 [define if strerror_r returns char* instead of int])
1056 AC_DEFUN([OL_STRERROR],
1057 [OL_SYS_ERRLIST dnl TEMPORARY
1058 AC_CHECK_FUNCS(strerror strerror_r)
1059 ol_cv_func_strerror_r=no
1060 if test "${ac_cv_func_strerror_r}" = yes ; then
1061 OL_NONPOSIX_STRERROR_R
1062 elif test "${ac_cv_func_strerror}" = no ; then
1066 dnl ====================================================================
1067 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1068 dnl "int x; int *volatile a = &x; *a = 0;"
1069 dnl -- borrowed from PDKSH
1070 AC_DEFUN([OL_C_VOLATILE],
1071 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1072 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
1073 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1074 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
1075 if test $ol_cv_c_volatile = yes; then
1078 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1082 dnl ====================================================================
1083 dnl Look for fetch(3)
1084 AC_DEFUN([OL_LIB_FETCH],
1086 LIBS="-lfetch -lcom_err $LIBS"
1087 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1088 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1089 #include <sys/param.h>
1091 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
1093 if test $ol_cv_lib_fetch != no ; then
1094 ol_link_fetch="-lfetch -lcom_err"
1095 AC_DEFINE(HAVE_FETCH,1,
1096 [define if you actually have FreeBSD fetch(3)])
1100 dnl ====================================================================
1101 dnl Define inet_aton is available
1102 AC_DEFUN([OL_FUNC_INET_ATON],
1103 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1104 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1105 #ifdef HAVE_SYS_TYPES_H
1106 # include <sys/types.h>
1108 #ifdef HAVE_SYS_SOCKET_H
1109 # include <sys/socket.h>
1110 # ifdef HAVE_SYS_SELECT_H
1111 # include <sys/select.h>
1113 # include <netinet/in.h>
1114 # ifdef HAVE_ARPA_INET_H
1115 # include <arpa/inet.h>
1118 ]], [[struct in_addr in;
1119 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
1120 if test $ol_cv_func_inet_aton != no; then
1121 AC_DEFINE(HAVE_INET_ATON, 1,
1122 [define to you inet_aton(3) is available])
1126 dnl ====================================================================
1127 dnl check no of arguments for ctime_r
1128 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
1129 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1130 [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])
1132 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])
1134 if test $ol_cv_func_ctime_r_nargs3 = yes &&
1135 test $ol_cv_func_ctime_r_nargs2 = no ; then
1137 ol_cv_func_ctime_r_nargs=3
1139 elif test $ol_cv_func_ctime_r_nargs3 = no &&
1140 test $ol_cv_func_ctime_r_nargs2 = yes ; then
1142 ol_cv_func_ctime_r_nargs=2
1145 ol_cv_func_ctime_r_nargs=0
1149 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1150 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1151 [set to the number of arguments ctime_r() expects])
1155 dnl --------------------------------------------------------------------
1156 dnl check return type of ctime_r()
1157 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1158 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1159 [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"])
1161 if test $ol_cv_func_ctime_r_type = "int" ; then
1162 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1165 dnl ====================================================================
1166 dnl check no of arguments for gethostbyname_r
1167 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1168 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1169 ol_cv_func_gethostbyname_r_nargs,
1170 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1171 #include <sys/socket.h>
1172 #include <netinet/in.h>
1174 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1175 int bufsize=BUFSIZE;int h_errno;
1176 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1177 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1179 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1180 #include <sys/socket.h>
1181 #include <netinet/in.h>
1183 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1184 char buffer[BUFSIZE];
1185 int bufsize=BUFSIZE;int h_errno;
1186 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1187 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1189 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1190 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1192 ol_cv_func_gethostbyname_r_nargs=5
1194 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1195 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1197 ol_cv_func_gethostbyname_r_nargs=6
1200 ol_cv_func_gethostbyname_r_nargs=0
1203 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1204 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1205 $ol_cv_func_gethostbyname_r_nargs,
1206 [set to the number of arguments gethostbyname_r() expects])
1210 dnl check no of arguments for gethostbyaddr_r
1211 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1212 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1213 [ol_cv_func_gethostbyaddr_r_nargs],
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; char buffer[BUFSIZE];
1220 size_t alen=sizeof(struct in_addr);
1221 int bufsize=BUFSIZE;int h_errno;
1222 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1223 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1225 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1226 #include <sys/socket.h>
1227 #include <netinet/in.h>
1229 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1230 struct hostent *rhent; char buffer[BUFSIZE];
1232 size_t alen=sizeof(struct in_addr);
1233 int bufsize=BUFSIZE;int h_errno;
1234 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1235 alen, AF_INET, &hent, buffer, bufsize,
1236 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1238 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1239 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1241 ol_cv_func_gethostbyaddr_r_nargs=7
1243 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1244 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1246 ol_cv_func_gethostbyaddr_r_nargs=8
1249 ol_cv_func_gethostbyaddr_r_nargs=0
1252 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1253 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1254 $ol_cv_func_gethostbyaddr_r_nargs,
1255 [set to the number of arguments gethostbyaddr_r() expects])
1259 dnl --------------------------------------------------------------------
1260 dnl Check for Cyrus SASL version compatility
1261 AC_DEFUN([OL_SASL_COMPAT],
1262 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1263 AC_EGREP_CPP(__sasl_compat,[
1264 #ifdef HAVE_SASL_SASL_H
1265 #include <sasl/sasl.h>
1270 /* Require 2.1.15+ */
1271 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1272 char *__sasl_compat = "2.2+ or better okay (we guess)";
1273 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1274 && SASL_VERSION_STEP >=15
1275 char *__sasl_compat = "2.1.15+ or better okay";
1277 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1279 dnl ====================================================================
1280 dnl check for SSL compatibility
1281 AC_DEFUN([OL_SSL_COMPAT],
1282 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1283 [ol_cv_ssl_crl_compat],[
1284 AC_EGREP_CPP(__ssl_compat,[
1285 #ifdef HAVE_OPENSSL_SSL_H
1286 #include <openssl/ssl.h>
1289 /* Require 0.9.7d+ */
1290 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1291 char *__ssl_compat = "0.9.7d";
1293 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])