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