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 ====================================================================
60 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
61 [changequote(<<, >>)dnl
62 dnl The name to #define.
63 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
64 dnl The cache variable name.
65 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
67 AC_MSG_CHECKING(size of $1)
68 AC_CACHE_VAL(AC_CV_NAME,
69 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
70 AC_TRY_COMPILE([#include "confdefs.h"
71 #include <sys/types.h>
73 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
74 if test x$AC_CV_NAME != x ; then break; fi
77 if test x$AC_CV_NAME = x ; then
78 AC_MSG_ERROR([cannot determine a size for $1])
80 AC_MSG_RESULT($AC_CV_NAME)
81 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
82 undefine([AC_TYPE_NAME])dnl
83 undefine([AC_CV_NAME])dnl
85 dnl ====================================================================
86 dnl check if hard links are supported.
88 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
89 AC_MSG_CHECKING(whether ln works)
90 AC_CACHE_VAL(ol_cv_prog_LN_H,
91 [rm -f conftest.src conftest.dst
92 echo "conftest" > conftest.src
93 if ln conftest.src conftest.dst 2>/dev/null
99 rm -f conftest.src conftest.dst
101 LN_H="$ol_cv_prog_LN_H"
102 if test "$ol_cv_prog_LN_H" = "ln"; then
110 dnl ====================================================================
111 dnl Check for dependency generation flag
112 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
115 if test -z "${MKDEP}"; then
117 if test -z "${MKDEP_FLAGS}"; then
118 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
120 for flag in "-M" "-xM"; do
121 cat > conftest.c <<EOF
124 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
125 | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
127 if test ! -f conftest."${ac_object}" ; then
129 OL_MKDEP_FLAGS="$flag"
138 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
143 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
146 AC_SUBST(OL_MKDEP_FLAGS)
149 dnl ====================================================================
150 dnl Check if system uses EBCDIC instead of ASCII
151 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
152 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
155 #include <__ASCII__/generate_error.h>
158 [ol_cv_cpp_ebcdic=yes],
159 [ol_cv_cpp_ebcdic=no])])
160 if test $ol_cv_cpp_ebcdic = yes ; then
161 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
165 dnl --------------------------------------------------------------------
166 dnl OpenLDAP version of STDC header check w/ EBCDIC support
167 AC_DEFUN(OL_HEADER_STDC,
169 AC_REQUIRE([OL_CPP_EBCDIC])dnl
170 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
171 [AC_TRY_CPP([#include <stdlib.h>
174 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
176 if test $ol_cv_header_stdc = yes; then
177 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
178 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
181 if test $ol_cv_header_stdc = yes; then
182 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
183 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
186 if test $ol_cv_header_stdc = yes; then
187 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
188 AC_TRY_RUN([#include <ctype.h>
190 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
191 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
193 # define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
194 || ('j' <= (c) && (c) <= 'r') \
195 || ('s' <= (c) && (c) <= 'z'))
196 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
198 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
199 int main () { int i; for (i = 0; i < 256; i++)
200 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
202 ], , ol_cv_header_stdc=no, :)
204 if test $ol_cv_header_stdc = yes; then
205 AC_DEFINE(STDC_HEADERS)
207 ac_cv_header_stdc=disable
210 dnl ====================================================================
211 dnl Check if struct passwd has pw_gecos
212 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
213 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
214 AC_TRY_COMPILE([#include <pwd.h>],[
216 pwd.pw_gecos = pwd.pw_name;
218 [ol_cv_struct_passwd_pw_gecos=yes],
219 [ol_cv_struct_passwd_pw_gecos=no])])
220 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
221 AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
225 dnl --------------------------------------------------------------------
226 dnl Check if struct passwd has pw_passwd
227 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
228 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
229 AC_TRY_COMPILE([#include <pwd.h>],[
231 pwd.pw_passwd = pwd.pw_name;
233 [ol_cv_struct_passwd_pw_passwd=yes],
234 [ol_cv_struct_passwd_pw_passwd=no])])
235 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
236 AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
240 dnl ====================================================================
241 dnl Check if db.h is Berkeley DB2
243 dnl defines ol_cv_header_db2 to 'yes' or 'no'
246 dnl AC_CHECK_HEADERS(db.h)
248 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
249 [AC_CHECK_HEADERS(db.h)
250 if test $ac_cv_header_db_h = yes ; then
251 AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
252 AC_EGREP_CPP(__db_version_2,[
254 /* this check could be improved */
255 # ifdef DB_VERSION_MAJOR
256 # if DB_VERSION_MAJOR == 2
260 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
265 dnl --------------------------------------------------------------------
266 dnl Check if Berkeley DB2 library exists
267 dnl Check for dbopen in standard libraries or -ldb
269 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
272 dnl AC_CHECK_LIB(db,db_appexit)
274 AC_DEFUN([OL_LIB_BERKELEY_DB2],
275 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
277 AC_CHECK_LIB(db,db_appexit,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
282 dnl --------------------------------------------------------------------
283 dnl Check if Berkeley db2 exists
285 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
288 dnl OL_LIB_BERKELEY_DB2
289 dnl OL_HEADER_BERKELEY_DB2
291 AC_DEFUN([OL_BERKELEY_DB2],
292 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
293 AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
294 AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
295 if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
296 ol_cv_berkeley_db2=no
298 ol_cv_berkeley_db2=yes
301 if test $ol_cv_berkeley_db2 = yes ; then
302 AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
307 dnl --------------------------------------------------------------------
308 dnl Check if Berkeley db2 supports DB_THREAD
309 AC_DEFUN([OL_BERKELEY_DB2_DB_THREAD],
310 [AC_CACHE_CHECK([for DB_THREAD support], [ol_cv_berkeley_db2_db_thread], [
312 if test $ol_cv_lib_db2 != yes ; then
313 LIBS="$ol_cv_lib_db2"
319 #define NULL ((void *)0)
325 u_int32_t flags = DB_CREATE | DB_THREAD;
327 memset( &env, '\0', sizeof(env) );
329 rc = db_appinit( NULL, NULL, &env, flags );
337 [ol_cv_berkeley_db2_db_thread=yes],
338 [ol_cv_berkeley_db2_db_thread=no],
339 [ol_cv_berkeley_db2_db_thread=cross])
343 if test $ol_cv_berkeley_db2_db_thread != no ; then
344 AC_DEFINE(HAVE_BERKELEY_DB2_DB_THREAD, 1,
345 [define if BerkeleyDB2 has DB_THREAD support])
348 dnl ====================================================================
349 dnl Check for db.h/db_185.h is Berkeley DB
351 dnl defines ol_cv_header_db to 'yes' or 'no'
354 dnl OL_HEADER_BERKELEY_DB2
355 dnl AC_CHECK_HEADERS(db_185.h)
357 AC_DEFUN([OL_HEADER_BERKELEY_DB],
358 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
359 AC_CHECK_HEADERS(db_185.h)
360 if test "$ol_cv_header_db2" = yes ; then
363 ol_cv_header_db=$ac_cv_header_db_185_h
365 ol_cv_header_db=$ac_cv_header_db_h
369 dnl --------------------------------------------------------------------
370 dnl Check if Berkeley DB library exists
371 dnl Check for dbopen in standard libraries or -ldb
373 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
374 dnl 'yes' implies dbopen is in $LIBS
377 dnl AC_CHECK_FUNC(dbopen)
378 dnl AC_CHECK_LIB(db,dbopen)
380 AC_DEFUN([OL_LIB_BERKELEY_DB],
381 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
383 AC_CHECK_HEADERS(db1/db.h)
385 AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
386 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
387 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
395 dnl --------------------------------------------------------------------
396 dnl Check if Berkeley DB exists
398 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
401 dnl OL_LIB_BERKELEY_DB
402 dnl OL_HEADER_BERKELEY_DB
404 AC_DEFUN([OL_BERKELEY_DB],
405 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
406 AC_REQUIRE([OL_HEADER_BERKELEY_DB])
407 AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
408 if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
411 ol_cv_berkeley_db=yes
414 if test $ol_cv_berkeley_db = yes ; then
415 AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
419 dnl ====================================================================
420 dnl Check if GDBM library exists
421 dnl Check for gdbm_open in standard libraries or -lgdbm
423 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
424 dnl 'yes' implies gdbm_open is in $LIBS
427 dnl AC_CHECK_FUNC(gdbm_open)
428 dnl AC_CHECK_LIB(gdbm,gdbm_open)
430 AC_DEFUN([OL_LIB_GDBM],
431 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
433 AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
434 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
440 dnl --------------------------------------------------------------------
441 dnl Check if GDBM exists
443 dnl defines ol_cv_gdbm to 'yes' or 'no'
447 dnl AC_CHECK_HEADERS(gdbm.h)
450 [AC_REQUIRE([OL_LIB_GDBM])
451 AC_CHECK_HEADERS(gdbm.h)
452 AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
453 if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
459 if test $ol_cv_gdbm = yes ; then
460 AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
464 dnl ====================================================================
465 dnl Check if MDBM library exists
466 dnl Check for mdbm_open in standard libraries or -lmdbm
468 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
469 dnl 'yes' implies mdbm_open is in $LIBS
472 dnl AC_CHECK_FUNC(mdbm_set_chain)
473 dnl AC_CHECK_LIB(mdbm,mdbm_set_chain)
475 AC_DEFUN([OL_LIB_MDBM],
476 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
478 AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
479 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
485 dnl --------------------------------------------------------------------
486 dnl Check if MDBM exists
488 dnl defines ol_cv_mdbm to 'yes' or 'no'
492 dnl AC_CHECK_HEADERS(mdbm.h)
495 [AC_REQUIRE([OL_LIB_MDBM])
496 AC_CHECK_HEADERS(mdbm.h)
497 AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
498 if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
504 if test $ol_cv_mdbm = yes ; then
505 AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
509 dnl ====================================================================
510 dnl Check if NDBM library exists
511 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
513 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
514 dnl 'yes' implies ndbm_open is in $LIBS
517 dnl AC_CHECK_FUNC(dbm_open)
518 dnl AC_CHECK_LIB(ndbm,dbm_open)
519 dnl AC_CHECK_LIB(dbm,dbm_open)
522 dnl should also check SVR4 case: dbm_open() in -lucb but that
523 dnl would requiring dealing with -L/usr/ucblib
525 AC_DEFUN([OL_LIB_NDBM],
526 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
528 AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
529 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
530 AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
531 [ol_cv_lib_ndbm=no])dnl
538 dnl --------------------------------------------------------------------
539 dnl Check if NDBM exists
541 dnl defines ol_cv_ndbm to 'yes' or 'no'
545 dnl AC_CHECK_HEADERS(ndbm.h)
548 dnl Doesn't handle SVR4 case (see above)
551 [AC_REQUIRE([OL_LIB_NDBM])
552 AC_CHECK_HEADERS(ndbm.h)
553 AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
554 if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
560 if test $ol_cv_ndbm = yes ; then
561 AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
565 dnl ====================================================================
566 dnl Check POSIX Thread version
568 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
569 dnl 'unknown' implies that the version could not be detected
570 dnl or that pthreads.h does exist. Existance of pthreads.h
571 dnl should be tested separately.
573 AC_DEFUN([OL_POSIX_THREAD_VERSION],
574 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
575 AC_EGREP_CPP(pthread_version_final,[
576 # include <pthread.h>
577 /* this check could be improved */
578 # ifdef PTHREAD_ONCE_INIT
579 pthread_version_final;
581 ], ol_pthread_final=yes, ol_pthread_final=no)
583 AC_EGREP_CPP(pthread_version_draft4,[
584 # include <pthread.h>
585 /* this check could be improved */
586 # ifdef pthread_once_init
587 pthread_version_draft4;
589 ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
591 if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
592 ol_cv_pthread_version=final
593 elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
594 ol_cv_pthread_version=draft4
596 ol_cv_pthread_version=unknown
601 dnl --------------------------------------------------------------------
602 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
603 [/* pthread test headers */
606 #define NULL (void*)0
612 return (void *) (p == NULL);
615 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
616 /* pthread test function */
620 /* make sure pthread_create() isn't just a stub */
622 status = pthread_create(&t, pthread_attr_default, task, NULL);
624 status = pthread_create(&t, NULL, task, NULL);
627 if( status ) exit( status );
629 /* make sure pthread_detach() isn't just a stub */
631 status = pthread_detach( &t );
633 status = pthread_detach( t );
636 #ifdef HAVE_LINUX_THREADS
637 pthread_kill_other_threads_np();
643 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
644 [OL_PTHREAD_TEST_INCLUDES
650 OL_PTHREAD_TEST_FUNCTION
653 dnl --------------------------------------------------------------------
654 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
655 if test "$ol_link_threads" = no ; then
657 AC_CACHE_CHECK([for pthread link with $1], [$2], [
662 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
664 [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
671 if test $$2 = yes ; then
672 ol_link_pthreads="$1"
673 ol_link_threads=posix
678 dnl ====================================================================
679 dnl Check GNU Pth pthread Header
681 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
682 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
683 dnl doesn't exists. Existance of pthread.h should separately
686 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
687 AC_CACHE_CHECK([for GNU Pth pthread.h],
688 [ol_cv_header_gnu_pth_pthread_h],
689 [AC_EGREP_CPP(__gnu_pth__,
690 [#include <pthread.h>
691 #ifdef _POSIX_THREAD_IS_GNU_PTH
695 [ol_cv_header_gnu_pth_pthread_h=yes],
696 [ol_cv_header_gnu_pth_pthread_h=no])
699 dnl ====================================================================
700 dnl Check LinuxThreads Header
702 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
703 dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h
704 dnl doesn't exists. Existance of pthread.h should separately
707 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
708 AC_CACHE_CHECK([for LinuxThreads pthread.h],
709 [ol_cv_header_linux_threads],
710 [AC_EGREP_CPP(pthread_kill_other_threads_np,
711 [#include <pthread.h>],
712 [ol_cv_header_linux_threads=yes],
713 [ol_cv_header_linux_threads=no])
715 if test $ol_cv_header_linux_threads = yes; then
716 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
719 dnl --------------------------------------------------------------------
720 dnl Check LinuxThreads Implementation
722 dnl defines ol_cv_sys_linux_threads to 'yes' or 'no'
723 dnl 'no' implies pthreads implementation is not LinuxThreads.
725 AC_DEFUN([OL_SYS_LINUX_THREADS], [
726 AC_CHECK_FUNC(pthread_kill_other_threads_np)
727 AC_CACHE_CHECK([for LinuxThreads implementation],
728 [ol_cv_sys_linux_threads],
729 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
732 dnl --------------------------------------------------------------------
733 dnl Check LinuxThreads consistency
734 AC_DEFUN([OL_LINUX_THREADS], [
735 AC_REQUIRE([OL_HEADER_LINUX_THREADS])
736 AC_REQUIRE([OL_SYS_LINUX_THREADS])
737 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
738 if test $ol_cv_header_linux_threads = yes -a \
739 $ol_cv_sys_linux_threads = yes; then
740 ol_cv_linux_threads=yes
741 elif test $ol_cv_header_linux_threads = no -a \
742 $ol_cv_sys_linux_threads = no; then
743 ol_cv_linux_threads=no
745 ol_cv_linux_threads=error
750 dnl ====================================================================
751 dnl Check for POSIX Regex
752 AC_DEFUN([OL_POSIX_REGEX], [
753 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
755 #include <sys/types.h>
757 static char *pattern, *string;
765 if(regcomp(&re, pattern, 0)) {
769 string = "ALL MATCH";
771 rc = regexec(&re, string, 0, (void*)0, 0);
777 [ol_cv_c_posix_regex=yes],
778 [ol_cv_c_posix_regex=no],
779 [ol_cv_c_posix_regex=cross])])
782 dnl ====================================================================
783 dnl Check if toupper() requires islower() to be called first
784 AC_DEFUN([OL_C_UPPER_LOWER],
785 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
790 if ('C' == toupper('C'))
795 [ol_cv_c_upper_lower=no],
796 [ol_cv_c_upper_lower=yes],
797 [ol_cv_c_upper_lower=safe])])
798 if test $ol_cv_c_upper_lower != no ; then
799 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
803 dnl ====================================================================
804 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
805 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
806 dnl Reported by Keith Bostic.
807 AC_DEFUN([OL_SYS_ERRLIST],
808 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
811 #include <sys/types.h>
816 [char *c = (char *) *sys_errlist],
817 [ol_cv_dcl_sys_errlist=yes
818 ol_cv_have_sys_errlist=yes],
819 [ol_cv_dcl_sys_errlist=no])])
821 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
822 if test $ol_cv_dcl_sys_errlist = no ; then
823 AC_DEFINE(DECL_SYS_ERRLIST,1,
824 [define if sys_errlist is not declared in stdio.h or errno.h])
826 AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
827 AC_TRY_LINK([#include <errno.h>],
828 [char *c = (char *) *sys_errlist],
829 [ol_cv_have_sys_errlist=yes],
830 [ol_cv_have_sys_errlist=no])])
832 if test $ol_cv_have_sys_errlist = yes ; then
833 AC_DEFINE(HAVE_SYS_ERRLIST,1,
834 [define if you actually have sys_errlist in your libs])
838 dnl ====================================================================
839 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
840 dnl "int x; int *volatile a = &x; *a = 0;"
841 dnl -- borrowed from PDKSH
842 AC_DEFUN(OL_C_VOLATILE,
843 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
844 [AC_TRY_COMPILE([int x, y, z;],
845 [volatile int a; int * volatile b = x ? &y : &z;
846 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
847 *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
848 if test $ol_cv_c_volatile = yes; then
851 AC_DEFINE(volatile,,[define as empty if volatile is not supported])
855 dnl ====================================================================
856 dnl Look for fetch(3)
857 AC_DEFUN([OL_LIB_FETCH],
859 LIBS="-lfetch -lcom_err $LIBS"
860 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
862 #include <sys/param.h>
865 [struct url *u = fetchParseURL("file:///"); ],
866 [ol_cv_lib_fetch=yes],
867 [ol_cv_lib_fetch=no])])
869 if test $ol_cv_lib_fetch != no ; then
870 ol_link_fetch="-lfetch -lcom_err"
871 AC_DEFINE(HAVE_FETCH,1,
872 [define if you actually have FreeBSD fetch(3)])
876 dnl ====================================================================
877 dnl Define sig_atomic_t if not defined in signal.h
878 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
879 [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
880 [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
881 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
882 if test $ol_cv_type_sig_atomic_t = no; then
883 AC_DEFINE(sig_atomic_t,int,
884 [define to atomic type if sig_atomic_t is not available])
888 dnl ====================================================================
889 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
890 AC_DEFUN(OL_TYPE_SOCKLEN_T,
891 [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
893 #ifdef HAVE_SYS_TYPES_H
894 #include <sys/types.h>
896 #ifdef HAVE_SYS_SOCKET_H
897 #include <sys/socket.h>
900 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
901 if test $ol_cv_type_socklen_t = no; then
902 AC_DEFINE(socklen_t, int,
903 [define to int if socklen_t is not available])
907 dnl ====================================================================
908 dnl Define inet_aton is available
909 AC_DEFUN(OL_FUNC_INET_ATON,
910 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
912 #ifdef HAVE_SYS_TYPES_H
913 # include <sys/types.h>
915 #ifdef HAVE_SYS_SOCKET_H
916 # include <sys/socket.h>
917 # ifdef HAVE_SYS_SELECT_H
918 # include <sys/select.h>
920 # include <netinet/in.h>
921 # ifdef HAVE_ARPA_INET_H
922 # include <arpa/inet.h>
925 ], [struct in_addr in;
926 int rc = inet_aton( "255.255.255.255", &in );],
927 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
928 if test $ol_cv_func_inet_aton != no; then
929 AC_DEFINE(HAVE_INET_ATON, 1,
930 [define to you inet_aton(3) is available])
934 dnl ====================================================================
935 dnl check no of arguments for ctime_r
936 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
937 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
938 [AC_TRY_COMPILE([#include <time.h>],
939 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
940 ol_cv_func_ctime_r_nargs3=yes,
941 ol_cv_func_ctime_r_nargs3=no)
943 AC_TRY_COMPILE([#include <time.h>],
944 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
945 ol_cv_func_ctime_r_nargs2=yes,
946 ol_cv_func_ctime_r_nargs2=no)
948 if test $ol_cv_func_ctime_r_nargs3 = yes -a \
949 $ol_cv_func_ctime_r_nargs2 = no ; then
951 ol_cv_func_ctime_r_nargs=3
953 elif test $ol_cv_func_ctime_r_nargs3 = no -a \
954 $ol_cv_func_ctime_r_nargs2 = yes ; then
956 ol_cv_func_ctime_r_nargs=2
959 ol_cv_func_ctime_r_nargs=0
963 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
964 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
965 [set to the number of arguments ctime_r() expects])
969 dnl --------------------------------------------------------------------
970 dnl check return type of ctime_r()
971 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
972 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
973 [AC_TRY_COMPILE([#include <time.h>],
974 [extern int (ctime_r)();],
975 ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
977 if test $ol_cv_func_ctime_r_type = "int" ; then
978 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
981 dnl ====================================================================
982 dnl check no of arguments for gethostbyname_r
983 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
984 [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
985 ol_cv_func_gethostbyname_r_nargs,
986 [AC_TRY_COMPILE([#include <sys/types.h>
987 #include <sys/socket.h>
988 #include <netinet/in.h>
990 #define BUFSIZE (sizeof(struct hostent)+10)],
991 [struct hostent hent; char buffer[BUFSIZE];
992 int bufsize=BUFSIZE;int h_errno;
993 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
994 buffer, bufsize, &h_errno);],
995 ol_cv_func_gethostbyname_r_nargs5=yes,
996 ol_cv_func_gethostbyname_r_nargs5=no)
998 AC_TRY_COMPILE([#include <sys/types.h>
999 #include <sys/socket.h>
1000 #include <netinet/in.h>
1002 #define BUFSIZE (sizeof(struct hostent)+10)],
1003 [struct hostent hent;struct hostent *rhent;
1004 char buffer[BUFSIZE];
1005 int bufsize=BUFSIZE;int h_errno;
1006 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1007 &rhent, &h_errno);],
1008 ol_cv_func_gethostbyname_r_nargs6=yes,
1009 ol_cv_func_gethostbyname_r_nargs6=no)
1011 if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1012 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1014 ol_cv_func_gethostbyname_r_nargs=5
1016 elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1017 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1019 ol_cv_func_gethostbyname_r_nargs=6
1022 ol_cv_func_gethostbyname_r_nargs=0
1025 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1026 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1027 $ol_cv_func_gethostbyname_r_nargs,
1028 [set to the number of arguments gethostbyname_r() expects])
1032 dnl check no of arguments for gethostbyaddr_r
1033 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1034 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1035 [ol_cv_func_gethostbyaddr_r_nargs],
1036 [AC_TRY_COMPILE([#include <sys/types.h>
1037 #include <sys/socket.h>
1038 #include <netinet/in.h>
1040 #define BUFSIZE (sizeof(struct hostent)+10)],
1041 [struct hostent hent; char buffer[BUFSIZE];
1043 size_t alen=sizeof(struct in_addr);
1044 int bufsize=BUFSIZE;int h_errno;
1045 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1046 alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1047 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1048 ol_cv_func_gethostbyaddr_r_nargs7=no)
1050 AC_TRY_COMPILE([#include <sys/types.h>
1051 #include <sys/socket.h>
1052 #include <netinet/in.h>
1054 #define BUFSIZE (sizeof(struct hostent)+10)],
1055 [struct hostent hent;
1056 struct hostent *rhent; char buffer[BUFSIZE];
1058 size_t alen=sizeof(struct in_addr);
1059 int bufsize=BUFSIZE;int h_errno;
1060 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1061 alen, AF_INET, &hent, buffer, bufsize,
1062 &rhent, &h_errno);],
1063 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1064 ol_cv_func_gethostbyaddr_r_nargs8=no)
1066 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1067 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1069 ol_cv_func_gethostbyaddr_r_nargs=7
1071 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1072 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1074 ol_cv_func_gethostbyaddr_r_nargs=8
1077 ol_cv_func_gethostbyaddr_r_nargs=0
1080 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1081 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1082 $ol_cv_func_gethostbyaddr_r_nargs,
1083 [set to the number of arguments gethostbyaddr_r() expects])