3 dnl Copyright 1998-2001 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,changequote(<,>)<$2 [>ifelse($3,,auto,$3)<]>changequote([,]),[
24 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
25 if test "$enableval" = "$ol_val" ; then
29 if test "$ol_arg" = "invalid" ; then
30 AC_MSG_ERROR(bad value $enableval for --enable-$1)
32 ol_enable_$1="$ol_arg"
34 [ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
35 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
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 or no)
46 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
47 AC_ARG_WITH($1,changequote(<,>)<$2 [>ifelse($3,,yes,$3)<]>changequote([,]),[
49 for ol_val in ifelse($4,,[yes no],[$4]) ; do
50 if test "$withval" = "$ol_val" ; then
54 if test "$ol_arg" = "invalid" ; then
55 AC_MSG_ERROR(bad value $withval for --with-$1)
59 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
60 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
64 dnl ====================================================================
66 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
67 [changequote(<<, >>)dnl
68 dnl The name to #define.
69 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
70 dnl The cache variable name.
71 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
73 AC_MSG_CHECKING(size of $1)
74 AC_CACHE_VAL(AC_CV_NAME,
75 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
76 AC_TRY_COMPILE([#include "confdefs.h"
77 #include <sys/types.h>
79 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
80 if test x$AC_CV_NAME != x ; then break; fi
83 if test x$AC_CV_NAME = x ; then
84 AC_MSG_ERROR([cannot determine a size for $1])
86 AC_MSG_RESULT($AC_CV_NAME)
87 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
88 undefine([AC_TYPE_NAME])dnl
89 undefine([AC_CV_NAME])dnl
91 dnl ====================================================================
92 dnl check if hard links are supported.
94 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
95 AC_MSG_CHECKING(whether ln works)
96 AC_CACHE_VAL(ol_cv_prog_LN_H,
97 [rm -f conftest.src conftest.dst
98 echo "conftest" > conftest.src
99 if ln conftest.src conftest.dst 2>/dev/null
105 rm -f conftest.src conftest.dst
107 LN_H="$ol_cv_prog_LN_H"
108 if test "$ol_cv_prog_LN_H" = "ln"; then
116 dnl ====================================================================
117 dnl Check for dependency generation flag
118 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
121 if test -z "${MKDEP}"; then
123 if test -z "${MKDEP_FLAGS}"; then
124 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
126 for flag in "-M" "-xM"; do
127 cat > conftest.c <<EOF
130 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
131 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
133 if test ! -f conftest."${ac_object}" ; then
135 OL_MKDEP_FLAGS="$flag"
144 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
149 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
152 AC_SUBST(OL_MKDEP_FLAGS)
155 dnl ====================================================================
156 dnl Check if system uses EBCDIC instead of ASCII
157 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
158 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
161 #include <__ASCII__/generate_error.h>
164 [ol_cv_cpp_ebcdic=yes],
165 [ol_cv_cpp_ebcdic=no])])
166 if test $ol_cv_cpp_ebcdic = yes ; then
167 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
171 dnl --------------------------------------------------------------------
172 dnl OpenLDAP version of STDC header check w/ EBCDIC support
173 AC_DEFUN(OL_HEADER_STDC,
175 AC_REQUIRE([OL_CPP_EBCDIC])dnl
176 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
177 [AC_TRY_CPP([#include <stdlib.h>
180 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
182 if test $ol_cv_header_stdc = yes; then
183 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
184 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
187 if test $ol_cv_header_stdc = yes; then
188 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
189 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
192 if test $ol_cv_header_stdc = yes; then
193 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
194 AC_TRY_RUN([#include <ctype.h>
196 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
197 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
199 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
200 || ('j' <= (c) && (c) <= 'r') \
201 || ('s' <= (c) && (c) <= 'z'))
202 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
204 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
205 int main () { int i; for (i = 0; i < 256; i++)
206 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
208 ], , ol_cv_header_stdc=no, :)
210 if test $ol_cv_header_stdc = yes; then
211 AC_DEFINE(STDC_HEADERS)
213 ac_cv_header_stdc=disable
216 dnl ====================================================================
217 dnl Check if struct passwd has pw_gecos
218 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
219 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
220 AC_TRY_COMPILE([#include <pwd.h>],[
222 pwd.pw_gecos = pwd.pw_name;
224 [ol_cv_struct_passwd_pw_gecos=yes],
225 [ol_cv_struct_passwd_pw_gecos=no])])
226 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
227 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
231 dnl --------------------------------------------------------------------
232 dnl Check if struct passwd has pw_passwd
233 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
234 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
235 AC_TRY_COMPILE([#include <pwd.h>],[
237 pwd.pw_passwd = pwd.pw_name;
239 [ol_cv_struct_passwd_pw_passwd=yes],
240 [ol_cv_struct_passwd_pw_passwd=no])])
241 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
242 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
246 dnl ====================================================================
247 dnl Berkeley DB macros
249 dnl --------------------------------------------------------------------
251 AC_DEFUN([OL_BERKELEY_DB_TRY],
252 [if test $ol_cv_lib_db = no ; then
253 AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
255 ol_DB_LIB=ifelse($2,,,$2)
257 LIBS="$ol_DB_LIB $LIBS"
266 #ifndef DB_VERSION_MAJOR
267 # define DB_VERSION_MAJOR 1
271 #define NULL ((void*)0)
274 #if DB_VERSION_MAJOR > 1
277 int major, minor, patch;
279 version = db_version( &major, &minor, &patch );
281 if( major != DB_VERSION_MAJOR ||
282 minor < DB_VERSION_MINOR )
284 printf("Berkeley DB version mismatch\n"
285 "\texpected: %s\n\tgot: %s\n",
286 DB_VERSION_STRING, version);
292 #if DB_VERSION_MAJOR > 2
293 db_env_create( NULL, 0 );
294 #elif DB_VERSION_MAJOR > 1
297 (void) dbopen( NULL, 0, 0, 0, NULL);
304 if test $$1 = yes ; then
305 ol_cv_lib_db=ifelse($2,,yes,$2)
310 dnl --------------------------------------------------------------------
311 dnl Try to locate appropriate library
312 AC_DEFUN([OL_BERKELEY_DB_LINK],
314 OL_BERKELEY_DB_TRY(ol_cv_db_none)
315 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
316 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
317 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
318 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
321 dnl --------------------------------------------------------------------
322 dnl Check if Berkeley DB supports DB_THREAD
323 AC_DEFUN([OL_BERKELEY_DB_THREAD],
324 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
326 if test $ol_cv_lib_db != yes ; then
337 #define NULL ((void *)0)
342 u_int32_t flags = DB_CREATE |
348 #if DB_VERSION_MAJOR > 2
351 rc = db_env_create( &env, 0 );
353 flags |= DB_INIT_MPOOL;
354 #ifdef DB_MPOOL_PRIVATE
355 flags |= DB_MPOOL_PRIVATE;
359 printf("BerkeleyDB: %s\n", db_strerror(rc) );
363 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
364 rc = env->open( env, NULL, flags, 0 );
366 rc = env->open( env, NULL, NULL, flags, 0 );
370 rc = env->close( env, 0 );
374 printf("BerkeleyDB: %s\n", db_strerror(rc) );
380 memset( &env, '\0', sizeof(env) );
382 rc = db_appinit( NULL, NULL, &env, flags );
388 unlink("__db_mpool.share");
389 unlink("__db_lock.share");
394 [ol_cv_berkeley_db_thread=yes],
395 [ol_cv_berkeley_db_thread=no],
396 [ol_cv_berkeley_db_thread=cross])
400 if test $ol_cv_berkeley_db_thread != no ; then
401 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
402 [define if Berkeley DB has DB_THREAD support])
406 dnl --------------------------------------------------------------------
408 AC_DEFUN([OL_BERKELEY_DB],
409 [ol_cv_berkeley_db=no
410 AC_CHECK_HEADERS(db.h)
411 if test $ac_cv_header_db_h = yes; then
413 if test "$ol_cv_lib_db" != no ; then
414 ol_cv_berkeley_db=yes
415 OL_BERKELEY_DB_THREAD
420 dnl --------------------------------------------------------------------
421 dnl Find old Berkeley DB 1.85/1.86
422 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
423 [ol_cv_berkeley_db=no
424 AC_CHECK_HEADERS(db_185.h db.h)
425 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
426 AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
427 AC_EGREP_CPP(__db_version_1,[
434 /* this check could be improved */
435 #ifndef DB_VERSION_MAJOR
436 # define DB_VERSION_MAJOR 1
439 #if DB_VERSION_MAJOR == 1
442 ], [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
444 if test $ol_cv_header_db1 = yes ; then
446 if test "$ol_cv_lib_db" != no ; then
447 ol_cv_berkeley_db=yes
453 dnl ====================================================================
454 dnl Check if GDBM library exists
455 dnl Check for gdbm_open in standard libraries or -lgdbm
457 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
458 dnl 'yes' implies gdbm_open is in $LIBS
461 dnl AC_CHECK_FUNC(gdbm_open)
462 dnl AC_CHECK_LIB(gdbm,gdbm_open)
464 AC_DEFUN([OL_LIB_GDBM],
465 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
467 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
468 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
474 dnl --------------------------------------------------------------------
475 dnl Check if GDBM exists
477 dnl defines ol_cv_gdbm to 'yes' or 'no'
481 dnl AC_CHECK_HEADERS(gdbm.h)
484 [AC_REQUIRE([OL_LIB_GDBM])
485 AC_CHECK_HEADERS(gdbm.h)
486 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
487 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
493 if test $ol_cv_gdbm = yes ; then
494 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
498 dnl ====================================================================
499 dnl Check if MDBM library exists
500 dnl Check for mdbm_open in standard libraries or -lmdbm
502 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
503 dnl 'yes' implies mdbm_open is in $LIBS
506 dnl AC_CHECK_FUNC(mdbm_set_chain)
507 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
509 AC_DEFUN([OL_LIB_MDBM],
510 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
512 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
513 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
519 dnl --------------------------------------------------------------------
520 dnl Check if MDBM exists
522 dnl defines ol_cv_mdbm to 'yes' or 'no'
526 dnl AC_CHECK_HEADERS(mdbm.h)
529 [AC_REQUIRE([OL_LIB_MDBM])
530 AC_CHECK_HEADERS(mdbm.h)
531 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
532 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
538 if test $ol_cv_mdbm = yes ; then
539 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
543 dnl ====================================================================
544 dnl Check if NDBM library exists
545 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
547 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
548 dnl 'yes' implies ndbm_open is in $LIBS
551 dnl AC_CHECK_FUNC(dbm_open)
552 dnl AC_CHECK_LIB(ndbm,dbm_open)
553 dnl AC_CHECK_LIB(dbm,dbm_open)
556 dnl should also check SVR4 case: dbm_open() in -lucb but that
557 dnl would requiring dealing with -L/usr/ucblib
559 AC_DEFUN([OL_LIB_NDBM],
560 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
562 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
563 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
564 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
565 [ol_cv_lib_ndbm=no])dnl
572 dnl --------------------------------------------------------------------
573 dnl Check if NDBM exists
575 dnl defines ol_cv_ndbm to 'yes' or 'no'
579 dnl AC_CHECK_HEADERS(ndbm.h)
582 dnl Doesn't handle SVR4 case (see above)
585 [AC_REQUIRE([OL_LIB_NDBM])
586 AC_CHECK_HEADERS(ndbm.h)
587 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
588 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
594 if test $ol_cv_ndbm = yes ; then
595 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
599 dnl ====================================================================
600 dnl Check POSIX Thread version
602 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
603 dnl 'unknown' implies that the version could not be detected
604 dnl or that pthreads.h does exist. Existance of pthreads.h
605 dnl should be tested separately.
607 AC_DEFUN([OL_POSIX_THREAD_VERSION],
608 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
609 AC_EGREP_CPP(pthread_version_final,[
610 # include <pthread.h>
611 /* this check could be improved */
612 # ifdef PTHREAD_ONCE_INIT
613 pthread_version_final;
615 ], ol_pthread_final=yes, ol_pthread_final=no)
617 AC_EGREP_CPP(pthread_version_draft4,[
618 # include <pthread.h>
619 /* this check could be improved */
620 # ifdef pthread_once_init
621 pthread_version_draft4;
623 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
625 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
626 ol_cv_pthread_version=final
627 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
628 ol_cv_pthread_version=draft4
630 ol_cv_pthread_version=unknown
635 dnl --------------------------------------------------------------------
636 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
637 [/* pthread test headers */
640 #define NULL (void*)0
646 return (void *) (p == NULL);
649 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
650 /* pthread test function */
655 #ifdef HAVE_PTHREADS_FINAL
659 status = pthread_attr_init(&attr);
660 if( status ) return status;
662 #if defined( PTHREAD_CREATE_JOINABLE ) || defined( PTHREAD_UNDETACHED )
664 #if defined( PTHREAD_CREATE_JOINABLE )
665 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
667 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED);
670 #ifdef PTHREAD_CREATE_DETACHED
672 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
675 if( status ) return status;
678 status = pthread_create( &t, &attr, task, NULL );
679 if( status ) return status;
681 #if !defined( PTHREAD_CREATE_JOINABLE ) && !defined( PTHREAD_UNDETACHED )
683 /* give thread a chance to complete */
684 /* it should remain joinable and hence detachable */
687 status = pthread_detach( t );
688 if( status ) return status;
693 /* Draft 4 pthreads */
694 status = pthread_create( &t, pthread_attr_default, task, NULL );
695 if( status ) return status;
698 /* give thread a chance to complete */
699 /* it should remain joinable and hence detachable */
702 status = pthread_detach( &t );
703 if( status ) return status;
707 #ifdef HAVE_LINUX_THREADS
708 pthread_kill_other_threads_np();
714 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
715 [OL_PTHREAD_TEST_INCLUDES
721 OL_PTHREAD_TEST_FUNCTION
724 dnl --------------------------------------------------------------------
725 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
726 if test "$ol_link_threads" = no ; then
728 AC_CACHE_CHECK([for pthread link with $1], [$2], [
733 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
735 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
742 if test $$2 = yes ; then
743 ol_link_pthreads="$1"
744 ol_link_threads=posix
749 dnl ====================================================================
750 dnl Check GNU Pth pthread Header
752 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
753 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
754 dnl doesn't exists. Existance of pthread.h should separately
757 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
758 AC_CACHE_CHECK([for GNU Pth pthread.h],
759 [ol_cv_header_gnu_pth_pthread_h],
760 [AC_EGREP_CPP(__gnu_pth__,
761 [#include <pthread.h>
762 #ifdef _POSIX_THREAD_IS_GNU_PTH
766 [ol_cv_header_gnu_pth_pthread_h=yes],
767 [ol_cv_header_gnu_pth_pthread_h=no])
770 dnl ====================================================================
771 dnl Check for NT Threads
772 AC_DEFUN([OL_NT_THREADS], [
773 AC_CHECK_FUNC(_beginthread)
775 if test $ac_cv_func__beginthread = yes ; then
776 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
779 dnl ====================================================================
780 dnl Check LinuxThreads Header
782 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
783 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
784 dnl doesn't exists. Existance of pthread.h should separately
787 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
788 AC_CACHE_CHECK([for LinuxThreads pthread.h],
789 [ol_cv_header_linux_threads],
790 [AC_EGREP_CPP(pthread_kill_other_threads_np,
791 [#include <pthread.h>],
792 [ol_cv_header_linux_threads=yes],
793 [ol_cv_header_linux_threads=no])
795 if test $ol_cv_header_linux_threads = yes; then
796 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
799 dnl --------------------------------------------------------------------
800 dnl Check LinuxThreads Implementation
802 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
803 dnl 'no' implies pthreads implementation is not LinuxThreads.
805 AC_DEFUN([OL_SYS_LINUX_THREADS], [
806 AC_CHECK_FUNCS(pthread_kill_other_threads_np)
807 AC_CACHE_CHECK([for LinuxThreads implementation],
808 [ol_cv_sys_linux_threads],
809 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
812 dnl --------------------------------------------------------------------
813 dnl Check LinuxThreads consistency
814 AC_DEFUN([OL_LINUX_THREADS], [
815 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
816 AC_REQUIRE([OL_SYS_LINUX_THREADS])
817 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
818 if test $ol_cv_header_linux_threads = yes -a \
819 $ol_cv_sys_linux_threads = yes; then
820 ol_cv_linux_threads=yes
821 elif test $ol_cv_header_linux_threads = no -a \
822 $ol_cv_sys_linux_threads = no; then
823 ol_cv_linux_threads=no
825 ol_cv_linux_threads=error
830 dnl ====================================================================
831 dnl Check for POSIX Regex
832 AC_DEFUN([OL_POSIX_REGEX], [
833 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
835 #include <sys/types.h>
837 static char *pattern, *string;
845 if(regcomp(&re, pattern, 0)) {
849 string = "ALL MATCH";
851 rc = regexec(&re, string, 0, (void*)0, 0);
857 [ol_cv_c_posix_regex=yes],
858 [ol_cv_c_posix_regex=no],
859 [ol_cv_c_posix_regex=cross])])
862 dnl ====================================================================
863 dnl Check if toupper() requires islower() to be called first
864 AC_DEFUN([OL_C_UPPER_LOWER],
865 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
870 if ('C' == toupper('C'))
875 [ol_cv_c_upper_lower=no],
876 [ol_cv_c_upper_lower=yes],
877 [ol_cv_c_upper_lower=safe])])
878 if test $ol_cv_c_upper_lower != no ; then
879 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
883 dnl ====================================================================
884 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
885 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
886 dnl Reported by Keith Bostic.
887 AC_DEFUN([OL_SYS_ERRLIST],
888 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
891 #include <sys/types.h>
896 [char *c = (char *) *sys_errlist],
897 [ol_cv_dcl_sys_errlist=yes
898 ol_cv_have_sys_errlist=yes],
899 [ol_cv_dcl_sys_errlist=no])])
901 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
902 if test $ol_cv_dcl_sys_errlist = no ; then
903 AC_DEFINE(DECL_SYS_ERRLIST,1,
904 [define if sys_errlist is not declared in stdio.h or errno.h])
906 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
907 AC_TRY_LINK([#include <errno.h>],
908 [char *c = (char *) *sys_errlist],
909 [ol_cv_have_sys_errlist=yes],
910 [ol_cv_have_sys_errlist=no])])
912 if test $ol_cv_have_sys_errlist = yes ; then
913 AC_DEFINE(HAVE_SYS_ERRLIST,1,
914 [define if you actually have sys_errlist in your libs])
918 dnl ====================================================================
919 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
920 dnl "int x; int *volatile a = &x; *a = 0;"
921 dnl -- borrowed from PDKSH
922 AC_DEFUN(OL_C_VOLATILE,
923 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
924 [AC_TRY_COMPILE([int x, y, z;],
925 [volatile int a; int * volatile b = x ? &y : &z;
926 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
927 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
928 if test $ol_cv_c_volatile = yes; then
931 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
935 dnl ====================================================================
936 dnl Look for fetch(3)
937 AC_DEFUN([OL_LIB_FETCH],
939 LIBS="-lfetch -lcom_err $LIBS"
940 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
942 #include <sys/param.h>
945 [struct url *u = fetchParseURL("file:///"); ],
946 [ol_cv_lib_fetch=yes],
947 [ol_cv_lib_fetch=no])])
949 if test $ol_cv_lib_fetch != no ; then
950 ol_link_fetch="-lfetch -lcom_err"
951 AC_DEFINE(HAVE_FETCH,1,
952 [define if you actually have FreeBSD fetch(3)])
956 dnl ====================================================================
957 dnl Define sig_atomic_t if not defined in signal.h
958 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
959 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
960 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
961 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
962 if test $ol_cv_type_sig_atomic_t = no; then
963 AC_DEFINE(sig_atomic_t,int,
964 [define to atomic type if sig_atomic_t is not available])
968 dnl ====================================================================
969 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
970 AC_DEFUN(OL_TYPE_SOCKLEN_T,
971 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
973 #ifdef HAVE_SYS_TYPES_H
974 #include <sys/types.h>
976 #ifdef HAVE_SYS_SOCKET_H
977 #include <sys/socket.h>
980 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
981 if test $ol_cv_type_socklen_t = no; then
982 AC_DEFINE(socklen_t, int,
983 [define to int if socklen_t is not available])
987 dnl ====================================================================
988 dnl Define inet_aton is available
989 AC_DEFUN(OL_FUNC_INET_ATON,
990 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
992 #ifdef HAVE_SYS_TYPES_H
993 # include <sys/types.h>
995 #ifdef HAVE_SYS_SOCKET_H
996 # include <sys/socket.h>
997 # ifdef HAVE_SYS_SELECT_H
998 # include <sys/select.h>
1000 # include <netinet/in.h>
1001 # ifdef HAVE_ARPA_INET_H
1002 # include <arpa/inet.h>
1005 ], [struct in_addr in;
1006 int rc = inet_aton( "255.255.255.255", &in );],
1007 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1008 if test $ol_cv_func_inet_aton != no; then
1009 AC_DEFINE(HAVE_INET_ATON, 1,
1010 [define to you inet_aton(3) is available])
1014 dnl ====================================================================
1015 dnl check no of arguments for ctime_r
1016 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1017 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1018 [AC_TRY_COMPILE([#include <time.h>],
1019 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1020 ol_cv_func_ctime_r_nargs3=yes,
1021 ol_cv_func_ctime_r_nargs3=no)
1023 AC_TRY_COMPILE([#include <time.h>],
1024 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1025 ol_cv_func_ctime_r_nargs2=yes,
1026 ol_cv_func_ctime_r_nargs2=no)
1028 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1029 $ol_cv_func_ctime_r_nargs2 = no ; then
1031 ol_cv_func_ctime_r_nargs=3
1033 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1034 $ol_cv_func_ctime_r_nargs2 = yes ; then
1036 ol_cv_func_ctime_r_nargs=2
1039 ol_cv_func_ctime_r_nargs=0
1043 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1044 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1045 [set to the number of arguments ctime_r() expects])
1049 dnl --------------------------------------------------------------------
1050 dnl check return type of ctime_r()
1051 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1052 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1053 [AC_TRY_COMPILE([#include <time.h>],
1054 [extern int (ctime_r)();],
1055 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1057 if test $ol_cv_func_ctime_r_type = "int" ; then
1058 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1061 dnl ====================================================================
1062 dnl check no of arguments for gethostbyname_r
1063 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1064 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1065 ol_cv_func_gethostbyname_r_nargs,
1066 [AC_TRY_COMPILE([#include <sys/types.h>
1067 #include <sys/socket.h>
1068 #include <netinet/in.h>
1070 #define BUFSIZE (sizeof(struct hostent)+10)],
1071 [struct hostent hent; char buffer[BUFSIZE];
1072 int bufsize=BUFSIZE;int h_errno;
1073 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1074 buffer, bufsize, &h_errno);],
1075 ol_cv_func_gethostbyname_r_nargs5=yes,
1076 ol_cv_func_gethostbyname_r_nargs5=no)
1078 AC_TRY_COMPILE([#include <sys/types.h>
1079 #include <sys/socket.h>
1080 #include <netinet/in.h>
1082 #define BUFSIZE (sizeof(struct hostent)+10)],
1083 [struct hostent hent;struct hostent *rhent;
1084 char buffer[BUFSIZE];
1085 int bufsize=BUFSIZE;int h_errno;
1086 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1087 &rhent, &h_errno);],
1088 ol_cv_func_gethostbyname_r_nargs6=yes,
1089 ol_cv_func_gethostbyname_r_nargs6=no)
1091 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1092 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1094 ol_cv_func_gethostbyname_r_nargs=5
1096 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1097 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1099 ol_cv_func_gethostbyname_r_nargs=6
1102 ol_cv_func_gethostbyname_r_nargs=0
1105 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1106 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1107 $ol_cv_func_gethostbyname_r_nargs,
1108 [set to the number of arguments gethostbyname_r() expects])
1112 dnl check no of arguments for gethostbyaddr_r
1113 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1114 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1115 [ol_cv_func_gethostbyaddr_r_nargs],
1116 [AC_TRY_COMPILE([#include <sys/types.h>
1117 #include <sys/socket.h>
1118 #include <netinet/in.h>
1120 #define BUFSIZE (sizeof(struct hostent)+10)],
1121 [struct hostent hent; char buffer[BUFSIZE];
1123 size_t alen=sizeof(struct in_addr);
1124 int bufsize=BUFSIZE;int h_errno;
1125 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1126 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1127 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1128 ol_cv_func_gethostbyaddr_r_nargs7=no)
1130 AC_TRY_COMPILE([#include <sys/types.h>
1131 #include <sys/socket.h>
1132 #include <netinet/in.h>
1134 #define BUFSIZE (sizeof(struct hostent)+10)],
1135 [struct hostent hent;
1136 struct hostent *rhent; char buffer[BUFSIZE];
1138 size_t alen=sizeof(struct in_addr);
1139 int bufsize=BUFSIZE;int h_errno;
1140 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1141 alen, AF_INET, &hent, buffer, bufsize,
1142 &rhent, &h_errno);],
1143 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1144 ol_cv_func_gethostbyaddr_r_nargs8=no)
1146 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1147 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1149 ol_cv_func_gethostbyaddr_r_nargs=7
1151 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1152 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1154 ol_cv_func_gethostbyaddr_r_nargs=8
1157 ol_cv_func_gethostbyaddr_r_nargs=0
1160 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1161 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1162 $ol_cv_func_gethostbyaddr_r_nargs,
1163 [set to the number of arguments gethostbyaddr_r() expects])