1 dnl OpenLDAP Autoconf Macros
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 dnl Copyright 1998-2004 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)
22 dnl $4 = allowed values (auto yes no)
23 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
24 AC_ARG_ENABLE($1,changequote(<,>)<$2 [>ifelse($3,,auto,$3)<]>changequote([,]),[
26 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
27 if test "$enableval" = "$ol_val" ; then
31 if test "$ol_arg" = "invalid" ; then
32 AC_MSG_ERROR(bad value $enableval for --enable-$1)
34 ol_enable_$1="$ol_arg"
36 [ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
37 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
41 dnl --------------------------------------------------------------------
42 dnl Restricted form of AC_ARG_WITH that limits user options
46 dnl $3 = default value (no)
47 dnl $4 = allowed values (yes or no)
48 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
49 AC_ARG_WITH($1,changequote(<,>)<$2 [>ifelse($3,,yes,$3)<]>changequote([,]),[
51 for ol_val in ifelse($4,,[yes no],[$4]) ; do
52 if test "$withval" = "$ol_val" ; then
56 if test "$ol_arg" = "invalid" ; then
57 AC_MSG_ERROR(bad value $withval for --with-$1)
61 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
62 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
66 dnl ====================================================================
68 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
69 [changequote(<<, >>)dnl
70 dnl The name to #define.
71 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
72 dnl The cache variable name.
73 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
75 AC_MSG_CHECKING(size of $1)
76 AC_CACHE_VAL(AC_CV_NAME,
77 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
78 AC_TRY_COMPILE([#include "confdefs.h"
79 #include <sys/types.h>
81 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
82 if test x$AC_CV_NAME != x ; then break; fi
85 if test x$AC_CV_NAME = x ; then
86 AC_MSG_ERROR([cannot determine a size for $1])
88 AC_MSG_RESULT($AC_CV_NAME)
89 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
90 undefine([AC_TYPE_NAME])dnl
91 undefine([AC_CV_NAME])dnl
93 dnl ====================================================================
94 dnl check if hard links are supported.
96 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
97 AC_MSG_CHECKING(whether ln works)
98 AC_CACHE_VAL(ol_cv_prog_LN_H,
99 [rm -f conftest.src conftest.dst
100 echo "conftest" > conftest.src
101 if ln conftest.src conftest.dst 2>/dev/null
107 rm -f conftest.src conftest.dst
109 LN_H="$ol_cv_prog_LN_H"
110 if test "$ol_cv_prog_LN_H" = "ln"; then
118 dnl ====================================================================
119 dnl Check for dependency generation flag
120 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
123 if test -z "${MKDEP}"; then
125 if test -z "${MKDEP_FLAGS}"; then
126 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
128 for flag in "-M" "-xM"; do
129 cat > conftest.c <<EOF
132 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
133 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
135 if test ! -f conftest."${ac_object}" ; then
137 OL_MKDEP_FLAGS="$flag"
146 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
151 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
154 AC_SUBST(OL_MKDEP_FLAGS)
157 dnl ====================================================================
158 dnl Check if system uses EBCDIC instead of ASCII
159 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
160 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
163 #include <__ASCII__/generate_error.h>
166 [ol_cv_cpp_ebcdic=yes],
167 [ol_cv_cpp_ebcdic=no])])
168 if test $ol_cv_cpp_ebcdic = yes ; then
169 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
173 dnl --------------------------------------------------------------------
174 dnl OpenLDAP version of STDC header check w/ EBCDIC support
175 AC_DEFUN(OL_HEADER_STDC,
177 AC_REQUIRE([OL_CPP_EBCDIC])dnl
178 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
179 [AC_TRY_CPP([#include <stdlib.h>
182 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
184 if test $ol_cv_header_stdc = yes; then
185 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
186 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
189 if test $ol_cv_header_stdc = yes; then
190 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
191 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
194 if test $ol_cv_header_stdc = yes; then
195 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
196 AC_TRY_RUN([#include <ctype.h>
198 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
199 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
201 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
202 || ('j' <= (c) && (c) <= 'r') \
203 || ('s' <= (c) && (c) <= 'z'))
204 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
206 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
207 int main () { int i; for (i = 0; i < 256; i++)
208 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
210 ], , ol_cv_header_stdc=no, :)
212 if test $ol_cv_header_stdc = yes; then
213 AC_DEFINE(STDC_HEADERS)
215 ac_cv_header_stdc=disable
218 dnl ====================================================================
219 dnl Check if struct passwd has pw_gecos
220 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
221 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
222 AC_TRY_COMPILE([#include <pwd.h>],[
224 pwd.pw_gecos = pwd.pw_name;
226 [ol_cv_struct_passwd_pw_gecos=yes],
227 [ol_cv_struct_passwd_pw_gecos=no])])
228 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
229 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
233 dnl --------------------------------------------------------------------
234 dnl Check if struct passwd has pw_passwd
235 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
236 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
237 AC_TRY_COMPILE([#include <pwd.h>],[
239 pwd.pw_passwd = pwd.pw_name;
241 [ol_cv_struct_passwd_pw_passwd=yes],
242 [ol_cv_struct_passwd_pw_passwd=no])])
243 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
244 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
248 dnl ====================================================================
249 dnl Berkeley DB macros
251 dnl --------------------------------------------------------------------
253 AC_DEFUN([OL_BERKELEY_DB_TRY],
254 [if test $ol_cv_lib_db = no ; then
255 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
257 ol_DB_LIB=ifelse($2,,,$2)
259 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
268 #ifndef DB_VERSION_MAJOR
269 # define DB_VERSION_MAJOR 1
273 #define NULL ((void*)0)
276 #if DB_VERSION_MAJOR > 1
279 int major, minor, patch;
281 version = db_version( &major, &minor, &patch );
283 if( major != DB_VERSION_MAJOR ||
284 minor < DB_VERSION_MINOR )
286 printf("Berkeley DB version mismatch\n"
287 "\texpected: %s\n\tgot: %s\n",
288 DB_VERSION_STRING, version);
294 #if DB_VERSION_MAJOR > 2
295 db_env_create( NULL, 0 );
296 #elif DB_VERSION_MAJOR > 1
299 (void) dbopen( NULL, 0, 0, 0, NULL);
306 if test $$1 = yes ; then
307 ol_cv_lib_db=ifelse($2,,yes,$2)
312 dnl --------------------------------------------------------------------
313 dnl Try to locate appropriate library
314 AC_DEFUN([OL_BERKELEY_DB_LINK],
316 OL_BERKELEY_DB_TRY(ol_cv_db_none)
317 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
318 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
320 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
321 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
322 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
323 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
324 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
325 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
326 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
327 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
328 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
329 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
330 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
331 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
332 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
333 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
336 dnl --------------------------------------------------------------------
337 dnl Check if Berkeley DB supports DB_THREAD
338 AC_DEFUN([OL_BERKELEY_DB_THREAD],
339 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
341 LIBS="$LTHREAD_LIBS $LIBS"
342 if test $ol_cv_lib_db != yes ; then
343 LIBS="$ol_cv_lib_db $LIBS"
353 #define NULL ((void *)0)
358 u_int32_t flags = DB_CREATE |
364 #if DB_VERSION_MAJOR > 2
367 rc = db_env_create( &env, 0 );
369 flags |= DB_INIT_MPOOL;
370 #ifdef DB_MPOOL_PRIVATE
371 flags |= DB_MPOOL_PRIVATE;
375 printf("BerkeleyDB: %s\n", db_strerror(rc) );
379 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
380 rc = env->open( env, NULL, flags, 0 );
382 rc = env->open( env, NULL, NULL, flags, 0 );
386 rc = env->close( env, 0 );
390 printf("BerkeleyDB: %s\n", db_strerror(rc) );
396 memset( &env, '\0', sizeof(env) );
398 rc = db_appinit( NULL, NULL, &env, flags );
404 unlink("__db_mpool.share");
405 unlink("__db_lock.share");
410 [ol_cv_berkeley_db_thread=yes],
411 [ol_cv_berkeley_db_thread=no],
412 [ol_cv_berkeley_db_thread=cross])
417 if test $ol_cv_berkeley_db_thread != no ; then
418 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
419 [define if Berkeley DB has DB_THREAD support])
423 dnl --------------------------------------------------------------------
425 AC_DEFUN([OL_BERKELEY_DB],
426 [ol_cv_berkeley_db=no
427 AC_CHECK_HEADERS(db.h)
428 if test $ac_cv_header_db_h = yes; then
430 if test "$ol_cv_lib_db" != no ; then
431 ol_cv_berkeley_db=yes
432 OL_BERKELEY_DB_THREAD
436 dnl --------------------------------------------------------------------
437 dnl Check for version compatility with back-bdb
438 AC_DEFUN([OL_BDB_COMPAT],
439 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
440 AC_EGREP_CPP(__db_version_compat,[
443 /* this check could be improved */
444 #ifndef DB_VERSION_MAJOR
445 # define DB_VERSION_MAJOR 1
447 #ifndef DB_VERSION_MINOR
448 # define DB_VERSION_MINOR 0
451 /* require 4.2 or later */
452 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
455 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
458 dnl --------------------------------------------------------------------
459 dnl Find old Berkeley DB 1.85/1.86
460 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
461 [AC_CHECK_HEADERS(db_185.h db.h)
462 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
463 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
464 AC_EGREP_CPP(__db_version_1,[
471 /* this check could be improved */
472 #ifndef DB_VERSION_MAJOR
473 # define DB_VERSION_MAJOR 1
476 #if DB_VERSION_MAJOR == 1
479 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
481 if test $ol_cv_header_db1 = yes ; then
483 if test "$ol_cv_lib_db" != no ; then
484 ol_cv_berkeley_db=yes
490 dnl ====================================================================
491 dnl Check if GDBM library exists
492 dnl Check for gdbm_open in standard libraries or -lgdbm
494 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
495 dnl 'yes' implies gdbm_open is in $LIBS
498 dnl AC_CHECK_FUNC(gdbm_open)
499 dnl AC_CHECK_LIB(gdbm,gdbm_open)
501 AC_DEFUN([OL_LIB_GDBM],
502 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
504 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
505 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
511 dnl --------------------------------------------------------------------
512 dnl Check if GDBM exists
514 dnl defines ol_cv_gdbm to 'yes' or 'no'
518 dnl AC_CHECK_HEADERS(gdbm.h)
521 [AC_REQUIRE([OL_LIB_GDBM])
522 AC_CHECK_HEADERS(gdbm.h)
523 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
524 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
530 if test $ol_cv_gdbm = yes ; then
531 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
535 dnl ====================================================================
536 dnl Check if MDBM library exists
537 dnl Check for mdbm_open in standard libraries or -lmdbm
539 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
540 dnl 'yes' implies mdbm_open is in $LIBS
543 dnl AC_CHECK_FUNC(mdbm_set_chain)
544 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
546 AC_DEFUN([OL_LIB_MDBM],
547 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
549 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
550 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
556 dnl --------------------------------------------------------------------
557 dnl Check if MDBM exists
559 dnl defines ol_cv_mdbm to 'yes' or 'no'
563 dnl AC_CHECK_HEADERS(mdbm.h)
566 [AC_REQUIRE([OL_LIB_MDBM])
567 AC_CHECK_HEADERS(mdbm.h)
568 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
569 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
575 if test $ol_cv_mdbm = yes ; then
576 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
580 dnl ====================================================================
581 dnl Check if NDBM library exists
582 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
584 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
585 dnl 'yes' implies ndbm_open is in $LIBS
588 dnl AC_CHECK_FUNC(dbm_open)
589 dnl AC_CHECK_LIB(ndbm,dbm_open)
590 dnl AC_CHECK_LIB(dbm,dbm_open)
593 dnl should also check SVR4 case: dbm_open() in -lucb but that
594 dnl would requiring dealing with -L/usr/ucblib
596 AC_DEFUN([OL_LIB_NDBM],
597 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
599 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
600 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
601 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
602 [ol_cv_lib_ndbm=no])dnl
609 dnl --------------------------------------------------------------------
610 dnl Check if NDBM exists
612 dnl defines ol_cv_ndbm to 'yes' or 'no'
616 dnl AC_CHECK_HEADERS(ndbm.h)
619 dnl Doesn't handle SVR4 case (see above)
622 [AC_REQUIRE([OL_LIB_NDBM])
623 AC_CHECK_HEADERS(ndbm.h)
624 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
625 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
631 if test $ol_cv_ndbm = yes ; then
632 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
636 dnl ====================================================================
637 dnl Check POSIX Thread version
639 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
640 dnl version of the POSIX.4a Draft that is implemented.
641 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
642 dnl Existence of pthread.h should be tested separately.
645 dnl pthread_detach() was dropped in Draft 8, it is present
646 dnl in every other version
647 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
648 dnl PTHREAD_CREATE_JOINABLE after that
649 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
650 dnl Draft 6-10 has _init, Draft 4-5 has _create.
651 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
652 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
653 dnl interesting to us because we don't try to statically
654 dnl initialize mutexes. 5-10 has it.
656 dnl Draft 9 and 10 are equivalent for our purposes.
658 AC_DEFUN([OL_POSIX_THREAD_VERSION],
659 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
661 # include <pthread.h>
663 int i = PTHREAD_CREATE_JOINABLE;
665 AC_EGREP_HEADER(pthread_detach,pthread.h,
666 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
667 AC_EGREP_CPP(draft7,[
668 # include <pthread.h>
669 # ifdef PTHREAD_CREATE_UNDETACHED
672 ], ol_cv_pthread_version=7, [
673 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
674 ol_cv_pthread_version=6, [
675 AC_EGREP_CPP(draft5,[
676 # include <pthread.h>
677 #ifdef PTHREAD_MUTEX_INITIALIZER
680 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
684 dnl --------------------------------------------------------------------
685 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
686 [/* pthread test headers */
688 #if HAVE_PTHREADS < 7
692 #define NULL (void*)0
698 return (void *) (p == NULL);
701 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
702 /* pthread test function */
703 #ifndef PTHREAD_CREATE_DETACHED
704 #define PTHREAD_CREATE_DETACHED 1
708 int detach = PTHREAD_CREATE_DETACHED;
710 #if HAVE_PTHREADS > 4
714 status = pthread_attr_init(&attr);
715 if( status ) return status;
717 #if HAVE_PTHREADS < 7
718 status = pthread_attr_setdetachstate(&attr, &detach);
719 if( status < 0 ) status = errno;
721 status = pthread_attr_setdetachstate(&attr, detach);
723 if( status ) return status;
724 status = pthread_create( &t, &attr, task, NULL );
725 #if HAVE_PTHREADS < 7
726 if( status < 0 ) status = errno;
728 if( status ) return status;
730 /* Draft 4 pthreads */
731 status = pthread_create( &t, pthread_attr_default, task, NULL );
732 if( status ) return errno;
734 /* give thread a chance to complete */
735 /* it should remain joinable and hence detachable */
738 status = pthread_detach( &t );
739 if( status ) return errno;
742 #ifdef HAVE_LINUX_THREADS
743 pthread_kill_other_threads_np();
749 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
750 [OL_PTHREAD_TEST_INCLUDES
756 OL_PTHREAD_TEST_FUNCTION
759 dnl --------------------------------------------------------------------
760 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
761 if test "$ol_link_threads" = no ; then
763 AC_CACHE_CHECK([for pthread link with $1], [$2], [
768 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
770 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
777 if test $$2 = yes ; then
778 ol_link_pthreads="$1"
779 ol_link_threads=posix
784 dnl ====================================================================
785 dnl Check GNU Pth pthread Header
787 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
788 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
789 dnl doesn't exists. Existance of pthread.h should separately
792 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
793 AC_CACHE_CHECK([for GNU Pth pthread.h],
794 [ol_cv_header_gnu_pth_pthread_h],
795 [AC_EGREP_CPP(__gnu_pth__,
796 [#include <pthread.h>
797 #ifdef _POSIX_THREAD_IS_GNU_PTH
801 [ol_cv_header_gnu_pth_pthread_h=yes],
802 [ol_cv_header_gnu_pth_pthread_h=no])
805 dnl ====================================================================
806 dnl Check for NT Threads
807 AC_DEFUN([OL_NT_THREADS], [
808 AC_CHECK_FUNC(_beginthread)
810 if test $ac_cv_func__beginthread = yes ; then
811 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
815 dnl ====================================================================
816 dnl Check LinuxThreads Header
818 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
819 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
820 dnl doesn't exists. Existance of pthread.h should separately
823 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
824 AC_CACHE_CHECK([for LinuxThreads pthread.h],
825 [ol_cv_header_linux_threads],
826 [AC_EGREP_CPP(pthread_kill_other_threads_np,
827 [#include <pthread.h>],
828 [ol_cv_header_linux_threads=yes],
829 [ol_cv_header_linux_threads=no])
831 if test $ol_cv_header_linux_threads = yes; then
832 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
835 dnl --------------------------------------------------------------------
836 dnl Check LinuxThreads Implementation
838 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
839 dnl 'no' implies pthreads implementation is not LinuxThreads.
841 AC_DEFUN([OL_SYS_LINUX_THREADS], [
842 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
843 AC_CACHE_CHECK([for LinuxThreads implementation],
844 [ol_cv_sys_linux_threads],
845 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
848 dnl --------------------------------------------------------------------
849 dnl Check LinuxThreads consistency
850 AC_DEFUN([OL_LINUX_THREADS], [
851 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
852 AC_REQUIRE([OL_SYS_LINUX_THREADS])
853 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
854 if test $ol_cv_header_linux_threads = yes -a \
855 $ol_cv_sys_linux_threads = yes; then
856 ol_cv_linux_threads=yes
857 elif test $ol_cv_header_linux_threads = no -a \
858 $ol_cv_sys_linux_threads = no; then
859 ol_cv_linux_threads=no
861 ol_cv_linux_threads=error
866 dnl ====================================================================
867 dnl Check for POSIX Regex
868 AC_DEFUN([OL_POSIX_REGEX], [
869 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
871 #include <sys/types.h>
873 static char *pattern, *string;
881 if(regcomp(&re, pattern, 0)) {
885 string = "ALL MATCH";
887 rc = regexec(&re, string, 0, (void*)0, 0);
893 [ol_cv_c_posix_regex=yes],
894 [ol_cv_c_posix_regex=no],
895 [ol_cv_c_posix_regex=cross])])
898 dnl ====================================================================
899 dnl Check if toupper() requires islower() to be called first
900 AC_DEFUN([OL_C_UPPER_LOWER],
901 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
906 if ('C' == toupper('C'))
911 [ol_cv_c_upper_lower=no],
912 [ol_cv_c_upper_lower=yes],
913 [ol_cv_c_upper_lower=safe])])
914 if test $ol_cv_c_upper_lower != no ; then
915 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
919 dnl ====================================================================
920 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
921 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
922 dnl Reported by Keith Bostic.
923 AC_DEFUN([OL_SYS_ERRLIST],
924 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
927 #include <sys/types.h>
932 [char *c = (char *) *sys_errlist],
933 [ol_cv_dcl_sys_errlist=yes
934 ol_cv_have_sys_errlist=yes],
935 [ol_cv_dcl_sys_errlist=no])])
937 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
938 if test $ol_cv_dcl_sys_errlist = no ; then
939 AC_DEFINE(DECL_SYS_ERRLIST,1,
940 [define if sys_errlist is not declared in stdio.h or errno.h])
942 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
943 AC_TRY_LINK([#include <errno.h>],
944 [char *c = (char *) *sys_errlist],
945 [ol_cv_have_sys_errlist=yes],
946 [ol_cv_have_sys_errlist=no])])
948 if test $ol_cv_have_sys_errlist = yes ; then
949 AC_DEFINE(HAVE_SYS_ERRLIST,1,
950 [define if you actually have sys_errlist in your libs])
954 dnl ====================================================================
955 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
956 dnl "int x; int *volatile a = &x; *a = 0;"
957 dnl -- borrowed from PDKSH
958 AC_DEFUN(OL_C_VOLATILE,
959 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
960 [AC_TRY_COMPILE([int x, y, z;],
961 [volatile int a; int * volatile b = x ? &y : &z;
962 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
963 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
964 if test $ol_cv_c_volatile = yes; then
967 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
971 dnl ====================================================================
972 dnl Look for fetch(3)
973 AC_DEFUN([OL_LIB_FETCH],
975 LIBS="-lfetch -lcom_err $LIBS"
976 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
978 #include <sys/param.h>
981 [struct url *u = fetchParseURL("file:///"); ],
982 [ol_cv_lib_fetch=yes],
983 [ol_cv_lib_fetch=no])])
985 if test $ol_cv_lib_fetch != no ; then
986 ol_link_fetch="-lfetch -lcom_err"
987 AC_DEFINE(HAVE_FETCH,1,
988 [define if you actually have FreeBSD fetch(3)])
992 dnl ====================================================================
993 dnl Define sig_atomic_t if not defined in signal.h
994 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
995 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
996 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
997 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
998 if test $ol_cv_type_sig_atomic_t = no; then
999 AC_DEFINE(sig_atomic_t,int,
1000 [define to atomic type if sig_atomic_t is not available])
1004 dnl ====================================================================
1005 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
1006 AC_DEFUN(OL_TYPE_SOCKLEN_T,
1007 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
1009 #ifdef HAVE_SYS_TYPES_H
1010 #include <sys/types.h>
1012 #ifdef HAVE_SYS_SOCKET_H
1013 #include <sys/socket.h>
1015 ], [socklen_t len;],
1016 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
1017 if test $ol_cv_type_socklen_t = no; then
1018 AC_DEFINE(socklen_t, int,
1019 [define to int if socklen_t is not available])
1023 dnl ====================================================================
1024 dnl Define inet_aton is available
1025 AC_DEFUN(OL_FUNC_INET_ATON,
1026 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1028 #ifdef HAVE_SYS_TYPES_H
1029 # include <sys/types.h>
1031 #ifdef HAVE_SYS_SOCKET_H
1032 # include <sys/socket.h>
1033 # ifdef HAVE_SYS_SELECT_H
1034 # include <sys/select.h>
1036 # include <netinet/in.h>
1037 # ifdef HAVE_ARPA_INET_H
1038 # include <arpa/inet.h>
1041 ], [struct in_addr in;
1042 int rc = inet_aton( "255.255.255.255", &in );],
1043 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1044 if test $ol_cv_func_inet_aton != no; then
1045 AC_DEFINE(HAVE_INET_ATON, 1,
1046 [define to you inet_aton(3) is available])
1050 dnl ====================================================================
1051 dnl check no of arguments for ctime_r
1052 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1053 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1054 [AC_TRY_COMPILE([#include <time.h>],
1055 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1056 ol_cv_func_ctime_r_nargs3=yes,
1057 ol_cv_func_ctime_r_nargs3=no)
1059 AC_TRY_COMPILE([#include <time.h>],
1060 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1061 ol_cv_func_ctime_r_nargs2=yes,
1062 ol_cv_func_ctime_r_nargs2=no)
1064 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1065 $ol_cv_func_ctime_r_nargs2 = no ; then
1067 ol_cv_func_ctime_r_nargs=3
1069 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1070 $ol_cv_func_ctime_r_nargs2 = yes ; then
1072 ol_cv_func_ctime_r_nargs=2
1075 ol_cv_func_ctime_r_nargs=0
1079 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1080 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1081 [set to the number of arguments ctime_r() expects])
1085 dnl --------------------------------------------------------------------
1086 dnl check return type of ctime_r()
1087 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1088 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1089 [AC_TRY_COMPILE([#include <time.h>],
1090 [extern int (ctime_r)();],
1091 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1093 if test $ol_cv_func_ctime_r_type = "int" ; then
1094 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1097 dnl ====================================================================
1098 dnl check no of arguments for gethostbyname_r
1099 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1100 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1101 ol_cv_func_gethostbyname_r_nargs,
1102 [AC_TRY_COMPILE([#include <sys/types.h>
1103 #include <sys/socket.h>
1104 #include <netinet/in.h>
1106 #define BUFSIZE (sizeof(struct hostent)+10)],
1107 [struct hostent hent; char buffer[BUFSIZE];
1108 int bufsize=BUFSIZE;int h_errno;
1109 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1110 buffer, bufsize, &h_errno);],
1111 ol_cv_func_gethostbyname_r_nargs5=yes,
1112 ol_cv_func_gethostbyname_r_nargs5=no)
1114 AC_TRY_COMPILE([#include <sys/types.h>
1115 #include <sys/socket.h>
1116 #include <netinet/in.h>
1118 #define BUFSIZE (sizeof(struct hostent)+10)],
1119 [struct hostent hent;struct hostent *rhent;
1120 char buffer[BUFSIZE];
1121 int bufsize=BUFSIZE;int h_errno;
1122 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1123 &rhent, &h_errno);],
1124 ol_cv_func_gethostbyname_r_nargs6=yes,
1125 ol_cv_func_gethostbyname_r_nargs6=no)
1127 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1128 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1130 ol_cv_func_gethostbyname_r_nargs=5
1132 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1133 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1135 ol_cv_func_gethostbyname_r_nargs=6
1138 ol_cv_func_gethostbyname_r_nargs=0
1141 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1142 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1143 $ol_cv_func_gethostbyname_r_nargs,
1144 [set to the number of arguments gethostbyname_r() expects])
1148 dnl check no of arguments for gethostbyaddr_r
1149 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1150 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1151 [ol_cv_func_gethostbyaddr_r_nargs],
1152 [AC_TRY_COMPILE([#include <sys/types.h>
1153 #include <sys/socket.h>
1154 #include <netinet/in.h>
1156 #define BUFSIZE (sizeof(struct hostent)+10)],
1157 [struct hostent hent; char buffer[BUFSIZE];
1159 size_t alen=sizeof(struct in_addr);
1160 int bufsize=BUFSIZE;int h_errno;
1161 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1162 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1163 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1164 ol_cv_func_gethostbyaddr_r_nargs7=no)
1166 AC_TRY_COMPILE([#include <sys/types.h>
1167 #include <sys/socket.h>
1168 #include <netinet/in.h>
1170 #define BUFSIZE (sizeof(struct hostent)+10)],
1171 [struct hostent hent;
1172 struct hostent *rhent; char buffer[BUFSIZE];
1174 size_t alen=sizeof(struct in_addr);
1175 int bufsize=BUFSIZE;int h_errno;
1176 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1177 alen, AF_INET, &hent, buffer, bufsize,
1178 &rhent, &h_errno);],
1179 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1180 ol_cv_func_gethostbyaddr_r_nargs8=no)
1182 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1183 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1185 ol_cv_func_gethostbyaddr_r_nargs=7
1187 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1188 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1190 ol_cv_func_gethostbyaddr_r_nargs=8
1193 ol_cv_func_gethostbyaddr_r_nargs=0
1196 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1197 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1198 $ol_cv_func_gethostbyaddr_r_nargs,
1199 [set to the number of arguments gethostbyaddr_r() expects])
1203 dnl --------------------------------------------------------------------
1204 dnl Check for Cyrus SASL version compatility
1205 AC_DEFUN([OL_SASL_COMPAT],
1206 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1207 AC_EGREP_CPP(__sasl_compat,[
1208 #ifdef HAVE_SASL_SASL_H
1209 #include <sasl/sasl.h>
1214 /* Require 2.1.15+ */
1215 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1216 char *__sasl_compat = "2.2+ or better okay (we guess)";
1217 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1218 && SASL_VERSION_STEP >=15
1219 char *__sasl_compat = "2.1.15+ or better okay";
1221 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1223 dnl ====================================================================
1224 dnl check for msg_accrights in msghdr
1225 AC_DEFUN(OL_MSGHDR_MSG_ACCRIGHTS,
1226 [AC_CACHE_CHECK(for msg_accrights in msghdr, ol_cv_msghdr_msg_accrights,
1227 [AC_TRY_COMPILE([#include <sys/socket.h>],
1228 [struct msghdr m; m.msg_accrightslen=0],
1229 ol_cv_msghdr_msg_accrights=yes, ol_cv_msghdr_msg_accrights=no)
1231 if test $ol_cv_msghdr_msg_accrights = "yes" ; then
1232 AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1,
1233 [define if struct msghdr has msg_accrights])