1 dnl OpenLDAP Autoconf Macros
2 dnl $OpenLDAP: pkg/ldap/build/openldap.m4,v 1.157.2.5 2008/02/11 23:26:37 kurt Exp $
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 if test $ol_cv_bdb_minor = 6 ; then
491 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_6,[-ldb-4.6])
492 OL_BERKELEY_DB_TRY(ol_cv_db_db46,[-ldb46])
493 OL_BERKELEY_DB_TRY(ol_cv_db_db_46,[-ldb-46])
494 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_6,[-ldb-4-6])
495 elif test $ol_cv_bdb_minor = 5 ; then
496 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_5,[-ldb-4.5])
497 OL_BERKELEY_DB_TRY(ol_cv_db_db45,[-ldb45])
498 OL_BERKELEY_DB_TRY(ol_cv_db_db_45,[-ldb-45])
499 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_5,[-ldb-4-5])
500 elif test $ol_cv_bdb_minor = 4 ; then
501 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_4,[-ldb-4.4])
502 OL_BERKELEY_DB_TRY(ol_cv_db_db44,[-ldb44])
503 OL_BERKELEY_DB_TRY(ol_cv_db_db_44,[-ldb-44])
504 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_4,[-ldb-4-4])
505 elif test $ol_cv_bdb_minor = 3 ; then
506 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
507 OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
508 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
509 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
510 elif test $ol_cv_bdb_minor = 2 ; then
511 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
512 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
513 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
514 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
516 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
517 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
518 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
520 elif test $ol_cv_bdb_major = 3 ; then
521 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
522 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
524 elif test $ol_cv_bdb_major = 2 ; then
525 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
526 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
528 elif test $ol_cv_bdb_major = 1 ; then
529 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
530 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
532 OL_BERKELEY_DB_TRY(ol_cv_db_none)
535 dnl --------------------------------------------------------------------
536 dnl Check if Berkeley DB version
537 AC_DEFUN([OL_BERKELEY_DB_VERSION],
538 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
540 LIBS="$LTHREAD_LIBS $LIBS"
541 if test $ol_cv_lib_db != yes ; then
542 LIBS="$ol_cv_lib_db $LIBS"
545 AC_RUN_IFELSE([AC_LANG_SOURCE([[
551 #ifndef DB_VERSION_MAJOR
552 # define DB_VERSION_MAJOR 1
555 #define NULL ((void *)0)
559 #if DB_VERSION_MAJOR > 1
561 int major, minor, patch;
563 version = db_version( &major, &minor, &patch );
565 if( major != DB_VERSION_MAJOR ||
566 minor != DB_VERSION_MINOR ||
567 patch != DB_VERSION_PATCH )
569 printf("Berkeley DB version mismatch\n"
570 "\theader: %s\n\tlibrary: %s\n",
571 DB_VERSION_STRING, version);
577 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
582 if test $ol_cv_berkeley_db_version = no ; then
583 AC_MSG_ERROR([Berkeley DB version mismatch])
587 dnl --------------------------------------------------------------------
588 dnl Check if Berkeley DB supports DB_THREAD
589 AC_DEFUN([OL_BERKELEY_DB_THREAD],
590 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
592 LIBS="$LTHREAD_LIBS $LIBS"
593 if test $ol_cv_lib_db != yes ; then
594 LIBS="$ol_cv_lib_db $LIBS"
597 AC_RUN_IFELSE([AC_LANG_SOURCE([[
604 #define NULL ((void *)0)
609 u_int32_t flags = DB_CREATE |
615 #if DB_VERSION_MAJOR > 2
618 rc = db_env_create( &env, 0 );
620 flags |= DB_INIT_MPOOL;
621 #ifdef DB_MPOOL_PRIVATE
622 flags |= DB_MPOOL_PRIVATE;
626 printf("BerkeleyDB: %s\n", db_strerror(rc) );
630 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
631 rc = (env->open)( env, NULL, flags, 0 );
633 rc = (env->open)( env, NULL, NULL, flags, 0 );
637 rc = env->close( env, 0 );
641 printf("BerkeleyDB: %s\n", db_strerror(rc) );
647 memset( &env, '\0', sizeof(env) );
649 rc = db_appinit( NULL, NULL, &env, flags );
655 unlink("__db_mpool.share");
656 unlink("__db_lock.share");
660 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
665 if test $ol_cv_berkeley_db_thread != no ; then
666 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
667 [define if Berkeley DB has DB_THREAD support])
671 dnl --------------------------------------------------------------------
673 AC_DEFUN([OL_BERKELEY_DB],
674 [ol_cv_berkeley_db=no
675 AC_CHECK_HEADERS(db.h)
676 if test $ac_cv_header_db_h = yes; then
678 if test "$ol_cv_lib_db" != no ; then
679 ol_cv_berkeley_db=yes
680 OL_BERKELEY_DB_VERSION
681 OL_BERKELEY_DB_THREAD
685 dnl --------------------------------------------------------------------
686 dnl Check for version compatility with back-bdb
687 AC_DEFUN([OL_BDB_COMPAT],
688 [AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[
689 AC_EGREP_CPP(__db_version_compat,[
692 /* this check could be improved */
693 #ifndef DB_VERSION_MAJOR
694 # define DB_VERSION_MAJOR 1
696 #ifndef DB_VERSION_MINOR
697 # define DB_VERSION_MINOR 0
700 /* require 4.2 or later, but exclude 4.3 */
701 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2) && (DB_VERSION_MINOR !=3)
704 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
707 dnl --------------------------------------------------------------------
708 dnl Find old Berkeley DB 1.85/1.86
709 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
710 [AC_CHECK_HEADERS(db_185.h db.h)
711 if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
712 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
713 AC_EGREP_CPP(__db_version_1,[
720 /* this check could be improved */
721 #ifndef DB_VERSION_MAJOR
722 # define DB_VERSION_MAJOR 1
725 #if DB_VERSION_MAJOR == 1
728 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
730 if test $ol_cv_header_db1 = yes ; then
732 if test "$ol_cv_lib_db" != no ; then
733 ol_cv_berkeley_db=yes
739 dnl ====================================================================
740 dnl Check POSIX Thread version
742 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
743 dnl version of the POSIX.4a Draft that is implemented.
744 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
745 dnl Existence of pthread.h should be tested separately.
748 dnl pthread_detach() was dropped in Draft 8, it is present
749 dnl in every other version
750 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
751 dnl PTHREAD_CREATE_JOINABLE after that
752 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
753 dnl Draft 6-10 has _init, Draft 4-5 has _create.
754 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
755 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
756 dnl interesting to us because we don't try to statically
757 dnl initialize mutexes. 5-10 has it.
759 dnl Draft 9 and 10 are equivalent for our purposes.
761 AC_DEFUN([OL_POSIX_THREAD_VERSION],
762 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
763 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
764 # include <pthread.h>
766 int i = PTHREAD_CREATE_JOINABLE;
768 AC_EGREP_HEADER(pthread_detach,pthread.h,
769 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
770 AC_EGREP_CPP(draft7,[
771 # include <pthread.h>
772 # ifdef PTHREAD_CREATE_UNDETACHED
775 ], ol_cv_pthread_version=7, [
776 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
777 ol_cv_pthread_version=6, [
778 AC_EGREP_CPP(draft5,[
779 # include <pthread.h>
780 #ifdef PTHREAD_MUTEX_INITIALIZER
783 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
787 dnl --------------------------------------------------------------------
788 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
789 /* pthread test headers */
791 #if HAVE_PTHREADS < 7
795 #define NULL (void*)0
801 return (void *) (p == NULL);
804 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
805 /* pthread test function */
806 #ifndef PTHREAD_CREATE_DETACHED
807 #define PTHREAD_CREATE_DETACHED 1
811 int detach = PTHREAD_CREATE_DETACHED;
813 #if HAVE_PTHREADS > 4
817 status = pthread_attr_init(&attr);
818 if( status ) return status;
820 #if HAVE_PTHREADS < 7
821 status = pthread_attr_setdetachstate(&attr, &detach);
822 if( status < 0 ) status = errno;
824 status = pthread_attr_setdetachstate(&attr, detach);
826 if( status ) return status;
827 status = pthread_create( &t, &attr, task, NULL );
828 #if HAVE_PTHREADS < 7
829 if( status < 0 ) status = errno;
831 if( status ) return status;
833 /* Draft 4 pthreads */
834 status = pthread_create( &t, pthread_attr_default, task, NULL );
835 if( status ) return errno;
837 /* give thread a chance to complete */
838 /* it should remain joinable and hence detachable */
841 status = pthread_detach( &t );
842 if( status ) return errno;
845 #ifdef HAVE_LINUX_THREADS
846 pthread_kill_other_threads_np();
852 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
853 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
859 OL_PTHREAD_TEST_FUNCTION
862 dnl --------------------------------------------------------------------
863 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
864 if test "$ol_link_threads" = no ; then
866 AC_CACHE_CHECK([for pthread link with $1], [$2], [
871 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
874 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
875 OL_PTHREAD_TEST_FUNCTION)],
882 if test $$2 = yes ; then
883 ol_link_pthreads="$1"
884 ol_link_threads=posix
889 dnl ====================================================================
890 dnl Check GNU Pth pthread 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_GNU_PTH_PTHREAD_H], [
898 AC_CACHE_CHECK([for GNU Pth pthread.h],
899 [ol_cv_header_gnu_pth_pthread_h],
900 [AC_EGREP_CPP(__gnu_pth__,
901 [#include <pthread.h>
902 #ifdef _POSIX_THREAD_IS_GNU_PTH
906 [ol_cv_header_gnu_pth_pthread_h=yes],
907 [ol_cv_header_gnu_pth_pthread_h=no])
910 dnl ====================================================================
911 dnl Check for NT Threads
912 AC_DEFUN([OL_NT_THREADS], [
913 AC_CHECK_FUNC(_beginthread)
915 if test $ac_cv_func__beginthread = yes ; then
916 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
920 dnl ====================================================================
921 dnl Check LinuxThreads Header
923 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
924 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
925 dnl doesn't exists. Existance of pthread.h should separately
928 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
929 AC_CACHE_CHECK([for LinuxThreads pthread.h],
930 [ol_cv_header_linux_threads],
931 [AC_EGREP_CPP(pthread_kill_other_threads_np,
932 [#include <pthread.h>],
933 [ol_cv_header_linux_threads=yes],
934 [ol_cv_header_linux_threads=no])
936 if test $ol_cv_header_linux_threads = yes; then
937 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
940 dnl --------------------------------------------------------------------
941 dnl Check LinuxThreads Implementation
943 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
944 dnl 'no' implies pthreads implementation is not LinuxThreads.
946 AC_DEFUN([OL_SYS_LINUX_THREADS], [
947 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
948 AC_CACHE_CHECK([for LinuxThreads implementation],
949 [ol_cv_sys_linux_threads],
950 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
953 dnl --------------------------------------------------------------------
954 dnl Check LinuxThreads consistency
955 AC_DEFUN([OL_LINUX_THREADS], [
956 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
957 AC_REQUIRE([OL_SYS_LINUX_THREADS])
958 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
959 if test $ol_cv_header_linux_threads = yes &&
960 test $ol_cv_sys_linux_threads = yes; then
961 ol_cv_linux_threads=yes
962 elif test $ol_cv_header_linux_threads = no &&
963 test $ol_cv_sys_linux_threads = no; then
964 ol_cv_linux_threads=no
966 ol_cv_linux_threads=error
971 dnl ====================================================================
972 dnl Check for POSIX Regex
973 AC_DEFUN([OL_POSIX_REGEX], [
974 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
975 AC_RUN_IFELSE([AC_LANG_SOURCE([[
976 #include <sys/types.h>
978 static char *pattern, *string;
986 if(regcomp(&re, pattern, 0)) {
990 string = "ALL MATCH";
992 rc = regexec(&re, string, 0, (void*)0, 0);
997 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
1000 dnl ====================================================================
1001 dnl Check if toupper() requires islower() to be called first
1002 AC_DEFUN([OL_C_UPPER_LOWER],
1003 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
1004 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1008 if ('C' == toupper('C'))
1012 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
1013 if test $ol_cv_c_upper_lower != no ; then
1014 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
1018 dnl ====================================================================
1019 dnl Error string checks
1021 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
1022 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
1023 dnl Reported by Keith Bostic.
1024 AC_DEFUN([OL_SYS_ERRLIST],
1025 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
1026 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1028 #include <sys/types.h>
1032 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
1033 ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
1035 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
1036 if test $ol_cv_dcl_sys_errlist = no ; then
1037 AC_DEFINE(DECL_SYS_ERRLIST,1,
1038 [define if sys_errlist is not declared in stdio.h or errno.h])
1040 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
1041 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])])
1043 if test $ol_cv_have_sys_errlist = yes ; then
1044 AC_DEFINE(HAVE_SYS_ERRLIST,1,
1045 [define if you actually have sys_errlist in your libs])
1048 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
1049 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
1050 AC_EGREP_CPP(strerror_r,[#include <string.h>],
1051 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
1053 if test $ol_decl_strerror_r = yes ; then
1054 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */
1056 char x = *strerror_r (0, buf, sizeof buf);
1057 char *p = strerror_r (0, buf, sizeof buf);
1058 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
1060 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1064 strerror_r( 1, buf, sizeof buf );
1065 exit( buf[0] == 0 );
1067 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
1070 if test $ol_cv_nonposix_strerror_r = yes ; then
1071 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1072 [define if strerror_r returns char* instead of int])
1076 AC_DEFUN([OL_STRERROR],
1077 [OL_SYS_ERRLIST dnl TEMPORARY
1078 AC_CHECK_FUNCS(strerror strerror_r)
1079 ol_cv_func_strerror_r=no
1080 if test "${ac_cv_func_strerror_r}" = yes ; then
1081 OL_NONPOSIX_STRERROR_R
1082 elif test "${ac_cv_func_strerror}" = no ; then
1086 dnl ====================================================================
1087 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1088 dnl "int x; int *volatile a = &x; *a = 0;"
1089 dnl -- borrowed from PDKSH
1090 AC_DEFUN([OL_C_VOLATILE],
1091 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1092 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
1093 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1094 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
1095 if test $ol_cv_c_volatile = yes; then
1098 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1102 dnl ====================================================================
1103 dnl Look for fetch(3)
1104 AC_DEFUN([OL_LIB_FETCH],
1106 LIBS="-lfetch -lcom_err $LIBS"
1107 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1108 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1109 #include <sys/param.h>
1111 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
1113 if test $ol_cv_lib_fetch != no ; then
1114 ol_link_fetch="-lfetch -lcom_err"
1115 AC_DEFINE(HAVE_FETCH,1,
1116 [define if you actually have FreeBSD fetch(3)])
1120 dnl ====================================================================
1121 dnl Define inet_aton is available
1122 AC_DEFUN([OL_FUNC_INET_ATON],
1123 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1124 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1125 #ifdef HAVE_SYS_TYPES_H
1126 # include <sys/types.h>
1128 #ifdef HAVE_SYS_SOCKET_H
1129 # include <sys/socket.h>
1130 # ifdef HAVE_SYS_SELECT_H
1131 # include <sys/select.h>
1133 # include <netinet/in.h>
1134 # ifdef HAVE_ARPA_INET_H
1135 # include <arpa/inet.h>
1138 ]], [[struct in_addr in;
1139 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
1140 if test $ol_cv_func_inet_aton != no; then
1141 AC_DEFINE(HAVE_INET_ATON, 1,
1142 [define to you inet_aton(3) is available])
1146 dnl ====================================================================
1147 dnl check no of arguments for ctime_r
1148 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
1149 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1150 [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])
1152 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])
1154 if test $ol_cv_func_ctime_r_nargs3 = yes &&
1155 test $ol_cv_func_ctime_r_nargs2 = no ; then
1157 ol_cv_func_ctime_r_nargs=3
1159 elif test $ol_cv_func_ctime_r_nargs3 = no &&
1160 test $ol_cv_func_ctime_r_nargs2 = yes ; then
1162 ol_cv_func_ctime_r_nargs=2
1165 ol_cv_func_ctime_r_nargs=0
1169 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1170 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1171 [set to the number of arguments ctime_r() expects])
1175 dnl --------------------------------------------------------------------
1176 dnl check return type of ctime_r()
1177 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1178 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1179 [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"])
1181 if test $ol_cv_func_ctime_r_type = "int" ; then
1182 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1185 dnl ====================================================================
1186 dnl check no of arguments for gethostbyname_r
1187 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1188 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1189 ol_cv_func_gethostbyname_r_nargs,
1190 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1191 #include <sys/socket.h>
1192 #include <netinet/in.h>
1194 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1195 int bufsize=BUFSIZE;int h_errno;
1196 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1197 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1199 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1200 #include <sys/socket.h>
1201 #include <netinet/in.h>
1203 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1204 char buffer[BUFSIZE];
1205 int bufsize=BUFSIZE;int h_errno;
1206 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1207 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1209 if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1210 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1212 ol_cv_func_gethostbyname_r_nargs=5
1214 elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1215 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1217 ol_cv_func_gethostbyname_r_nargs=6
1220 ol_cv_func_gethostbyname_r_nargs=0
1223 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1224 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1225 $ol_cv_func_gethostbyname_r_nargs,
1226 [set to the number of arguments gethostbyname_r() expects])
1230 dnl check no of arguments for gethostbyaddr_r
1231 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1232 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1233 [ol_cv_func_gethostbyaddr_r_nargs],
1234 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1235 #include <sys/socket.h>
1236 #include <netinet/in.h>
1238 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1240 size_t alen=sizeof(struct in_addr);
1241 int bufsize=BUFSIZE;int h_errno;
1242 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1243 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1245 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1246 #include <sys/socket.h>
1247 #include <netinet/in.h>
1249 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1250 struct hostent *rhent; char buffer[BUFSIZE];
1252 size_t alen=sizeof(struct in_addr);
1253 int bufsize=BUFSIZE;int h_errno;
1254 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1255 alen, AF_INET, &hent, buffer, bufsize,
1256 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1258 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1259 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1261 ol_cv_func_gethostbyaddr_r_nargs=7
1263 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1264 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1266 ol_cv_func_gethostbyaddr_r_nargs=8
1269 ol_cv_func_gethostbyaddr_r_nargs=0
1272 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1273 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1274 $ol_cv_func_gethostbyaddr_r_nargs,
1275 [set to the number of arguments gethostbyaddr_r() expects])
1279 dnl --------------------------------------------------------------------
1280 dnl Check for Cyrus SASL version compatility
1281 AC_DEFUN([OL_SASL_COMPAT],
1282 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1283 AC_EGREP_CPP(__sasl_compat,[
1284 #ifdef HAVE_SASL_SASL_H
1285 #include <sasl/sasl.h>
1290 /* Require 2.1.15+ */
1291 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1292 char *__sasl_compat = "2.2+ or better okay (we guess)";
1293 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1294 && SASL_VERSION_STEP >=15
1295 char *__sasl_compat = "2.1.15+ or better okay";
1297 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1299 dnl ====================================================================
1300 dnl check for SSL compatibility
1301 AC_DEFUN([OL_SSL_COMPAT],
1302 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1303 [ol_cv_ssl_crl_compat],[
1304 AC_EGREP_CPP(__ssl_compat,[
1305 #ifdef HAVE_OPENSSL_SSL_H
1306 #include <openssl/ssl.h>
1309 /* Require 0.9.7d+ */
1310 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1311 char *__ssl_compat = "0.9.7d";
1313 ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])