3 dnl Copyright 1998-1999 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,[$2 (]ifelse($3,,auto,$3)[)],[
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,[$2 (]ifelse($3,,yes,$3)[)],[
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 ====================================================================
59 dnl check if hard links are supported.
61 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
62 AC_MSG_CHECKING(whether ln works)
63 AC_CACHE_VAL(ol_cv_prog_LN_H,
64 [rm -f conftest.src conftest.dst
65 echo "conftest" > conftest.src
66 if ln conftest.src conftest.dst 2>/dev/null
72 rm -f conftest.src conftest.dst
74 LN_H="$ol_cv_prog_LN_H"
75 if test "$ol_cv_prog_LN_H" = "ln"; then
83 dnl ====================================================================
84 dnl Check for dependency generation flag
85 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
88 if test -z "${MKDEP}"; then
90 if test -z "${MKDEP_FLAGS}"; then
91 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
93 for flag in "-M" "-xM"; do
94 cat > conftest.c <<EOF
97 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
98 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
100 if test ! -f conftest."${ac_object}" ; then
102 OL_MKDEP_FLAGS="$flag"
111 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
116 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
119 AC_SUBST(OL_MKDEP_FLAGS)
122 dnl ====================================================================
123 dnl Check if system uses EBCDIC instead of ASCII
124 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
125 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
128 #include <__ASCII__/generate_error.h>
131 [ol_cv_cpp_ebcdic=yes],
132 [ol_cv_cpp_ebcdic=no])])
133 if test $ol_cv_cpp_ebcdic = yes ; then
134 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
138 dnl --------------------------------------------------------------------
139 dnl OpenLDAP version of STDC header check w/ EBCDIC support
140 AC_DEFUN(OL_HEADER_STDC,
142 AC_REQUIRE([OL_CPP_EBCDIC])dnl
143 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
144 [AC_TRY_CPP([#include <stdlib.h>
147 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
149 if test $ol_cv_header_stdc = yes; then
150 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
151 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
154 if test $ol_cv_header_stdc = yes; then
155 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
156 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
159 if test $ol_cv_header_stdc = yes; then
160 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
161 AC_TRY_RUN([#include <ctype.h>
163 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
164 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
166 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
167 || ('j' <= (c) && (c) <= 'r') \
168 || ('s' <= (c) && (c) <= 'z'))
169 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
171 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
172 int main () { int i; for (i = 0; i < 256; i++)
173 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
175 ], , ol_cv_header_stdc=no, :)
177 if test $ol_cv_header_stdc = yes; then
178 AC_DEFINE(STDC_HEADERS)
180 ac_cv_header_stdc=disable
183 dnl ====================================================================
184 dnl Check if struct passwd has pw_gecos
185 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
186 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
187 AC_TRY_COMPILE([#include <pwd.h>],[
189 pwd.pw_gecos = pwd.pw_name;
191 [ol_cv_struct_passwd_pw_gecos=yes],
192 [ol_cv_struct_passwd_pw_gecos=no])])
193 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
194 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
198 dnl --------------------------------------------------------------------
199 dnl Check if struct passwd has pw_passwd
200 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
201 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
202 AC_TRY_COMPILE([#include <pwd.h>],[
204 pwd.pw_passwd = pwd.pw_name;
206 [ol_cv_struct_passwd_pw_passwd=yes],
207 [ol_cv_struct_passwd_pw_passwd=no])])
208 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
209 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
213 dnl ====================================================================
214 dnl Check if db.h is Berkeley DB2
216 dnl defines ol_cv_header_db2 to 'yes' or 'no'
219 dnl AC_CHECK_HEADERS(db.h)
221 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
222 [AC_CHECK_HEADERS(db.h)
223 if test $ac_cv_header_db_h = yes ; then
224 AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
225 AC_EGREP_CPP(__db_version_2,[
227 /* this check could be improved */
228 # ifdef DB_VERSION_MAJOR
229 # if DB_VERSION_MAJOR == 2
233 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
238 dnl --------------------------------------------------------------------
239 dnl Check if Berkeley DB2 library exists
240 dnl Check for dbopen in standard libraries or -ldb
242 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
245 dnl AC_CHECK_LIB(db,db_appexit)
247 AC_DEFUN([OL_LIB_BERKELEY_DB2],
248 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
250 AC_CHECK_LIB(db,db_appexit,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
255 dnl --------------------------------------------------------------------
256 dnl Check if Berkeley db2 exists
258 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
261 dnl OL_LIB_BERKELEY_DB2
262 dnl OL_HEADER_BERKELEY_DB2
264 AC_DEFUN([OL_BERKELEY_DB2],
265 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
266 AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
267 AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
268 if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
269 ol_cv_berkeley_db2=no
271 ol_cv_berkeley_db2=yes
274 if test $ol_cv_berkeley_db2 = yes ; then
275 AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
280 dnl --------------------------------------------------------------------
281 dnl Check if Berkeley db2 supports DB_THREAD
282 AC_DEFUN([OL_BERKELEY_DB2_DB_THREAD],
283 [AC_CACHE_CHECK([for DB_THREAD support], [ol_cv_berkeley_db2_db_thread], [
285 if test $ol_cv_lib_db2 != yes ; then
286 LIBS="$ol_cv_lib_db2"
292 #define NULL ((void *)0)
298 u_int32_t flags = DB_CREATE | DB_THREAD;
300 memset( &env, '\0', sizeof(env) );
302 rc = db_appinit( NULL, NULL, &env, flags );
310 [ol_cv_berkeley_db2_db_thread=yes],
311 [ol_cv_berkeley_db2_db_thread=no],
312 [ol_cv_berkeley_db2_db_thread=cross])
316 if test $ol_cv_berkeley_db2_db_thread != no ; then
317 AC_DEFINE(HAVE_BERKELEY_DB2_DB_THREAD, 1,
318 [define if BerkeleyDB2 has DB_THREAD support])
321 dnl ====================================================================
322 dnl Check for db.h/db_185.h is Berkeley DB
324 dnl defines ol_cv_header_db to 'yes' or 'no'
327 dnl OL_HEADER_BERKELEY_DB2
328 dnl AC_CHECK_HEADERS(db_185.h)
330 AC_DEFUN([OL_HEADER_BERKELEY_DB],
331 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
332 AC_CHECK_HEADERS(db_185.h)
333 if test "$ol_cv_header_db2" = yes ; then
336 ol_cv_header_db=$ac_cv_header_db_185_h
338 ol_cv_header_db=$ac_cv_header_db_h
342 dnl --------------------------------------------------------------------
343 dnl Check if Berkeley DB library exists
344 dnl Check for dbopen in standard libraries or -ldb
346 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
347 dnl 'yes' implies dbopen is in $LIBS
350 dnl AC_CHECK_FUNC(dbopen)
351 dnl AC_CHECK_LIB(db,dbopen)
353 AC_DEFUN([OL_LIB_BERKELEY_DB],
354 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
356 AC_CHECK_HEADERS(db1/db.h)
358 AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
359 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
360 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
368 dnl --------------------------------------------------------------------
369 dnl Check if Berkeley DB exists
371 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
374 dnl OL_LIB_BERKELEY_DB
375 dnl OL_HEADER_BERKELEY_DB
377 AC_DEFUN([OL_BERKELEY_DB],
378 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
379 AC_REQUIRE([OL_HEADER_BERKELEY_DB])
380 AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
381 if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
384 ol_cv_berkeley_db=yes
387 if test $ol_cv_berkeley_db = yes ; then
388 AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
392 dnl ====================================================================
393 dnl Check if GDBM library exists
394 dnl Check for gdbm_open in standard libraries or -lgdbm
396 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
397 dnl 'yes' implies gdbm_open is in $LIBS
400 dnl AC_CHECK_FUNC(gdbm_open)
401 dnl AC_CHECK_LIB(gdbm,gdbm_open)
403 AC_DEFUN([OL_LIB_GDBM],
404 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
406 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
407 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
413 dnl --------------------------------------------------------------------
414 dnl Check if GDBM exists
416 dnl defines ol_cv_gdbm to 'yes' or 'no'
420 dnl AC_CHECK_HEADERS(gdbm.h)
423 [AC_REQUIRE([OL_LIB_GDBM])
424 AC_CHECK_HEADERS(gdbm.h)
425 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
426 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
432 if test $ol_cv_gdbm = yes ; then
433 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
437 dnl ====================================================================
438 dnl Check if MDBM library exists
439 dnl Check for mdbm_open in standard libraries or -lmdbm
441 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
442 dnl 'yes' implies mdbm_open is in $LIBS
445 dnl AC_CHECK_FUNC(mdbm_set_chain)
446 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
448 AC_DEFUN([OL_LIB_MDBM],
449 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
451 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
452 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
458 dnl --------------------------------------------------------------------
459 dnl Check if MDBM exists
461 dnl defines ol_cv_mdbm to 'yes' or 'no'
465 dnl AC_CHECK_HEADERS(mdbm.h)
468 [AC_REQUIRE([OL_LIB_MDBM])
469 AC_CHECK_HEADERS(mdbm.h)
470 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
471 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
477 if test $ol_cv_mdbm = yes ; then
478 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
482 dnl ====================================================================
483 dnl Check if NDBM library exists
484 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
486 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
487 dnl 'yes' implies ndbm_open is in $LIBS
490 dnl AC_CHECK_FUNC(dbm_open)
491 dnl AC_CHECK_LIB(ndbm,dbm_open)
492 dnl AC_CHECK_LIB(dbm,dbm_open)
495 dnl should also check SVR4 case: dbm_open() in -lucb but that
496 dnl would requiring dealing with -L/usr/ucblib
498 AC_DEFUN([OL_LIB_NDBM],
499 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
501 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
502 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
503 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
504 [ol_cv_lib_ndbm=no])dnl
511 dnl --------------------------------------------------------------------
512 dnl Check if NDBM exists
514 dnl defines ol_cv_ndbm to 'yes' or 'no'
518 dnl AC_CHECK_HEADERS(ndbm.h)
521 dnl Doesn't handle SVR4 case (see above)
524 [AC_REQUIRE([OL_LIB_NDBM])
525 AC_CHECK_HEADERS(ndbm.h)
526 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
527 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
533 if test $ol_cv_ndbm = yes ; then
534 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
538 dnl ====================================================================
539 dnl Check POSIX Thread version
541 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
542 dnl 'unknown' implies that the version could not be detected
543 dnl or that pthreads.h does exist. Existance of pthreads.h
544 dnl should be tested separately.
546 AC_DEFUN([OL_POSIX_THREAD_VERSION],
547 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
548 AC_EGREP_CPP(pthread_version_final,[
549 # include <pthread.h>
550 /* this check could be improved */
551 # ifdef PTHREAD_ONCE_INIT
552 pthread_version_final;
554 ], ol_pthread_final=yes, ol_pthread_final=no)
556 AC_EGREP_CPP(pthread_version_draft4,[
557 # include <pthread.h>
558 /* this check could be improved */
559 # ifdef pthread_once_init
560 pthread_version_draft4;
562 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
564 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
565 ol_cv_pthread_version=final
566 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
567 ol_cv_pthread_version=draft4
569 ol_cv_pthread_version=unknown
574 dnl --------------------------------------------------------------------
575 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
576 [/* pthread test headers */
579 #define NULL (void*)0
585 return (void *) (p == NULL);
588 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
589 /* pthread test function */
593 /* make sure pthread_create() isn't just a stub */
595 status = pthread_create(&t, pthread_attr_default, task, NULL);
597 status = pthread_create(&t, NULL, task, NULL);
600 if( status ) exit( status );
602 /* make sure pthread_detach() isn't just a stub */
604 status = pthread_detach( &t );
606 status = pthread_detach( t );
609 #ifdef HAVE_LINUX_THREADS
610 pthread_kill_other_threads_np();
616 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
617 [OL_PTHREAD_TEST_INCLUDES
623 OL_PTHREAD_TEST_FUNCTION
626 dnl --------------------------------------------------------------------
627 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
628 if test "$ol_link_threads" = no ; then
630 AC_CACHE_CHECK([for pthread link with $1], [$2], [
635 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
637 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
644 if test $$2 = yes ; then
645 ol_link_pthreads="$1"
646 ol_link_threads=posix
651 dnl ====================================================================
652 dnl Check GNU Pth pthread Header
654 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
655 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
656 dnl doesn't exists. Existance of pthread.h should separately
659 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
660 AC_CACHE_CHECK([for GNU Pth pthread.h],
661 [ol_cv_header_gnu_pth_pthread_h],
662 [AC_EGREP_CPP(__gnu_pth__,
663 [#include <pthread.h>
664 #ifdef _POSIX_THREAD_IS_GNU_PTH
668 [ol_cv_header_gnu_pth_pthread_h=yes],
669 [ol_cv_header_gnu_pth_pthread_h=no])
672 dnl ====================================================================
673 dnl Check LinuxThreads Header
675 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
676 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
677 dnl doesn't exists. Existance of pthread.h should separately
680 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
681 AC_CACHE_CHECK([for LinuxThreads pthread.h],
682 [ol_cv_header_linux_threads],
683 [AC_EGREP_CPP(pthread_kill_other_threads_np,
684 [#include <pthread.h>],
685 [ol_cv_header_linux_threads=yes],
686 [ol_cv_header_linux_threads=no])
688 if test $ol_cv_header_linux_threads = yes; then
689 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
692 dnl --------------------------------------------------------------------
693 dnl Check LinuxThreads Implementation
695 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
696 dnl 'no' implies pthreads implementation is not LinuxThreads.
698 AC_DEFUN([OL_SYS_LINUX_THREADS], [
699 AC_CHECK_FUNC(pthread_kill_other_threads_np)
700 AC_CACHE_CHECK([for LinuxThreads implementation],
701 [ol_cv_sys_linux_threads],
702 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
705 dnl --------------------------------------------------------------------
706 dnl Check LinuxThreads consistency
707 AC_DEFUN([OL_LINUX_THREADS], [
708 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
709 AC_REQUIRE([OL_SYS_LINUX_THREADS])
710 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
711 if test $ol_cv_header_linux_threads = yes -a \
712 $ol_cv_sys_linux_threads = yes; then
713 ol_cv_linux_threads=yes
714 elif test $ol_cv_header_linux_threads = no -a \
715 $ol_cv_sys_linux_threads = no; then
716 ol_cv_linux_threads=no
718 ol_cv_linux_threads=error
723 dnl ====================================================================
724 dnl Check for POSIX Regex
725 AC_DEFUN([OL_POSIX_REGEX], [
726 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
728 #include <sys/types.h>
730 static char *pattern, *string;
738 if(regcomp(&re, pattern, 0)) {
742 string = "ALL MATCH";
744 rc = regexec(&re, string, 0, (void*)0, 0);
750 [ol_cv_c_posix_regex=yes],
751 [ol_cv_c_posix_regex=no],
752 [ol_cv_c_posix_regex=cross])])
755 dnl ====================================================================
756 dnl Check if toupper() requires islower() to be called first
757 AC_DEFUN([OL_C_UPPER_LOWER],
758 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
763 if ('C' == toupper('C'))
768 [ol_cv_c_upper_lower=no],
769 [ol_cv_c_upper_lower=yes],
770 [ol_cv_c_upper_lower=safe])])
771 if test $ol_cv_c_upper_lower != no ; then
772 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
776 dnl ====================================================================
777 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
778 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
779 dnl Reported by Keith Bostic.
780 AC_DEFUN([OL_SYS_ERRLIST],
781 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
784 #include <sys/types.h>
785 #include <errno.h> ],
786 [char *c = (char *) *sys_errlist],
787 [ol_cv_dcl_sys_errlist=yes
788 ol_cv_have_sys_errlist=yes],
789 [ol_cv_dcl_sys_errlist=no])])
791 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
792 if test $ol_cv_dcl_sys_errlist = no ; then
793 AC_DEFINE(DECL_SYS_ERRLIST,1,
794 [define if sys_errlist is not declared in stdio.h or errno.h])
796 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
797 AC_TRY_LINK([#include <errno.h>],
798 [char *c = (char *) *sys_errlist],
799 [ol_cv_have_sys_errlist=yes],
800 [ol_cv_have_sys_errlist=no])])
802 if test $ol_cv_have_sys_errlist = yes ; then
803 AC_DEFINE(HAVE_SYS_ERRLIST,1,
804 [define if you actually have sys_errlist in your libs])
808 dnl ====================================================================
809 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
810 dnl "int x; int *volatile a = &x; *a = 0;"
811 dnl -- borrowed from PDKSH
812 AC_DEFUN(OL_C_VOLATILE,
813 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
814 [AC_TRY_COMPILE([int x, y, z;],
815 [volatile int a; int * volatile b = x ? &y : &z;
816 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
817 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
818 if test $ol_cv_c_volatile = yes; then
821 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
825 dnl ====================================================================
826 dnl Look for fetch(3)
827 AC_DEFUN([OL_LIB_FETCH],
829 LIBS="-lfetch -lcom_err $LIBS"
830 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
832 #include <sys/param.h>
835 [struct url *u = fetchParseURL("file:///"); ],
836 [ol_cv_lib_fetch=yes],
837 [ol_cv_lib_fetch=no])])
839 if test $ol_cv_lib_fetch != no ; then
840 ol_link_fetch="-lfetch -lcom_err"
841 AC_DEFINE(HAVE_FETCH,1,
842 [define if you actually have FreeBSD fetch(3)])
846 dnl ====================================================================
847 dnl Define sig_atomic_t if not defined in signal.h
848 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
849 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
850 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
851 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
852 if test $ol_cv_type_sig_atomic_t = no; then
853 AC_DEFINE(sig_atomic_t,int,
854 [define to atomic type if sig_atomic_t is not available])
858 dnl ====================================================================
859 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
860 AC_DEFUN(OL_TYPE_SOCKLEN_T,
861 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
863 #ifdef HAVE_SYS_TYPES_H
864 #include <sys/types.h>
866 #ifdef HAVE_SYS_SOCKET_H
867 #include <sys/socket.h>
870 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
871 if test $ol_cv_type_socklen_t = no; then
872 AC_DEFINE(socklen_t, int,
873 [define to int if socklen_t is not available])
877 dnl ====================================================================
878 dnl Define inet_aton is available
879 AC_DEFUN(OL_FUNC_INET_ATON,
880 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
882 #ifdef HAVE_SYS_TYPES_H
883 # include <sys/types.h>
885 #ifdef HAVE_SYS_SOCKET_H
886 # include <sys/socket.h>
887 # ifdef HAVE_SYS_SELECT_H
888 # include <sys/select.h>
890 # include <netinet/in.h>
891 # ifdef HAVE_ARPA_INET_H
892 # include <arpa/inet.h>
895 ], [struct in_addr in;
896 int rc = inet_aton( "255.255.255.255", &in );],
897 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
898 if test $ol_cv_func_inet_aton != no; then
899 AC_DEFINE(HAVE_INET_ATON, 1,
900 [define to you inet_aton(3) is available])
904 dnl ====================================================================
905 dnl check no of arguments for ctime_r
906 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
907 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
908 [AC_TRY_COMPILE([#include <time.h>],
909 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
910 ol_cv_func_ctime_r_nargs=3,
911 [AC_TRY_COMPILE([#include <time.h>],
912 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
913 ol_cv_func_ctime_r_nargs=2,
914 ol_cv_func_ctime_r_nargs=0)])])
915 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
916 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
917 [set to the number of arguments ctime_r() expects])
921 dnl --------------------------------------------------------------------
922 dnl check return type of ctime_r()
923 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
924 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
925 [AC_TRY_COMPILE([#include <time.h>],
926 [extern int (ctime_r)();],
927 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
929 if test $ol_cv_func_ctime_r_type = "int" ; then
930 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
933 dnl ====================================================================
934 dnl check no of arguments for gethostbyname_r
935 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
936 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
937 ol_cv_func_gethostbyname_r_nargs,
938 [AC_TRY_COMPILE([#include <sys/types.h>
939 #include <sys/socket.h>
940 #include <netinet/in.h>
942 #define BUFSIZE (sizeof(struct hostent)+10)],
943 [struct hostent hent; char buffer[BUFSIZE];
944 int bufsize=BUFSIZE;int h_errno;
945 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
946 buffer, bufsize, &h_errno);],
947 ol_cv_func_gethostbyname_r_nargs=5,
948 [AC_TRY_COMPILE([#include <sys/types.h>
949 #include <sys/socket.h>
950 #include <netinet/in.h>
952 #define BUFSIZE (sizeof(struct hostent)+10)],
953 [struct hostent hent;struct hostent *rhent;
954 char buffer[BUFSIZE];
955 int bufsize=BUFSIZE;int h_errno;
956 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
958 ol_cv_func_gethostbyname_r_nargs=6,
959 ol_cv_func_gethostbyname_r_nargs=0)])])
960 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
961 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
962 $ol_cv_func_gethostbyname_r_nargs,
963 [set to the number of arguments gethostbyname_r() expects])
967 dnl check no of arguments for gethostbyaddr_r
968 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
969 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
970 [ol_cv_func_gethostbyaddr_r_nargs],
971 [AC_TRY_COMPILE([#include <sys/types.h>
972 #include <sys/socket.h>
973 #include <netinet/in.h>
975 #define BUFSIZE (sizeof(struct hostent)+10)],
976 [struct hostent hent; char buffer[BUFSIZE];
978 size_t alen=sizeof(struct in_addr);
979 int bufsize=BUFSIZE;int h_errno;
980 (void)gethostbyaddr_r( (void *)&(add.s_addr),
981 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
982 ol_cv_func_gethostbyaddr_r_nargs=7,
983 [AC_TRY_COMPILE([#include <sys/types.h>
984 #include <sys/socket.h>
985 #include <netinet/in.h>
987 #define BUFSIZE (sizeof(struct hostent)+10)],
988 [struct hostent hent;
989 struct hostent *rhent; char buffer[BUFSIZE];
991 size_t alen=sizeof(struct in_addr);
992 int bufsize=BUFSIZE;int h_errno;
993 (void)gethostbyaddr_r( (void *)&(add.s_addr),
994 alen, AF_INET, &hent, buffer, bufsize,
996 ol_cv_func_gethostbyaddr_r_nargs=8,
997 ol_cv_func_gethostbyaddr_r_nargs=0)])])
998 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
999 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1000 $ol_cv_func_gethostbyaddr_r_nargs,
1001 [set to the number of arguments gethostbyaddr_r() expects])