1 dnl Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
2 dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
4 dnl OpenLDAP Autoconf Macros
6 dnl --------------------------------------------------------------------
7 dnl Restricted form of AC_ARG_ENABLE that limits user options
11 dnl $3 = default value (auto)
12 dnl $4 = allowed values (auto yes no)
13 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
14 AC_ARG_ENABLE($1,[$2 (]ifelse($3,,auto,$3)[)],[
16 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
17 if test "$enableval" = "$ol_val" ; then
21 if test "$ol_arg" = "invalid" ; then
22 AC_MSG_ERROR(bad value $enableval for --enable-$1)
24 ol_enable_$1="$ol_arg"
26 [ ol_enable_$1=ifelse($3,,"auto","$3")])dnl
27 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
31 dnl --------------------------------------------------------------------
32 dnl Restricted form of AC_ARG_WITH that limits user options
36 dnl $3 = default value (no)
37 dnl $4 = allowed values (yes or no)
38 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
39 AC_ARG_WITH($1,[$2 (]ifelse($3,,yes,$3)[)],[
41 for ol_val in ifelse($4,,[yes no],[$4]) ; do
42 if test "$withval" = "$ol_val" ; then
46 if test "$ol_arg" = "invalid" ; then
47 AC_MSG_ERROR(bad value $withval for --with-$1)
51 [ ol_with_$1=ifelse($3,,"no","$3")])dnl
52 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
56 dnl ====================================================================
57 dnl check if hard links are supported.
59 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
60 AC_MSG_CHECKING(whether ln works)
61 AC_CACHE_VAL(ol_cv_prog_LN_H,
62 [rm -f conftest.src conftest.dst
63 echo "conftest" > conftest.src
64 if ln conftest.src conftest.dst 2>/dev/null
70 rm -f conftest.src conftest.dst
72 LN_H="$ol_cv_prog_LN_H"
73 if test "$ol_cv_prog_LN_H" = "ln"; then
81 dnl ====================================================================
82 dnl Check for dependency generation flag
83 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
86 if test -z "${MKDEP}"; then
88 if test -z "${MKDEP_FLAGS}"; then
89 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
91 for flag in "-M" "-xM"; do
92 cat > conftest.c <<EOF
95 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
96 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
98 if test ! -f conftest."${ac_object}" ; then
100 OL_MKDEP_FLAGS="$flag"
109 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
114 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
117 AC_SUBST(OL_MKDEP_FLAGS)
120 dnl ====================================================================
121 dnl Check if system uses EBCDIC instead of ASCII
122 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
123 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
126 #include <__ASCII__/generate_error.h>
129 [ol_cv_cpp_ebcdic=yes],
130 [ol_cv_cpp_ebcdic=no])])
131 if test $ol_cv_cpp_ebcdic = yes ; then
132 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
136 dnl --------------------------------------------------------------------
137 dnl OpenLDAP version of STDC header check w/ EBCDIC support
138 AC_DEFUN(OL_HEADER_STDC,
140 AC_REQUIRE([OL_CPP_EBCDIC])dnl
141 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
142 [AC_TRY_CPP([#include <stdlib.h>
145 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
147 if test $ol_cv_header_stdc = yes; then
148 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
149 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
152 if test $ol_cv_header_stdc = yes; then
153 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
154 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
157 if test $ol_cv_header_stdc = yes; then
158 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
159 AC_TRY_RUN([#include <ctype.h>
161 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
162 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
164 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
165 || ('j' <= (c) && (c) <= 'r') \
166 || ('s' <= (c) && (c) <= 'z'))
167 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
169 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
170 int main () { int i; for (i = 0; i < 256; i++)
171 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
173 ], , ol_cv_header_stdc=no, :)
175 if test $ol_cv_header_stdc = yes; then
176 AC_DEFINE(STDC_HEADERS)
178 ac_cv_header_stdc=disable
181 dnl ====================================================================
182 dnl Check if struct passwd has pw_gecos
183 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
184 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
185 AC_TRY_COMPILE([#include <pwd.h>],[
187 pwd.pw_gecos = pwd.pw_name;
189 [ol_cv_struct_passwd_pw_gecos=yes],
190 [ol_cv_struct_passwd_pw_gecos=no])])
191 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
192 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
196 dnl --------------------------------------------------------------------
197 dnl Check if struct passwd has pw_passwd
198 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
199 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
200 AC_TRY_COMPILE([#include <pwd.h>],[
202 pwd.pw_passwd = pwd.pw_name;
204 [ol_cv_struct_passwd_pw_passwd=yes],
205 [ol_cv_struct_passwd_pw_passwd=no])])
206 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
207 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
211 dnl ====================================================================
212 dnl Check if db.h is Berkeley DB2
214 dnl defines ol_cv_header_db2 to 'yes' or 'no'
217 dnl AC_CHECK_HEADERS(db.h)
219 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
220 [AC_CHECK_HEADERS(db.h)
221 if test $ac_cv_header_db_h = yes ; then
222 AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
223 AC_EGREP_CPP(__db_version_2,[
225 /* this check could be improved */
226 # ifdef DB_VERSION_MAJOR
227 # if DB_VERSION_MAJOR == 2
231 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
236 dnl --------------------------------------------------------------------
237 dnl Check if Berkeley DB2 library exists
238 dnl Check for dbopen in standard libraries or -ldb
240 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
243 dnl AC_CHECK_LIB(db,db_open)
245 AC_DEFUN([OL_LIB_BERKELEY_DB2],
246 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
248 AC_CHECK_LIB(db,db_open,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
253 dnl --------------------------------------------------------------------
254 dnl Check if Berkeley db2 exists
256 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
259 dnl OL_LIB_BERKELEY_DB2
260 dnl OL_HEADER_BERKELEY_DB2
262 AC_DEFUN([OL_BERKELEY_DB2],
263 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
264 AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
265 AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
266 if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
267 ol_cv_berkeley_db2=no
269 ol_cv_berkeley_db2=yes
272 if test $ol_cv_berkeley_db2 = yes ; then
273 AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
277 dnl ====================================================================
278 dnl Check for db.h/db_185.h is Berkeley DB
280 dnl defines ol_cv_header_db to 'yes' or 'no'
283 dnl OL_HEADER_BERKELEY_DB2
284 dnl AC_CHECK_HEADERS(db_185.h)
286 AC_DEFUN([OL_HEADER_BERKELEY_DB],
287 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
288 AC_CHECK_HEADERS(db_185.h)
289 if test "$ol_cv_header_db2" = yes ; then
292 ol_cv_header_db=$ac_cv_header_db_185_h
294 ol_cv_header_db=$ac_cv_header_db_h
298 dnl --------------------------------------------------------------------
299 dnl Check if Berkeley DB library exists
300 dnl Check for dbopen in standard libraries or -ldb
302 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
303 dnl 'yes' implies dbopen is in $LIBS
306 dnl AC_CHECK_FUNC(dbopen)
307 dnl AC_CHECK_LIB(db,dbopen)
309 AC_DEFUN([OL_LIB_BERKELEY_DB],
310 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
312 AC_CHECK_HEADERS(db1/db.h)
314 AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
315 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
316 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
324 dnl --------------------------------------------------------------------
325 dnl Check if Berkeley DB exists
327 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
330 dnl OL_LIB_BERKELEY_DB
331 dnl OL_HEADER_BERKELEY_DB
333 AC_DEFUN([OL_BERKELEY_DB],
334 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
335 AC_REQUIRE([OL_HEADER_BERKELEY_DB])
336 AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
337 if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
340 ol_cv_berkeley_db=yes
343 if test $ol_cv_berkeley_db = yes ; then
344 AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
348 dnl ====================================================================
349 dnl Check if GDBM library exists
350 dnl Check for gdbm_open in standard libraries or -lgdbm
352 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
353 dnl 'yes' implies gdbm_open is in $LIBS
356 dnl AC_CHECK_FUNC(gdbm_open)
357 dnl AC_CHECK_LIB(gdbm,gdbm_open)
359 AC_DEFUN([OL_LIB_GDBM],
360 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
362 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
363 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
369 dnl --------------------------------------------------------------------
370 dnl Check if GDBM exists
372 dnl defines ol_cv_gdbm to 'yes' or 'no'
376 dnl AC_CHECK_HEADERS(gdbm.h)
379 [AC_REQUIRE([OL_LIB_GDBM])
380 AC_CHECK_HEADERS(gdbm.h)
381 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
382 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
388 if test $ol_cv_gdbm = yes ; then
389 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
393 dnl ====================================================================
394 dnl Check if MDBM library exists
395 dnl Check for mdbm_open in standard libraries or -lmdbm
397 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
398 dnl 'yes' implies mdbm_open is in $LIBS
401 dnl AC_CHECK_FUNC(mdbm_set_chain)
402 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
404 AC_DEFUN([OL_LIB_MDBM],
405 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
407 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
408 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
414 dnl --------------------------------------------------------------------
415 dnl Check if MDBM exists
417 dnl defines ol_cv_mdbm to 'yes' or 'no'
421 dnl AC_CHECK_HEADERS(mdbm.h)
424 [AC_REQUIRE([OL_LIB_MDBM])
425 AC_CHECK_HEADERS(mdbm.h)
426 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
427 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
433 if test $ol_cv_mdbm = yes ; then
434 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
438 dnl ====================================================================
439 dnl Check if NDBM library exists
440 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
442 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
443 dnl 'yes' implies ndbm_open is in $LIBS
446 dnl AC_CHECK_FUNC(dbm_open)
447 dnl AC_CHECK_LIB(ndbm,dbm_open)
448 dnl AC_CHECK_LIB(dbm,dbm_open)
451 dnl should also check SVR4 case: dbm_open() in -lucb but that
452 dnl would requiring dealing with -L/usr/ucblib
454 AC_DEFUN([OL_LIB_NDBM],
455 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
457 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
458 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
459 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
460 [ol_cv_lib_ndbm=no])dnl
467 dnl --------------------------------------------------------------------
468 dnl Check if NDBM exists
470 dnl defines ol_cv_ndbm to 'yes' or 'no'
474 dnl AC_CHECK_HEADERS(ndbm.h)
477 dnl Doesn't handle SVR4 case (see above)
480 [AC_REQUIRE([OL_LIB_NDBM])
481 AC_CHECK_HEADERS(ndbm.h)
482 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
483 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
489 if test $ol_cv_ndbm = yes ; then
490 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
494 dnl ====================================================================
495 dnl Check POSIX Thread version
497 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
498 dnl 'unknown' implies that the version could not be detected
499 dnl or that pthreads.h does exist. Existance of pthreads.h
500 dnl should be tested separately.
502 AC_DEFUN([OL_POSIX_THREAD_VERSION],
503 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
504 AC_EGREP_CPP(pthread_version_final,[
505 # include <pthread.h>
506 /* this check could be improved */
507 # ifdef PTHREAD_ONCE_INIT
508 pthread_version_final
510 ], ol_pthread_final=yes, ol_pthread_final=no)
512 AC_EGREP_CPP(pthread_version_draft4,[
513 # include <pthread.h>
514 /* this check could be improved */
515 # ifdef pthread_once_init
516 pthread_version_draft4
518 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
520 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
521 ol_cv_pthread_version=final
522 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
523 ol_cv_pthread_version=draft4
525 ol_cv_pthread_version=unknown
530 dnl --------------------------------------------------------------------
531 AC_DEFUN([OL_PTHREAD_TRY_LINK], [# Pthread try link: $1 ($2)
532 if test "$ol_link_threads" = no ; then
534 AC_CACHE_CHECK([for pthread link with $1], [$2], [
542 #define NULL (void*)0
548 pthread_create(&t, pthread_attr_default, NULL, NULL);
549 pthread_detach( &t );
551 pthread_create(&t, NULL, NULL, NULL);
554 #ifdef HAVE_LINUX_THREADS
555 pthread_kill_other_threads_np();
557 ], [$2=yes], [$2=no])
563 if test $$2 = yes ; then
564 ol_link_pthreads="$1"
565 ol_link_threads=posix
570 dnl ====================================================================
571 dnl Check LinuxThreads Header
573 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
574 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
575 dnl doesn't exists. Existance of pthread.h should separately
578 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
579 AC_CACHE_CHECK([for LinuxThreads pthread.h],
580 [ol_cv_header_linux_threads],
581 [AC_EGREP_CPP(pthread_kill_other_threads_np,
582 [#include <pthread.h>],
583 [ol_cv_header_linux_threads=yes],
584 [ol_cv_header_linux_threads=no])
586 if test $ol_cv_header_linux_threads = yes; then
587 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
590 dnl --------------------------------------------------------------------
591 dnl Check LinuxThreads Implementation
593 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
594 dnl 'no' implies pthreads implementation is not LinuxThreads.
596 AC_DEFUN([OL_SYS_LINUX_THREADS], [
597 AC_CHECK_FUNC(pthread_kill_other_threads_np)
598 AC_CACHE_CHECK([for LinuxThreads implementation],
599 [ol_cv_sys_linux_threads],
600 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
603 dnl --------------------------------------------------------------------
604 dnl Check LinuxThreads consistency
605 AC_DEFUN([OL_LINUX_THREADS], [
606 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
607 AC_REQUIRE([OL_SYS_LINUX_THREADS])
608 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
609 if test $ol_cv_header_linux_threads = yes -a \
610 $ol_cv_sys_linux_threads = yes; then
611 ol_cv_linux_threads=yes
612 elif test $ol_cv_header_linux_threads = no -a \
613 $ol_cv_sys_linux_threads = no; then
614 ol_cv_linux_threads=no
616 ol_cv_linux_threads=error
621 dnl ====================================================================
622 dnl Check for POSIX Regex
623 AC_DEFUN([OL_POSIX_REGEX], [
624 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
626 #include <sys/types.h>
628 static char *pattern, *string;
636 if(regcomp(&re, pattern, 0)) {
640 string = "ALL MATCH";
642 rc = regexec(&re, string, 0, (void*)0, 0);
648 [ol_cv_c_posix_regex=yes],
649 [ol_cv_c_posix_regex=no],
650 [ol_cv_c_posix_regex=cross])])
653 dnl ====================================================================
654 dnl Check if toupper() requires islower() to be called first
655 AC_DEFUN([OL_C_UPPER_LOWER],
656 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
661 if ('C' == toupper('C'))
666 [ol_cv_c_upper_lower=no],
667 [ol_cv_c_upper_lower=yes],
668 [ol_cv_c_upper_lower=safe])])
669 if test $ol_cv_c_upper_lower != no ; then
670 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
674 dnl ====================================================================
675 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
676 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
677 dnl Reported by Keith Bostic.
678 AC_DEFUN([OL_SYS_ERRLIST],
679 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
682 #include <sys/types.h>
683 #include <errno.h> ],
684 [char *c = (char *) *sys_errlist],
685 [ol_cv_dcl_sys_errlist=yes
686 ol_cv_have_sys_errlist=yes],
687 [ol_cv_dcl_sys_errlist=no])])
689 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
690 if test $ol_cv_dcl_sys_errlist = no ; then
691 AC_DEFINE(DECL_SYS_ERRLIST,1,
692 [define if sys_errlist is not declared in stdio.h or errno.h])
694 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
695 AC_TRY_LINK([#include <errno.h>],
696 [char *c = (char *) *sys_errlist],
697 [ol_cv_have_sys_errlist=yes],
698 [ol_cv_have_sys_errlist=no])])
700 if test $ol_cv_have_sys_errlist = yes ; then
701 AC_DEFINE(HAVE_SYS_ERRLIST,1,
702 [define if you actually have sys_errlist in your libs])
706 dnl ====================================================================
707 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
708 dnl "int x; int *volatile a = &x; *a = 0;"
709 dnl -- borrowed from PDKSH
710 AC_DEFUN(OL_C_VOLATILE,
711 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
712 [AC_TRY_COMPILE([int x, y, z;],
713 [volatile int a; int * volatile b = x ? &y : &z;
714 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
715 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
716 if test $ol_cv_c_volatile = yes; then
719 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
723 dnl ====================================================================
724 dnl Look for fetch(3)
725 AC_DEFUN([OL_LIB_FETCH],
727 LIBS="-lfetch -lcom_err $LIBS"
728 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
730 #include <sys/param.h>
733 [struct url *u = fetchParseURL("file:///"); ],
734 [ol_cv_lib_fetch=yes],
735 [ol_cv_lib_fetch=no])])
737 if test $ol_cv_lib_fetch != no ; then
738 ol_link_fetch="-lfetch -lcom_err"
739 AC_DEFINE(HAVE_FETCH,1,
740 [define if you actually have FreeBSD fetch(3)])
744 dnl ====================================================================
745 dnl Define sig_atomic_t if not defined in signal.h
746 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
747 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
748 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
749 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
750 if test $ol_cv_type_sig_atomic_t = no; then
751 AC_DEFINE(sig_atomic_t,int,
752 [define to atomic type if sig_atomic_t is not available])
756 dnl ====================================================================
757 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
758 AC_DEFUN(OL_TYPE_SOCKLEN_T,
759 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
761 #ifdef HAVE_SYS_TYPES_H
762 #include <sys/types.h>
764 #ifdef HAVE_SYS_SOCKET_H
765 #include <sys/socket.h>
768 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
769 if test $ol_cv_type_socklen_t = no; then
770 AC_DEFINE(socklen_t, int,
771 [define to int if socklen_t is not available])
775 dnl ====================================================================
776 dnl check no of arguments for ctime_r
777 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
778 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
779 [AC_TRY_COMPILE([#include <time.h>],
780 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
781 ol_cv_func_ctime_r_nargs=3,
782 [AC_TRY_COMPILE([#include <time.h>],
783 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
784 ol_cv_func_ctime_r_nargs=2,
785 ol_cv_func_ctime_r_nargs=0)])])
786 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
787 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
788 [set to the number of arguments ctime_r() expects])
792 dnl --------------------------------------------------------------------
793 dnl check return type of ctime_r()
794 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
795 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
796 [AC_TRY_COMPILE([#include <time.h>],
797 [extern int (ctime_r)();],
798 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
800 if test $ol_cv_func_ctime_r_type = "int" ; then
801 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
804 dnl ====================================================================
805 dnl check no of arguments for gethostbyname_r
806 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
807 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
808 ol_cv_func_gethostbyname_r_nargs,
809 [AC_TRY_COMPILE([#include <sys/types.h>
810 #include <sys/socket.h>
811 #include <netinet/in.h>
813 #define BUFSIZE (sizeof(struct hostent)+10)],
814 [struct hostent hent; char buffer[BUFSIZE];
815 int bufsize=BUFSIZE;int h_errno;
816 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
817 buffer, bufsize, &h_errno);],
818 ol_cv_func_gethostbyname_r_nargs=5,
819 [AC_TRY_COMPILE([#include <sys/types.h>
820 #include <sys/socket.h>
821 #include <netinet/in.h>
823 #define BUFSIZE (sizeof(struct hostent)+10)],
824 [struct hostent hent;struct hostent *rhent;
825 char buffer[BUFSIZE];
826 int bufsize=BUFSIZE;int h_errno;
827 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
829 ol_cv_func_gethostbyname_r_nargs=6,
830 ol_cv_func_gethostbyname_r_nargs=0)])])
831 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
832 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
833 $ol_cv_func_gethostbyname_r_nargs,
834 [set to the number of arguments gethostbyname_r() expects])
838 dnl check no of arguments for gethostbyaddr_r
839 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
840 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
841 [ol_cv_func_gethostbyaddr_r_nargs],
842 [AC_TRY_COMPILE([#include <sys/types.h>
843 #include <sys/socket.h>
844 #include <netinet/in.h>
846 #define BUFSIZE (sizeof(struct hostent)+10)],
847 [struct hostent hent; char buffer[BUFSIZE];
849 size_t alen=sizeof(struct in_addr);
850 int bufsize=BUFSIZE;int h_errno;
851 (void)gethostbyaddr_r( (void *)&(add.s_addr),
852 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
853 ol_cv_func_gethostbyaddr_r_nargs=7,
854 [AC_TRY_COMPILE([#include <sys/types.h>
855 #include <sys/socket.h>
856 #include <netinet/in.h>
858 #define BUFSIZE (sizeof(struct hostent)+10)],
859 [struct hostent hent;
860 struct hostent *rhent; char buffer[BUFSIZE];
862 size_t alen=sizeof(struct in_addr);
863 int bufsize=BUFSIZE;int h_errno;
864 (void)gethostbyaddr_r( (void *)&(add.s_addr),
865 alen, AF_INET, &hent, buffer, bufsize,
867 ol_cv_func_gethostbyaddr_r_nargs=8,
868 ol_cv_func_gethostbyaddr_r_nargs=0)])])
869 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
870 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
871 $ol_cv_func_gethostbyaddr_r_nargs,
872 [set to the number of arguments gethostbyaddr_r() expects])