3 dnl Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA
4 dnl All rights reserved.
6 dnl Redistribution and use in source and binary forms, with or without
7 dnl modification, are permitted only as authorized by the OpenLDAP
8 dnl Public License. A copy of this license is available at
9 dnl http://www.OpenLDAP.org/license.html or in file LICENSE in the
10 dnl top-level directory of the distribution.
12 dnl OpenLDAP Autoconf Macros
14 dnl --------------------------------------------------------------------
15 dnl Restricted form of AC_ARG_ENABLE that limits user options
19 dnl $3 = default value (auto)
20 dnl $4 = allowed values (auto yes no)
21 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
22 AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1],
23 [$2 <m4_ifval([$4],[$4],[auto yes no])> default=m4_ifval([$3],[$3],[auto])]),
25 for ol_val in m4_ifval([$4],[$4],[auto yes no]) ; do
26 if test "$enableval" = "$ol_val" ; then
30 if test "$ol_arg" = "invalid" ; then
31 AC_MSG_ERROR(bad value $enableval for --enable-$1)
33 ol_enable_$1="$ol_arg"
35 [ ol_enable_$1=m4_ifval([$3],["$3"],["auto"])])dnl
39 dnl --------------------------------------------------------------------
40 dnl Restricted form of AC_ARG_WITH that limits user options
44 dnl $3 = default value (no)
45 dnl $4 = allowed values (yes no)
46 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
47 AC_ARG_WITH([$1], AC_HELP_STRING([--with-$1],
48 [$2 <m4_ifval([$4],[$4],[auto yes no])> default=m4_ifval([$3],[$3],[auto])]),
50 for ol_val in m4_ifval([$4],[$4],[auto yes no]) ; do
51 if test "$withval" = "$ol_val" ; then
55 if test "$ol_arg" = "invalid" ; then
56 AC_MSG_ERROR(bad value $withval for --with-$1)
60 [ ol_with_$1=m4_ifval([$3],["$3"],["auto"])])dnl
64 dnl ====================================================================
65 dnl check if hard links are supported.
67 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
68 AC_MSG_CHECKING(whether ln works)
69 AC_CACHE_VAL(ol_cv_prog_LN_H,
70 [rm -f conftest.src conftest.dst
71 echo "conftest" > conftest.src
72 if ln conftest.src conftest.dst 2>/dev/null
78 rm -f conftest.src conftest.dst
80 LN_H="$ol_cv_prog_LN_H"
81 if test "$ol_cv_prog_LN_H" = "ln"; then
89 dnl ====================================================================
90 dnl Check for dependency generation flag
91 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
94 if test -z "${MKDEP}"; then
96 if test -z "${MKDEP_FLAGS}"; then
97 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
99 for flag in "-M" "-xM"; do
100 cat > conftest.c <<EOF
103 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
104 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
106 if test ! -f conftest."${ac_object}" ; then
108 OL_MKDEP_FLAGS="$flag"
117 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
122 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
125 AC_SUBST(OL_MKDEP_FLAGS)
128 dnl ====================================================================
129 dnl Check if system uses EBCDIC instead of ASCII
130 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
131 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
134 #include <__ASCII__/generate_error.h>
137 [ol_cv_cpp_ebcdic=yes],
138 [ol_cv_cpp_ebcdic=no])])
139 if test $ol_cv_cpp_ebcdic = yes ; then
140 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
144 dnl --------------------------------------------------------------------
145 dnl OpenLDAP version of STDC header check w/ EBCDIC support
146 AC_DEFUN(OL_HEADER_STDC,
148 AC_REQUIRE([OL_CPP_EBCDIC])dnl
149 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
150 [AC_TRY_CPP([#include <stdlib.h>
153 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
155 if test $ol_cv_header_stdc = yes; then
156 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
157 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
160 if test $ol_cv_header_stdc = yes; then
161 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
162 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
165 if test $ol_cv_header_stdc = yes; then
166 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
167 AC_TRY_RUN([#include <ctype.h>
169 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
170 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
172 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
173 || ('j' <= (c) && (c) <= 'r') \
174 || ('s' <= (c) && (c) <= 'z'))
175 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
177 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
178 int main () { int i; for (i = 0; i < 256; i++)
179 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
181 ], , ol_cv_header_stdc=no, :)
183 if test $ol_cv_header_stdc = yes; then
184 AC_DEFINE(STDC_HEADERS)
186 ac_cv_header_stdc=disable
189 dnl ====================================================================
190 dnl Check if struct passwd has pw_gecos
191 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
192 AC_CHECK_MEMBER(struct passwd.pw_gecos,,,[#include <pwd.h>])
193 if test $ac_cv_member_struct_passwd_pw_gecos = "yes" ; then
194 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
197 dnl --------------------------------------------------------------------
198 dnl Check if struct passwd has pw_passwd
199 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
200 AC_CHECK_MEMBER(struct passwd.pw_passwd,,,[#include <pwd.h>])
201 if test $ac_cv_member_struct_passwd_pw_passwd = "yes" ; then
202 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
205 dnl ====================================================================
206 dnl Berkeley DB macros
208 dnl --------------------------------------------------------------------
210 AC_DEFUN([OL_BERKELEY_DB_TRY],
211 [if test $ol_cv_lib_db = no ; then
212 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
214 ol_DB_LIB=ifelse($2,,,$2)
216 LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
225 #ifndef DB_VERSION_MAJOR
226 # define DB_VERSION_MAJOR 1
230 #define NULL ((void*)0)
233 #if DB_VERSION_MAJOR > 1
236 int major, minor, patch;
238 version = db_version( &major, &minor, &patch );
240 if( major != DB_VERSION_MAJOR ||
241 minor < DB_VERSION_MINOR )
243 printf("Berkeley DB version mismatch\n"
244 "\texpected: %s\n\tgot: %s\n",
245 DB_VERSION_STRING, version);
251 #if DB_VERSION_MAJOR > 2
252 db_env_create( NULL, 0 );
253 #elif DB_VERSION_MAJOR > 1
256 (void) dbopen( NULL, 0, 0, 0, NULL);
263 if test $$1 = yes ; then
264 ol_cv_lib_db=ifelse($2,,yes,$2)
269 dnl --------------------------------------------------------------------
270 dnl Try to locate appropriate library
271 AC_DEFUN([OL_BERKELEY_DB_LINK],
273 OL_BERKELEY_DB_TRY(ol_cv_db_none)
274 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
275 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
276 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
277 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
278 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
279 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
280 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
281 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
282 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
283 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
284 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
285 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
286 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
289 dnl --------------------------------------------------------------------
290 dnl Check if Berkeley DB supports DB_THREAD
291 AC_DEFUN([OL_BERKELEY_DB_THREAD],
292 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
294 LIBS="$LTHREAD_LIBS $LIBS"
295 if test $ol_cv_lib_db != yes ; then
296 LIBS="$ol_cv_lib_db $LIBS"
306 #define NULL ((void *)0)
311 u_int32_t flags = DB_CREATE |
317 #if DB_VERSION_MAJOR > 2
320 rc = db_env_create( &env, 0 );
322 flags |= DB_INIT_MPOOL;
323 #ifdef DB_MPOOL_PRIVATE
324 flags |= DB_MPOOL_PRIVATE;
328 printf("BerkeleyDB: %s\n", db_strerror(rc) );
332 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
333 rc = env->open( env, NULL, flags, 0 );
335 rc = env->open( env, NULL, NULL, flags, 0 );
339 rc = env->close( env, 0 );
343 printf("BerkeleyDB: %s\n", db_strerror(rc) );
349 memset( &env, '\0', sizeof(env) );
351 rc = db_appinit( NULL, NULL, &env, flags );
357 unlink("__db_mpool.share");
358 unlink("__db_lock.share");
363 [ol_cv_berkeley_db_thread=yes],
364 [ol_cv_berkeley_db_thread=no],
365 [ol_cv_berkeley_db_thread=cross])
370 if test $ol_cv_berkeley_db_thread != no ; then
371 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
372 [define if Berkeley DB has DB_THREAD support])
376 dnl --------------------------------------------------------------------
378 AC_DEFUN([OL_BERKELEY_DB],
379 [ol_cv_berkeley_db=no
380 AC_CHECK_HEADERS(db.h)
381 if test $ac_cv_header_db_h = yes; then
383 if test "$ol_cv_lib_db" != no ; then
384 ol_cv_berkeley_db=yes
385 OL_BERKELEY_DB_THREAD
389 dnl --------------------------------------------------------------------
390 dnl Check for version compatility with back-bdb
391 AC_DEFUN([OL_BDB_COMPAT],
392 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
393 AC_EGREP_CPP(__db_version_compat,[
396 /* this check could be improved */
397 #ifndef DB_VERSION_MAJOR
398 # define DB_VERSION_MAJOR 1
400 #ifndef DB_VERSION_MINOR
401 # define DB_VERSION_MINOR 0
404 /* require 4.1 or later */
405 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 1)
408 ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
411 dnl --------------------------------------------------------------------
412 dnl Find old Berkeley DB 1.85/1.86
413 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
414 [AC_CHECK_HEADERS(db_185.h db.h)
415 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
416 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
417 AC_EGREP_CPP(__db_version_1,[
424 /* this check could be improved */
425 #ifndef DB_VERSION_MAJOR
426 # define DB_VERSION_MAJOR 1
429 #if DB_VERSION_MAJOR == 1
432 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
434 if test $ol_cv_header_db1 = yes ; then
436 if test "$ol_cv_lib_db" != no ; then
437 ol_cv_berkeley_db=yes
443 dnl ====================================================================
444 dnl Check if GDBM library exists
445 dnl Check for gdbm_open in standard libraries or -lgdbm
447 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
448 dnl 'yes' implies gdbm_open is in $LIBS
451 dnl AC_CHECK_FUNC(gdbm_open)
452 dnl AC_CHECK_LIB(gdbm,gdbm_open)
454 AC_DEFUN([OL_LIB_GDBM],
455 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
457 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
458 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
464 dnl --------------------------------------------------------------------
465 dnl Check if GDBM exists
467 dnl defines ol_cv_gdbm to 'yes' or 'no'
471 dnl AC_CHECK_HEADERS(gdbm.h)
474 [AC_REQUIRE([OL_LIB_GDBM])
475 AC_CHECK_HEADERS(gdbm.h)
476 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
477 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
483 if test $ol_cv_gdbm = yes ; then
484 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
488 dnl ====================================================================
489 dnl Check if MDBM library exists
490 dnl Check for mdbm_open in standard libraries or -lmdbm
492 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
493 dnl 'yes' implies mdbm_open is in $LIBS
496 dnl AC_CHECK_FUNC(mdbm_set_chain)
497 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
499 AC_DEFUN([OL_LIB_MDBM],
500 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
502 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
503 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
509 dnl --------------------------------------------------------------------
510 dnl Check if MDBM exists
512 dnl defines ol_cv_mdbm to 'yes' or 'no'
516 dnl AC_CHECK_HEADERS(mdbm.h)
519 [AC_REQUIRE([OL_LIB_MDBM])
520 AC_CHECK_HEADERS(mdbm.h)
521 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
522 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
528 if test $ol_cv_mdbm = yes ; then
529 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
533 dnl ====================================================================
534 dnl Check if NDBM library exists
535 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
537 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
538 dnl 'yes' implies ndbm_open is in $LIBS
541 dnl AC_CHECK_FUNC(dbm_open)
542 dnl AC_CHECK_LIB(ndbm,dbm_open)
543 dnl AC_CHECK_LIB(dbm,dbm_open)
546 dnl should also check SVR4 case: dbm_open() in -lucb but that
547 dnl would requiring dealing with -L/usr/ucblib
549 AC_DEFUN([OL_LIB_NDBM],
550 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
552 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
553 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
554 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
555 [ol_cv_lib_ndbm=no])dnl
562 dnl --------------------------------------------------------------------
563 dnl Check if NDBM exists
565 dnl defines ol_cv_ndbm to 'yes' or 'no'
569 dnl AC_CHECK_HEADERS(ndbm.h)
572 dnl Doesn't handle SVR4 case (see above)
575 [AC_REQUIRE([OL_LIB_NDBM])
576 AC_CHECK_HEADERS(ndbm.h)
577 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
578 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
584 if test $ol_cv_ndbm = yes ; then
585 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
589 dnl ====================================================================
590 dnl Check POSIX Thread version
592 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
593 dnl version of the POSIX.4a Draft that is implemented.
594 dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
595 dnl Existence of pthread.h should be tested separately.
598 dnl pthread_detach() was dropped in Draft 8, it is present
599 dnl in every other version
600 dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
601 dnl PTHREAD_CREATE_JOINABLE after that
602 dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
603 dnl Draft 6-10 has _init, Draft 4-5 has _create.
604 dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
605 dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
606 dnl interesting to us because we don't try to statically
607 dnl initialize mutexes. 5-10 has it.
609 dnl Draft 9 and 10 are equivalent for our purposes.
611 AC_DEFUN([OL_POSIX_THREAD_VERSION],
612 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
614 # include <pthread.h>
616 int i = PTHREAD_CREATE_JOINABLE;
618 AC_EGREP_HEADER(pthread_detach,pthread.h,
619 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
620 AC_EGREP_CPP(draft7,[
621 # include <pthread.h>
622 # ifdef PTHREAD_CREATE_UNDETACHED
625 ], ol_cv_pthread_version=7, [
626 AC_EGREP_HEADER(pthread_attr_init,pthread.h,
627 ol_cv_pthread_version=6, [
628 AC_EGREP_CPP(draft5,[
629 # include <pthread.h>
630 #ifdef PTHREAD_MUTEX_INITIALIZER
633 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
637 dnl --------------------------------------------------------------------
638 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
639 [/* pthread test headers */
641 #if HAVE_PTHREADS < 7
645 #define NULL (void*)0
651 return (void *) (p == NULL);
654 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
655 /* pthread test function */
656 #ifndef PTHREAD_CREATE_DETACHED
657 #define PTHREAD_CREATE_DETACHED 1
661 int detach = PTHREAD_CREATE_DETACHED;
663 #if HAVE_PTHREADS > 4
667 status = pthread_attr_init(&attr);
668 if( status ) return status;
670 #if HAVE_PTHREADS < 7
671 status = pthread_attr_setdetachstate(&attr, &detach);
672 if( status < 0 ) status = errno;
674 status = pthread_attr_setdetachstate(&attr, detach);
676 if( status ) return status;
677 status = pthread_create( &t, &attr, task, NULL );
678 #if HAVE_PTHREADS < 7
679 if( status < 0 ) status = errno;
681 if( status ) return status;
683 /* Draft 4 pthreads */
684 status = pthread_create( &t, pthread_attr_default, task, NULL );
685 if( status ) return errno;
687 /* give thread a chance to complete */
688 /* it should remain joinable and hence detachable */
691 status = pthread_detach( &t );
692 if( status ) return errno;
695 #ifdef HAVE_LINUX_THREADS
696 pthread_kill_other_threads_np();
702 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
703 [OL_PTHREAD_TEST_INCLUDES
709 OL_PTHREAD_TEST_FUNCTION
712 dnl --------------------------------------------------------------------
713 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
714 if test "$ol_link_threads" = no ; then
716 AC_CACHE_CHECK([for pthread link with $1], [$2], [
721 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
723 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
730 if test $$2 = yes ; then
731 ol_link_pthreads="$1"
732 ol_link_threads=posix
737 dnl ====================================================================
738 dnl Check GNU Pth pthread Header
740 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
741 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
742 dnl doesn't exists. Existance of pthread.h should separately
745 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
746 AC_CACHE_CHECK([for GNU Pth pthread.h],
747 [ol_cv_header_gnu_pth_pthread_h],
748 [AC_EGREP_CPP(__gnu_pth__,
749 [#include <pthread.h>
750 #ifdef _POSIX_THREAD_IS_GNU_PTH
754 [ol_cv_header_gnu_pth_pthread_h=yes],
755 [ol_cv_header_gnu_pth_pthread_h=no])
758 dnl ====================================================================
759 dnl Check for NT Threads
760 AC_DEFUN([OL_NT_THREADS], [
761 AC_CHECK_FUNC(_beginthread)
763 if test $ac_cv_func__beginthread = yes ; then
764 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
768 dnl ====================================================================
769 dnl Check LinuxThreads Header
771 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
772 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
773 dnl doesn't exists. Existance of pthread.h should separately
776 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
777 AC_CACHE_CHECK([for LinuxThreads pthread.h],
778 [ol_cv_header_linux_threads],
779 [AC_EGREP_CPP(pthread_kill_other_threads_np,
780 [#include <pthread.h>],
781 [ol_cv_header_linux_threads=yes],
782 [ol_cv_header_linux_threads=no])
784 if test $ol_cv_header_linux_threads = yes; then
785 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
788 dnl --------------------------------------------------------------------
789 dnl Check LinuxThreads Implementation
791 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
792 dnl 'no' implies pthreads implementation is not LinuxThreads.
794 AC_DEFUN([OL_SYS_LINUX_THREADS], [
795 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
796 AC_CACHE_CHECK([for LinuxThreads implementation],
797 [ol_cv_sys_linux_threads],
798 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
801 dnl --------------------------------------------------------------------
802 dnl Check LinuxThreads consistency
803 AC_DEFUN([OL_LINUX_THREADS], [
804 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
805 AC_REQUIRE([OL_SYS_LINUX_THREADS])
806 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
807 if test $ol_cv_header_linux_threads = yes -a \
808 $ol_cv_sys_linux_threads = yes; then
809 ol_cv_linux_threads=yes
810 elif test $ol_cv_header_linux_threads = no -a \
811 $ol_cv_sys_linux_threads = no; then
812 ol_cv_linux_threads=no
814 ol_cv_linux_threads=error
819 dnl ====================================================================
820 dnl Check for POSIX Regex
821 AC_DEFUN([OL_POSIX_REGEX], [
822 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
824 #include <sys/types.h>
826 static char *pattern, *string;
834 if(regcomp(&re, pattern, 0)) {
838 string = "ALL MATCH";
840 rc = regexec(&re, string, 0, (void*)0, 0);
846 [ol_cv_c_posix_regex=yes],
847 [ol_cv_c_posix_regex=no],
848 [ol_cv_c_posix_regex=cross])])
851 dnl ====================================================================
852 dnl Check if toupper() requires islower() to be called first
853 AC_DEFUN([OL_C_UPPER_LOWER],
854 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
859 if ('C' == toupper('C'))
864 [ol_cv_c_upper_lower=no],
865 [ol_cv_c_upper_lower=yes],
866 [ol_cv_c_upper_lower=safe])])
867 if test $ol_cv_c_upper_lower != no ; then
868 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
872 dnl ====================================================================
873 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
874 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
875 dnl Reported by Keith Bostic.
876 AC_DEFUN([OL_SYS_ERRLIST],
877 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
880 #include <sys/types.h>
885 [char *c = (char *) *sys_errlist],
886 [ol_cv_dcl_sys_errlist=yes
887 ol_cv_have_sys_errlist=yes],
888 [ol_cv_dcl_sys_errlist=no])])
890 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
891 if test $ol_cv_dcl_sys_errlist = no ; then
892 AC_DEFINE(DECL_SYS_ERRLIST,1,
893 [define if sys_errlist is not declared in stdio.h or errno.h])
895 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
896 AC_TRY_LINK([#include <errno.h>],
897 [char *c = (char *) *sys_errlist],
898 [ol_cv_have_sys_errlist=yes],
899 [ol_cv_have_sys_errlist=no])])
901 if test $ol_cv_have_sys_errlist = yes ; then
902 AC_DEFINE(HAVE_SYS_ERRLIST,1,
903 [define if you actually have sys_errlist in your libs])
907 dnl ====================================================================
908 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
909 dnl "int x; int *volatile a = &x; *a = 0;"
910 dnl -- borrowed from PDKSH
911 AC_DEFUN(OL_C_VOLATILE,
912 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
913 [AC_TRY_COMPILE([int x, y, z;],
914 [volatile int a; int * volatile b = x ? &y : &z;
915 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
916 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
917 if test $ol_cv_c_volatile = yes; then
920 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
924 dnl ====================================================================
925 dnl Look for fetch(3)
926 AC_DEFUN([OL_LIB_FETCH],
928 LIBS="-lfetch -lcom_err $LIBS"
929 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
931 #include <sys/param.h>
934 [struct url *u = fetchParseURL("file:///"); ],
935 [ol_cv_lib_fetch=yes],
936 [ol_cv_lib_fetch=no])])
938 if test $ol_cv_lib_fetch != no ; then
939 ol_link_fetch="-lfetch -lcom_err"
940 AC_DEFINE(HAVE_FETCH,1,
941 [define if you actually have FreeBSD fetch(3)])
945 dnl ====================================================================
946 dnl Define sig_atomic_t if not defined in signal.h
947 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
948 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
949 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
950 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
951 if test $ol_cv_type_sig_atomic_t = no; then
952 AC_DEFINE(sig_atomic_t,int,
953 [define to atomic type if sig_atomic_t is not available])
957 dnl ====================================================================
958 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
959 AC_DEFUN(OL_TYPE_SOCKLEN_T,
960 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
962 #ifdef HAVE_SYS_TYPES_H
963 #include <sys/types.h>
965 #ifdef HAVE_SYS_SOCKET_H
966 #include <sys/socket.h>
969 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
970 if test $ol_cv_type_socklen_t = no; then
971 AC_DEFINE(socklen_t, int,
972 [define to int if socklen_t is not available])
976 dnl ====================================================================
977 dnl Define inet_aton is available
978 AC_DEFUN(OL_FUNC_INET_ATON,
979 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
981 #ifdef HAVE_SYS_TYPES_H
982 # include <sys/types.h>
984 #ifdef HAVE_SYS_SOCKET_H
985 # include <sys/socket.h>
986 # ifdef HAVE_SYS_SELECT_H
987 # include <sys/select.h>
989 # include <netinet/in.h>
990 # ifdef HAVE_ARPA_INET_H
991 # include <arpa/inet.h>
994 ], [struct in_addr in;
995 int rc = inet_aton( "255.255.255.255", &in );],
996 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
997 if test $ol_cv_func_inet_aton != no; then
998 AC_DEFINE(HAVE_INET_ATON, 1,
999 [define to you inet_aton(3) is available])
1003 dnl ====================================================================
1004 dnl check no of arguments for ctime_r
1005 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1006 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1007 [AC_TRY_COMPILE([#include <time.h>],
1008 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1009 ol_cv_func_ctime_r_nargs3=yes,
1010 ol_cv_func_ctime_r_nargs3=no)
1012 AC_TRY_COMPILE([#include <time.h>],
1013 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1014 ol_cv_func_ctime_r_nargs2=yes,
1015 ol_cv_func_ctime_r_nargs2=no)
1017 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1018 $ol_cv_func_ctime_r_nargs2 = no ; then
1020 ol_cv_func_ctime_r_nargs=3
1022 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1023 $ol_cv_func_ctime_r_nargs2 = yes ; then
1025 ol_cv_func_ctime_r_nargs=2
1028 ol_cv_func_ctime_r_nargs=0
1032 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1033 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1034 [set to the number of arguments ctime_r() expects])
1038 dnl --------------------------------------------------------------------
1039 dnl check return type of ctime_r()
1040 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1041 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1042 [AC_TRY_COMPILE([#include <time.h>],
1043 [extern int (ctime_r)();],
1044 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1046 if test $ol_cv_func_ctime_r_type = "int" ; then
1047 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1050 dnl ====================================================================
1051 dnl check no of arguments for gethostbyname_r
1052 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1053 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1054 ol_cv_func_gethostbyname_r_nargs,
1055 [AC_TRY_COMPILE([#include <sys/types.h>
1056 #include <sys/socket.h>
1057 #include <netinet/in.h>
1059 #define BUFSIZE (sizeof(struct hostent)+10)],
1060 [struct hostent hent; char buffer[BUFSIZE];
1061 int bufsize=BUFSIZE;int h_errno;
1062 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1063 buffer, bufsize, &h_errno);],
1064 ol_cv_func_gethostbyname_r_nargs5=yes,
1065 ol_cv_func_gethostbyname_r_nargs5=no)
1067 AC_TRY_COMPILE([#include <sys/types.h>
1068 #include <sys/socket.h>
1069 #include <netinet/in.h>
1071 #define BUFSIZE (sizeof(struct hostent)+10)],
1072 [struct hostent hent;struct hostent *rhent;
1073 char buffer[BUFSIZE];
1074 int bufsize=BUFSIZE;int h_errno;
1075 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1076 &rhent, &h_errno);],
1077 ol_cv_func_gethostbyname_r_nargs6=yes,
1078 ol_cv_func_gethostbyname_r_nargs6=no)
1080 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1081 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1083 ol_cv_func_gethostbyname_r_nargs=5
1085 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1086 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1088 ol_cv_func_gethostbyname_r_nargs=6
1091 ol_cv_func_gethostbyname_r_nargs=0
1094 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1095 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1096 $ol_cv_func_gethostbyname_r_nargs,
1097 [set to the number of arguments gethostbyname_r() expects])
1101 dnl check no of arguments for gethostbyaddr_r
1102 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1103 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1104 [ol_cv_func_gethostbyaddr_r_nargs],
1105 [AC_TRY_COMPILE([#include <sys/types.h>
1106 #include <sys/socket.h>
1107 #include <netinet/in.h>
1109 #define BUFSIZE (sizeof(struct hostent)+10)],
1110 [struct hostent hent; char buffer[BUFSIZE];
1112 size_t alen=sizeof(struct in_addr);
1113 int bufsize=BUFSIZE;int h_errno;
1114 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1115 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1116 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1117 ol_cv_func_gethostbyaddr_r_nargs7=no)
1119 AC_TRY_COMPILE([#include <sys/types.h>
1120 #include <sys/socket.h>
1121 #include <netinet/in.h>
1123 #define BUFSIZE (sizeof(struct hostent)+10)],
1124 [struct hostent hent;
1125 struct hostent *rhent; char buffer[BUFSIZE];
1127 size_t alen=sizeof(struct in_addr);
1128 int bufsize=BUFSIZE;int h_errno;
1129 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1130 alen, AF_INET, &hent, buffer, bufsize,
1131 &rhent, &h_errno);],
1132 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1133 ol_cv_func_gethostbyaddr_r_nargs8=no)
1135 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1136 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1138 ol_cv_func_gethostbyaddr_r_nargs=7
1140 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1141 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1143 ol_cv_func_gethostbyaddr_r_nargs=8
1146 ol_cv_func_gethostbyaddr_r_nargs=0
1149 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1150 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1151 $ol_cv_func_gethostbyaddr_r_nargs,
1152 [set to the number of arguments gethostbyaddr_r() expects])
1156 dnl --------------------------------------------------------------------
1157 dnl Check for Cyrus SASL version compatility, need 2.1.3 or newer
1158 AC_DEFUN([OL_SASL_COMPAT],
1159 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1160 AC_EGREP_CPP(__sasl_compat,[
1161 #ifdef HAVE_SASL_SASL_H
1162 #include <sasl/sasl.h>
1167 /* require 2.1.3 or later */
1168 #if SASL_VERSION_MAJOR == 1 && SASL_VERSION_MINOR >= 5
1169 char *__sasl_compat = "1.5.x okay";
1170 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1
1171 __sasl_compat "2.2+ or better okay (we guess)";
1172 #elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \
1173 && SASL_VERSION_STEP >=3
1174 __sasl_compat = "2.1.3+ or better okay";
1176 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1178 dnl ====================================================================
1179 dnl check for msg_accrights in msghdr
1180 AC_DEFUN(OL_MSGHDR_MSG_ACCRIGHTS,
1181 [AC_CHECK_MEMBER(struct msghdr.msg_accrights,,,[#include <sys/socket.h>])
1182 if test $ac_cv_member_struct_msghdr_msg_accrights = "yes" ; then
1183 AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1,
1184 [define if struct msghdr has msg_accrights])