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 AC_DEFUN([OL_RCS_ID], "[$]$1[$]")dnl
10 dnl --------------------------------------------------------------------
11 dnl Restricted form of AC_ARG_ENABLE that limits user options
15 dnl $3 = default value (auto)
16 dnl $4 = allowed values (auto yes no)
17 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
18 AC_ARG_ENABLE($1,[$2 (]ifelse($3,,auto,$3)[)],[
20 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
21 if test "$enableval" = "$ol_val" ; then
25 if test "$ol_arg" = "invalid" ; then
26 AC_MSG_ERROR(bad value $enableval for --enable-$1)
28 ol_enable_$1="$ol_arg"
30 [ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
31 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
35 dnl --------------------------------------------------------------------
36 dnl Restricted form of AC_ARG_WITH that limits user options
40 dnl $3 = default value (no)
41 dnl $4 = allowed values (yes or no)
42 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
43 AC_ARG_WITH($1,[$2 (]ifelse($3,,yes,$3)[)],[
45 for ol_val in ifelse($4,,[yes no],[$4]) ; do
46 if test "$withval" = "$ol_val" ; then
50 if test "$ol_arg" = "invalid" ; then
51 AC_MSG_ERROR(bad value $withval for --with-$1)
55 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
56 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
60 dnl ====================================================================
61 dnl check if hard links are supported.
63 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
64 AC_MSG_CHECKING(whether ln works)
65 AC_CACHE_VAL(ol_cv_prog_LN_H,
66 [rm -f conftest.src conftest.dst
67 echo "conftest" > conftest.src
68 if ln conftest.src conftest.dst 2>/dev/null
74 rm -f conftest.src conftest.dst
76 LN_H="$ol_cv_prog_LN_H"
77 if test "$ol_cv_prog_LN_H" = "ln"; then
85 dnl ====================================================================
86 dnl Check for dependency generation flag
87 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
90 if test -z "${MKDEP}"; then
92 if test -z "${MKDEP_FLAGS}"; then
93 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
95 for flag in "-M" "-xM"; do
96 cat > conftest.c <<EOF
99 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
100 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
102 if test ! -f conftest."${ac_object}" ; then
104 OL_MKDEP_FLAGS="$flag"
113 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
118 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
121 AC_SUBST(OL_MKDEP_FLAGS)
124 dnl ====================================================================
125 dnl Check if system uses EBCDIC instead of ASCII
126 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
127 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
130 #include <__ASCII__/generate_error.h>
133 [ol_cv_cpp_ebcdic=yes],
134 [ol_cv_cpp_ebcdic=no])])
135 if test $ol_cv_cpp_ebcdic = yes ; then
136 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
140 dnl --------------------------------------------------------------------
141 dnl OpenLDAP version of STDC header check w/ EBCDIC support
142 AC_DEFUN(OL_HEADER_STDC,
144 AC_REQUIRE([OL_CPP_EBCDIC])dnl
145 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
146 [AC_TRY_CPP([#include <stdlib.h>
149 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
151 if test $ol_cv_header_stdc = yes; then
152 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
153 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
156 if test $ol_cv_header_stdc = yes; then
157 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
158 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
161 if test $ol_cv_header_stdc = yes; then
162 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
163 AC_TRY_RUN([#include <ctype.h>
165 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
166 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
168 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
169 || ('j' <= (c) && (c) <= 'r') \
170 || ('s' <= (c) && (c) <= 'z'))
171 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
173 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
174 int main () { int i; for (i = 0; i < 256; i++)
175 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
177 ], , ol_cv_header_stdc=no, :)
179 if test $ol_cv_header_stdc = yes; then
180 AC_DEFINE(STDC_HEADERS)
182 ac_cv_header_stdc=disable
185 dnl ====================================================================
186 dnl Check if struct passwd has pw_gecos
187 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
188 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
189 AC_TRY_COMPILE([#include <pwd.h>],[
191 pwd.pw_gecos = pwd.pw_name;
193 [ol_cv_struct_passwd_pw_gecos=yes],
194 [ol_cv_struct_passwd_pw_gecos=no])])
195 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
196 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
200 dnl --------------------------------------------------------------------
201 dnl Check if struct passwd has pw_passwd
202 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
203 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
204 AC_TRY_COMPILE([#include <pwd.h>],[
206 pwd.pw_passwd = pwd.pw_name;
208 [ol_cv_struct_passwd_pw_passwd=yes],
209 [ol_cv_struct_passwd_pw_passwd=no])])
210 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
211 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
215 dnl ====================================================================
216 dnl Check if db.h is Berkeley DB2
218 dnl defines ol_cv_header_db2 to 'yes' or 'no'
221 dnl AC_CHECK_HEADERS(db.h)
223 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
224 [AC_CHECK_HEADERS(db.h)
225 if test $ac_cv_header_db_h = yes ; then
226 AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
227 AC_EGREP_CPP(__db_version_2,[
229 /* this check could be improved */
230 # ifdef DB_VERSION_MAJOR
231 # if DB_VERSION_MAJOR == 2
235 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
240 dnl --------------------------------------------------------------------
241 dnl Check if Berkeley DB2 library exists
242 dnl Check for dbopen in standard libraries or -ldb
244 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
247 dnl AC_CHECK_LIB(db,db_open)
249 AC_DEFUN([OL_LIB_BERKELEY_DB2],
250 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
252 AC_CHECK_LIB(db,db_open,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
257 dnl --------------------------------------------------------------------
258 dnl Check if Berkeley db2 exists
260 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
263 dnl OL_LIB_BERKELEY_DB2
264 dnl OL_HEADER_BERKELEY_DB2
266 AC_DEFUN([OL_BERKELEY_DB2],
267 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
268 AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
269 AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
270 if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
271 ol_cv_berkeley_db2=no
273 ol_cv_berkeley_db2=yes
276 if test $ol_cv_berkeley_db2 = yes ; then
277 AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
281 dnl ====================================================================
282 dnl Check for db.h/db_185.h is Berkeley DB
284 dnl defines ol_cv_header_db to 'yes' or 'no'
287 dnl OL_HEADER_BERKELEY_DB2
288 dnl AC_CHECK_HEADERS(db_185.h)
290 AC_DEFUN([OL_HEADER_BERKELEY_DB],
291 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
292 AC_CHECK_HEADERS(db_185.h)
293 if test "$ol_cv_header_db2" = yes ; then
296 ol_cv_header_db=$ac_cv_header_db_185_h
298 ol_cv_header_db=$ac_cv_header_db_h
302 dnl --------------------------------------------------------------------
303 dnl Check if Berkeley DB library exists
304 dnl Check for dbopen in standard libraries or -ldb
306 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
307 dnl 'yes' implies dbopen is in $LIBS
310 dnl AC_CHECK_FUNC(dbopen)
311 dnl AC_CHECK_LIB(db,dbopen)
313 AC_DEFUN([OL_LIB_BERKELEY_DB],
314 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
316 AC_CHECK_HEADERS(db1/db.h)
318 AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
319 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
320 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
328 dnl --------------------------------------------------------------------
329 dnl Check if Berkeley DB exists
331 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
334 dnl OL_LIB_BERKELEY_DB
335 dnl OL_HEADER_BERKELEY_DB
337 AC_DEFUN([OL_BERKELEY_DB],
338 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
339 AC_REQUIRE([OL_HEADER_BERKELEY_DB])
340 AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
341 if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
344 ol_cv_berkeley_db=yes
347 if test $ol_cv_berkeley_db = yes ; then
348 AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
352 dnl ====================================================================
353 dnl Check if GDBM library exists
354 dnl Check for gdbm_open in standard libraries or -lgdbm
356 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
357 dnl 'yes' implies gdbm_open is in $LIBS
360 dnl AC_CHECK_FUNC(gdbm_open)
361 dnl AC_CHECK_LIB(gdbm,gdbm_open)
363 AC_DEFUN([OL_LIB_GDBM],
364 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
366 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
367 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
373 dnl --------------------------------------------------------------------
374 dnl Check if GDBM exists
376 dnl defines ol_cv_gdbm to 'yes' or 'no'
380 dnl AC_CHECK_HEADERS(gdbm.h)
383 [AC_REQUIRE([OL_LIB_GDBM])
384 AC_CHECK_HEADERS(gdbm.h)
385 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
386 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
392 if test $ol_cv_gdbm = yes ; then
393 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
397 dnl ====================================================================
398 dnl Check if MDBM library exists
399 dnl Check for mdbm_open in standard libraries or -lmdbm
401 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
402 dnl 'yes' implies mdbm_open is in $LIBS
405 dnl AC_CHECK_FUNC(mdbm_set_chain)
406 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
408 AC_DEFUN([OL_LIB_MDBM],
409 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
411 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
412 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
418 dnl --------------------------------------------------------------------
419 dnl Check if MDBM exists
421 dnl defines ol_cv_mdbm to 'yes' or 'no'
425 dnl AC_CHECK_HEADERS(mdbm.h)
428 [AC_REQUIRE([OL_LIB_MDBM])
429 AC_CHECK_HEADERS(mdbm.h)
430 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
431 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
437 if test $ol_cv_mdbm = yes ; then
438 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
442 dnl ====================================================================
443 dnl Check if NDBM library exists
444 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
446 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
447 dnl 'yes' implies ndbm_open is in $LIBS
450 dnl AC_CHECK_FUNC(dbm_open)
451 dnl AC_CHECK_LIB(ndbm,dbm_open)
452 dnl AC_CHECK_LIB(dbm,dbm_open)
455 dnl should also check SVR4 case: dbm_open() in -lucb but that
456 dnl would requiring dealing with -L/usr/ucblib
458 AC_DEFUN([OL_LIB_NDBM],
459 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
461 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
462 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
463 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
464 [ol_cv_lib_ndbm=no])dnl
471 dnl --------------------------------------------------------------------
472 dnl Check if NDBM exists
474 dnl defines ol_cv_ndbm to 'yes' or 'no'
478 dnl AC_CHECK_HEADERS(ndbm.h)
481 dnl Doesn't handle SVR4 case (see above)
484 [AC_REQUIRE([OL_LIB_NDBM])
485 AC_CHECK_HEADERS(ndbm.h)
486 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
487 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
493 if test $ol_cv_ndbm = yes ; then
494 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
498 dnl ====================================================================
499 dnl Check POSIX Thread version
501 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
502 dnl 'unknown' implies that the version could not be detected
503 dnl or that pthreads.h does exist. Existance of pthreads.h
504 dnl should be tested separately.
506 AC_DEFUN([OL_POSIX_THREAD_VERSION],
507 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
508 AC_EGREP_CPP(pthread_version_final,[
509 # include <pthread.h>
510 /* this check could be improved */
511 # ifdef PTHREAD_ONCE_INIT
512 pthread_version_final
514 ], ol_pthread_final=yes, ol_pthread_final=no)
516 AC_EGREP_CPP(pthread_version_draft4,[
517 # include <pthread.h>
518 /* this check could be improved */
519 # ifdef pthread_once_init
520 pthread_version_draft4
522 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
524 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
525 ol_cv_pthread_version=final
526 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
527 ol_cv_pthread_version=draft4
529 ol_cv_pthread_version=unknown
534 dnl --------------------------------------------------------------------
535 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
536 [/* pthread test headers */
539 #define NULL (void*)0
545 return (void *) (p == NULL);
548 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
549 /* pthread test function */
553 /* make sure pthread_create() isn't just a stub */
555 status = pthread_create(&t, pthread_attr_default, task, NULL);
557 status = pthread_create(&t, NULL, task, NULL);
560 if( status ) exit( status );
562 /* make sure pthread_detach() isn't just a stub */
564 status = pthread_detach( &t );
566 status = pthread_detach( t );
569 #ifdef HAVE_LINUX_THREADS
570 pthread_kill_other_threads_np();
576 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
577 [OL_PTHREAD_TEST_INCLUDES
583 OL_PTHREAD_TEST_FUNCTION
586 dnl --------------------------------------------------------------------
587 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
588 if test "$ol_link_threads" = no ; then
590 AC_CACHE_CHECK([for pthread link with $1], [$2], [
595 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
597 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
604 if test $$2 = yes ; then
605 ol_link_pthreads="$1"
606 ol_link_threads=posix
611 dnl ====================================================================
612 dnl Check GNU Pth pthread Header
614 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
615 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
616 dnl doesn't exists. Existance of pthread.h should separately
619 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
620 AC_CACHE_CHECK([for GNU Pth pthread.h],
621 [ol_cv_header_gnu_pth_pthread_h],
622 [AC_EGREP_CPP(__gnu_pth__,
623 [#include <pthread.h>
624 #ifdef _POSIX_THREAD_IS_GNU_PTH
628 [ol_cv_header_gnu_pth_pthread_h=yes],
629 [ol_cv_header_gnu_pth_pthread_h=no])
632 dnl ====================================================================
633 dnl Check LinuxThreads Header
635 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
636 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
637 dnl doesn't exists. Existance of pthread.h should separately
640 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
641 AC_CACHE_CHECK([for LinuxThreads pthread.h],
642 [ol_cv_header_linux_threads],
643 [AC_EGREP_CPP(pthread_kill_other_threads_np,
644 [#include <pthread.h>],
645 [ol_cv_header_linux_threads=yes],
646 [ol_cv_header_linux_threads=no])
648 if test $ol_cv_header_linux_threads = yes; then
649 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
652 dnl --------------------------------------------------------------------
653 dnl Check LinuxThreads Implementation
655 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
656 dnl 'no' implies pthreads implementation is not LinuxThreads.
658 AC_DEFUN([OL_SYS_LINUX_THREADS], [
659 AC_CHECK_FUNC(pthread_kill_other_threads_np)
660 AC_CACHE_CHECK([for LinuxThreads implementation],
661 [ol_cv_sys_linux_threads],
662 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
665 dnl --------------------------------------------------------------------
666 dnl Check LinuxThreads consistency
667 AC_DEFUN([OL_LINUX_THREADS], [
668 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
669 AC_REQUIRE([OL_SYS_LINUX_THREADS])
670 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
671 if test $ol_cv_header_linux_threads = yes -a \
672 $ol_cv_sys_linux_threads = yes; then
673 ol_cv_linux_threads=yes
674 elif test $ol_cv_header_linux_threads = no -a \
675 $ol_cv_sys_linux_threads = no; then
676 ol_cv_linux_threads=no
678 ol_cv_linux_threads=error
683 dnl ====================================================================
684 dnl Check for POSIX Regex
685 AC_DEFUN([OL_POSIX_REGEX], [
686 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
688 #include <sys/types.h>
690 static char *pattern, *string;
698 if(regcomp(&re, pattern, 0)) {
702 string = "ALL MATCH";
704 rc = regexec(&re, string, 0, (void*)0, 0);
710 [ol_cv_c_posix_regex=yes],
711 [ol_cv_c_posix_regex=no],
712 [ol_cv_c_posix_regex=cross])])
715 dnl ====================================================================
716 dnl Check if toupper() requires islower() to be called first
717 AC_DEFUN([OL_C_UPPER_LOWER],
718 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
723 if ('C' == toupper('C'))
728 [ol_cv_c_upper_lower=no],
729 [ol_cv_c_upper_lower=yes],
730 [ol_cv_c_upper_lower=safe])])
731 if test $ol_cv_c_upper_lower != no ; then
732 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
736 dnl ====================================================================
737 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
738 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
739 dnl Reported by Keith Bostic.
740 AC_DEFUN([OL_SYS_ERRLIST],
741 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
744 #include <sys/types.h>
745 #include <errno.h> ],
746 [char *c = (char *) *sys_errlist],
747 [ol_cv_dcl_sys_errlist=yes
748 ol_cv_have_sys_errlist=yes],
749 [ol_cv_dcl_sys_errlist=no])])
751 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
752 if test $ol_cv_dcl_sys_errlist = no ; then
753 AC_DEFINE(DECL_SYS_ERRLIST,1,
754 [define if sys_errlist is not declared in stdio.h or errno.h])
756 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
757 AC_TRY_LINK([#include <errno.h>],
758 [char *c = (char *) *sys_errlist],
759 [ol_cv_have_sys_errlist=yes],
760 [ol_cv_have_sys_errlist=no])])
762 if test $ol_cv_have_sys_errlist = yes ; then
763 AC_DEFINE(HAVE_SYS_ERRLIST,1,
764 [define if you actually have sys_errlist in your libs])
768 dnl ====================================================================
769 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
770 dnl "int x; int *volatile a = &x; *a = 0;"
771 dnl -- borrowed from PDKSH
772 AC_DEFUN(OL_C_VOLATILE,
773 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
774 [AC_TRY_COMPILE([int x, y, z;],
775 [volatile int a; int * volatile b = x ? &y : &z;
776 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
777 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
778 if test $ol_cv_c_volatile = yes; then
781 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
785 dnl ====================================================================
786 dnl Look for fetch(3)
787 AC_DEFUN([OL_LIB_FETCH],
789 LIBS="-lfetch -lcom_err $LIBS"
790 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
792 #include <sys/param.h>
795 [struct url *u = fetchParseURL("file:///"); ],
796 [ol_cv_lib_fetch=yes],
797 [ol_cv_lib_fetch=no])])
799 if test $ol_cv_lib_fetch != no ; then
800 ol_link_fetch="-lfetch -lcom_err"
801 AC_DEFINE(HAVE_FETCH,1,
802 [define if you actually have FreeBSD fetch(3)])
806 dnl ====================================================================
807 dnl Define sig_atomic_t if not defined in signal.h
808 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
809 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
810 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
811 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
812 if test $ol_cv_type_sig_atomic_t = no; then
813 AC_DEFINE(sig_atomic_t,int,
814 [define to atomic type if sig_atomic_t is not available])
818 dnl ====================================================================
819 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
820 AC_DEFUN(OL_TYPE_SOCKLEN_T,
821 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
823 #ifdef HAVE_SYS_TYPES_H
824 #include <sys/types.h>
826 #ifdef HAVE_SYS_SOCKET_H
827 #include <sys/socket.h>
830 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
831 if test $ol_cv_type_socklen_t = no; then
832 AC_DEFINE(socklen_t, int,
833 [define to int if socklen_t is not available])
837 dnl ====================================================================
838 dnl Define inet_aton is available
839 AC_DEFUN(OL_FUNC_INET_ATON,
840 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
842 #ifdef HAVE_SYS_TYPES_H
843 # include <sys/types.h>
845 #ifdef HAVE_SYS_SOCKET_H
846 # include <sys/socket.h>
847 # ifdef HAVE_SYS_SELECT_H
848 # include <sys/select.h>
850 # include <netinet/in.h>
851 # ifdef HAVE_ARPA_INET_H
852 # include <arpa/inet.h>
855 ], [struct in_addr in;
856 int rc = inet_aton( "255.255.255.255", &in );],
857 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
858 if test $ol_cv_func_inet_aton != no; then
859 AC_DEFINE(HAVE_INET_ATON, 1,
860 [define to you inet_aton(3) is available])
864 dnl ====================================================================
865 dnl check no of arguments for ctime_r
866 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
867 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
868 [AC_TRY_COMPILE([#include <time.h>],
869 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
870 ol_cv_func_ctime_r_nargs=3,
871 [AC_TRY_COMPILE([#include <time.h>],
872 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
873 ol_cv_func_ctime_r_nargs=2,
874 ol_cv_func_ctime_r_nargs=0)])])
875 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
876 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
877 [set to the number of arguments ctime_r() expects])
881 dnl --------------------------------------------------------------------
882 dnl check return type of ctime_r()
883 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
884 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
885 [AC_TRY_COMPILE([#include <time.h>],
886 [extern int (ctime_r)();],
887 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
889 if test $ol_cv_func_ctime_r_type = "int" ; then
890 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
893 dnl ====================================================================
894 dnl check no of arguments for gethostbyname_r
895 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
896 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
897 ol_cv_func_gethostbyname_r_nargs,
898 [AC_TRY_COMPILE([#include <sys/types.h>
899 #include <sys/socket.h>
900 #include <netinet/in.h>
902 #define BUFSIZE (sizeof(struct hostent)+10)],
903 [struct hostent hent; char buffer[BUFSIZE];
904 int bufsize=BUFSIZE;int h_errno;
905 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
906 buffer, bufsize, &h_errno);],
907 ol_cv_func_gethostbyname_r_nargs=5,
908 [AC_TRY_COMPILE([#include <sys/types.h>
909 #include <sys/socket.h>
910 #include <netinet/in.h>
912 #define BUFSIZE (sizeof(struct hostent)+10)],
913 [struct hostent hent;struct hostent *rhent;
914 char buffer[BUFSIZE];
915 int bufsize=BUFSIZE;int h_errno;
916 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
918 ol_cv_func_gethostbyname_r_nargs=6,
919 ol_cv_func_gethostbyname_r_nargs=0)])])
920 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
921 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
922 $ol_cv_func_gethostbyname_r_nargs,
923 [set to the number of arguments gethostbyname_r() expects])
927 dnl check no of arguments for gethostbyaddr_r
928 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
929 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
930 [ol_cv_func_gethostbyaddr_r_nargs],
931 [AC_TRY_COMPILE([#include <sys/types.h>
932 #include <sys/socket.h>
933 #include <netinet/in.h>
935 #define BUFSIZE (sizeof(struct hostent)+10)],
936 [struct hostent hent; char buffer[BUFSIZE];
938 size_t alen=sizeof(struct in_addr);
939 int bufsize=BUFSIZE;int h_errno;
940 (void)gethostbyaddr_r( (void *)&(add.s_addr),
941 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
942 ol_cv_func_gethostbyaddr_r_nargs=7,
943 [AC_TRY_COMPILE([#include <sys/types.h>
944 #include <sys/socket.h>
945 #include <netinet/in.h>
947 #define BUFSIZE (sizeof(struct hostent)+10)],
948 [struct hostent hent;
949 struct hostent *rhent; char buffer[BUFSIZE];
951 size_t alen=sizeof(struct in_addr);
952 int bufsize=BUFSIZE;int h_errno;
953 (void)gethostbyaddr_r( (void *)&(add.s_addr),
954 alen, AF_INET, &hent, buffer, bufsize,
956 ol_cv_func_gethostbyaddr_r_nargs=8,
957 ol_cv_func_gethostbyaddr_r_nargs=0)])])
958 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
959 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
960 $ol_cv_func_gethostbyaddr_r_nargs,
961 [set to the number of arguments gethostbyaddr_r() expects])