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