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