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"
80 #include <sys/types.h>
82 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
83 if test x$AC_CV_NAME != x ; then break; fi
86 if test x$AC_CV_NAME = x ; then
87 AC_MSG_ERROR([cannot determine a size for $1])
89 AC_MSG_RESULT($AC_CV_NAME)
90 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
91 undefine([AC_TYPE_NAME])dnl
92 undefine([AC_CV_NAME])dnl
94 dnl ====================================================================
95 dnl check if hard links are supported.
97 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
98 AC_MSG_CHECKING(whether ln works)
99 AC_CACHE_VAL(ol_cv_prog_LN_H,
100 [rm -f conftest.src conftest.dst
101 echo "conftest" > conftest.src
102 if ln conftest.src conftest.dst 2>/dev/null
108 rm -f conftest.src conftest.dst
110 LN_H="$ol_cv_prog_LN_H"
111 if test "$ol_cv_prog_LN_H" = "ln"; then
119 dnl ====================================================================
120 dnl Check for dependency generation flag
121 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
124 if test -z "${MKDEP}"; then
126 if test -z "${MKDEP_FLAGS}"; then
127 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
129 for flag in "-M" "-xM"; do
130 cat > conftest.c <<EOF
133 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
134 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
136 if test ! -f conftest."${ac_object}" ; then
138 OL_MKDEP_FLAGS="$flag"
147 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
152 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
155 AC_SUBST(OL_MKDEP_FLAGS)
158 dnl ====================================================================
159 dnl Check if system uses EBCDIC instead of ASCII
160 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
161 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
164 #include <__ASCII__/generate_error.h>
167 [ol_cv_cpp_ebcdic=yes],
168 [ol_cv_cpp_ebcdic=no])])
169 if test $ol_cv_cpp_ebcdic = yes ; then
170 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
174 dnl --------------------------------------------------------------------
175 dnl OpenLDAP version of STDC header check w/ EBCDIC support
176 AC_DEFUN(OL_HEADER_STDC,
178 AC_REQUIRE([OL_CPP_EBCDIC])dnl
179 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
180 [AC_TRY_CPP([#include <stdlib.h>
183 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
185 if test $ol_cv_header_stdc = yes; then
186 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
187 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
190 if test $ol_cv_header_stdc = yes; then
191 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
192 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
195 if test $ol_cv_header_stdc = yes; then
196 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
197 AC_TRY_RUN([#include <ctype.h>
199 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
200 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
202 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
203 || ('j' <= (c) && (c) <= 'r') \
204 || ('s' <= (c) && (c) <= 'z'))
205 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
207 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
208 int main () { int i; for (i = 0; i < 256; i++)
209 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
211 ], , ol_cv_header_stdc=no, :)
213 if test $ol_cv_header_stdc = yes; then
214 AC_DEFINE(STDC_HEADERS)
216 ac_cv_header_stdc=disable
219 dnl ====================================================================
220 dnl Check if struct passwd has pw_gecos
221 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
222 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
223 AC_TRY_COMPILE([#include <pwd.h>],[
225 pwd.pw_gecos = pwd.pw_name;
227 [ol_cv_struct_passwd_pw_gecos=yes],
228 [ol_cv_struct_passwd_pw_gecos=no])])
229 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
230 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
234 dnl --------------------------------------------------------------------
235 dnl Check if struct passwd has pw_passwd
236 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
237 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
238 AC_TRY_COMPILE([#include <pwd.h>],[
240 pwd.pw_passwd = pwd.pw_name;
242 [ol_cv_struct_passwd_pw_passwd=yes],
243 [ol_cv_struct_passwd_pw_passwd=no])])
244 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
245 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
249 dnl ====================================================================
250 dnl Berkeley DB macros
252 dnl --------------------------------------------------------------------
254 AC_DEFUN([OL_BERKELEY_DB_TRY],
255 [if test $ol_cv_lib_db = no ; then
256 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
258 ol_DB_LIB=ifelse($2,,,$2)
260 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
269 #ifndef DB_VERSION_MAJOR
270 # define DB_VERSION_MAJOR 1
274 #define NULL ((void*)0)
277 #if DB_VERSION_MAJOR > 1
280 int major, minor, patch;
282 version = db_version( &major, &minor, &patch );
284 if( major != DB_VERSION_MAJOR ||
285 minor < DB_VERSION_MINOR )
287 printf("Berkeley DB version mismatch\n"
288 "\texpected: %s\n\tgot: %s\n",
289 DB_VERSION_STRING, version);
295 #if DB_VERSION_MAJOR > 2
296 db_env_create( NULL, 0 );
297 #elif DB_VERSION_MAJOR > 1
300 (void) dbopen( NULL, 0, 0, 0, NULL);
307 if test $$1 = yes ; then
308 ol_cv_lib_db=ifelse($2,,yes,$2)
313 dnl --------------------------------------------------------------------
314 dnl Try to locate appropriate library
315 AC_DEFUN([OL_BERKELEY_DB_LINK],
317 OL_BERKELEY_DB_TRY(ol_cv_db_none)
318 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
320 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
321 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
322 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
323 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
324 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
325 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
326 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
327 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
328 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
329 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
330 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
331 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
332 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
333 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
334 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
337 dnl --------------------------------------------------------------------
338 dnl Check if Berkeley DB supports DB_THREAD
339 AC_DEFUN([OL_BERKELEY_DB_THREAD],
340 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
342 LIBS="$LTHREAD_LIBS $LIBS"
343 if test $ol_cv_lib_db != yes ; then
344 LIBS="$ol_cv_lib_db $LIBS"
354 #define NULL ((void *)0)
359 u_int32_t flags = DB_CREATE |
365 #if DB_VERSION_MAJOR > 2
368 rc = db_env_create( &env, 0 );
370 flags |= DB_INIT_MPOOL;
371 #ifdef DB_MPOOL_PRIVATE
372 flags |= DB_MPOOL_PRIVATE;
376 printf("BerkeleyDB: %s\n", db_strerror(rc) );
380 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
381 rc = env->open( env, NULL, flags, 0 );
383 rc = env->open( env, NULL, NULL, flags, 0 );
387 rc = env->close( env, 0 );
391 printf("BerkeleyDB: %s\n", db_strerror(rc) );
397 memset( &env, '\0', sizeof(env) );
399 rc = db_appinit( NULL, NULL, &env, flags );
405 unlink("__db_mpool.share");
406 unlink("__db_lock.share");
411 [ol_cv_berkeley_db_thread=yes],
412 [ol_cv_berkeley_db_thread=no],
413 [ol_cv_berkeley_db_thread=cross])
418 if test $ol_cv_berkeley_db_thread != no ; then
419 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
420 [define if Berkeley DB has DB_THREAD support])
424 dnl --------------------------------------------------------------------
426 AC_DEFUN([OL_BERKELEY_DB],
427 [ol_cv_berkeley_db=no
428 AC_CHECK_HEADERS(db.h)
429 if test $ac_cv_header_db_h = yes; then
431 if test "$ol_cv_lib_db" != no ; then
432 ol_cv_berkeley_db=yes
433 OL_BERKELEY_DB_THREAD
437 dnl --------------------------------------------------------------------
438 dnl Check for version compatility with back-bdb
439 AC_DEFUN([OL_BDB_COMPAT],
440 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
441 AC_EGREP_CPP(__db_version_compat,[
444 /* this check could be improved */
445 #ifndef DB_VERSION_MAJOR
446 # define DB_VERSION_MAJOR 1
448 #ifndef DB_VERSION_MINOR
449 # define DB_VERSION_MINOR 0
452 /* require 4.2 or later */
453 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
456 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
459 dnl --------------------------------------------------------------------
460 dnl Find old Berkeley DB 1.85/1.86
461 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
462 [AC_CHECK_HEADERS(db_185.h db.h)
463 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
464 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
465 AC_EGREP_CPP(__db_version_1,[
472 /* this check could be improved */
473 #ifndef DB_VERSION_MAJOR
474 # define DB_VERSION_MAJOR 1
477 #if DB_VERSION_MAJOR == 1
480 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
482 if test $ol_cv_header_db1 = yes ; then
484 if test "$ol_cv_lib_db" != no ; then
485 ol_cv_berkeley_db=yes
491 dnl ====================================================================
492 dnl Check if GDBM library exists
493 dnl Check for gdbm_open in standard libraries or -lgdbm
495 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
496 dnl 'yes' implies gdbm_open is in $LIBS
499 dnl AC_CHECK_FUNC(gdbm_open)
500 dnl AC_CHECK_LIB(gdbm,gdbm_open)
502 AC_DEFUN([OL_LIB_GDBM],
503 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
505 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
506 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
512 dnl --------------------------------------------------------------------
513 dnl Check if GDBM exists
515 dnl defines ol_cv_gdbm to 'yes' or 'no'
519 dnl AC_CHECK_HEADERS(gdbm.h)
522 [AC_REQUIRE([OL_LIB_GDBM])
523 AC_CHECK_HEADERS(gdbm.h)
524 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
525 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
531 if test $ol_cv_gdbm = yes ; then
532 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
536 dnl ====================================================================
537 dnl Check if MDBM library exists
538 dnl Check for mdbm_open in standard libraries or -lmdbm
540 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
541 dnl 'yes' implies mdbm_open is in $LIBS
544 dnl AC_CHECK_FUNC(mdbm_set_chain)
545 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
547 AC_DEFUN([OL_LIB_MDBM],
548 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
550 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
551 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
557 dnl --------------------------------------------------------------------
558 dnl Check if MDBM exists
560 dnl defines ol_cv_mdbm to 'yes' or 'no'
564 dnl AC_CHECK_HEADERS(mdbm.h)
567 [AC_REQUIRE([OL_LIB_MDBM])
568 AC_CHECK_HEADERS(mdbm.h)
569 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
570 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
576 if test $ol_cv_mdbm = yes ; then
577 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
581 dnl ====================================================================
582 dnl Check if NDBM library exists
583 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
585 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
586 dnl 'yes' implies ndbm_open is in $LIBS
589 dnl AC_CHECK_FUNC(dbm_open)
590 dnl AC_CHECK_LIB(ndbm,dbm_open)
591 dnl AC_CHECK_LIB(dbm,dbm_open)
594 dnl should also check SVR4 case: dbm_open() in -lucb but that
595 dnl would requiring dealing with -L/usr/ucblib
597 AC_DEFUN([OL_LIB_NDBM],
598 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
600 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
601 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
602 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
603 [ol_cv_lib_ndbm=no])dnl
610 dnl --------------------------------------------------------------------
611 dnl Check if NDBM exists
613 dnl defines ol_cv_ndbm to 'yes' or 'no'
617 dnl AC_CHECK_HEADERS(ndbm.h)
620 dnl Doesn't handle SVR4 case (see above)
623 [AC_REQUIRE([OL_LIB_NDBM])
624 AC_CHECK_HEADERS(ndbm.h)
625 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
626 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
632 if test $ol_cv_ndbm = yes ; then
633 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
637 dnl ====================================================================
638 dnl Check POSIX Thread version
640 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
641 dnl version of the POSIX.4a Draft that is implemented.
642 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
643 dnl Existence of pthread.h should be tested separately.
646 dnl pthread_detach() was dropped in Draft 8, it is present
647 dnl in every other version
648 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
649 dnl PTHREAD_CREATE_JOINABLE after that
650 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
651 dnl Draft 6-10 has _init, Draft 4-5 has _create.
652 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
653 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
654 dnl interesting to us because we don't try to statically
655 dnl initialize mutexes. 5-10 has it.
657 dnl Draft 9 and 10 are equivalent for our purposes.
659 AC_DEFUN([OL_POSIX_THREAD_VERSION],
660 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
662 # include <pthread.h>
664 int i = PTHREAD_CREATE_JOINABLE;
666 AC_EGREP_HEADER(pthread_detach,pthread.h,
667 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
668 AC_EGREP_CPP(draft7,[
669 # include <pthread.h>
670 # ifdef PTHREAD_CREATE_UNDETACHED
673 ], ol_cv_pthread_version=7, [
674 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
675 ol_cv_pthread_version=6, [
676 AC_EGREP_CPP(draft5,[
677 # include <pthread.h>
678 #ifdef PTHREAD_MUTEX_INITIALIZER
681 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
685 dnl --------------------------------------------------------------------
686 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
687 [/* pthread test headers */
689 #if HAVE_PTHREADS < 7
693 #define NULL (void*)0
699 return (void *) (p == NULL);
702 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
703 /* pthread test function */
704 #ifndef PTHREAD_CREATE_DETACHED
705 #define PTHREAD_CREATE_DETACHED 1
709 int detach = PTHREAD_CREATE_DETACHED;
711 #if HAVE_PTHREADS > 4
715 status = pthread_attr_init(&attr);
716 if( status ) return status;
718 #if HAVE_PTHREADS < 7
719 status = pthread_attr_setdetachstate(&attr, &detach);
720 if( status < 0 ) status = errno;
722 status = pthread_attr_setdetachstate(&attr, detach);
724 if( status ) return status;
725 status = pthread_create( &t, &attr, task, NULL );
726 #if HAVE_PTHREADS < 7
727 if( status < 0 ) status = errno;
729 if( status ) return status;
731 /* Draft 4 pthreads */
732 status = pthread_create( &t, pthread_attr_default, task, NULL );
733 if( status ) return errno;
735 /* give thread a chance to complete */
736 /* it should remain joinable and hence detachable */
739 status = pthread_detach( &t );
740 if( status ) return errno;
743 #ifdef HAVE_LINUX_THREADS
744 pthread_kill_other_threads_np();
750 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
751 [OL_PTHREAD_TEST_INCLUDES
757 OL_PTHREAD_TEST_FUNCTION
760 dnl --------------------------------------------------------------------
761 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
762 if test "$ol_link_threads" = no ; then
764 AC_CACHE_CHECK([for pthread link with $1], [$2], [
769 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
771 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
778 if test $$2 = yes ; then
779 ol_link_pthreads="$1"
780 ol_link_threads=posix
785 dnl ====================================================================
786 dnl Check GNU Pth pthread Header
788 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
789 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
790 dnl doesn't exists. Existance of pthread.h should separately
793 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
794 AC_CACHE_CHECK([for GNU Pth pthread.h],
795 [ol_cv_header_gnu_pth_pthread_h],
796 [AC_EGREP_CPP(__gnu_pth__,
797 [#include <pthread.h>
798 #ifdef _POSIX_THREAD_IS_GNU_PTH
802 [ol_cv_header_gnu_pth_pthread_h=yes],
803 [ol_cv_header_gnu_pth_pthread_h=no])
806 dnl ====================================================================
807 dnl Check for NT Threads
808 AC_DEFUN([OL_NT_THREADS], [
809 AC_CHECK_FUNC(_beginthread)
811 if test $ac_cv_func__beginthread = yes ; then
812 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
816 dnl ====================================================================
817 dnl Check LinuxThreads Header
819 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
820 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
821 dnl doesn't exists. Existance of pthread.h should separately
824 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
825 AC_CACHE_CHECK([for LinuxThreads pthread.h],
826 [ol_cv_header_linux_threads],
827 [AC_EGREP_CPP(pthread_kill_other_threads_np,
828 [#include <pthread.h>],
829 [ol_cv_header_linux_threads=yes],
830 [ol_cv_header_linux_threads=no])
832 if test $ol_cv_header_linux_threads = yes; then
833 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
836 dnl --------------------------------------------------------------------
837 dnl Check LinuxThreads Implementation
839 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
840 dnl 'no' implies pthreads implementation is not LinuxThreads.
842 AC_DEFUN([OL_SYS_LINUX_THREADS], [
843 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
844 AC_CACHE_CHECK([for LinuxThreads implementation],
845 [ol_cv_sys_linux_threads],
846 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
849 dnl --------------------------------------------------------------------
850 dnl Check LinuxThreads consistency
851 AC_DEFUN([OL_LINUX_THREADS], [
852 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
853 AC_REQUIRE([OL_SYS_LINUX_THREADS])
854 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
855 if test $ol_cv_header_linux_threads = yes -a \
856 $ol_cv_sys_linux_threads = yes; then
857 ol_cv_linux_threads=yes
858 elif test $ol_cv_header_linux_threads = no -a \
859 $ol_cv_sys_linux_threads = no; then
860 ol_cv_linux_threads=no
862 ol_cv_linux_threads=error
867 dnl ====================================================================
868 dnl Check for POSIX Regex
869 AC_DEFUN([OL_POSIX_REGEX], [
870 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
872 #include <sys/types.h>
874 static char *pattern, *string;
882 if(regcomp(&re, pattern, 0)) {
886 string = "ALL MATCH";
888 rc = regexec(&re, string, 0, (void*)0, 0);
894 [ol_cv_c_posix_regex=yes],
895 [ol_cv_c_posix_regex=no],
896 [ol_cv_c_posix_regex=cross])])
899 dnl ====================================================================
900 dnl Check if toupper() requires islower() to be called first
901 AC_DEFUN([OL_C_UPPER_LOWER],
902 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
907 if ('C' == toupper('C'))
912 [ol_cv_c_upper_lower=no],
913 [ol_cv_c_upper_lower=yes],
914 [ol_cv_c_upper_lower=safe])])
915 if test $ol_cv_c_upper_lower != no ; then
916 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
920 dnl ====================================================================
921 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
922 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
923 dnl Reported by Keith Bostic.
924 AC_DEFUN([OL_SYS_ERRLIST],
925 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
928 #include <sys/types.h>
933 [char *c = (char *) *sys_errlist],
934 [ol_cv_dcl_sys_errlist=yes
935 ol_cv_have_sys_errlist=yes],
936 [ol_cv_dcl_sys_errlist=no])])
938 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
939 if test $ol_cv_dcl_sys_errlist = no ; then
940 AC_DEFINE(DECL_SYS_ERRLIST,1,
941 [define if sys_errlist is not declared in stdio.h or errno.h])
943 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
944 AC_TRY_LINK([#include <errno.h>],
945 [char *c = (char *) *sys_errlist],
946 [ol_cv_have_sys_errlist=yes],
947 [ol_cv_have_sys_errlist=no])])
949 if test $ol_cv_have_sys_errlist = yes ; then
950 AC_DEFINE(HAVE_SYS_ERRLIST,1,
951 [define if you actually have sys_errlist in your libs])
955 dnl ====================================================================
956 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
957 dnl "int x; int *volatile a = &x; *a = 0;"
958 dnl -- borrowed from PDKSH
959 AC_DEFUN(OL_C_VOLATILE,
960 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
961 [AC_TRY_COMPILE([int x, y, z;],
962 [volatile int a; int * volatile b = x ? &y : &z;
963 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
964 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
965 if test $ol_cv_c_volatile = yes; then
968 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
972 dnl ====================================================================
973 dnl Look for fetch(3)
974 AC_DEFUN([OL_LIB_FETCH],
976 LIBS="-lfetch -lcom_err $LIBS"
977 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
979 #include <sys/param.h>
982 [struct url *u = fetchParseURL("file:///"); ],
983 [ol_cv_lib_fetch=yes],
984 [ol_cv_lib_fetch=no])])
986 if test $ol_cv_lib_fetch != no ; then
987 ol_link_fetch="-lfetch -lcom_err"
988 AC_DEFINE(HAVE_FETCH,1,
989 [define if you actually have FreeBSD fetch(3)])
993 dnl ====================================================================
994 dnl Define sig_atomic_t if not defined in signal.h
995 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
996 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
997 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
998 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
999 if test $ol_cv_type_sig_atomic_t = no; then
1000 AC_DEFINE(sig_atomic_t,int,
1001 [define to atomic type if sig_atomic_t is not available])
1005 dnl ====================================================================
1006 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
1007 AC_DEFUN(OL_TYPE_SOCKLEN_T,
1008 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
1010 #ifdef HAVE_SYS_TYPES_H
1011 #include <sys/types.h>
1013 #ifdef HAVE_SYS_SOCKET_H
1014 #include <sys/socket.h>
1016 ], [socklen_t len;],
1017 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
1018 if test $ol_cv_type_socklen_t = no; then
1019 AC_DEFINE(socklen_t, int,
1020 [define to int if socklen_t is not available])
1024 dnl ====================================================================
1025 dnl Define inet_aton is available
1026 AC_DEFUN(OL_FUNC_INET_ATON,
1027 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1029 #ifdef HAVE_SYS_TYPES_H
1030 # include <sys/types.h>
1032 #ifdef HAVE_SYS_SOCKET_H
1033 # include <sys/socket.h>
1034 # ifdef HAVE_SYS_SELECT_H
1035 # include <sys/select.h>
1037 # include <netinet/in.h>
1038 # ifdef HAVE_ARPA_INET_H
1039 # include <arpa/inet.h>
1042 ], [struct in_addr in;
1043 int rc = inet_aton( "255.255.255.255", &in );],
1044 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1045 if test $ol_cv_func_inet_aton != no; then
1046 AC_DEFINE(HAVE_INET_ATON, 1,
1047 [define to you inet_aton(3) is available])
1051 dnl ====================================================================
1052 dnl check no of arguments for ctime_r
1053 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1054 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1055 [AC_TRY_COMPILE([#include <time.h>],
1056 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1057 ol_cv_func_ctime_r_nargs3=yes,
1058 ol_cv_func_ctime_r_nargs3=no)
1060 AC_TRY_COMPILE([#include <time.h>],
1061 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1062 ol_cv_func_ctime_r_nargs2=yes,
1063 ol_cv_func_ctime_r_nargs2=no)
1065 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1066 $ol_cv_func_ctime_r_nargs2 = no ; then
1068 ol_cv_func_ctime_r_nargs=3
1070 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1071 $ol_cv_func_ctime_r_nargs2 = yes ; then
1073 ol_cv_func_ctime_r_nargs=2
1076 ol_cv_func_ctime_r_nargs=0
1080 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1081 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1082 [set to the number of arguments ctime_r() expects])
1086 dnl --------------------------------------------------------------------
1087 dnl check return type of ctime_r()
1088 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1089 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1090 [AC_TRY_COMPILE([#include <time.h>],
1091 [extern int (ctime_r)();],
1092 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1094 if test $ol_cv_func_ctime_r_type = "int" ; then
1095 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1098 dnl ====================================================================
1099 dnl check no of arguments for gethostbyname_r
1100 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1101 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1102 ol_cv_func_gethostbyname_r_nargs,
1103 [AC_TRY_COMPILE([#include <sys/types.h>
1104 #include <sys/socket.h>
1105 #include <netinet/in.h>
1107 #define BUFSIZE (sizeof(struct hostent)+10)],
1108 [struct hostent hent; char buffer[BUFSIZE];
1109 int bufsize=BUFSIZE;int h_errno;
1110 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1111 buffer, bufsize, &h_errno);],
1112 ol_cv_func_gethostbyname_r_nargs5=yes,
1113 ol_cv_func_gethostbyname_r_nargs5=no)
1115 AC_TRY_COMPILE([#include <sys/types.h>
1116 #include <sys/socket.h>
1117 #include <netinet/in.h>
1119 #define BUFSIZE (sizeof(struct hostent)+10)],
1120 [struct hostent hent;struct hostent *rhent;
1121 char buffer[BUFSIZE];
1122 int bufsize=BUFSIZE;int h_errno;
1123 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1124 &rhent, &h_errno);],
1125 ol_cv_func_gethostbyname_r_nargs6=yes,
1126 ol_cv_func_gethostbyname_r_nargs6=no)
1128 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1129 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1131 ol_cv_func_gethostbyname_r_nargs=5
1133 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1134 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1136 ol_cv_func_gethostbyname_r_nargs=6
1139 ol_cv_func_gethostbyname_r_nargs=0
1142 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1143 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1144 $ol_cv_func_gethostbyname_r_nargs,
1145 [set to the number of arguments gethostbyname_r() expects])
1149 dnl check no of arguments for gethostbyaddr_r
1150 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1151 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1152 [ol_cv_func_gethostbyaddr_r_nargs],
1153 [AC_TRY_COMPILE([#include <sys/types.h>
1154 #include <sys/socket.h>
1155 #include <netinet/in.h>
1157 #define BUFSIZE (sizeof(struct hostent)+10)],
1158 [struct hostent hent; char buffer[BUFSIZE];
1160 size_t alen=sizeof(struct in_addr);
1161 int bufsize=BUFSIZE;int h_errno;
1162 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1163 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1164 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1165 ol_cv_func_gethostbyaddr_r_nargs7=no)
1167 AC_TRY_COMPILE([#include <sys/types.h>
1168 #include <sys/socket.h>
1169 #include <netinet/in.h>
1171 #define BUFSIZE (sizeof(struct hostent)+10)],
1172 [struct hostent hent;
1173 struct hostent *rhent; char buffer[BUFSIZE];
1175 size_t alen=sizeof(struct in_addr);
1176 int bufsize=BUFSIZE;int h_errno;
1177 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1178 alen, AF_INET, &hent, buffer, bufsize,
1179 &rhent, &h_errno);],
1180 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1181 ol_cv_func_gethostbyaddr_r_nargs8=no)
1183 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1184 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1186 ol_cv_func_gethostbyaddr_r_nargs=7
1188 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1189 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1191 ol_cv_func_gethostbyaddr_r_nargs=8
1194 ol_cv_func_gethostbyaddr_r_nargs=0
1197 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1198 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1199 $ol_cv_func_gethostbyaddr_r_nargs,
1200 [set to the number of arguments gethostbyaddr_r() expects])
1204 dnl --------------------------------------------------------------------
1205 dnl Check for Cyrus SASL version compatility
1206 AC_DEFUN([OL_SASL_COMPAT],
1207 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1208 AC_EGREP_CPP(__sasl_compat,[
1209 #ifdef HAVE_SASL_SASL_H
1210 #include <sasl/sasl.h>
1215 /* Require 2.1.15+ */
1216 #if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1217 char *__sasl_compat = "2.2+ or better okay (we guess)";
1218 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1219 && SASL_VERSION_STEP >=15
1220 char *__sasl_compat = "2.1.15+ or better okay";
1222 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1224 dnl ====================================================================
1225 dnl check for msg_accrights in msghdr
1226 AC_DEFUN(OL_MSGHDR_MSG_ACCRIGHTS,
1227 [AC_CACHE_CHECK(for msg_accrights in msghdr, ol_cv_msghdr_msg_accrights,
1228 [AC_TRY_COMPILE([#include <sys/socket.h>],
1229 [struct msghdr m; m.msg_accrightslen=0],
1230 ol_cv_msghdr_msg_accrights=yes, ol_cv_msghdr_msg_accrights=no)
1232 if test $ol_cv_msghdr_msg_accrights = "yes" ; then
1233 AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1,
1234 [define if struct msghdr has msg_accrights])