1 dnl OpenLDAP Autoconf Macros
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 dnl Copyright 1998-2014 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 --------------------------------------------------------------------
126 AC_CACHE_CHECK([whether we are using MS Visual C++], ol_cv_msvc,
127 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
129 #include <__FOO__/generate_error.h>
131 ]])],[ol_cv_msvc=yes],[ol_cv_msvc=no])])])
133 dnl --------------------------------------------------------------------
134 dnl OpenLDAP version of STDC header check w/ EBCDIC support
135 AC_DEFUN([OL_HEADER_STDC],
137 AC_REQUIRE([OL_CPP_EBCDIC])dnl
138 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
139 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
142 #include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no])
144 if test $ol_cv_header_stdc = yes; then
145 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
146 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
149 if test $ol_cv_header_stdc = yes; then
150 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
151 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
154 if test $ol_cv_header_stdc = yes; then
155 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
156 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h>
158 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
159 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
161 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
162 || ('j' <= (c) && (c) <= 'r') \
163 || ('s' <= (c) && (c) <= 'z'))
164 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
166 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
167 int main () { int i; for (i = 0; i < 256; i++)
168 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
170 ]])],[],[ol_cv_header_stdc=no],[:])
172 if test $ol_cv_header_stdc = yes; then
173 AC_DEFINE(STDC_HEADERS)
175 ac_cv_header_stdc=disable
178 dnl ====================================================================
179 dnl DNS resolver macros
180 AC_DEFUN([OL_RESOLVER_TRY],
181 [if test $ol_cv_lib_resolver = no ; then
182 AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1],
184 ol_RESOLVER_LIB=ifelse($2,,,$2)
186 LIBS="$ol_RESOLVER_LIB $LIBS"
188 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
189 #ifdef HAVE_SYS_TYPES_H
190 # include <sys/types.h>
192 #include <netinet/in.h>
193 #ifdef HAVE_ARPA_NAMESER_H
194 # include <arpa/nameser.h>
201 char *request = NULL;
202 unsigned char reply[64*1024];
203 unsigned char host[64*1024];
207 /* Bind 8/9 interface */
208 len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply));
210 /* Bind 4 interface */
214 len = res_query(request, C_IN, T_SRV, reply, sizeof(reply));
218 /* Bind 8/9 interface */
220 #elif defined(HFIXEDSZ)
221 /* Bind 4 interface w/ HFIXEDSZ */
224 /* Bind 4 interface w/o HFIXEDSZ */
227 status = dn_expand( reply, reply+len, p, host, sizeof(host));
228 }]])],[$1=yes],[$1=no])
233 if test $$1 = yes ; then
234 ol_cv_lib_resolver=ifelse($2,,yes,$2)
238 dnl --------------------------------------------------------------------
239 dnl Try to locate appropriate library
240 AC_DEFUN([OL_RESOLVER_LINK],
241 [ol_cv_lib_resolver=no
242 OL_RESOLVER_TRY(ol_cv_resolver_none)
243 OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv])
244 OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind])
247 dnl ====================================================================
248 dnl International Components for Unicode (ICU)
251 AC_CHECK_HEADERS( unicode/utypes.h )
252 if test $ac_cv_header_unicode_utypes_h = yes ; then
253 dnl OL_ICULIBS="-licui18n -licuuc -licudata"
254 OL_ICULIBS="-licuuc -licudata"
256 AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [
258 LIBS="$OL_ICULIBS $LIBS"
259 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
260 #include <unicode/utypes.h>
262 (void) u_errorName(0);
263 ]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no])
267 if test $ol_cv_lib_icu != no ; then
269 AC_DEFINE(HAVE_ICU,1,[define if you actually have ICU])
274 dnl ====================================================================
275 dnl Berkeley DB macros
277 dnl --------------------------------------------------------------------
279 AC_DEFUN([OL_BERKELEY_DB_TRY],
280 [if test $ol_cv_lib_db = no ; then
281 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
283 ol_DB_LIB=ifelse($2,,,$2)
285 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
287 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
294 #ifndef DB_VERSION_MAJOR
295 # define DB_VERSION_MAJOR 1
299 #define NULL ((void*)0)
302 #if DB_VERSION_MAJOR > 2
303 db_env_create( NULL, 0 );
304 #elif DB_VERSION_MAJOR > 1
307 (void) dbopen( NULL, 0, 0, 0, NULL);
309 ]])],[$1=yes],[$1=no])
314 if test $$1 = yes ; then
315 ol_cv_lib_db=ifelse($2,,yes,$2)
320 dnl --------------------------------------------------------------------
321 dnl Get major and minor version from <db.h>
322 AC_DEFUN([OL_BDB_HEADER_VERSION],
323 [AC_CACHE_CHECK([for Berkeley DB major version in db.h], [ol_cv_bdb_major],[
326 #ifndef DB_VERSION_MAJOR
327 # define DB_VERSION_MAJOR 1
329 __db_version DB_VERSION_MAJOR
331 set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
334 case $ol_cv_bdb_major in [[1-9]]*) : ;; *)
335 AC_MSG_ERROR([Unknown Berkeley DB major version in db.h]) ;;
338 dnl Determine minor version
339 AC_CACHE_CHECK([for Berkeley DB minor version in db.h], [ol_cv_bdb_minor],[
342 #ifndef DB_VERSION_MINOR
343 # define DB_VERSION_MINOR 0
345 __db_version DB_VERSION_MINOR
347 set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
350 case $ol_cv_bdb_minor in [[0-9]]*) : ;; *)
351 AC_MSG_ERROR([Unknown Berkeley DB minor version in db.h]) ;;
355 dnl --------------------------------------------------------------------
356 dnl Try to locate appropriate library
357 AC_DEFUN([OL_BERKELEY_DB_LINK],
360 if test $ol_cv_bdb_major = 5 ; then
361 OL_BERKELEY_DB_TRY(ol_cv_db_db_5_dot_m,[-ldb-5.$ol_cv_bdb_minor])
362 OL_BERKELEY_DB_TRY(ol_cv_db_db5m,[-ldb5$ol_cv_bdb_minor])
363 OL_BERKELEY_DB_TRY(ol_cv_db_db_5m,[-ldb-5$ol_cv_bdb_minor])
364 OL_BERKELEY_DB_TRY(ol_cv_db_db_5_m,[-ldb-5-$ol_cv_bdb_minor])
365 OL_BERKELEY_DB_TRY(ol_cv_db_db_5,[-ldb-5])
366 OL_BERKELEY_DB_TRY(ol_cv_db_db5,[-ldb5])
367 elif test $ol_cv_bdb_major = 4 ; then
368 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor])
369 OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor])
370 OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor])
371 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor])
372 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
373 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
375 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
376 OL_BERKELEY_DB_TRY(ol_cv_db_none)
379 dnl --------------------------------------------------------------------
380 dnl Check if Berkeley DB version
381 AC_DEFUN([OL_BERKELEY_DB_VERSION],
382 [AC_CACHE_CHECK([for Berkeley DB library and header version match], [ol_cv_berkeley_db_version], [
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([[
395 #ifndef DB_VERSION_MAJOR
396 # define DB_VERSION_MAJOR 1
399 #define NULL ((void *)0)
403 #if DB_VERSION_MAJOR > 1
405 int major, minor, patch;
407 version = db_version( &major, &minor, &patch );
409 if( major != DB_VERSION_MAJOR ||
410 minor != DB_VERSION_MINOR ||
411 patch != DB_VERSION_PATCH )
413 printf("Berkeley DB version mismatch\n"
414 "\theader: %s\n\tlibrary: %s\n",
415 DB_VERSION_STRING, version);
421 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
426 if test $ol_cv_berkeley_db_version = no ; then
427 AC_MSG_ERROR([Berkeley DB version mismatch])
431 dnl --------------------------------------------------------------------
432 dnl Check if Berkeley DB supports DB_THREAD
433 AC_DEFUN([OL_BERKELEY_DB_THREAD],
434 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
436 LIBS="$LTHREAD_LIBS $LIBS"
437 if test $ol_cv_lib_db != yes ; then
438 LIBS="$ol_cv_lib_db $LIBS"
441 AC_RUN_IFELSE([AC_LANG_SOURCE([[
448 #define NULL ((void *)0)
453 u_int32_t flags = DB_CREATE |
459 #if DB_VERSION_MAJOR > 2
462 rc = db_env_create( &env, 0 );
464 flags |= DB_INIT_MPOOL;
465 #ifdef DB_MPOOL_PRIVATE
466 flags |= DB_MPOOL_PRIVATE;
470 printf("BerkeleyDB: %s\n", db_strerror(rc) );
474 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
475 rc = (env->open)( env, NULL, flags, 0 );
477 rc = (env->open)( env, NULL, NULL, flags, 0 );
481 rc = env->close( env, 0 );
485 printf("BerkeleyDB: %s\n", db_strerror(rc) );
491 memset( &env, '\0', sizeof(env) );
493 rc = db_appinit( NULL, NULL, &env, flags );
499 unlink("__db_mpool.share");
500 unlink("__db_lock.share");
504 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
509 if test $ol_cv_berkeley_db_thread != no ; then
510 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
511 [define if Berkeley DB has DB_THREAD support])
515 dnl --------------------------------------------------------------------
517 AC_DEFUN([OL_BERKELEY_DB],
518 [ol_cv_berkeley_db=no
519 AC_CHECK_HEADERS(db.h)
520 if test $ac_cv_header_db_h = yes; then
521 OL_BDB_HEADER_VERSION
524 if test $ol_cv_bdb_compat != yes ; then
525 AC_MSG_ERROR([BerkeleyDB version incompatible with BDB/HDB backends])
529 if test "$ol_cv_lib_db" != no ; then
530 ol_cv_berkeley_db=yes
531 OL_BERKELEY_DB_VERSION
532 OL_BERKELEY_DB_THREAD
536 dnl --------------------------------------------------------------------
537 dnl Check for version compatility with back-bdb
538 AC_DEFUN([OL_BDB_COMPAT],
539 [AC_CACHE_CHECK([if Berkeley DB version supported by BDB/HDB backends], [ol_cv_bdb_compat],[
540 AC_EGREP_CPP(__db_version_compat,[
543 /* this check could be improved */
544 #ifndef DB_VERSION_MAJOR
545 # define DB_VERSION_MAJOR 1
547 #ifndef DB_VERSION_MINOR
548 # define DB_VERSION_MINOR 0
551 #define DB_VERSION_MM ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR)
553 /* require 4.4 or later */
554 #if DB_VERSION_MM >= 0x0404
557 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
561 dnl ====================================================================
562 dnl Check POSIX Thread version
564 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
565 dnl version of the POSIX.4a Draft that is implemented.
566 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
567 dnl Existence of pthread.h should be tested separately.
570 dnl pthread_detach() was dropped in Draft 8, it is present
571 dnl in every other version
572 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
573 dnl PTHREAD_CREATE_JOINABLE after that
574 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
575 dnl Draft 6-10 has _init, Draft 4-5 has _create.
576 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
577 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
578 dnl interesting to us because we don't try to statically
579 dnl initialize mutexes. 5-10 has it.
581 dnl Draft 9 and 10 are equivalent for our purposes.
583 AC_DEFUN([OL_POSIX_THREAD_VERSION],
584 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
586 # include <pthread.h>
588 int i = PTHREAD_CREATE_JOINABLE;
590 AC_EGREP_HEADER(pthread_detach,pthread.h,
591 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
592 AC_EGREP_CPP(draft7,[
593 # include <pthread.h>
594 # ifdef PTHREAD_CREATE_UNDETACHED
597 ], ol_cv_pthread_version=7, [
598 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
599 ol_cv_pthread_version=6, [
600 AC_EGREP_CPP(draft5,[
601 # include <pthread.h>
602 #ifdef PTHREAD_MUTEX_INITIALIZER
605 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
609 dnl --------------------------------------------------------------------
610 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
611 /* pthread test headers */
613 #if HAVE_PTHREADS < 7
617 #define NULL (void*)0
623 return (void *) (p == NULL);
626 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
627 /* pthread test function */
628 #ifndef PTHREAD_CREATE_DETACHED
629 #define PTHREAD_CREATE_DETACHED 1
633 int detach = PTHREAD_CREATE_DETACHED;
635 #if HAVE_PTHREADS > 4
639 status = pthread_attr_init(&attr);
640 if( status ) return status;
642 #if HAVE_PTHREADS < 7
643 status = pthread_attr_setdetachstate(&attr, &detach);
644 if( status < 0 ) status = errno;
646 status = pthread_attr_setdetachstate(&attr, detach);
648 if( status ) return status;
649 status = pthread_create( &t, &attr, task, NULL );
650 #if HAVE_PTHREADS < 7
651 if( status < 0 ) status = errno;
653 if( status ) return status;
655 /* Draft 4 pthreads */
656 status = pthread_create( &t, pthread_attr_default, task, NULL );
657 if( status ) return errno;
659 /* give thread a chance to complete */
660 /* it should remain joinable and hence detachable */
663 status = pthread_detach( &t );
664 if( status ) return errno;
667 #ifdef HAVE_LINUX_THREADS
668 pthread_kill_other_threads_np();
674 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
675 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
681 OL_PTHREAD_TEST_FUNCTION
684 dnl --------------------------------------------------------------------
685 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
686 if test "$ol_link_threads" = no ; then
688 AC_CACHE_CHECK([for pthread link with $1], [$2], [
693 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
696 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
697 OL_PTHREAD_TEST_FUNCTION)],
704 if test $$2 = yes ; then
705 ol_link_pthreads="$1"
706 ol_link_threads=posix
711 dnl ====================================================================
712 dnl Check GNU Pth pthread Header
714 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
715 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
716 dnl doesn't exists. Existance of pthread.h should separately
719 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
720 AC_CACHE_CHECK([for GNU Pth pthread.h],
721 [ol_cv_header_gnu_pth_pthread_h],
722 [AC_EGREP_CPP(__gnu_pth__,
723 [#include <pthread.h>
724 #ifdef _POSIX_THREAD_IS_GNU_PTH
728 [ol_cv_header_gnu_pth_pthread_h=yes],
729 [ol_cv_header_gnu_pth_pthread_h=no])
732 dnl ====================================================================
733 dnl Check for NT Threads
734 AC_DEFUN([OL_NT_THREADS], [
735 AC_CHECK_FUNC(_beginthread)
737 if test $ac_cv_func__beginthread = yes ; then
738 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
742 dnl ====================================================================
743 dnl Check LinuxThreads Header
745 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
746 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
747 dnl doesn't exists. Existance of pthread.h should separately
750 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
751 AC_CACHE_CHECK([for LinuxThreads pthread.h],
752 [ol_cv_header_linux_threads],
753 [AC_EGREP_CPP(pthread_kill_other_threads_np,
754 [#include <pthread.h>],
755 [ol_cv_header_linux_threads=yes],
756 [ol_cv_header_linux_threads=no])
758 if test $ol_cv_header_linux_threads = yes; then
759 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
762 dnl --------------------------------------------------------------------
763 dnl Check LinuxThreads Implementation
765 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
766 dnl 'no' implies pthreads implementation is not LinuxThreads.
768 AC_DEFUN([OL_SYS_LINUX_THREADS], [
769 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
770 AC_CACHE_CHECK([for LinuxThreads implementation],
771 [ol_cv_sys_linux_threads],
772 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
775 dnl --------------------------------------------------------------------
776 dnl Check LinuxThreads consistency
777 AC_DEFUN([OL_LINUX_THREADS], [
778 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
779 AC_REQUIRE([OL_SYS_LINUX_THREADS])
780 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
781 if test $ol_cv_header_linux_threads = yes &&
782 test $ol_cv_sys_linux_threads = yes; then
783 ol_cv_linux_threads=yes
784 elif test $ol_cv_header_linux_threads = no &&
785 test $ol_cv_sys_linux_threads = no; then
786 ol_cv_linux_threads=no
788 ol_cv_linux_threads=error
793 dnl ====================================================================
794 dnl Check for POSIX Regex
795 AC_DEFUN([OL_POSIX_REGEX], [
796 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
797 AC_RUN_IFELSE([AC_LANG_SOURCE([[
798 #include <sys/types.h>
800 static char *pattern, *string;
808 if(regcomp(&re, pattern, 0)) {
812 string = "ALL MATCH";
814 rc = regexec(&re, string, 0, (void*)0, 0);
819 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
822 dnl ====================================================================
823 dnl Check if toupper() requires islower() to be called first
824 AC_DEFUN([OL_C_UPPER_LOWER],
825 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
826 AC_RUN_IFELSE([AC_LANG_SOURCE([[
830 if ('C' == toupper('C'))
834 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
835 if test $ol_cv_c_upper_lower != no ; then
836 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
840 dnl ====================================================================
841 dnl Error string checks
843 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
844 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
845 dnl Reported by Keith Bostic.
846 AC_DEFUN([OL_SYS_ERRLIST],
847 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
850 #include <sys/types.h>
854 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
855 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
857 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
858 if test $ol_cv_dcl_sys_errlist = no ; then
859 AC_DEFINE(DECL_SYS_ERRLIST,1,
860 [define if sys_errlist is not declared in stdio.h or errno.h])
862 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
863 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])])
865 if test $ol_cv_have_sys_errlist = yes ; then
866 AC_DEFINE(HAVE_SYS_ERRLIST,1,
867 [define if you actually have sys_errlist in your libs])
870 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
871 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
872 AC_EGREP_CPP(strerror_r,[#include <string.h>],
873 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
875 if test $ol_decl_strerror_r = yes ; then
876 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
878 char x = *strerror_r (0, buf, sizeof buf);
879 char *p = strerror_r (0, buf, sizeof buf);
880 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
882 AC_RUN_IFELSE([AC_LANG_SOURCE([[
886 strerror_r( 1, buf, sizeof buf );
889 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
892 if test $ol_cv_nonposix_strerror_r = yes ; then
893 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
894 [define if strerror_r returns char* instead of int])
898 AC_DEFUN([OL_STRERROR],
899 [OL_SYS_ERRLIST dnl TEMPORARY
900 AC_CHECK_FUNCS(strerror strerror_r)
901 ol_cv_func_strerror_r=no
902 if test "${ac_cv_func_strerror_r}" = yes ; then
903 OL_NONPOSIX_STRERROR_R
904 elif test "${ac_cv_func_strerror}" = no ; then
908 dnl ====================================================================
909 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
910 dnl "int x; int *volatile a = &x; *a = 0;"
911 dnl -- borrowed from PDKSH
912 AC_DEFUN([OL_C_VOLATILE],
913 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
914 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
915 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
916 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
917 if test $ol_cv_c_volatile = yes; then
920 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
924 dnl ====================================================================
925 dnl Look for fetch(3)
926 AC_DEFUN([OL_LIB_FETCH],
928 LIBS="-lfetch -lcom_err $LIBS"
929 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
930 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
931 #ifdef HAVE_SYS_PARAM_H
932 #include <sys/param.h>
935 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
937 if test $ol_cv_lib_fetch != no ; then
938 ol_link_fetch="-lfetch -lcom_err"
939 AC_DEFINE(HAVE_FETCH,1,
940 [define if you actually have FreeBSD fetch(3)])
944 dnl ====================================================================
945 dnl Define inet_aton is available
946 AC_DEFUN([OL_FUNC_INET_ATON],
947 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
948 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
949 #ifdef HAVE_SYS_TYPES_H
950 # include <sys/types.h>
952 #ifdef HAVE_SYS_SOCKET_H
953 # include <sys/socket.h>
954 # ifdef HAVE_SYS_SELECT_H
955 # include <sys/select.h>
957 # include <netinet/in.h>
958 # ifdef HAVE_ARPA_INET_H
959 # include <arpa/inet.h>
962 ]], [[struct in_addr in;
963 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
964 if test $ol_cv_func_inet_aton != no; then
965 AC_DEFINE(HAVE_INET_ATON, 1,
966 [define to you inet_aton(3) is available])
970 dnl ====================================================================
971 dnl check no of arguments for ctime_r
972 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
973 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
974 [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])
976 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])
978 if test $ol_cv_func_ctime_r_nargs3 = yes &&
979 test $ol_cv_func_ctime_r_nargs2 = no ; then
981 ol_cv_func_ctime_r_nargs=3
983 elif test $ol_cv_func_ctime_r_nargs3 = no &&
984 test $ol_cv_func_ctime_r_nargs2 = yes ; then
986 ol_cv_func_ctime_r_nargs=2
989 ol_cv_func_ctime_r_nargs=0
993 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
994 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
995 [set to the number of arguments ctime_r() expects])
999 dnl --------------------------------------------------------------------
1000 dnl check return type of ctime_r()
1001 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1002 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1003 [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"])
1005 if test $ol_cv_func_ctime_r_type = "int" ; then
1006 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1009 dnl ====================================================================
1010 dnl check no of arguments for gethostbyname_r
1011 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1012 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1013 ol_cv_func_gethostbyname_r_nargs,
1014 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1015 #include <sys/socket.h>
1016 #include <netinet/in.h>
1018 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1019 int bufsize=BUFSIZE;int h_errno;
1020 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1021 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1024 #include <sys/socket.h>
1025 #include <netinet/in.h>
1027 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1028 char buffer[BUFSIZE];
1029 int bufsize=BUFSIZE;int h_errno;
1030 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1031 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1033 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1034 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1036 ol_cv_func_gethostbyname_r_nargs=5
1038 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1039 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1041 ol_cv_func_gethostbyname_r_nargs=6
1044 ol_cv_func_gethostbyname_r_nargs=0
1047 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1048 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1049 $ol_cv_func_gethostbyname_r_nargs,
1050 [set to the number of arguments gethostbyname_r() expects])
1054 dnl check no of arguments for gethostbyaddr_r
1055 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1056 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1057 [ol_cv_func_gethostbyaddr_r_nargs],
1058 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1059 #include <sys/socket.h>
1060 #include <netinet/in.h>
1062 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1064 size_t alen=sizeof(struct in_addr);
1065 int bufsize=BUFSIZE;int h_errno;
1066 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1067 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1069 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1070 #include <sys/socket.h>
1071 #include <netinet/in.h>
1073 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1074 struct hostent *rhent; char buffer[BUFSIZE];
1076 size_t alen=sizeof(struct in_addr);
1077 int bufsize=BUFSIZE;int h_errno;
1078 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1079 alen, AF_INET, &hent, buffer, bufsize,
1080 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1082 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1083 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1085 ol_cv_func_gethostbyaddr_r_nargs=7
1087 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1088 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1090 ol_cv_func_gethostbyaddr_r_nargs=8
1093 ol_cv_func_gethostbyaddr_r_nargs=0
1096 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1097 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1098 $ol_cv_func_gethostbyaddr_r_nargs,
1099 [set to the number of arguments gethostbyaddr_r() expects])
1103 dnl --------------------------------------------------------------------
1104 dnl Check for Cyrus SASL version compatility
1105 AC_DEFUN([OL_SASL_COMPAT],
1106 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1107 AC_EGREP_CPP(__sasl_compat,[
1108 #ifdef HAVE_SASL_SASL_H
1109 #include <sasl/sasl.h>
1114 /* Require 2.1.15+ */
1115 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1116 char *__sasl_compat = "2.2+ or better okay (we guess)";
1117 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1118 && SASL_VERSION_STEP >=15
1119 char *__sasl_compat = "2.1.15+ or better okay";
1121 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1123 dnl ====================================================================
1124 dnl check for SSL compatibility
1125 AC_DEFUN([OL_SSL_COMPAT],
1126 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1127 [ol_cv_ssl_crl_compat],[
1128 AC_EGREP_CPP(__ssl_compat,[
1129 #ifdef HAVE_OPENSSL_SSL_H
1130 #include <openssl/ssl.h>
1133 /* Require 0.9.7d+ */
1134 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1135 char *__ssl_compat = "0.9.7d";
1137 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])