3 dnl Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
6 dnl OpenLDAP Autoconf Macros
8 dnl --------------------------------------------------------------------
9 dnl Restricted form of AC_ARG_ENABLE that limits user options
13 dnl $3 = default value (auto)
14 dnl $4 = allowed values (auto yes no)
15 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
16 AC_ARG_ENABLE($1,changequote(<,>)<$2 [>ifelse($3,,auto,$3)<]>changequote([,]),[
18 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
19 if test "$enableval" = "$ol_val" ; then
23 if test "$ol_arg" = "invalid" ; then
24 AC_MSG_ERROR(bad value $enableval for --enable-$1)
26 ol_enable_$1="$ol_arg"
28 [ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
29 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
33 dnl --------------------------------------------------------------------
34 dnl Restricted form of AC_ARG_WITH that limits user options
38 dnl $3 = default value (no)
39 dnl $4 = allowed values (yes or no)
40 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
41 AC_ARG_WITH($1,changequote(<,>)<$2 [>ifelse($3,,yes,$3)<]>changequote([,]),[
43 for ol_val in ifelse($4,,[yes no],[$4]) ; do
44 if test "$withval" = "$ol_val" ; then
48 if test "$ol_arg" = "invalid" ; then
49 AC_MSG_ERROR(bad value $withval for --with-$1)
53 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
54 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
58 dnl ====================================================================
60 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
61 [changequote(<<, >>)dnl
62 dnl The name to #define.
63 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
64 dnl The cache variable name.
65 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
67 AC_MSG_CHECKING(size of $1)
68 AC_CACHE_VAL(AC_CV_NAME,
69 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
70 AC_TRY_COMPILE([#include "confdefs.h"
71 #include <sys/types.h>
73 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
74 if test x$AC_CV_NAME != x ; then break; fi
77 if test x$AC_CV_NAME = x ; then
78 AC_MSG_ERROR([cannot determine a size for $1])
80 AC_MSG_RESULT($AC_CV_NAME)
81 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
82 undefine([AC_TYPE_NAME])dnl
83 undefine([AC_CV_NAME])dnl
85 dnl ====================================================================
86 dnl check if hard links are supported.
88 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
89 AC_MSG_CHECKING(whether ln works)
90 AC_CACHE_VAL(ol_cv_prog_LN_H,
91 [rm -f conftest.src conftest.dst
92 echo "conftest" > conftest.src
93 if ln conftest.src conftest.dst 2>/dev/null
99 rm -f conftest.src conftest.dst
101 LN_H="$ol_cv_prog_LN_H"
102 if test "$ol_cv_prog_LN_H" = "ln"; then
110 dnl ====================================================================
111 dnl Check for dependency generation flag
112 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
115 if test -z "${MKDEP}"; then
117 if test -z "${MKDEP_FLAGS}"; then
118 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
120 for flag in "-M" "-xM"; do
121 cat > conftest.c <<EOF
124 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
125 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
127 if test ! -f conftest."${ac_object}" ; then
129 OL_MKDEP_FLAGS="$flag"
138 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
143 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
146 AC_SUBST(OL_MKDEP_FLAGS)
149 dnl ====================================================================
150 dnl Check if system uses EBCDIC instead of ASCII
151 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
152 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
155 #include <__ASCII__/generate_error.h>
158 [ol_cv_cpp_ebcdic=yes],
159 [ol_cv_cpp_ebcdic=no])])
160 if test $ol_cv_cpp_ebcdic = yes ; then
161 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
165 dnl --------------------------------------------------------------------
166 dnl OpenLDAP version of STDC header check w/ EBCDIC support
167 AC_DEFUN(OL_HEADER_STDC,
169 AC_REQUIRE([OL_CPP_EBCDIC])dnl
170 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
171 [AC_TRY_CPP([#include <stdlib.h>
174 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
176 if test $ol_cv_header_stdc = yes; then
177 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
178 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
181 if test $ol_cv_header_stdc = yes; then
182 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
183 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
186 if test $ol_cv_header_stdc = yes; then
187 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
188 AC_TRY_RUN([#include <ctype.h>
190 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
191 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
193 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
194 || ('j' <= (c) && (c) <= 'r') \
195 || ('s' <= (c) && (c) <= 'z'))
196 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
198 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
199 int main () { int i; for (i = 0; i < 256; i++)
200 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
202 ], , ol_cv_header_stdc=no, :)
204 if test $ol_cv_header_stdc = yes; then
205 AC_DEFINE(STDC_HEADERS)
207 ac_cv_header_stdc=disable
210 dnl ====================================================================
211 dnl Check if struct passwd has pw_gecos
212 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
213 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
214 AC_TRY_COMPILE([#include <pwd.h>],[
216 pwd.pw_gecos = pwd.pw_name;
218 [ol_cv_struct_passwd_pw_gecos=yes],
219 [ol_cv_struct_passwd_pw_gecos=no])])
220 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
221 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
225 dnl --------------------------------------------------------------------
226 dnl Check if struct passwd has pw_passwd
227 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
228 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
229 AC_TRY_COMPILE([#include <pwd.h>],[
231 pwd.pw_passwd = pwd.pw_name;
233 [ol_cv_struct_passwd_pw_passwd=yes],
234 [ol_cv_struct_passwd_pw_passwd=no])])
235 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
236 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
240 dnl ====================================================================
241 dnl Berkeley DB macros
243 dnl --------------------------------------------------------------------
245 AC_DEFUN([OL_BERKELEY_DB_TRY],
246 [if test $ol_cv_lib_db = no ; then
247 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
249 ol_DB_LIB=ifelse($2,,,$2)
251 LIBS="$ol_DB_LIB $LIBS"
260 #ifndef DB_VERSION_MAJOR
261 # define DB_VERSION_MAJOR 1
265 #define NULL ((void*)0)
268 #if DB_VERSION_MAJOR > 1
271 int major, minor, patch;
273 version = db_version( &major, &minor, &patch );
275 if( major != DB_VERSION_MAJOR ||
276 minor < DB_VERSION_MINOR )
278 printf("Berkeley DB version mismatch\n"
279 "\texpected: %s\n\tgot: %s\n",
280 DB_VERSION_STRING, version);
286 #if DB_VERSION_MAJOR > 2
287 db_env_create( NULL, 0 );
288 #elif DB_VERSION_MAJOR > 1
291 (void) dbopen( NULL, 0, 0, 0, NULL);
298 if test $$1 = yes ; then
299 ol_cv_lib_db=ifelse($2,,yes,$2)
304 dnl --------------------------------------------------------------------
305 dnl Try to locate appropriate library
306 AC_DEFUN([OL_BERKELEY_DB_LINK],
308 OL_BERKELEY_DB_TRY(ol_cv_db_none)
309 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
310 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
311 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
312 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
315 dnl --------------------------------------------------------------------
316 dnl Check if Berkeley DB supports DB_THREAD
317 AC_DEFUN([OL_BERKELEY_DB_THREAD],
318 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
320 if test $ol_cv_lib_db != yes ; then
331 #define NULL ((void *)0)
336 u_int32_t flags = DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL |
340 #ifdef DB_MPOOL_PRIVATE
345 #if DB_VERSION_MAJOR > 2
348 rc = db_env_create( &env, 0 );
351 printf("BerkeleyDB: %s\n", db_strerror(rc) );
356 rc = env->set_flags( env, DB_CDB_ALLDB, 1 );
360 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
361 rc = env->open( env, NULL, flags, 0 );
363 rc = env->open( env, NULL, NULL, flags, 0 );
369 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
370 env->remove( env, NULL, DB_FORCE);
372 env->remove( env, NULL, NULL, DB_FORCE);
377 memset( &env, '\0', sizeof(env) );
379 rc = db_appinit( NULL, NULL, &env, flags );
385 unlink("__db_mpool.share");
386 unlink("__db_lock.share");
391 [ol_cv_berkeley_db_thread=yes],
392 [ol_cv_berkeley_db_thread=no],
393 [ol_cv_berkeley_db_thread=cross])
397 if test $ol_cv_berkeley_db_thread != no ; then
398 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
399 [define if Berkeley DB has DB_THREAD support])
403 dnl --------------------------------------------------------------------
405 AC_DEFUN([OL_BERKELEY_DB],
406 [ol_cv_berkeley_db=no
407 AC_CHECK_HEADERS(db.h)
408 if test $ac_cv_header_db_h = yes; then
410 if test "$ol_cv_lib_db" != no ; then
411 ol_cv_berkeley_db=yes
412 OL_BERKELEY_DB_THREAD
417 dnl --------------------------------------------------------------------
418 dnl Find old Berkeley DB 1.85/1.86
419 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
420 [ol_cv_berkeley_db=no
421 AC_CHECK_HEADERS(db_185.h db.h)
422 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
423 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
424 AC_EGREP_CPP(__db_version_1,[
431 /* this check could be improved */
432 #ifndef DB_VERSION_MAJOR
433 # define DB_VERSION_MAJOR 1
436 #if DB_VERSION_MAJOR == 1
439 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
441 if test ol_cv_header_db1=yes ; then
443 if test "$ol_cv_lib_db" != no ; then
444 ol_cv_berkeley_db=yes
450 dnl ====================================================================
451 dnl Check if GDBM library exists
452 dnl Check for gdbm_open in standard libraries or -lgdbm
454 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
455 dnl 'yes' implies gdbm_open is in $LIBS
458 dnl AC_CHECK_FUNC(gdbm_open)
459 dnl AC_CHECK_LIB(gdbm,gdbm_open)
461 AC_DEFUN([OL_LIB_GDBM],
462 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
464 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
465 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
471 dnl --------------------------------------------------------------------
472 dnl Check if GDBM exists
474 dnl defines ol_cv_gdbm to 'yes' or 'no'
478 dnl AC_CHECK_HEADERS(gdbm.h)
481 [AC_REQUIRE([OL_LIB_GDBM])
482 AC_CHECK_HEADERS(gdbm.h)
483 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
484 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
490 if test $ol_cv_gdbm = yes ; then
491 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
495 dnl ====================================================================
496 dnl Check if MDBM library exists
497 dnl Check for mdbm_open in standard libraries or -lmdbm
499 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
500 dnl 'yes' implies mdbm_open is in $LIBS
503 dnl AC_CHECK_FUNC(mdbm_set_chain)
504 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
506 AC_DEFUN([OL_LIB_MDBM],
507 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
509 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
510 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
516 dnl --------------------------------------------------------------------
517 dnl Check if MDBM exists
519 dnl defines ol_cv_mdbm to 'yes' or 'no'
523 dnl AC_CHECK_HEADERS(mdbm.h)
526 [AC_REQUIRE([OL_LIB_MDBM])
527 AC_CHECK_HEADERS(mdbm.h)
528 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
529 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
535 if test $ol_cv_mdbm = yes ; then
536 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
540 dnl ====================================================================
541 dnl Check if NDBM library exists
542 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
544 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
545 dnl 'yes' implies ndbm_open is in $LIBS
548 dnl AC_CHECK_FUNC(dbm_open)
549 dnl AC_CHECK_LIB(ndbm,dbm_open)
550 dnl AC_CHECK_LIB(dbm,dbm_open)
553 dnl should also check SVR4 case: dbm_open() in -lucb but that
554 dnl would requiring dealing with -L/usr/ucblib
556 AC_DEFUN([OL_LIB_NDBM],
557 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
559 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
560 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
561 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
562 [ol_cv_lib_ndbm=no])dnl
569 dnl --------------------------------------------------------------------
570 dnl Check if NDBM exists
572 dnl defines ol_cv_ndbm to 'yes' or 'no'
576 dnl AC_CHECK_HEADERS(ndbm.h)
579 dnl Doesn't handle SVR4 case (see above)
582 [AC_REQUIRE([OL_LIB_NDBM])
583 AC_CHECK_HEADERS(ndbm.h)
584 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
585 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
591 if test $ol_cv_ndbm = yes ; then
592 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
596 dnl ====================================================================
597 dnl Check POSIX Thread version
599 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
600 dnl 'unknown' implies that the version could not be detected
601 dnl or that pthreads.h does exist. Existance of pthreads.h
602 dnl should be tested separately.
604 AC_DEFUN([OL_POSIX_THREAD_VERSION],
605 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
606 AC_EGREP_CPP(pthread_version_final,[
607 # include <pthread.h>
608 /* this check could be improved */
609 # ifdef PTHREAD_ONCE_INIT
610 pthread_version_final;
612 ], ol_pthread_final=yes, ol_pthread_final=no)
614 AC_EGREP_CPP(pthread_version_draft4,[
615 # include <pthread.h>
616 /* this check could be improved */
617 # ifdef pthread_once_init
618 pthread_version_draft4;
620 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
622 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
623 ol_cv_pthread_version=final
624 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
625 ol_cv_pthread_version=draft4
627 ol_cv_pthread_version=unknown
632 dnl --------------------------------------------------------------------
633 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
634 [/* pthread test headers */
637 #define NULL (void*)0
643 return (void *) (p == NULL);
646 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
647 /* pthread test function */
650 #if HAVE_PTHREADS_FINAL && defined(PTHREAD_CREATE_UNDETACHED)
651 /* This system (e.g. AIX) defaults detached; must override */
654 status = pthread_attr_init(&attr);
655 if( status ) exit( status );
657 status = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_UNDETACHED);
658 if( status ) exit( status );
661 #elif defined( HAVE_PTHREADS_D4 )
662 # define ATTR pthread_attr_default
667 /* make sure pthread_create() isn't just a stub */
668 status = pthread_create(&t, ATTR, task, NULL);
669 if( status ) exit( status );
671 /* give the thread a chance to complete...
672 * it should remain joinable and hence detachable
676 /* make sure pthread_detach() isn't just a stub */
678 status = pthread_detach( &t );
680 status = pthread_detach( t );
683 #ifdef HAVE_LINUX_THREADS
684 pthread_kill_other_threads_np();
690 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
691 [OL_PTHREAD_TEST_INCLUDES
697 OL_PTHREAD_TEST_FUNCTION
700 dnl --------------------------------------------------------------------
701 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
702 if test "$ol_link_threads" = no ; then
704 AC_CACHE_CHECK([for pthread link with $1], [$2], [
709 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
711 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
718 if test $$2 = yes ; then
719 ol_link_pthreads="$1"
720 ol_link_threads=posix
725 dnl ====================================================================
726 dnl Check GNU Pth pthread Header
728 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
729 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
730 dnl doesn't exists. Existance of pthread.h should separately
733 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
734 AC_CACHE_CHECK([for GNU Pth pthread.h],
735 [ol_cv_header_gnu_pth_pthread_h],
736 [AC_EGREP_CPP(__gnu_pth__,
737 [#include <pthread.h>
738 #ifdef _POSIX_THREAD_IS_GNU_PTH
742 [ol_cv_header_gnu_pth_pthread_h=yes],
743 [ol_cv_header_gnu_pth_pthread_h=no])
746 dnl ====================================================================
747 dnl Check for NT Threads
748 AC_DEFUN([OL_NT_THREADS], [
749 AC_CHECK_FUNC(_beginthread)
751 if test $ac_cv_func__beginthread = yes ; then
752 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
755 dnl ====================================================================
756 dnl Check LinuxThreads Header
758 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
759 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
760 dnl doesn't exists. Existance of pthread.h should separately
763 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
764 AC_CACHE_CHECK([for LinuxThreads pthread.h],
765 [ol_cv_header_linux_threads],
766 [AC_EGREP_CPP(pthread_kill_other_threads_np,
767 [#include <pthread.h>],
768 [ol_cv_header_linux_threads=yes],
769 [ol_cv_header_linux_threads=no])
771 if test $ol_cv_header_linux_threads = yes; then
772 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
775 dnl --------------------------------------------------------------------
776 dnl Check LinuxThreads Implementation
778 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
779 dnl 'no' implies pthreads implementation is not LinuxThreads.
781 AC_DEFUN([OL_SYS_LINUX_THREADS], [
782 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
783 AC_CACHE_CHECK([for LinuxThreads implementation],
784 [ol_cv_sys_linux_threads],
785 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
788 dnl --------------------------------------------------------------------
789 dnl Check LinuxThreads consistency
790 AC_DEFUN([OL_LINUX_THREADS], [
791 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
792 AC_REQUIRE([OL_SYS_LINUX_THREADS])
793 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
794 if test $ol_cv_header_linux_threads = yes -a \
795 $ol_cv_sys_linux_threads = yes; then
796 ol_cv_linux_threads=yes
797 elif test $ol_cv_header_linux_threads = no -a \
798 $ol_cv_sys_linux_threads = no; then
799 ol_cv_linux_threads=no
801 ol_cv_linux_threads=error
806 dnl ====================================================================
807 dnl Check for POSIX Regex
808 AC_DEFUN([OL_POSIX_REGEX], [
809 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
811 #include <sys/types.h>
813 static char *pattern, *string;
821 if(regcomp(&re, pattern, 0)) {
825 string = "ALL MATCH";
827 rc = regexec(&re, string, 0, (void*)0, 0);
833 [ol_cv_c_posix_regex=yes],
834 [ol_cv_c_posix_regex=no],
835 [ol_cv_c_posix_regex=cross])])
838 dnl ====================================================================
839 dnl Check if toupper() requires islower() to be called first
840 AC_DEFUN([OL_C_UPPER_LOWER],
841 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
846 if ('C' == toupper('C'))
851 [ol_cv_c_upper_lower=no],
852 [ol_cv_c_upper_lower=yes],
853 [ol_cv_c_upper_lower=safe])])
854 if test $ol_cv_c_upper_lower != no ; then
855 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
859 dnl ====================================================================
860 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
861 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
862 dnl Reported by Keith Bostic.
863 AC_DEFUN([OL_SYS_ERRLIST],
864 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
867 #include <sys/types.h>
872 [char *c = (char *) *sys_errlist],
873 [ol_cv_dcl_sys_errlist=yes
874 ol_cv_have_sys_errlist=yes],
875 [ol_cv_dcl_sys_errlist=no])])
877 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
878 if test $ol_cv_dcl_sys_errlist = no ; then
879 AC_DEFINE(DECL_SYS_ERRLIST,1,
880 [define if sys_errlist is not declared in stdio.h or errno.h])
882 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
883 AC_TRY_LINK([#include <errno.h>],
884 [char *c = (char *) *sys_errlist],
885 [ol_cv_have_sys_errlist=yes],
886 [ol_cv_have_sys_errlist=no])])
888 if test $ol_cv_have_sys_errlist = yes ; then
889 AC_DEFINE(HAVE_SYS_ERRLIST,1,
890 [define if you actually have sys_errlist in your libs])
894 dnl ====================================================================
895 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
896 dnl "int x; int *volatile a = &x; *a = 0;"
897 dnl -- borrowed from PDKSH
898 AC_DEFUN(OL_C_VOLATILE,
899 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
900 [AC_TRY_COMPILE([int x, y, z;],
901 [volatile int a; int * volatile b = x ? &y : &z;
902 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
903 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
904 if test $ol_cv_c_volatile = yes; then
907 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
911 dnl ====================================================================
912 dnl Look for fetch(3)
913 AC_DEFUN([OL_LIB_FETCH],
915 LIBS="-lfetch -lcom_err $LIBS"
916 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
918 #include <sys/param.h>
921 [struct url *u = fetchParseURL("file:///"); ],
922 [ol_cv_lib_fetch=yes],
923 [ol_cv_lib_fetch=no])])
925 if test $ol_cv_lib_fetch != no ; then
926 ol_link_fetch="-lfetch -lcom_err"
927 AC_DEFINE(HAVE_FETCH,1,
928 [define if you actually have FreeBSD fetch(3)])
932 dnl ====================================================================
933 dnl Define sig_atomic_t if not defined in signal.h
934 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
935 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
936 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
937 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
938 if test $ol_cv_type_sig_atomic_t = no; then
939 AC_DEFINE(sig_atomic_t,int,
940 [define to atomic type if sig_atomic_t is not available])
944 dnl ====================================================================
945 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
946 AC_DEFUN(OL_TYPE_SOCKLEN_T,
947 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
949 #ifdef HAVE_SYS_TYPES_H
950 #include <sys/types.h>
952 #ifdef HAVE_SYS_SOCKET_H
953 #include <sys/socket.h>
956 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
957 if test $ol_cv_type_socklen_t = no; then
958 AC_DEFINE(socklen_t, int,
959 [define to int if socklen_t is not available])
963 dnl ====================================================================
964 dnl Define inet_aton is available
965 AC_DEFUN(OL_FUNC_INET_ATON,
966 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
968 #ifdef HAVE_SYS_TYPES_H
969 # include <sys/types.h>
971 #ifdef HAVE_SYS_SOCKET_H
972 # include <sys/socket.h>
973 # ifdef HAVE_SYS_SELECT_H
974 # include <sys/select.h>
976 # include <netinet/in.h>
977 # ifdef HAVE_ARPA_INET_H
978 # include <arpa/inet.h>
981 ], [struct in_addr in;
982 int rc = inet_aton( "255.255.255.255", &in );],
983 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
984 if test $ol_cv_func_inet_aton != no; then
985 AC_DEFINE(HAVE_INET_ATON, 1,
986 [define to you inet_aton(3) is available])
990 dnl ====================================================================
991 dnl check no of arguments for ctime_r
992 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
993 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
994 [AC_TRY_COMPILE([#include <time.h>],
995 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
996 ol_cv_func_ctime_r_nargs3=yes,
997 ol_cv_func_ctime_r_nargs3=no)
999 AC_TRY_COMPILE([#include <time.h>],
1000 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1001 ol_cv_func_ctime_r_nargs2=yes,
1002 ol_cv_func_ctime_r_nargs2=no)
1004 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1005 $ol_cv_func_ctime_r_nargs2 = no ; then
1007 ol_cv_func_ctime_r_nargs=3
1009 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1010 $ol_cv_func_ctime_r_nargs2 = yes ; then
1012 ol_cv_func_ctime_r_nargs=2
1015 ol_cv_func_ctime_r_nargs=0
1019 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1020 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1021 [set to the number of arguments ctime_r() expects])
1025 dnl --------------------------------------------------------------------
1026 dnl check return type of ctime_r()
1027 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1028 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1029 [AC_TRY_COMPILE([#include <time.h>],
1030 [extern int (ctime_r)();],
1031 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1033 if test $ol_cv_func_ctime_r_type = "int" ; then
1034 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1037 dnl ====================================================================
1038 dnl check no of arguments for gethostbyname_r
1039 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1040 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1041 ol_cv_func_gethostbyname_r_nargs,
1042 [AC_TRY_COMPILE([#include <sys/types.h>
1043 #include <sys/socket.h>
1044 #include <netinet/in.h>
1046 #define BUFSIZE (sizeof(struct hostent)+10)],
1047 [struct hostent hent; char buffer[BUFSIZE];
1048 int bufsize=BUFSIZE;int h_errno;
1049 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1050 buffer, bufsize, &h_errno);],
1051 ol_cv_func_gethostbyname_r_nargs5=yes,
1052 ol_cv_func_gethostbyname_r_nargs5=no)
1054 AC_TRY_COMPILE([#include <sys/types.h>
1055 #include <sys/socket.h>
1056 #include <netinet/in.h>
1058 #define BUFSIZE (sizeof(struct hostent)+10)],
1059 [struct hostent hent;struct hostent *rhent;
1060 char buffer[BUFSIZE];
1061 int bufsize=BUFSIZE;int h_errno;
1062 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1063 &rhent, &h_errno);],
1064 ol_cv_func_gethostbyname_r_nargs6=yes,
1065 ol_cv_func_gethostbyname_r_nargs6=no)
1067 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1068 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1070 ol_cv_func_gethostbyname_r_nargs=5
1072 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1073 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1075 ol_cv_func_gethostbyname_r_nargs=6
1078 ol_cv_func_gethostbyname_r_nargs=0
1081 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1082 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1083 $ol_cv_func_gethostbyname_r_nargs,
1084 [set to the number of arguments gethostbyname_r() expects])
1088 dnl check no of arguments for gethostbyaddr_r
1089 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1090 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1091 [ol_cv_func_gethostbyaddr_r_nargs],
1092 [AC_TRY_COMPILE([#include <sys/types.h>
1093 #include <sys/socket.h>
1094 #include <netinet/in.h>
1096 #define BUFSIZE (sizeof(struct hostent)+10)],
1097 [struct hostent hent; char buffer[BUFSIZE];
1099 size_t alen=sizeof(struct in_addr);
1100 int bufsize=BUFSIZE;int h_errno;
1101 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1102 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1103 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1104 ol_cv_func_gethostbyaddr_r_nargs7=no)
1106 AC_TRY_COMPILE([#include <sys/types.h>
1107 #include <sys/socket.h>
1108 #include <netinet/in.h>
1110 #define BUFSIZE (sizeof(struct hostent)+10)],
1111 [struct hostent hent;
1112 struct hostent *rhent; char buffer[BUFSIZE];
1114 size_t alen=sizeof(struct in_addr);
1115 int bufsize=BUFSIZE;int h_errno;
1116 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1117 alen, AF_INET, &hent, buffer, bufsize,
1118 &rhent, &h_errno);],
1119 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1120 ol_cv_func_gethostbyaddr_r_nargs8=no)
1122 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1123 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1125 ol_cv_func_gethostbyaddr_r_nargs=7
1127 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1128 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1130 ol_cv_func_gethostbyaddr_r_nargs=8
1133 ol_cv_func_gethostbyaddr_r_nargs=0
1136 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1137 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1138 $ol_cv_func_gethostbyaddr_r_nargs,
1139 [set to the number of arguments gethostbyaddr_r() expects])