]> git.sur5r.net Git - openldap/blob - build/openldap.m4
More syncrepl fixes
[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                                 "\texpected: %s\n\tgot: %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_db42,[-ldb42])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
320 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
321 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
322 OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
323 OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
324 OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
325 OL_BERKELEY_DB_TRY(ol_cv_db_db41,[-ldb41])
326 OL_BERKELEY_DB_TRY(ol_cv_db_db_41,[-ldb-41])
327 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_1,[-ldb-4.1])
328 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_1,[-ldb-4-1])
329 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
330 OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
331 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
332 OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
333 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
334 OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
335 ])
336 dnl
337 dnl --------------------------------------------------------------------
338 dnl Check if Berkeley DB version
339 AC_DEFUN([OL_BERKELEY_DB_VERSION],
340 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
341         ol_LIBS="$LIBS"
342         LIBS="$LTHREAD_LIBS $LIBS"
343         if test $ol_cv_lib_db != yes ; then
344                 LIBS="$ol_cv_lib_db $LIBS"
345         fi
346
347         AC_TRY_RUN([
348 #ifdef HAVE_DB_185_H
349         choke me;
350 #else
351 #include <db.h>
352 #endif
353 #ifndef DB_VERSION_MAJOR
354 # define DB_VERSION_MAJOR 1
355 #endif
356 #ifndef NULL
357 #define NULL ((void *)0)
358 #endif
359 main()
360 {
361 #if DB_VERSION_MAJOR > 1
362         char *version;
363         int major, minor, patch;
364
365         version = db_version( &major, &minor, &patch );
366
367         if( major != DB_VERSION_MAJOR || minor < DB_VERSION_MINOR ) {
368                 printf("Berkeley DB version mismatch\n"
369                         "\texpected: %s\n\tgot: %s\n",
370                         DB_VERSION_STRING, version);
371                 return 1;
372         }
373 #endif
374
375         return 0;
376 }],
377         [ol_cv_berkeley_db_version=yes],
378         [ol_cv_berkeley_db_version=no],
379         [ol_cv_berkeley_db_version=cross])
380
381         LIBS="$ol_LIBS"
382 ])
383
384         if test $ol_cv_berkeley_db_version = no ; then
385                 AC_MSG_ERROR([Berkeley DB version mismatch])
386         fi
387 ])dnl
388 dnl
389 dnl --------------------------------------------------------------------
390 dnl Check if Berkeley DB supports DB_THREAD
391 AC_DEFUN([OL_BERKELEY_DB_THREAD],
392 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
393         ol_LIBS="$LIBS"
394         LIBS="$LTHREAD_LIBS $LIBS"
395         if test $ol_cv_lib_db != yes ; then
396                 LIBS="$ol_cv_lib_db $LIBS"
397         fi
398
399         AC_TRY_RUN([
400 #ifdef HAVE_DB_185_H
401         choke me;
402 #else
403 #include <db.h>
404 #endif
405 #ifndef NULL
406 #define NULL ((void *)0)
407 #endif
408 main()
409 {
410         int rc;
411         u_int32_t flags = DB_CREATE |
412 #ifdef DB_PRIVATE
413                 DB_PRIVATE |
414 #endif
415                 DB_THREAD;
416
417 #if DB_VERSION_MAJOR > 2
418         DB_ENV *env = NULL;
419
420         rc = db_env_create( &env, 0 );
421
422         flags |= DB_INIT_MPOOL;
423 #ifdef DB_MPOOL_PRIVATE
424         flags |= DB_MPOOL_PRIVATE;
425 #endif
426
427         if( rc ) {
428                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
429                 return rc;
430         }
431
432 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
433         rc = env->open( env, NULL, flags, 0 );
434 #else
435         rc = env->open( env, NULL, NULL, flags, 0 );
436 #endif
437
438         if ( rc == 0 ) {
439                 rc = env->close( env, 0 );
440         }
441
442         if( rc ) {
443                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
444                 return rc;
445         }
446
447 #else
448         DB_ENV env;
449         memset( &env, '\0', sizeof(env) );
450
451         rc = db_appinit( NULL, NULL, &env, flags );
452
453         if( rc == 0 ) {
454                 db_appexit( &env );
455         }
456
457         unlink("__db_mpool.share");
458         unlink("__db_lock.share");
459 #endif
460
461         return rc;
462 }],
463         [ol_cv_berkeley_db_thread=yes],
464         [ol_cv_berkeley_db_thread=no],
465         [ol_cv_berkeley_db_thread=cross])
466
467         LIBS="$ol_LIBS"
468 ])
469
470         if test $ol_cv_berkeley_db_thread != no ; then
471                 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
472                         [define if Berkeley DB has DB_THREAD support])
473         fi
474 ])dnl
475 dnl
476 dnl --------------------------------------------------------------------
477 dnl Find any DB
478 AC_DEFUN([OL_BERKELEY_DB],
479 [ol_cv_berkeley_db=no
480 AC_CHECK_HEADERS(db.h)
481 if test $ac_cv_header_db_h = yes; then
482         OL_BERKELEY_DB_LINK
483         if test "$ol_cv_lib_db" != no ; then
484                 ol_cv_berkeley_db=yes
485                 OL_BERKELEY_DB_VERSION
486                 OL_BERKELEY_DB_THREAD
487         fi
488 fi
489 ])
490 dnl --------------------------------------------------------------------
491 dnl Check for version compatility with back-bdb
492 AC_DEFUN([OL_BDB_COMPAT],
493 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
494         AC_EGREP_CPP(__db_version_compat,[
495 #include <db.h>
496
497  /* this check could be improved */
498 #ifndef DB_VERSION_MAJOR
499 #       define DB_VERSION_MAJOR 1
500 #endif
501 #ifndef DB_VERSION_MINOR
502 #       define DB_VERSION_MINOR 0
503 #endif
504
505 /* require 4.2 or later */
506 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2)
507         __db_version_compat
508 #endif
509         ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
510 ])
511
512 dnl --------------------------------------------------------------------
513 dnl Find old Berkeley DB 1.85/1.86
514 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
515 [AC_CHECK_HEADERS(db_185.h db.h)
516 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
517         AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
518                 AC_EGREP_CPP(__db_version_1,[
519 #if HAVE_DB_185_H
520 #       include <db_185.h>
521 #else
522 #       include <db.h>
523 #endif
524
525  /* this check could be improved */
526 #ifndef DB_VERSION_MAJOR
527 #       define DB_VERSION_MAJOR 1
528 #endif
529
530 #if DB_VERSION_MAJOR == 1 
531         __db_version_1
532 #endif
533 ],      [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
534
535         if test $ol_cv_header_db1 = yes ; then
536                 OL_BERKELEY_DB_LINK
537                 if test "$ol_cv_lib_db" != no ; then
538                         ol_cv_berkeley_db=yes
539                 fi
540         fi
541 fi
542 ])
543 dnl
544 dnl ====================================================================
545 dnl Check if GDBM library exists
546 dnl Check for gdbm_open in standard libraries or -lgdbm
547 dnl
548 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
549 dnl             'yes' implies gdbm_open is in $LIBS
550 dnl
551 dnl uses:
552 dnl             AC_CHECK_FUNC(gdbm_open)
553 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
554 dnl
555 AC_DEFUN([OL_LIB_GDBM],
556 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
557 [       ol_LIBS="$LIBS"
558         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
559                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
560         ])
561         LIBS="$ol_LIBS"
562 ])
563 ])dnl
564 dnl
565 dnl --------------------------------------------------------------------
566 dnl Check if GDBM exists
567 dnl
568 dnl defines ol_cv_gdbm to 'yes' or 'no'
569 dnl 
570 dnl uses:
571 dnl             OL_LIB_GDBM
572 dnl             AC_CHECK_HEADERS(gdbm.h)
573 dnl
574 AC_DEFUN([OL_GDBM],
575 [AC_REQUIRE([OL_LIB_GDBM])
576  AC_CHECK_HEADERS(gdbm.h)
577  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
578         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
579                 ol_cv_gdbm=no
580         else
581                 ol_cv_gdbm=yes
582         fi
583 ])
584  if test $ol_cv_gdbm = yes ; then
585         AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
586  fi
587 ])dnl
588 dnl
589 dnl ====================================================================
590 dnl Check if MDBM library exists
591 dnl Check for mdbm_open in standard libraries or -lmdbm
592 dnl
593 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
594 dnl             'yes' implies mdbm_open is in $LIBS
595 dnl
596 dnl uses:
597 dnl             AC_CHECK_FUNC(mdbm_set_chain)
598 dnl             AC_CHECK_LIB(mdbm,mdbm_set_chain)
599 dnl
600 AC_DEFUN([OL_LIB_MDBM],
601 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
602 [       ol_LIBS="$LIBS"
603         AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
604                 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
605         ])
606         LIBS="$ol_LIBS"
607 ])
608 ])dnl
609 dnl
610 dnl --------------------------------------------------------------------
611 dnl Check if MDBM exists
612 dnl
613 dnl defines ol_cv_mdbm to 'yes' or 'no'
614 dnl 
615 dnl uses:
616 dnl             OL_LIB_MDBM
617 dnl             AC_CHECK_HEADERS(mdbm.h)
618 dnl
619 AC_DEFUN([OL_MDBM],
620 [AC_REQUIRE([OL_LIB_MDBM])
621  AC_CHECK_HEADERS(mdbm.h)
622  AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
623         if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
624                 ol_cv_mdbm=no
625         else
626                 ol_cv_mdbm=yes
627         fi
628 ])
629  if test $ol_cv_mdbm = yes ; then
630         AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
631  fi
632 ])dnl
633 dnl
634 dnl ====================================================================
635 dnl Check if NDBM library exists
636 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
637 dnl
638 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
639 dnl             'yes' implies ndbm_open is in $LIBS
640 dnl
641 dnl uses:
642 dnl             AC_CHECK_FUNC(dbm_open)
643 dnl             AC_CHECK_LIB(ndbm,dbm_open)
644 dnl             AC_CHECK_LIB(dbm,dbm_open)
645 dnl
646 dnl restrictions:
647 dnl             should also check SVR4 case: dbm_open() in -lucb but that
648 dnl             would requiring dealing with -L/usr/ucblib
649 dnl
650 AC_DEFUN([OL_LIB_NDBM],
651 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
652 [       ol_LIBS="$LIBS"
653         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
654                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
655                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
656                                 [ol_cv_lib_ndbm=no])dnl
657                 ])
658         ])
659         LIBS="$ol_LIBS"
660 ])
661 ])dnl
662 dnl
663 dnl --------------------------------------------------------------------
664 dnl Check if NDBM exists
665 dnl
666 dnl defines ol_cv_ndbm to 'yes' or 'no'
667 dnl 
668 dnl uses:
669 dnl             OL_LIB_NDBM
670 dnl             AC_CHECK_HEADERS(ndbm.h)
671 dnl
672 dnl restrictions:
673 dnl             Doesn't handle SVR4 case (see above)
674 dnl
675 AC_DEFUN([OL_NDBM],
676 [AC_REQUIRE([OL_LIB_NDBM])
677  AC_CHECK_HEADERS(ndbm.h)
678  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
679         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
680                 ol_cv_ndbm=no
681         else
682                 ol_cv_ndbm=yes
683         fi
684 ])
685  if test $ol_cv_ndbm = yes ; then
686         AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
687  fi
688 ])dnl
689 dnl
690 dnl ====================================================================
691 dnl Check POSIX Thread version 
692 dnl
693 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
694 dnl     version of the POSIX.4a Draft that is implemented.
695 dnl     10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
696 dnl     Existence of pthread.h should be tested separately.
697 dnl
698 dnl tests:
699 dnl     pthread_detach() was dropped in Draft 8, it is present
700 dnl             in every other version
701 dnl     PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
702 dnl             PTHREAD_CREATE_JOINABLE after that
703 dnl     pthread_attr_create was renamed to pthread_attr_init in Draft 6.
704 dnl             Draft 6-10 has _init, Draft 4-5 has _create.
705 dnl     pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
706 dnl     PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
707 dnl             interesting to us because we don't try to statically
708 dnl             initialize mutexes. 5-10 has it.
709 dnl
710 dnl Draft 9 and 10 are equivalent for our purposes.
711 dnl
712 AC_DEFUN([OL_POSIX_THREAD_VERSION],
713 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
714         AC_TRY_COMPILE([
715 #               include <pthread.h>
716         ],[
717                 int i = PTHREAD_CREATE_JOINABLE;
718         ],[
719         AC_EGREP_HEADER(pthread_detach,pthread.h,
720         ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
721         AC_EGREP_CPP(draft7,[
722 #               include <pthread.h>
723 #               ifdef PTHREAD_CREATE_UNDETACHED
724                 draft7
725 #               endif
726         ], ol_cv_pthread_version=7, [
727         AC_EGREP_HEADER(pthread_attr_init,pthread.h,
728         ol_cv_pthread_version=6, [
729         AC_EGREP_CPP(draft5,[
730 #               include <pthread.h>
731 #ifdef          PTHREAD_MUTEX_INITIALIZER
732                 draft5
733 #endif
734         ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
735 ])
736 ])dnl
737 dnl
738 dnl --------------------------------------------------------------------
739 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
740 [/* pthread test headers */
741 #include <pthread.h>
742 #if HAVE_PTHREADS < 7
743 #include <errno.h>
744 #endif
745 #ifndef NULL
746 #define NULL (void*)0
747 #endif
748
749 static void *task(p)
750         void *p;
751 {
752         return (void *) (p == NULL);
753 }
754 ])
755 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
756         /* pthread test function */
757 #ifndef PTHREAD_CREATE_DETACHED
758 #define PTHREAD_CREATE_DETACHED 1
759 #endif
760         pthread_t t;
761         int status;
762         int detach = PTHREAD_CREATE_DETACHED;
763
764 #if HAVE_PTHREADS > 4
765         /* Final pthreads */
766         pthread_attr_t attr;
767
768         status = pthread_attr_init(&attr);
769         if( status ) return status;
770
771 #if HAVE_PTHREADS < 7
772         status = pthread_attr_setdetachstate(&attr, &detach);
773         if( status < 0 ) status = errno;
774 #else
775         status = pthread_attr_setdetachstate(&attr, detach);
776 #endif
777         if( status ) return status;
778         status = pthread_create( &t, &attr, task, NULL );
779 #if HAVE_PTHREADS < 7
780         if( status < 0 ) status = errno;
781 #endif
782         if( status ) return status;
783 #else
784         /* Draft 4 pthreads */
785         status = pthread_create( &t, pthread_attr_default, task, NULL );
786         if( status ) return errno;
787
788         /* give thread a chance to complete */
789         /* it should remain joinable and hence detachable */
790         sleep( 1 );
791
792         status = pthread_detach( &t );
793         if( status ) return errno;
794 #endif
795
796 #ifdef HAVE_LINUX_THREADS
797         pthread_kill_other_threads_np();
798 #endif
799
800         return 0;
801 ])
802
803 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
804 [OL_PTHREAD_TEST_INCLUDES
805
806 int main(argc, argv)
807         int argc;
808         char **argv;
809 {
810 OL_PTHREAD_TEST_FUNCTION
811 }
812 ])
813 dnl --------------------------------------------------------------------
814 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
815 if test "$ol_link_threads" = no ; then
816         # try $1
817         AC_CACHE_CHECK([for pthread link with $1], [$2], [
818                 # save the flags
819                 ol_LIBS="$LIBS"
820                 LIBS="$1 $LIBS"
821
822                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
823                         [$2=yes], [$2=no],
824                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
825                                 [$2=yes], [$2=no])])
826
827                 # restore the LIBS
828                 LIBS="$ol_LIBS"
829         ])
830
831         if test $$2 = yes ; then
832                 ol_link_pthreads="$1"
833                 ol_link_threads=posix
834         fi
835 fi
836 ])
837 dnl
838 dnl ====================================================================
839 dnl Check GNU Pth pthread Header
840 dnl
841 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
842 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
843 dnl             doesn't exists.  Existance of pthread.h should separately
844 dnl             checked.
845 dnl 
846 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
847         AC_CACHE_CHECK([for GNU Pth pthread.h],
848                 [ol_cv_header_gnu_pth_pthread_h],
849                 [AC_EGREP_CPP(__gnu_pth__,
850                         [#include <pthread.h>
851 #ifdef _POSIX_THREAD_IS_GNU_PTH
852         __gnu_pth__;
853 #endif
854 ],
855                         [ol_cv_header_gnu_pth_pthread_h=yes],
856                         [ol_cv_header_gnu_pth_pthread_h=no])
857                 ])
858 ])dnl
859 dnl ====================================================================
860 dnl Check for NT Threads
861 AC_DEFUN([OL_NT_THREADS], [
862         AC_CHECK_FUNC(_beginthread)
863
864         if test $ac_cv_func__beginthread = yes ; then
865                 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
866                 ol_cv_nt_threads=yes
867         fi
868 ])
869 dnl ====================================================================
870 dnl Check LinuxThreads Header
871 dnl
872 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
873 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
874 dnl             doesn't exists.  Existance of pthread.h should separately
875 dnl             checked.
876 dnl 
877 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
878         AC_CACHE_CHECK([for LinuxThreads pthread.h],
879                 [ol_cv_header_linux_threads],
880                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
881                         [#include <pthread.h>],
882                         [ol_cv_header_linux_threads=yes],
883                         [ol_cv_header_linux_threads=no])
884                 ])
885         if test $ol_cv_header_linux_threads = yes; then
886                 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
887         fi
888 ])dnl
889 dnl --------------------------------------------------------------------
890 dnl     Check LinuxThreads Implementation
891 dnl
892 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
893 dnl     'no' implies pthreads implementation is not LinuxThreads.
894 dnl 
895 AC_DEFUN([OL_SYS_LINUX_THREADS], [
896         AC_CHECK_FUNCS(pthread_kill_other_threads_np)
897         AC_CACHE_CHECK([for LinuxThreads implementation],
898                 [ol_cv_sys_linux_threads],
899                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
900 ])dnl
901 dnl
902 dnl --------------------------------------------------------------------
903 dnl Check LinuxThreads consistency
904 AC_DEFUN([OL_LINUX_THREADS], [
905         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
906         AC_REQUIRE([OL_SYS_LINUX_THREADS])
907         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
908                 if test $ol_cv_header_linux_threads = yes -a \
909                         $ol_cv_sys_linux_threads = yes; then
910                         ol_cv_linux_threads=yes
911                 elif test $ol_cv_header_linux_threads = no -a \
912                         $ol_cv_sys_linux_threads = no; then
913                         ol_cv_linux_threads=no
914                 else
915                         ol_cv_linux_threads=error
916                 fi
917         ])
918 ])dnl
919 dnl
920 dnl ====================================================================
921 dnl Check for POSIX Regex
922 AC_DEFUN([OL_POSIX_REGEX], [
923 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
924         AC_TRY_RUN([
925 #include <sys/types.h>
926 #include <regex.h>
927 static char *pattern, *string;
928 main()
929 {
930         int rc;
931         regex_t re;
932
933         pattern = "^A";
934
935         if(regcomp(&re, pattern, 0)) {
936                 return -1;
937         }
938         
939         string = "ALL MATCH";
940         
941         rc = regexec(&re, string, 0, (void*)0, 0);
942
943         regfree(&re);
944
945         return rc;
946 }],
947         [ol_cv_c_posix_regex=yes],
948         [ol_cv_c_posix_regex=no],
949         [ol_cv_c_posix_regex=cross])])
950 ])
951 dnl
952 dnl ====================================================================
953 dnl Check if toupper() requires islower() to be called first
954 AC_DEFUN([OL_C_UPPER_LOWER],
955 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
956         AC_TRY_RUN([
957 #include <ctype.h>
958 main()
959 {
960         if ('C' == toupper('C'))
961                 exit(0);
962         else
963                 exit(1);
964 }],
965         [ol_cv_c_upper_lower=no],
966         [ol_cv_c_upper_lower=yes],
967         [ol_cv_c_upper_lower=safe])])
968 if test $ol_cv_c_upper_lower != no ; then
969         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
970 fi
971 ])
972 dnl
973 dnl ====================================================================
974 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
975 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
976 dnl Reported by Keith Bostic.
977 AC_DEFUN([OL_SYS_ERRLIST],
978 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
979         AC_TRY_COMPILE([
980 #include <stdio.h>
981 #include <sys/types.h>
982 #include <errno.h>
983 #ifdef WINNT
984 #include <stdlib.h>
985 #endif ],
986         [char *c = (char *) *sys_errlist],
987         [ol_cv_dcl_sys_errlist=yes
988         ol_cv_have_sys_errlist=yes],
989         [ol_cv_dcl_sys_errlist=no])])
990 #
991 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
992 if test $ol_cv_dcl_sys_errlist = no ; then
993         AC_DEFINE(DECL_SYS_ERRLIST,1,
994                 [define if sys_errlist is not declared in stdio.h or errno.h])
995
996         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
997                 AC_TRY_LINK([#include <errno.h>],
998                         [char *c = (char *) *sys_errlist],
999                         [ol_cv_have_sys_errlist=yes],
1000                         [ol_cv_have_sys_errlist=no])])
1001 fi
1002 if test $ol_cv_have_sys_errlist = yes ; then
1003         AC_DEFINE(HAVE_SYS_ERRLIST,1,
1004                 [define if you actually have sys_errlist in your libs])
1005 fi
1006 ])dnl
1007 dnl
1008 dnl ====================================================================
1009 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1010 dnl "int x; int *volatile a = &x; *a = 0;"
1011 dnl     -- borrowed from PDKSH
1012 AC_DEFUN(OL_C_VOLATILE,
1013  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1014     [AC_TRY_COMPILE([int x, y, z;],
1015       [volatile int a; int * volatile b = x ? &y : &z;
1016       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1017       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
1018   if test $ol_cv_c_volatile = yes; then
1019     : 
1020   else
1021     AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1022   fi
1023  ])dnl
1024 dnl
1025 dnl ====================================================================
1026 dnl Look for fetch(3)
1027 AC_DEFUN([OL_LIB_FETCH],
1028 [ol_LIBS=$LIBS
1029 LIBS="-lfetch -lcom_err $LIBS"
1030 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1031         AC_TRY_LINK([
1032 #include <sys/param.h>
1033 #include <stdio.h>
1034 #include <fetch.h>],
1035         [struct url *u = fetchParseURL("file:///"); ],
1036         [ol_cv_lib_fetch=yes],
1037         [ol_cv_lib_fetch=no])])
1038 LIBS=$ol_LIBS
1039 if test $ol_cv_lib_fetch != no ; then
1040         ol_link_fetch="-lfetch -lcom_err"
1041         AC_DEFINE(HAVE_FETCH,1,
1042                 [define if you actually have FreeBSD fetch(3)])
1043 fi
1044 ])dnl
1045 dnl
1046 dnl ====================================================================
1047 dnl Define sig_atomic_t if not defined in signal.h
1048 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
1049  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
1050     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
1051                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
1052   if test $ol_cv_type_sig_atomic_t = no; then
1053     AC_DEFINE(sig_atomic_t,int,
1054                 [define to atomic type if sig_atomic_t is not available])
1055   fi
1056  ])dnl
1057 dnl
1058 dnl ====================================================================
1059 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
1060 AC_DEFUN(OL_TYPE_SOCKLEN_T,
1061  [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
1062     [AC_TRY_COMPILE([
1063 #ifdef HAVE_SYS_TYPES_H
1064 #include <sys/types.h>
1065 #endif
1066 #ifdef HAVE_SYS_SOCKET_H
1067 #include <sys/socket.h>
1068 #endif
1069 ], [socklen_t len;],
1070                 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
1071   if test $ol_cv_type_socklen_t = no; then
1072     AC_DEFINE(socklen_t, int,
1073                 [define to int if socklen_t is not available])
1074   fi
1075  ])dnl
1076 dnl
1077 dnl ====================================================================
1078 dnl Define inet_aton is available
1079 AC_DEFUN(OL_FUNC_INET_ATON,
1080  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1081     [AC_TRY_LINK([
1082 #ifdef HAVE_SYS_TYPES_H
1083 #       include <sys/types.h>
1084 #endif
1085 #ifdef HAVE_SYS_SOCKET_H
1086 #       include <sys/socket.h>
1087 #       ifdef HAVE_SYS_SELECT_H
1088 #               include <sys/select.h>
1089 #       endif
1090 #       include <netinet/in.h>
1091 #       ifdef HAVE_ARPA_INET_H
1092 #               include <arpa/inet.h>
1093 #       endif
1094 #endif
1095 ], [struct in_addr in;
1096 int rc = inet_aton( "255.255.255.255", &in );],
1097                 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1098   if test $ol_cv_func_inet_aton != no; then
1099     AC_DEFINE(HAVE_INET_ATON, 1,
1100                 [define to you inet_aton(3) is available])
1101   fi
1102  ])dnl
1103 dnl
1104 dnl ====================================================================
1105 dnl check no of arguments for ctime_r
1106 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1107  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1108    [AC_TRY_COMPILE([#include <time.h>],
1109                 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1110                         ol_cv_func_ctime_r_nargs3=yes,
1111                         ol_cv_func_ctime_r_nargs3=no)
1112
1113         AC_TRY_COMPILE([#include <time.h>],
1114                 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1115                         ol_cv_func_ctime_r_nargs2=yes,
1116                         ol_cv_func_ctime_r_nargs2=no)
1117
1118         if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1119                 $ol_cv_func_ctime_r_nargs2 = no ; then
1120
1121                 ol_cv_func_ctime_r_nargs=3
1122
1123         elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1124                 $ol_cv_func_ctime_r_nargs2 = yes ; then
1125
1126                 ol_cv_func_ctime_r_nargs=2
1127
1128         else
1129                 ol_cv_func_ctime_r_nargs=0
1130         fi
1131   ])
1132
1133   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1134         AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1135                 [set to the number of arguments ctime_r() expects])
1136   fi
1137 ])dnl
1138 dnl
1139 dnl --------------------------------------------------------------------
1140 dnl check return type of ctime_r()
1141 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1142  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1143    [AC_TRY_COMPILE([#include <time.h>],
1144                 [extern int (ctime_r)();],
1145                         ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1146         ])
1147   if test $ol_cv_func_ctime_r_type = "int" ; then
1148         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1149   fi
1150 ])dnl
1151 dnl ====================================================================
1152 dnl check no of arguments for gethostbyname_r
1153 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1154  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1155         ol_cv_func_gethostbyname_r_nargs,
1156         [AC_TRY_COMPILE([#include <sys/types.h>
1157 #include <sys/socket.h>
1158 #include <netinet/in.h>
1159 #include <netdb.h>
1160 #define BUFSIZE (sizeof(struct hostent)+10)],
1161                 [struct hostent hent; char buffer[BUFSIZE];
1162                 int bufsize=BUFSIZE;int h_errno;
1163                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1164                         buffer, bufsize, &h_errno);],
1165                 ol_cv_func_gethostbyname_r_nargs5=yes, 
1166                 ol_cv_func_gethostbyname_r_nargs5=no)
1167
1168         AC_TRY_COMPILE([#include <sys/types.h>
1169 #include <sys/socket.h>
1170 #include <netinet/in.h>
1171 #include <netdb.h>
1172 #define BUFSIZE (sizeof(struct hostent)+10)],
1173                 [struct hostent hent;struct hostent *rhent;
1174                 char buffer[BUFSIZE];
1175                 int bufsize=BUFSIZE;int h_errno;
1176                 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1177                         &rhent, &h_errno);],
1178                 ol_cv_func_gethostbyname_r_nargs6=yes,
1179                 ol_cv_func_gethostbyname_r_nargs6=no)
1180
1181         if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1182                 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1183
1184                 ol_cv_func_gethostbyname_r_nargs=5
1185
1186         elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1187                 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1188
1189                 ol_cv_func_gethostbyname_r_nargs=6
1190
1191         else
1192                 ol_cv_func_gethostbyname_r_nargs=0
1193         fi
1194   ])
1195   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1196         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1197                 $ol_cv_func_gethostbyname_r_nargs,
1198                 [set to the number of arguments gethostbyname_r() expects])
1199   fi
1200 ])dnl
1201 dnl
1202 dnl check no of arguments for gethostbyaddr_r
1203 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1204  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1205         [ol_cv_func_gethostbyaddr_r_nargs],
1206         [AC_TRY_COMPILE([#include <sys/types.h>
1207 #include <sys/socket.h>
1208 #include <netinet/in.h>
1209 #include <netdb.h>
1210 #define BUFSIZE (sizeof(struct hostent)+10)],
1211            [struct hostent hent; char buffer[BUFSIZE]; 
1212             struct in_addr add;
1213             size_t alen=sizeof(struct in_addr);
1214             int bufsize=BUFSIZE;int h_errno;
1215                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1216                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1217                 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1218                 ol_cv_func_gethostbyaddr_r_nargs7=no)
1219
1220         AC_TRY_COMPILE([#include <sys/types.h>
1221 #include <sys/socket.h>
1222 #include <netinet/in.h>
1223 #include <netdb.h>
1224 #define BUFSIZE (sizeof(struct hostent)+10)],
1225                 [struct hostent hent;
1226                 struct hostent *rhent; char buffer[BUFSIZE]; 
1227                 struct in_addr add;
1228                 size_t alen=sizeof(struct in_addr);
1229                 int bufsize=BUFSIZE;int h_errno;
1230                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1231                         alen, AF_INET, &hent, buffer, bufsize, 
1232                         &rhent, &h_errno);],
1233                 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1234                 ol_cv_func_gethostbyaddr_r_nargs8=no)
1235
1236         if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1237                 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1238
1239                 ol_cv_func_gethostbyaddr_r_nargs=7
1240
1241         elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1242                 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1243
1244                 ol_cv_func_gethostbyaddr_r_nargs=8
1245
1246         else
1247                 ol_cv_func_gethostbyaddr_r_nargs=0
1248         fi
1249   ])
1250   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1251     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1252                 $ol_cv_func_gethostbyaddr_r_nargs,
1253                 [set to the number of arguments gethostbyaddr_r() expects])
1254   fi
1255 ])dnl
1256 dnl
1257 dnl --------------------------------------------------------------------
1258 dnl Check for Cyrus SASL version compatility
1259 AC_DEFUN([OL_SASL_COMPAT],
1260 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1261         AC_EGREP_CPP(__sasl_compat,[
1262 #ifdef HAVE_SASL_SASL_H
1263 #include <sasl/sasl.h>
1264 #else
1265 #include <sasl.h>
1266 #endif
1267
1268 /* Require 2.1.15+ */
1269 #if SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR > 1
1270         char *__sasl_compat = "2.2+ or better okay (we guess)";
1271 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR == 1 \
1272         && SASL_VERSION_STEP >=15
1273         char *__sasl_compat = "2.1.15+ or better okay";
1274 #endif
1275         ],      [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1276 ])
1277 dnl ====================================================================
1278 dnl check for msg_accrights in msghdr
1279 AC_DEFUN(OL_MSGHDR_MSG_ACCRIGHTS,
1280  [AC_CACHE_CHECK(for msg_accrights in msghdr, ol_cv_msghdr_msg_accrights,
1281    [AC_TRY_COMPILE([#include <sys/socket.h>],
1282                 [struct msghdr m; m.msg_accrightslen=0],
1283                 ol_cv_msghdr_msg_accrights=yes, ol_cv_msghdr_msg_accrights=no)
1284         ])
1285   if test $ol_cv_msghdr_msg_accrights = "yes" ; then
1286         AC_DEFINE(HAVE_MSGHDR_MSG_ACCRIGHTS,1,
1287                 [define if struct msghdr has msg_accrights])
1288   fi
1289 ])dnl