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