]> git.sur5r.net Git - openldap/blob - build/openldap.m4
BDB 4.3 detection, new static backend handler
[openldap] / build / openldap.m4
1 dnl OpenLDAP Autoconf Macros
2 dnl $OpenLDAP$
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 dnl
5 dnl Copyright 1998-2004 The OpenLDAP Foundation.
6 dnl All rights reserved.
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted only as authorized by the OpenLDAP
10 dnl Public License.
11 dnl
12 dnl A copy of this license is available in the file LICENSE in the
13 dnl top-level directory of the distribution or, alternatively, at
14 dnl <http://www.OpenLDAP.org/license.html>.
15 dnl
16 dnl --------------------------------------------------------------------
17 dnl Restricted form of AC_ARG_ENABLE that limits user options
18 dnl
19 dnl $1 = option name
20 dnl $2 = help-string
21 dnl $3 = default value  (auto)
22 dnl $4 = allowed values (auto yes no)
23 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
24         AC_ARG_ENABLE($1,changequote(<,>)<$2 [>ifelse($3,,auto,$3)<]>changequote([,]),[
25         ol_arg=invalid
26         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
27                 if test "$enableval" = "$ol_val" ; then
28                         ol_arg="$ol_val"
29                 fi
30         done
31         if test "$ol_arg" = "invalid" ; then
32                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
33         fi
34         ol_enable_$1="$ol_arg"
35 ],
36 [       ol_enable_$1=ifelse($3,,"auto","$3")])dnl
37 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
38 # end --enable-$1
39 ])dnl
40 dnl
41 dnl --------------------------------------------------------------------
42 dnl Restricted form of AC_ARG_WITH that limits user options
43 dnl
44 dnl $1 = option name
45 dnl $2 = help-string
46 dnl $3 = default value (no)
47 dnl $4 = allowed values (yes or no)
48 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
49         AC_ARG_WITH($1,changequote(<,>)<$2 [>ifelse($3,,yes,$3)<]>changequote([,]),[
50         ol_arg=invalid
51         for ol_val in ifelse($4,,[yes no],[$4]) ; do
52                 if test "$withval" = "$ol_val" ; then
53                         ol_arg="$ol_val"
54                 fi
55         done
56         if test "$ol_arg" = "invalid" ; then
57                 AC_MSG_ERROR(bad value $withval for --with-$1)
58         fi
59         ol_with_$1="$ol_arg"
60 ],
61 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
62 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
63 # end --with-$1
64 ])dnl
65 dnl
66 dnl ====================================================================
67 dnl
68 AC_DEFUN(AC_COMPILE_CHECK_SIZEOF,
69 [changequote(<<, >>)dnl 
70 dnl The name to #define. 
71 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl 
72 dnl The cache variable name. 
73 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl 
74 changequote([, ])dnl 
75 AC_MSG_CHECKING(size of $1) 
76 AC_CACHE_VAL(AC_CV_NAME, 
77 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence. 
78   AC_TRY_COMPILE([#include "confdefs.h" 
79 #include <stdlib.h>
80 #include <sys/types.h> 
81 $2 
82 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) 
83   if test x$AC_CV_NAME != x ; then break; fi 
84 done 
85 ]) 
86 if test x$AC_CV_NAME = x ; then 
87   AC_MSG_ERROR([cannot determine a size for $1]) 
88 fi 
89 AC_MSG_RESULT($AC_CV_NAME) 
90 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) 
91 undefine([AC_TYPE_NAME])dnl 
92 undefine([AC_CV_NAME])dnl 
93 ])
94 dnl ====================================================================
95 dnl check if hard links are supported.
96 dnl
97 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
98 AC_MSG_CHECKING(whether ln works)
99 AC_CACHE_VAL(ol_cv_prog_LN_H,
100 [rm -f conftest.src conftest.dst
101 echo "conftest" > conftest.src
102 if ln conftest.src conftest.dst 2>/dev/null
103 then
104   ol_cv_prog_LN_H="ln"
105 else
106   ol_cv_prog_LN_H="cp"
107 fi
108 rm -f conftest.src conftest.dst
109 ])dnl
110 LN_H="$ol_cv_prog_LN_H"
111 if test "$ol_cv_prog_LN_H" = "ln"; then
112         AC_MSG_RESULT(yes)
113 else
114         AC_MSG_RESULT(no)
115 fi
116 AC_SUBST(LN_H)dnl
117 ])dnl
118 dnl
119 dnl ====================================================================
120 dnl Check for dependency generation flag
121 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
122 OL_MKDEP=
123 OL_MKDEP_FLAGS=
124 if test -z "${MKDEP}"; then
125         OL_MKDEP="${CC-cc}"
126         if test -z "${MKDEP_FLAGS}"; then
127                 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
128                         ol_cv_mkdep=no
129                         for flag in "-M" "-xM"; do
130                                 cat > conftest.c <<EOF
131  noCode;
132 EOF
133                                 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
134                                         | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
135                                 then
136                                         if test ! -f conftest."${ac_object}" ; then
137                                                 ol_cv_mkdep=$flag
138                                                 OL_MKDEP_FLAGS="$flag"
139                                                 break
140                                         fi
141                                 fi
142                         done
143                         rm -f conftest*
144                 ])
145         else
146                 cc_cv_mkdep=yes
147                 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
148         fi
149 else
150         cc_cv_mkdep=yes
151         OL_MKDEP="${MKDEP}"
152         OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
153 fi
154 AC_SUBST(OL_MKDEP)
155 AC_SUBST(OL_MKDEP_FLAGS)
156 ])
157 dnl
158 dnl ====================================================================
159 dnl Check if system uses EBCDIC instead of ASCII
160 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
161 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
162         AC_TRY_CPP([
163 #if !('M' == 0xd4)
164 #include <__ASCII__/generate_error.h>
165 #endif
166 ],
167         [ol_cv_cpp_ebcdic=yes],
168         [ol_cv_cpp_ebcdic=no])])
169 if test $ol_cv_cpp_ebcdic = yes ; then
170         AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
171 fi
172 ])
173 dnl
174 dnl --------------------------------------------------------------------
175 dnl OpenLDAP version of STDC header check w/ EBCDIC support
176 AC_DEFUN(OL_HEADER_STDC,
177 [AC_REQUIRE_CPP()dnl
178 AC_REQUIRE([OL_CPP_EBCDIC])dnl
179 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
180 [AC_TRY_CPP([#include <stdlib.h>
181 #include <stdarg.h>
182 #include <string.h>
183 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
184
185 if test $ol_cv_header_stdc = yes; then
186   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
187 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
188 fi
189
190 if test $ol_cv_header_stdc = yes; then
191   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
192 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
193 fi
194
195 if test $ol_cv_header_stdc = yes; then
196   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
197 AC_TRY_RUN([#include <ctype.h>
198 #ifndef HAVE_EBCDIC
199 #       define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
200 #       define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
201 #else
202 #       define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
203                 || ('j' <= (c) && (c) <= 'r') \
204                 || ('s' <= (c) && (c) <= 'z'))
205 #       define TOUPPER(c)       (ISLOWER(c) ? ((c) | 0x40) : (c))
206 #endif
207 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
208 int main () { int i; for (i = 0; i < 256; i++)
209 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
210 exit (0); }
211 ], , ol_cv_header_stdc=no, :)
212 fi])
213 if test $ol_cv_header_stdc = yes; then
214   AC_DEFINE(STDC_HEADERS)
215 fi
216 ac_cv_header_stdc=disable
217 ])
218 dnl
219 dnl ====================================================================
220 dnl Check if struct passwd has pw_gecos
221 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
222 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
223         AC_TRY_COMPILE([#include <pwd.h>],[
224         struct passwd pwd;
225         pwd.pw_gecos = pwd.pw_name;
226 ],
227         [ol_cv_struct_passwd_pw_gecos=yes],
228         [ol_cv_struct_passwd_pw_gecos=no])])
229 if test $ol_cv_struct_passwd_pw_gecos = yes ; then
230         AC_DEFINE(HAVE_PW_GECOS,1, [define if struct passwd has pw_gecos])
231 fi
232 ])
233 dnl
234 dnl --------------------------------------------------------------------
235 dnl Check if struct passwd has pw_passwd
236 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
237 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
238         AC_TRY_COMPILE([#include <pwd.h>],[
239         struct passwd pwd;
240         pwd.pw_passwd = pwd.pw_name;
241 ],
242         [ol_cv_struct_passwd_pw_passwd=yes],
243         [ol_cv_struct_passwd_pw_passwd=no])])
244 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
245         AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
246 fi
247 ])
248 dnl
249 dnl ====================================================================
250 dnl Berkeley DB macros
251 dnl
252 dnl --------------------------------------------------------------------
253 dnl Try to link
254 AC_DEFUN([OL_BERKELEY_DB_TRY],
255 [if test $ol_cv_lib_db = no ; then
256         AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
257 [
258         ol_DB_LIB=ifelse($2,,,$2)
259         ol_LIBS=$LIBS
260         LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
261
262         AC_TRY_LINK([
263 #ifdef HAVE_DB_185_H
264 # include <db_185.h>
265 #else
266 # include <db.h>
267 #endif
268
269 #ifndef DB_VERSION_MAJOR
270 # define DB_VERSION_MAJOR 1
271 #endif
272
273 #ifndef NULL
274 #define NULL ((void*)0)
275 #endif
276 ],[
277 #if DB_VERSION_MAJOR > 1
278         {
279                 char *version;
280                 int major, minor, patch;
281
282                 version = db_version( &major, &minor, &patch );
283
284                 if( major != DB_VERSION_MAJOR ||
285                         minor < DB_VERSION_MINOR )
286                 {
287                         printf("Berkeley DB version mismatch\n"
288                                 "\theader: %s\n\tlibrary: %s\n",
289                                 DB_VERSION_STRING, version);
290                         return 1;
291                 }
292         }
293 #endif
294
295 #if DB_VERSION_MAJOR > 2
296         db_env_create( NULL, 0 );
297 #elif DB_VERSION_MAJOR > 1
298         db_appexit( NULL );
299 #else
300         (void) dbopen( NULL, 0, 0, 0, NULL);
301 #endif
302 ],[$1=yes],[$1=no])
303
304         LIBS="$ol_LIBS"
305 ])
306
307         if test $$1 = yes ; then
308                 ol_cv_lib_db=ifelse($2,,yes,$2)
309         fi
310 fi
311 ])
312 dnl
313 dnl --------------------------------------------------------------------
314 dnl Try to locate appropriate library
315 AC_DEFUN([OL_BERKELEY_DB_LINK],
316 [ol_cv_lib_db=no
317 OL_BERKELEY_DB_TRY(ol_cv_db_none)
318 OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
320 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
321 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
322 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
323 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
324 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
325 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
326 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
327 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
328 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
329 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
330 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
331 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
332 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
333 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
334 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
335 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
336 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
337 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
338 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
339 ])
340 dnl
341 dnl --------------------------------------------------------------------
342 dnl Check if Berkeley DB version
343 AC_DEFUN([OL_BERKELEY_DB_VERSION],
344 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
345         ol_LIBS="$LIBS"
346         LIBS="$LTHREAD_LIBS $LIBS"
347         if test $ol_cv_lib_db != yes ; then
348                 LIBS="$ol_cv_lib_db $LIBS"
349         fi
350
351         AC_TRY_RUN([
352 #ifdef HAVE_DB_185_H
353         choke me;
354 #else
355 #include <db.h>
356 #endif
357 #ifndef DB_VERSION_MAJOR
358 # define DB_VERSION_MAJOR 1
359 #endif
360 #ifndef NULL
361 #define NULL ((void *)0)
362 #endif
363 main()
364 {
365 #if DB_VERSION_MAJOR > 1
366         char *version;
367         int major, minor, patch;
368
369         version = db_version( &major, &minor, &patch );
370
371         if( major != DB_VERSION_MAJOR || minor < DB_VERSION_MINOR ) {
372                 printf("Berkeley DB version mismatch\n"
373                         "\theader: %s\n\tlibrary: %s\n",
374                         DB_VERSION_STRING, version);
375                 return 1;
376         }
377 #endif
378
379         return 0;
380 }],
381         [ol_cv_berkeley_db_version=yes],
382         [ol_cv_berkeley_db_version=no],
383         [ol_cv_berkeley_db_version=cross])
384
385         LIBS="$ol_LIBS"
386 ])
387
388         if test $ol_cv_berkeley_db_version = no ; then
389                 AC_MSG_ERROR([Berkeley DB version mismatch])
390         fi
391 ])dnl
392 dnl
393 dnl --------------------------------------------------------------------
394 dnl Check if Berkeley DB supports DB_THREAD
395 AC_DEFUN([OL_BERKELEY_DB_THREAD],
396 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
397         ol_LIBS="$LIBS"
398         LIBS="$LTHREAD_LIBS $LIBS"
399         if test $ol_cv_lib_db != yes ; then
400                 LIBS="$ol_cv_lib_db $LIBS"
401         fi
402
403         AC_TRY_RUN([
404 #ifdef HAVE_DB_185_H
405         choke me;
406 #else
407 #include <db.h>
408 #endif
409 #ifndef NULL
410 #define NULL ((void *)0)
411 #endif
412 main()
413 {
414         int rc;
415         u_int32_t flags = DB_CREATE |
416 #ifdef DB_PRIVATE
417                 DB_PRIVATE |
418 #endif
419                 DB_THREAD;
420
421 #if DB_VERSION_MAJOR > 2
422         DB_ENV *env = NULL;
423
424         rc = db_env_create( &env, 0 );
425
426         flags |= DB_INIT_MPOOL;
427 #ifdef DB_MPOOL_PRIVATE
428         flags |= DB_MPOOL_PRIVATE;
429 #endif
430
431         if( rc ) {
432                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
433                 return rc;
434         }
435
436 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
437         rc = env->open( env, NULL, flags, 0 );
438 #else
439         rc = env->open( env, NULL, NULL, flags, 0 );
440 #endif
441
442         if ( rc == 0 ) {
443                 rc = env->close( env, 0 );
444         }
445
446         if( rc ) {
447                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
448                 return rc;
449         }
450
451 #else
452         DB_ENV env;
453         memset( &env, '\0', sizeof(env) );
454
455         rc = db_appinit( NULL, NULL, &env, flags );
456
457         if( rc == 0 ) {
458                 db_appexit( &env );
459         }
460
461         unlink("__db_mpool.share");
462         unlink("__db_lock.share");
463 #endif
464
465         return rc;
466 }],
467         [ol_cv_berkeley_db_thread=yes],
468         [ol_cv_berkeley_db_thread=no],
469         [ol_cv_berkeley_db_thread=cross])
470
471         LIBS="$ol_LIBS"
472 ])
473
474         if test $ol_cv_berkeley_db_thread != no ; then
475                 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
476                         [define if Berkeley DB has DB_THREAD support])
477         fi
478 ])dnl
479 dnl
480 dnl --------------------------------------------------------------------
481 dnl Find any DB
482 AC_DEFUN([OL_BERKELEY_DB],
483 [ol_cv_berkeley_db=no
484 AC_CHECK_HEADERS(db.h)
485 if test $ac_cv_header_db_h = yes; then
486         OL_BERKELEY_DB_LINK
487         if test "$ol_cv_lib_db" != no ; then
488                 ol_cv_berkeley_db=yes
489                 OL_BERKELEY_DB_VERSION
490                 OL_BERKELEY_DB_THREAD
491         fi
492 fi
493 ])
494 dnl --------------------------------------------------------------------
495 dnl Check for version compatility with back-bdb
496 AC_DEFUN([OL_BDB_COMPAT],
497 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
498         AC_EGREP_CPP(__db_version_compat,[
499 #include <db.h>
500
501  /* this check could be improved */
502 #ifndef DB_VERSION_MAJOR
503 #       define DB_VERSION_MAJOR 1
504 #endif
505 #ifndef DB_VERSION_MINOR
506 #       define DB_VERSION_MINOR 0
507 #endif
508
509 /* require 4.2 or later */
510 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
511         __db_version_compat
512 #endif
513         ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
514 ])
515
516 dnl --------------------------------------------------------------------
517 dnl Find old Berkeley DB 1.85/1.86
518 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
519 [AC_CHECK_HEADERS(db_185.h db.h)
520 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
521         AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
522                 AC_EGREP_CPP(__db_version_1,[
523 #if HAVE_DB_185_H
524 #       include <db_185.h>
525 #else
526 #       include <db.h>
527 #endif
528
529  /* this check could be improved */
530 #ifndef DB_VERSION_MAJOR
531 #       define DB_VERSION_MAJOR 1
532 #endif
533
534 #if DB_VERSION_MAJOR == 1 
535         __db_version_1
536 #endif
537 ],      [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
538
539         if test $ol_cv_header_db1 = yes ; then
540                 OL_BERKELEY_DB_LINK
541                 if test "$ol_cv_lib_db" != no ; then
542                         ol_cv_berkeley_db=yes
543                 fi
544         fi
545 fi
546 ])
547 dnl
548 dnl ====================================================================
549 dnl Check if GDBM library exists
550 dnl Check for gdbm_open in standard libraries or -lgdbm
551 dnl
552 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
553 dnl             'yes' implies gdbm_open is in $LIBS
554 dnl
555 dnl uses:
556 dnl             AC_CHECK_FUNC(gdbm_open)
557 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
558 dnl
559 AC_DEFUN([OL_LIB_GDBM],
560 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
561 [       ol_LIBS="$LIBS"
562         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
563                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
564         ])
565         LIBS="$ol_LIBS"
566 ])
567 ])dnl
568 dnl
569 dnl --------------------------------------------------------------------
570 dnl Check if GDBM exists
571 dnl
572 dnl defines ol_cv_gdbm to 'yes' or 'no'
573 dnl 
574 dnl uses:
575 dnl             OL_LIB_GDBM
576 dnl             AC_CHECK_HEADERS(gdbm.h)
577 dnl
578 AC_DEFUN([OL_GDBM],
579 [AC_REQUIRE([OL_LIB_GDBM])
580  AC_CHECK_HEADERS(gdbm.h)
581  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
582         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
583                 ol_cv_gdbm=no
584         else
585                 ol_cv_gdbm=yes
586         fi
587 ])
588  if test $ol_cv_gdbm = yes ; then
589         AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
590  fi
591 ])dnl
592 dnl
593 dnl ====================================================================
594 dnl Check if MDBM library exists
595 dnl Check for mdbm_open in standard libraries or -lmdbm
596 dnl
597 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
598 dnl             'yes' implies mdbm_open is in $LIBS
599 dnl
600 dnl uses:
601 dnl             AC_CHECK_FUNC(mdbm_set_chain)
602 dnl             AC_CHECK_LIB(mdbm,mdbm_set_chain)
603 dnl
604 AC_DEFUN([OL_LIB_MDBM],
605 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
606 [       ol_LIBS="$LIBS"
607         AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
608                 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
609         ])
610         LIBS="$ol_LIBS"
611 ])
612 ])dnl
613 dnl
614 dnl --------------------------------------------------------------------
615 dnl Check if MDBM exists
616 dnl
617 dnl defines ol_cv_mdbm to 'yes' or 'no'
618 dnl 
619 dnl uses:
620 dnl             OL_LIB_MDBM
621 dnl             AC_CHECK_HEADERS(mdbm.h)
622 dnl
623 AC_DEFUN([OL_MDBM],
624 [AC_REQUIRE([OL_LIB_MDBM])
625  AC_CHECK_HEADERS(mdbm.h)
626  AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
627         if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
628                 ol_cv_mdbm=no
629         else
630                 ol_cv_mdbm=yes
631         fi
632 ])
633  if test $ol_cv_mdbm = yes ; then
634         AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
635  fi
636 ])dnl
637 dnl
638 dnl ====================================================================
639 dnl Check if NDBM library exists
640 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
641 dnl
642 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
643 dnl             'yes' implies ndbm_open is in $LIBS
644 dnl
645 dnl uses:
646 dnl             AC_CHECK_FUNC(dbm_open)
647 dnl             AC_CHECK_LIB(ndbm,dbm_open)
648 dnl             AC_CHECK_LIB(dbm,dbm_open)
649 dnl
650 dnl restrictions:
651 dnl             should also check SVR4 case: dbm_open() in -lucb but that
652 dnl             would requiring dealing with -L/usr/ucblib
653 dnl
654 AC_DEFUN([OL_LIB_NDBM],
655 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
656 [       ol_LIBS="$LIBS"
657         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
658                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
659                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
660                                 [ol_cv_lib_ndbm=no])dnl
661                 ])
662         ])
663         LIBS="$ol_LIBS"
664 ])
665 ])dnl
666 dnl
667 dnl --------------------------------------------------------------------
668 dnl Check if NDBM exists
669 dnl
670 dnl defines ol_cv_ndbm to 'yes' or 'no'
671 dnl 
672 dnl uses:
673 dnl             OL_LIB_NDBM
674 dnl             AC_CHECK_HEADERS(ndbm.h)
675 dnl
676 dnl restrictions:
677 dnl             Doesn't handle SVR4 case (see above)
678 dnl
679 AC_DEFUN([OL_NDBM],
680 [AC_REQUIRE([OL_LIB_NDBM])
681  AC_CHECK_HEADERS(ndbm.h)
682  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
683         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
684                 ol_cv_ndbm=no
685         else
686                 ol_cv_ndbm=yes
687         fi
688 ])
689  if test $ol_cv_ndbm = yes ; then
690         AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
691  fi
692 ])dnl
693 dnl
694 dnl ====================================================================
695 dnl Check POSIX Thread version 
696 dnl
697 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
698 dnl     version of the POSIX.4a Draft that is implemented.
699 dnl     10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
700 dnl     Existence of pthread.h should be tested separately.
701 dnl
702 dnl tests:
703 dnl     pthread_detach() was dropped in Draft 8, it is present
704 dnl             in every other version
705 dnl     PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
706 dnl             PTHREAD_CREATE_JOINABLE after that
707 dnl     pthread_attr_create was renamed to pthread_attr_init in Draft 6.
708 dnl             Draft 6-10 has _init, Draft 4-5 has _create.
709 dnl     pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
710 dnl     PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
711 dnl             interesting to us because we don't try to statically
712 dnl             initialize mutexes. 5-10 has it.
713 dnl
714 dnl Draft 9 and 10 are equivalent for our purposes.
715 dnl
716 AC_DEFUN([OL_POSIX_THREAD_VERSION],
717 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
718         AC_TRY_COMPILE([
719 #               include <pthread.h>
720         ],[
721                 int i = PTHREAD_CREATE_JOINABLE;
722         ],[
723         AC_EGREP_HEADER(pthread_detach,pthread.h,
724         ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
725         AC_EGREP_CPP(draft7,[
726 #               include <pthread.h>
727 #               ifdef PTHREAD_CREATE_UNDETACHED
728                 draft7
729 #               endif
730         ], ol_cv_pthread_version=7, [
731         AC_EGREP_HEADER(pthread_attr_init,pthread.h,
732         ol_cv_pthread_version=6, [
733         AC_EGREP_CPP(draft5,[
734 #               include <pthread.h>
735 #ifdef          PTHREAD_MUTEX_INITIALIZER
736                 draft5
737 #endif
738         ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
739 ])
740 ])dnl
741 dnl
742 dnl --------------------------------------------------------------------
743 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
744 [/* pthread test headers */
745 #include <pthread.h>
746 #if HAVE_PTHREADS < 7
747 #include <errno.h>
748 #endif
749 #ifndef NULL
750 #define NULL (void*)0
751 #endif
752
753 static void *task(p)
754         void *p;
755 {
756         return (void *) (p == NULL);
757 }
758 ])
759 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
760         /* pthread test function */
761 #ifndef PTHREAD_CREATE_DETACHED
762 #define PTHREAD_CREATE_DETACHED 1
763 #endif
764         pthread_t t;
765         int status;
766         int detach = PTHREAD_CREATE_DETACHED;
767
768 #if HAVE_PTHREADS > 4
769         /* Final pthreads */
770         pthread_attr_t attr;
771
772         status = pthread_attr_init(&attr);
773         if( status ) return status;
774
775 #if HAVE_PTHREADS < 7
776         status = pthread_attr_setdetachstate(&attr, &detach);
777         if( status < 0 ) status = errno;
778 #else
779         status = pthread_attr_setdetachstate(&attr, detach);
780 #endif
781         if( status ) return status;
782         status = pthread_create( &t, &attr, task, NULL );
783 #if HAVE_PTHREADS < 7
784         if( status < 0 ) status = errno;
785 #endif
786         if( status ) return status;
787 #else
788         /* Draft 4 pthreads */
789         status = pthread_create( &t, pthread_attr_default, task, NULL );
790         if( status ) return errno;
791
792         /* give thread a chance to complete */
793         /* it should remain joinable and hence detachable */
794         sleep( 1 );
795
796         status = pthread_detach( &t );
797         if( status ) return errno;
798 #endif
799
800 #ifdef HAVE_LINUX_THREADS
801         pthread_kill_other_threads_np();
802 #endif
803
804         return 0;
805 ])
806
807 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
808 [OL_PTHREAD_TEST_INCLUDES
809
810 int main(argc, argv)
811         int argc;
812         char **argv;
813 {
814 OL_PTHREAD_TEST_FUNCTION
815 }
816 ])
817 dnl --------------------------------------------------------------------
818 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
819 if test "$ol_link_threads" = no ; then
820         # try $1
821         AC_CACHE_CHECK([for pthread link with $1], [$2], [
822                 # save the flags
823                 ol_LIBS="$LIBS"
824                 LIBS="$1 $LIBS"
825
826                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
827                         [$2=yes], [$2=no],
828                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
829                                 [$2=yes], [$2=no])])
830
831                 # restore the LIBS
832                 LIBS="$ol_LIBS"
833         ])
834
835         if test $$2 = yes ; then
836                 ol_link_pthreads="$1"
837                 ol_link_threads=posix
838         fi
839 fi
840 ])
841 dnl
842 dnl ====================================================================
843 dnl Check GNU Pth pthread Header
844 dnl
845 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
846 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
847 dnl             doesn't exists.  Existance of pthread.h should separately
848 dnl             checked.
849 dnl 
850 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
851         AC_CACHE_CHECK([for GNU Pth pthread.h],
852                 [ol_cv_header_gnu_pth_pthread_h],
853                 [AC_EGREP_CPP(__gnu_pth__,
854                         [#include <pthread.h>
855 #ifdef _POSIX_THREAD_IS_GNU_PTH
856         __gnu_pth__;
857 #endif
858 ],
859                         [ol_cv_header_gnu_pth_pthread_h=yes],
860                         [ol_cv_header_gnu_pth_pthread_h=no])
861                 ])
862 ])dnl
863 dnl ====================================================================
864 dnl Check for NT Threads
865 AC_DEFUN([OL_NT_THREADS], [
866         AC_CHECK_FUNC(_beginthread)
867
868         if test $ac_cv_func__beginthread = yes ; then
869                 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
870                 ol_cv_nt_threads=yes
871         fi
872 ])
873 dnl ====================================================================
874 dnl Check LinuxThreads Header
875 dnl
876 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
877 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
878 dnl             doesn't exists.  Existance of pthread.h should separately
879 dnl             checked.
880 dnl 
881 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
882         AC_CACHE_CHECK([for LinuxThreads pthread.h],
883                 [ol_cv_header_linux_threads],
884                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
885                         [#include <pthread.h>],
886                         [ol_cv_header_linux_threads=yes],
887                         [ol_cv_header_linux_threads=no])
888                 ])
889         if test $ol_cv_header_linux_threads = yes; then
890                 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
891         fi
892 ])dnl
893 dnl --------------------------------------------------------------------
894 dnl     Check LinuxThreads Implementation
895 dnl
896 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
897 dnl     'no' implies pthreads implementation is not LinuxThreads.
898 dnl 
899 AC_DEFUN([OL_SYS_LINUX_THREADS], [
900         AC_CHECK_FUNCS(pthread_kill_other_threads_np)
901         AC_CACHE_CHECK([for LinuxThreads implementation],
902                 [ol_cv_sys_linux_threads],
903                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
904 ])dnl
905 dnl
906 dnl --------------------------------------------------------------------
907 dnl Check LinuxThreads consistency
908 AC_DEFUN([OL_LINUX_THREADS], [
909         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
910         AC_REQUIRE([OL_SYS_LINUX_THREADS])
911         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
912                 if test $ol_cv_header_linux_threads = yes -a \
913                         $ol_cv_sys_linux_threads = yes; then
914                         ol_cv_linux_threads=yes
915                 elif test $ol_cv_header_linux_threads = no -a \
916                         $ol_cv_sys_linux_threads = no; then
917                         ol_cv_linux_threads=no
918                 else
919                         ol_cv_linux_threads=error
920                 fi
921         ])
922 ])dnl
923 dnl
924 dnl ====================================================================
925 dnl Check for POSIX Regex
926 AC_DEFUN([OL_POSIX_REGEX], [
927 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
928         AC_TRY_RUN([
929 #include <sys/types.h>
930 #include <regex.h>
931 static char *pattern, *string;
932 main()
933 {
934         int rc;
935         regex_t re;
936
937         pattern = "^A";
938
939         if(regcomp(&re, pattern, 0)) {
940                 return -1;
941         }
942         
943         string = "ALL MATCH";
944         
945         rc = regexec(&re, string, 0, (void*)0, 0);
946
947         regfree(&re);
948
949         return rc;
950 }],
951         [ol_cv_c_posix_regex=yes],
952         [ol_cv_c_posix_regex=no],
953         [ol_cv_c_posix_regex=cross])])
954 ])
955 dnl
956 dnl ====================================================================
957 dnl Check if toupper() requires islower() to be called first
958 AC_DEFUN([OL_C_UPPER_LOWER],
959 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
960         AC_TRY_RUN([
961 #include <ctype.h>
962 main()
963 {
964         if ('C' == toupper('C'))
965                 exit(0);
966         else
967                 exit(1);
968 }],
969         [ol_cv_c_upper_lower=no],
970         [ol_cv_c_upper_lower=yes],
971         [ol_cv_c_upper_lower=safe])])
972 if test $ol_cv_c_upper_lower != no ; then
973         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
974 fi
975 ])
976 dnl
977 dnl ====================================================================
978 dnl Error string checks
979 dnl
980 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
981 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
982 dnl Reported by Keith Bostic.
983 AC_DEFUN([OL_SYS_ERRLIST],
984 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
985         AC_TRY_COMPILE([
986 #include <stdio.h>
987 #include <sys/types.h>
988 #include <errno.h>
989 #ifdef WINNT
990 #include <stdlib.h>
991 #endif ],
992         [char *c = (char *) *sys_errlist],
993         [ol_cv_dcl_sys_errlist=yes
994         ol_cv_have_sys_errlist=yes],
995         [ol_cv_dcl_sys_errlist=no])])
996 #
997 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
998 if test $ol_cv_dcl_sys_errlist = no ; then
999         AC_DEFINE(DECL_SYS_ERRLIST,1,
1000                 [define if sys_errlist is not declared in stdio.h or errno.h])
1001
1002         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
1003                 AC_TRY_LINK([#include <errno.h>],
1004                         [char *c = (char *) *sys_errlist],
1005                         [ol_cv_have_sys_errlist=yes],
1006                         [ol_cv_have_sys_errlist=no])])
1007 fi
1008 if test $ol_cv_have_sys_errlist = yes ; then
1009         AC_DEFINE(HAVE_SYS_ERRLIST,1,
1010                 [define if you actually have sys_errlist in your libs])
1011 fi
1012 ])dnl
1013 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
1014 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
1015         AC_EGREP_CPP(strerror_r,[#include <string.h>],
1016                 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
1017
1018         if test $ol_decl_strerror_r = yes ; then
1019                 AC_TRY_COMPILE([#include <string.h>],
1020                         [   /* from autoconf 2.59 */
1021                                 char buf[100];
1022                                 char x = *strerror_r (0, buf, sizeof buf);
1023                                 char *p = strerror_r (0, buf, sizeof buf);
1024                         ], ol_cv_nonposix_strerror_r=yes, ol_cv_nonposix_strerror_r=no)
1025         else
1026                 AC_TRY_RUN([
1027                         main() {
1028                                 char buf[100];
1029                                 buf[0] = 0;
1030                                 strerror_r( 1, buf, sizeof buf );
1031                                 exit( buf[0] == 0 );
1032                         }
1033                         ], ol_cv_nonposix_strerror_r=yes, ol_cv_nonposix_strerror=no)
1034         fi
1035         ])
1036 if test $ol_cv_nonposix_strerror_r = yes ; then
1037         AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1038                 [define if strerror_r returns char* instead of int])
1039 fi
1040 ])dnl
1041 dnl
1042 AC_DEFUN([OL_STRERROR],
1043 [OL_SYS_ERRLIST dnl TEMPORARY
1044 AC_CHECK_FUNCS(strerror strerror_r)
1045 ol_cv_func_strerror_r=no
1046 if test "${ac_cv_func_strerror_r}" = yes ; then
1047         OL_NONPOSIX_STRERROR_R
1048 elif test "${ac_cv_func_strerror}" = no ; then
1049         OL_SYS_ERRLIST
1050 fi
1051 ])dnl
1052 dnl ====================================================================
1053 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1054 dnl "int x; int *volatile a = &x; *a = 0;"
1055 dnl     -- borrowed from PDKSH
1056 AC_DEFUN(OL_C_VOLATILE,
1057  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1058     [AC_TRY_COMPILE([int x, y, z;],
1059       [volatile int a; int * volatile b = x ? &y : &z;
1060       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1061       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
1062   if test $ol_cv_c_volatile = yes; then
1063     : 
1064   else
1065     AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1066   fi
1067  ])dnl
1068 dnl
1069 dnl ====================================================================
1070 dnl Look for fetch(3)
1071 AC_DEFUN([OL_LIB_FETCH],
1072 [ol_LIBS=$LIBS
1073 LIBS="-lfetch -lcom_err $LIBS"
1074 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1075         AC_TRY_LINK([
1076 #include <sys/param.h>
1077 #include <stdio.h>
1078 #include <fetch.h>],
1079         [struct url *u = fetchParseURL("file:///"); ],
1080         [ol_cv_lib_fetch=yes],
1081         [ol_cv_lib_fetch=no])])
1082 LIBS=$ol_LIBS
1083 if test $ol_cv_lib_fetch != no ; then
1084         ol_link_fetch="-lfetch -lcom_err"
1085         AC_DEFINE(HAVE_FETCH,1,
1086                 [define if you actually have FreeBSD fetch(3)])
1087 fi
1088 ])dnl
1089 dnl
1090 dnl ====================================================================
1091 dnl Define sig_atomic_t if not defined in signal.h
1092 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
1093  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
1094     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
1095                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
1096   if test $ol_cv_type_sig_atomic_t = no; then
1097     AC_DEFINE(sig_atomic_t,int,
1098                 [define to atomic type if sig_atomic_t is not available])
1099   fi
1100  ])dnl
1101 dnl
1102 dnl ====================================================================
1103 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
1104 AC_DEFUN(OL_TYPE_SOCKLEN_T,
1105  [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
1106     [AC_TRY_COMPILE([
1107 #ifdef HAVE_SYS_TYPES_H
1108 #include <sys/types.h>
1109 #endif
1110 #ifdef HAVE_SYS_SOCKET_H
1111 #include <sys/socket.h>
1112 #endif
1113 ], [socklen_t len;],
1114                 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
1115   if test $ol_cv_type_socklen_t = no; then
1116     AC_DEFINE(socklen_t, int,
1117                 [define to int if socklen_t is not available])
1118   fi
1119  ])dnl
1120 dnl
1121 dnl ====================================================================
1122 dnl Define inet_aton is available
1123 AC_DEFUN(OL_FUNC_INET_ATON,
1124  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1125     [AC_TRY_LINK([
1126 #ifdef HAVE_SYS_TYPES_H
1127 #       include <sys/types.h>
1128 #endif
1129 #ifdef HAVE_SYS_SOCKET_H
1130 #       include <sys/socket.h>
1131 #       ifdef HAVE_SYS_SELECT_H
1132 #               include <sys/select.h>
1133 #       endif
1134 #       include <netinet/in.h>
1135 #       ifdef HAVE_ARPA_INET_H
1136 #               include <arpa/inet.h>
1137 #       endif
1138 #endif
1139 ], [struct in_addr in;
1140 int rc = inet_aton( "255.255.255.255", &in );],
1141                 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1142   if test $ol_cv_func_inet_aton != no; then
1143     AC_DEFINE(HAVE_INET_ATON, 1,
1144                 [define to you inet_aton(3) is available])
1145   fi
1146  ])dnl
1147 dnl
1148 dnl ====================================================================
1149 dnl check no of arguments for ctime_r
1150 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1151  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1152    [AC_TRY_COMPILE([#include <time.h>],
1153                 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1154                         ol_cv_func_ctime_r_nargs3=yes,
1155                         ol_cv_func_ctime_r_nargs3=no)
1156
1157         AC_TRY_COMPILE([#include <time.h>],
1158                 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1159                         ol_cv_func_ctime_r_nargs2=yes,
1160                         ol_cv_func_ctime_r_nargs2=no)
1161
1162         if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1163                 $ol_cv_func_ctime_r_nargs2 = no ; then
1164
1165                 ol_cv_func_ctime_r_nargs=3
1166
1167         elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1168                 $ol_cv_func_ctime_r_nargs2 = yes ; then
1169
1170                 ol_cv_func_ctime_r_nargs=2
1171
1172         else
1173                 ol_cv_func_ctime_r_nargs=0
1174         fi
1175   ])
1176
1177   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1178         AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1179                 [set to the number of arguments ctime_r() expects])
1180   fi
1181 ])dnl
1182 dnl
1183 dnl --------------------------------------------------------------------
1184 dnl check return type of ctime_r()
1185 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1186  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1187    [AC_TRY_COMPILE([#include <time.h>],
1188                 [extern int (ctime_r)();],
1189                         ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1190         ])
1191   if test $ol_cv_func_ctime_r_type = "int" ; then
1192         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1193   fi
1194 ])dnl
1195 dnl ====================================================================
1196 dnl check no of arguments for gethostbyname_r
1197 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1198  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1199         ol_cv_func_gethostbyname_r_nargs,
1200         [AC_TRY_COMPILE([#include <sys/types.h>
1201 #include <sys/socket.h>
1202 #include <netinet/in.h>
1203 #include <netdb.h>
1204 #define BUFSIZE (sizeof(struct hostent)+10)],
1205                 [struct hostent hent; char buffer[BUFSIZE];
1206                 int bufsize=BUFSIZE;int h_errno;
1207                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1208                         buffer, bufsize, &h_errno);],
1209                 ol_cv_func_gethostbyname_r_nargs5=yes, 
1210                 ol_cv_func_gethostbyname_r_nargs5=no)
1211
1212         AC_TRY_COMPILE([#include <sys/types.h>
1213 #include <sys/socket.h>
1214 #include <netinet/in.h>
1215 #include <netdb.h>
1216 #define BUFSIZE (sizeof(struct hostent)+10)],
1217                 [struct hostent hent;struct hostent *rhent;
1218                 char buffer[BUFSIZE];
1219                 int bufsize=BUFSIZE;int h_errno;
1220                 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1221                         &rhent, &h_errno);],
1222                 ol_cv_func_gethostbyname_r_nargs6=yes,
1223                 ol_cv_func_gethostbyname_r_nargs6=no)
1224
1225         if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1226                 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1227
1228                 ol_cv_func_gethostbyname_r_nargs=5
1229
1230         elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1231                 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1232
1233                 ol_cv_func_gethostbyname_r_nargs=6
1234
1235         else
1236                 ol_cv_func_gethostbyname_r_nargs=0
1237         fi
1238   ])
1239   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1240         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1241                 $ol_cv_func_gethostbyname_r_nargs,
1242                 [set to the number of arguments gethostbyname_r() expects])
1243   fi
1244 ])dnl
1245 dnl
1246 dnl check no of arguments for gethostbyaddr_r
1247 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1248  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1249         [ol_cv_func_gethostbyaddr_r_nargs],
1250         [AC_TRY_COMPILE([#include <sys/types.h>
1251 #include <sys/socket.h>
1252 #include <netinet/in.h>
1253 #include <netdb.h>
1254 #define BUFSIZE (sizeof(struct hostent)+10)],
1255            [struct hostent hent; char buffer[BUFSIZE]; 
1256             struct in_addr add;
1257             size_t alen=sizeof(struct in_addr);
1258             int bufsize=BUFSIZE;int h_errno;
1259                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1260                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1261                 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1262                 ol_cv_func_gethostbyaddr_r_nargs7=no)
1263
1264         AC_TRY_COMPILE([#include <sys/types.h>
1265 #include <sys/socket.h>
1266 #include <netinet/in.h>
1267 #include <netdb.h>
1268 #define BUFSIZE (sizeof(struct hostent)+10)],
1269                 [struct hostent hent;
1270                 struct hostent *rhent; char buffer[BUFSIZE]; 
1271                 struct in_addr add;
1272                 size_t alen=sizeof(struct in_addr);
1273                 int bufsize=BUFSIZE;int h_errno;
1274                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1275                         alen, AF_INET, &hent, buffer, bufsize, 
1276                         &rhent, &h_errno);],
1277                 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1278                 ol_cv_func_gethostbyaddr_r_nargs8=no)
1279
1280         if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1281                 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1282
1283                 ol_cv_func_gethostbyaddr_r_nargs=7
1284
1285         elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1286                 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1287
1288                 ol_cv_func_gethostbyaddr_r_nargs=8
1289
1290         else
1291                 ol_cv_func_gethostbyaddr_r_nargs=0
1292         fi
1293   ])
1294   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1295     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1296                 $ol_cv_func_gethostbyaddr_r_nargs,
1297                 [set to the number of arguments gethostbyaddr_r() expects])
1298   fi
1299 ])dnl
1300 dnl
1301 dnl --------------------------------------------------------------------
1302 dnl Check for Cyrus SASL version compatility
1303 AC_DEFUN([OL_SASL_COMPAT],
1304 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1305         AC_EGREP_CPP(__sasl_compat,[
1306 #ifdef HAVE_SASL_SASL_H
1307 #include <sasl/sasl.h>
1308 #else
1309 #include <sasl.h>
1310 #endif
1311
1312 /* Require 2.1.15+ */
1313 #if SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR > 1
1314         char *__sasl_compat = "2.2+ or better okay (we guess)";
1315 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR == 1 \
1316         && SASL_VERSION_STEP >=15
1317         char *__sasl_compat = "2.1.15+ or better okay";
1318 #endif
1319         ],      [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1320 ])
1321 dnl ====================================================================
1322 dnl check for msg_accrights in msghdr
1323 AC_DEFUN(OL_MSGHDR_MSG_ACCRIGHTS,
1324  [AC_CACHE_CHECK(for msg_accrights in msghdr, ol_cv_msghdr_msg_accrights,
1325    [AC_TRY_COMPILE([#include <sys/socket.h>],
1326                 [struct msghdr m; m.msg_accrightslen=0],
1327                 ol_cv_msghdr_msg_accrights=yes, ol_cv_msghdr_msg_accrights=no)
1328         ])
1329   if test $ol_cv_msghdr_msg_accrights = "yes" ; then
1330         AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1,
1331                 [define if struct msghdr has msg_accrights])
1332   fi
1333 ])dnl
1334 AC_DEFUN([OL_SSL_COMPAT],
1335 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)], [ol_cv_ssl_crl_compat],[
1336         AC_EGREP_CPP(__ssl_compat,[
1337 #ifdef HAVE_OPENSSL_SSL_H
1338 #include <openssl/ssl.h>
1339 #else
1340 #include <ssl.h>
1341 #endif
1342
1343 /* Require 0.9.7d+ */
1344 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1345         char *__ssl_compat = "0.9.7d";
1346 #endif
1347         ],      [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])
1348 ])