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_open)
247 AC_DEFUN([OL_LIB_BERKELEY_DB2],
248 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
250 AC_CHECK_LIB(db,db_open,[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])
279 dnl ====================================================================
280 dnl Check for db.h/db_185.h is Berkeley DB
282 dnl defines ol_cv_header_db to 'yes' or 'no'
285 dnl OL_HEADER_BERKELEY_DB2
286 dnl AC_CHECK_HEADERS(db_185.h)
288 AC_DEFUN([OL_HEADER_BERKELEY_DB],
289 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
290 AC_CHECK_HEADERS(db_185.h)
291 if test "$ol_cv_header_db2" = yes ; then
294 ol_cv_header_db=$ac_cv_header_db_185_h
296 ol_cv_header_db=$ac_cv_header_db_h
300 dnl --------------------------------------------------------------------
301 dnl Check if Berkeley DB library exists
302 dnl Check for dbopen in standard libraries or -ldb
304 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
305 dnl 'yes' implies dbopen is in $LIBS
308 dnl AC_CHECK_FUNC(dbopen)
309 dnl AC_CHECK_LIB(db,dbopen)
311 AC_DEFUN([OL_LIB_BERKELEY_DB],
312 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
314 AC_CHECK_HEADERS(db1/db.h)
316 AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
317 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
318 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
326 dnl --------------------------------------------------------------------
327 dnl Check if Berkeley DB exists
329 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
332 dnl OL_LIB_BERKELEY_DB
333 dnl OL_HEADER_BERKELEY_DB
335 AC_DEFUN([OL_BERKELEY_DB],
336 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
337 AC_REQUIRE([OL_HEADER_BERKELEY_DB])
338 AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
339 if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
342 ol_cv_berkeley_db=yes
345 if test $ol_cv_berkeley_db = yes ; then
346 AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
350 dnl ====================================================================
351 dnl Check if GDBM library exists
352 dnl Check for gdbm_open in standard libraries or -lgdbm
354 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
355 dnl 'yes' implies gdbm_open is in $LIBS
358 dnl AC_CHECK_FUNC(gdbm_open)
359 dnl AC_CHECK_LIB(gdbm,gdbm_open)
361 AC_DEFUN([OL_LIB_GDBM],
362 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
364 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
365 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
371 dnl --------------------------------------------------------------------
372 dnl Check if GDBM exists
374 dnl defines ol_cv_gdbm to 'yes' or 'no'
378 dnl AC_CHECK_HEADERS(gdbm.h)
381 [AC_REQUIRE([OL_LIB_GDBM])
382 AC_CHECK_HEADERS(gdbm.h)
383 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
384 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
390 if test $ol_cv_gdbm = yes ; then
391 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
395 dnl ====================================================================
396 dnl Check if MDBM library exists
397 dnl Check for mdbm_open in standard libraries or -lmdbm
399 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
400 dnl 'yes' implies mdbm_open is in $LIBS
403 dnl AC_CHECK_FUNC(mdbm_set_chain)
404 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
406 AC_DEFUN([OL_LIB_MDBM],
407 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
409 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
410 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
416 dnl --------------------------------------------------------------------
417 dnl Check if MDBM exists
419 dnl defines ol_cv_mdbm to 'yes' or 'no'
423 dnl AC_CHECK_HEADERS(mdbm.h)
426 [AC_REQUIRE([OL_LIB_MDBM])
427 AC_CHECK_HEADERS(mdbm.h)
428 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
429 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
435 if test $ol_cv_mdbm = yes ; then
436 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
440 dnl ====================================================================
441 dnl Check if NDBM library exists
442 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
444 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
445 dnl 'yes' implies ndbm_open is in $LIBS
448 dnl AC_CHECK_FUNC(dbm_open)
449 dnl AC_CHECK_LIB(ndbm,dbm_open)
450 dnl AC_CHECK_LIB(dbm,dbm_open)
453 dnl should also check SVR4 case: dbm_open() in -lucb but that
454 dnl would requiring dealing with -L/usr/ucblib
456 AC_DEFUN([OL_LIB_NDBM],
457 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
459 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
460 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
461 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
462 [ol_cv_lib_ndbm=no])dnl
469 dnl --------------------------------------------------------------------
470 dnl Check if NDBM exists
472 dnl defines ol_cv_ndbm to 'yes' or 'no'
476 dnl AC_CHECK_HEADERS(ndbm.h)
479 dnl Doesn't handle SVR4 case (see above)
482 [AC_REQUIRE([OL_LIB_NDBM])
483 AC_CHECK_HEADERS(ndbm.h)
484 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
485 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
491 if test $ol_cv_ndbm = yes ; then
492 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
496 dnl ====================================================================
497 dnl Check POSIX Thread version
499 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
500 dnl 'unknown' implies that the version could not be detected
501 dnl or that pthreads.h does exist. Existance of pthreads.h
502 dnl should be tested separately.
504 AC_DEFUN([OL_POSIX_THREAD_VERSION],
505 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
506 AC_EGREP_CPP(pthread_version_final,[
507 # include <pthread.h>
508 /* this check could be improved */
509 # ifdef PTHREAD_ONCE_INIT
510 pthread_version_final;
512 ], ol_pthread_final=yes, ol_pthread_final=no)
514 AC_EGREP_CPP(pthread_version_draft4,[
515 # include <pthread.h>
516 /* this check could be improved */
517 # ifdef pthread_once_init
518 pthread_version_draft4;
520 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
522 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
523 ol_cv_pthread_version=final
524 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
525 ol_cv_pthread_version=draft4
527 ol_cv_pthread_version=unknown
532 dnl --------------------------------------------------------------------
533 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
534 [/* pthread test headers */
537 #define NULL (void*)0
543 return (void *) (p == NULL);
546 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
547 /* pthread test function */
551 /* make sure pthread_create() isn't just a stub */
553 status = pthread_create(&t, pthread_attr_default, task, NULL);
555 status = pthread_create(&t, NULL, task, NULL);
558 if( status ) exit( status );
560 /* make sure pthread_detach() isn't just a stub */
562 status = pthread_detach( &t );
564 status = pthread_detach( t );
567 #ifdef HAVE_LINUX_THREADS
568 pthread_kill_other_threads_np();
574 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
575 [OL_PTHREAD_TEST_INCLUDES
581 OL_PTHREAD_TEST_FUNCTION
584 dnl --------------------------------------------------------------------
585 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
586 if test "$ol_link_threads" = no ; then
588 AC_CACHE_CHECK([for pthread link with $1], [$2], [
593 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
595 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
602 if test $$2 = yes ; then
603 ol_link_pthreads="$1"
604 ol_link_threads=posix
609 dnl ====================================================================
610 dnl Check GNU Pth pthread Header
612 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
613 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
614 dnl doesn't exists. Existance of pthread.h should separately
617 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
618 AC_CACHE_CHECK([for GNU Pth pthread.h],
619 [ol_cv_header_gnu_pth_pthread_h],
620 [AC_EGREP_CPP(__gnu_pth__,
621 [#include <pthread.h>
622 #ifdef _POSIX_THREAD_IS_GNU_PTH
626 [ol_cv_header_gnu_pth_pthread_h=yes],
627 [ol_cv_header_gnu_pth_pthread_h=no])
630 dnl ====================================================================
631 dnl Check LinuxThreads Header
633 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
634 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
635 dnl doesn't exists. Existance of pthread.h should separately
638 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
639 AC_CACHE_CHECK([for LinuxThreads pthread.h],
640 [ol_cv_header_linux_threads],
641 [AC_EGREP_CPP(pthread_kill_other_threads_np,
642 [#include <pthread.h>],
643 [ol_cv_header_linux_threads=yes],
644 [ol_cv_header_linux_threads=no])
646 if test $ol_cv_header_linux_threads = yes; then
647 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
650 dnl --------------------------------------------------------------------
651 dnl Check LinuxThreads Implementation
653 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
654 dnl 'no' implies pthreads implementation is not LinuxThreads.
656 AC_DEFUN([OL_SYS_LINUX_THREADS], [
657 AC_CHECK_FUNC(pthread_kill_other_threads_np)
658 AC_CACHE_CHECK([for LinuxThreads implementation],
659 [ol_cv_sys_linux_threads],
660 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
663 dnl --------------------------------------------------------------------
664 dnl Check LinuxThreads consistency
665 AC_DEFUN([OL_LINUX_THREADS], [
666 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
667 AC_REQUIRE([OL_SYS_LINUX_THREADS])
668 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
669 if test $ol_cv_header_linux_threads = yes -a \
670 $ol_cv_sys_linux_threads = yes; then
671 ol_cv_linux_threads=yes
672 elif test $ol_cv_header_linux_threads = no -a \
673 $ol_cv_sys_linux_threads = no; then
674 ol_cv_linux_threads=no
676 ol_cv_linux_threads=error
681 dnl ====================================================================
682 dnl Check for POSIX Regex
683 AC_DEFUN([OL_POSIX_REGEX], [
684 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
686 #include <sys/types.h>
688 static char *pattern, *string;
696 if(regcomp(&re, pattern, 0)) {
700 string = "ALL MATCH";
702 rc = regexec(&re, string, 0, (void*)0, 0);
708 [ol_cv_c_posix_regex=yes],
709 [ol_cv_c_posix_regex=no],
710 [ol_cv_c_posix_regex=cross])])
713 dnl ====================================================================
714 dnl Check if toupper() requires islower() to be called first
715 AC_DEFUN([OL_C_UPPER_LOWER],
716 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
721 if ('C' == toupper('C'))
726 [ol_cv_c_upper_lower=no],
727 [ol_cv_c_upper_lower=yes],
728 [ol_cv_c_upper_lower=safe])])
729 if test $ol_cv_c_upper_lower != no ; then
730 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
734 dnl ====================================================================
735 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
736 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
737 dnl Reported by Keith Bostic.
738 AC_DEFUN([OL_SYS_ERRLIST],
739 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
742 #include <sys/types.h>
743 #include <errno.h> ],
744 [char *c = (char *) *sys_errlist],
745 [ol_cv_dcl_sys_errlist=yes
746 ol_cv_have_sys_errlist=yes],
747 [ol_cv_dcl_sys_errlist=no])])
749 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
750 if test $ol_cv_dcl_sys_errlist = no ; then
751 AC_DEFINE(DECL_SYS_ERRLIST,1,
752 [define if sys_errlist is not declared in stdio.h or errno.h])
754 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
755 AC_TRY_LINK([#include <errno.h>],
756 [char *c = (char *) *sys_errlist],
757 [ol_cv_have_sys_errlist=yes],
758 [ol_cv_have_sys_errlist=no])])
760 if test $ol_cv_have_sys_errlist = yes ; then
761 AC_DEFINE(HAVE_SYS_ERRLIST,1,
762 [define if you actually have sys_errlist in your libs])
766 dnl ====================================================================
767 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
768 dnl "int x; int *volatile a = &x; *a = 0;"
769 dnl -- borrowed from PDKSH
770 AC_DEFUN(OL_C_VOLATILE,
771 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
772 [AC_TRY_COMPILE([int x, y, z;],
773 [volatile int a; int * volatile b = x ? &y : &z;
774 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
775 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
776 if test $ol_cv_c_volatile = yes; then
779 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
783 dnl ====================================================================
784 dnl Look for fetch(3)
785 AC_DEFUN([OL_LIB_FETCH],
787 LIBS="-lfetch -lcom_err $LIBS"
788 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
790 #include <sys/param.h>
793 [struct url *u = fetchParseURL("file:///"); ],
794 [ol_cv_lib_fetch=yes],
795 [ol_cv_lib_fetch=no])])
797 if test $ol_cv_lib_fetch != no ; then
798 ol_link_fetch="-lfetch -lcom_err"
799 AC_DEFINE(HAVE_FETCH,1,
800 [define if you actually have FreeBSD fetch(3)])
804 dnl ====================================================================
805 dnl Define sig_atomic_t if not defined in signal.h
806 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
807 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
808 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
809 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
810 if test $ol_cv_type_sig_atomic_t = no; then
811 AC_DEFINE(sig_atomic_t,int,
812 [define to atomic type if sig_atomic_t is not available])
816 dnl ====================================================================
817 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
818 AC_DEFUN(OL_TYPE_SOCKLEN_T,
819 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
821 #ifdef HAVE_SYS_TYPES_H
822 #include <sys/types.h>
824 #ifdef HAVE_SYS_SOCKET_H
825 #include <sys/socket.h>
828 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
829 if test $ol_cv_type_socklen_t = no; then
830 AC_DEFINE(socklen_t, int,
831 [define to int if socklen_t is not available])
835 dnl ====================================================================
836 dnl Define inet_aton is available
837 AC_DEFUN(OL_FUNC_INET_ATON,
838 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
840 #ifdef HAVE_SYS_TYPES_H
841 # include <sys/types.h>
843 #ifdef HAVE_SYS_SOCKET_H
844 # include <sys/socket.h>
845 # ifdef HAVE_SYS_SELECT_H
846 # include <sys/select.h>
848 # include <netinet/in.h>
849 # ifdef HAVE_ARPA_INET_H
850 # include <arpa/inet.h>
853 ], [struct in_addr in;
854 int rc = inet_aton( "255.255.255.255", &in );],
855 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
856 if test $ol_cv_func_inet_aton != no; then
857 AC_DEFINE(HAVE_INET_ATON, 1,
858 [define to you inet_aton(3) is available])
862 dnl ====================================================================
863 dnl check no of arguments for ctime_r
864 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
865 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
866 [AC_TRY_COMPILE([#include <time.h>],
867 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
868 ol_cv_func_ctime_r_nargs=3,
869 [AC_TRY_COMPILE([#include <time.h>],
870 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
871 ol_cv_func_ctime_r_nargs=2,
872 ol_cv_func_ctime_r_nargs=0)])])
873 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
874 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
875 [set to the number of arguments ctime_r() expects])
879 dnl --------------------------------------------------------------------
880 dnl check return type of ctime_r()
881 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
882 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
883 [AC_TRY_COMPILE([#include <time.h>],
884 [extern int (ctime_r)();],
885 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
887 if test $ol_cv_func_ctime_r_type = "int" ; then
888 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
891 dnl ====================================================================
892 dnl check no of arguments for gethostbyname_r
893 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
894 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
895 ol_cv_func_gethostbyname_r_nargs,
896 [AC_TRY_COMPILE([#include <sys/types.h>
897 #include <sys/socket.h>
898 #include <netinet/in.h>
900 #define BUFSIZE (sizeof(struct hostent)+10)],
901 [struct hostent hent; char buffer[BUFSIZE];
902 int bufsize=BUFSIZE;int h_errno;
903 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
904 buffer, bufsize, &h_errno);],
905 ol_cv_func_gethostbyname_r_nargs=5,
906 [AC_TRY_COMPILE([#include <sys/types.h>
907 #include <sys/socket.h>
908 #include <netinet/in.h>
910 #define BUFSIZE (sizeof(struct hostent)+10)],
911 [struct hostent hent;struct hostent *rhent;
912 char buffer[BUFSIZE];
913 int bufsize=BUFSIZE;int h_errno;
914 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
916 ol_cv_func_gethostbyname_r_nargs=6,
917 ol_cv_func_gethostbyname_r_nargs=0)])])
918 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
919 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
920 $ol_cv_func_gethostbyname_r_nargs,
921 [set to the number of arguments gethostbyname_r() expects])
925 dnl check no of arguments for gethostbyaddr_r
926 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
927 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
928 [ol_cv_func_gethostbyaddr_r_nargs],
929 [AC_TRY_COMPILE([#include <sys/types.h>
930 #include <sys/socket.h>
931 #include <netinet/in.h>
933 #define BUFSIZE (sizeof(struct hostent)+10)],
934 [struct hostent hent; char buffer[BUFSIZE];
936 size_t alen=sizeof(struct in_addr);
937 int bufsize=BUFSIZE;int h_errno;
938 (void)gethostbyaddr_r( (void *)&(add.s_addr),
939 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
940 ol_cv_func_gethostbyaddr_r_nargs=7,
941 [AC_TRY_COMPILE([#include <sys/types.h>
942 #include <sys/socket.h>
943 #include <netinet/in.h>
945 #define BUFSIZE (sizeof(struct hostent)+10)],
946 [struct hostent hent;
947 struct hostent *rhent; char buffer[BUFSIZE];
949 size_t alen=sizeof(struct in_addr);
950 int bufsize=BUFSIZE;int h_errno;
951 (void)gethostbyaddr_r( (void *)&(add.s_addr),
952 alen, AF_INET, &hent, buffer, bufsize,
954 ol_cv_func_gethostbyaddr_r_nargs=8,
955 ol_cv_func_gethostbyaddr_r_nargs=0)])])
956 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
957 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
958 $ol_cv_func_gethostbyaddr_r_nargs,
959 [set to the number of arguments gethostbyaddr_r() expects])