Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / openldap / dist / build / openldap.m4
bloba9c67923f4fb653cf2efd3c2b68e2d8ad164c619
1 dnl OpenLDAP Autoconf Macros
2 dnl $OpenLDAP: pkg/ldap/build/openldap.m4,v 1.157.2.5 2008/02/11 23:26:37 kurt Exp $
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 dnl
5 dnl Copyright 1998-2008 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).  "--" means do not set it by default
22 dnl $4 = allowed values (auto yes no)
23 dnl $5 = overridden default
24 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
25         pushdef([ol_DefVal],ifelse($3,,auto,$3))
26         AC_ARG_ENABLE($1,ifelse($4,,[$2],[$2] translit([$4],[ ],[|])) ifelse($3,--,,@<:@ol_DefVal@:>@),[
27         ol_arg=invalid
28         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
29                 if test "$enableval" = "$ol_val" ; then
30                         ol_arg="$ol_val"
31                 fi
32         done
33         if test "$ol_arg" = "invalid" ; then
34                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
35         fi
36         ol_enable_$1="$ol_arg"
37 ]ifelse($3,--,,[,
38 [       ol_enable_$1=ifelse($5,,ol_DefVal,[${]$5[:-]ol_DefVal[}])]]))dnl
39 dnl AC_MSG_RESULT([OpenLDAP -enable-$1 $ol_enable_$1])
40         popdef([ol_DefVal])
41 # end --enable-$1
42 ])dnl
43 dnl
44 dnl --------------------------------------------------------------------
45 dnl Restricted form of AC_ARG_WITH that limits user options
46 dnl
47 dnl $1 = option name
48 dnl $2 = help-string
49 dnl $3 = default value (no)
50 dnl $4 = allowed values (yes or no)
51 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
52         AC_ARG_WITH($1,[$2 @<:@]ifelse($3,,yes,$3)@:>@,[
53         ol_arg=invalid
54         for ol_val in ifelse($4,,[yes no],[$4]) ; do
55                 if test "$withval" = "$ol_val" ; then
56                         ol_arg="$ol_val"
57                 fi
58         done
59         if test "$ol_arg" = "invalid" ; then
60                 AC_MSG_ERROR(bad value $withval for --with-$1)
61         fi
62         ol_with_$1="$ol_arg"
64 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
65 dnl AC_MSG_RESULT([OpenLDAP --with-$1 $ol_with_$1])
66 # end --with-$1
67 ])dnl
68 dnl ====================================================================
69 dnl Check for dependency generation flag
70 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
71 OL_MKDEP=
72 OL_MKDEP_FLAGS=
73 if test -z "${MKDEP}"; then
74         OL_MKDEP="${CC-cc}"
75         if test -z "${MKDEP_FLAGS}"; then
76                 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
77                         ol_cv_mkdep=no
78                         for flag in "-M" "-xM"; do
79                                 cat > conftest.c <<EOF
80  noCode;
81 EOF
82                                 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
83                                         | grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
84                                 then
85                                         if test ! -f conftest."${ac_object}" ; then
86                                                 ol_cv_mkdep=$flag
87                                                 OL_MKDEP_FLAGS="$flag"
88                                                 break
89                                         fi
90                                 fi
91                         done
92                         rm -f conftest*
93                 ])
94                 test "$ol_cv_mkdep" = no && OL_MKDEP=":"
95         else
96                 cc_cv_mkdep=yes
97                 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
98         fi
99 else
100         cc_cv_mkdep=yes
101         OL_MKDEP="${MKDEP}"
102         OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
104 AC_SUBST(OL_MKDEP)
105 AC_SUBST(OL_MKDEP_FLAGS)
108 dnl ====================================================================
109 dnl Check if system uses EBCDIC instead of ASCII
110 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
111 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
112         AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
113 #if !('M' == 0xd4)
114 #include <__ASCII__/generate_error.h>
115 #endif
116 ]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])])
117 if test $ol_cv_cpp_ebcdic = yes ; then
118         AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
122 dnl --------------------------------------------------------------------
123 dnl OpenLDAP version of STDC header check w/ EBCDIC support
124 AC_DEFUN([OL_HEADER_STDC],
125 [AC_REQUIRE_CPP()dnl
126 AC_REQUIRE([OL_CPP_EBCDIC])dnl
127 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
128 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
129 #include <stdarg.h>
130 #include <string.h>
131 #include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no])
133 if test $ol_cv_header_stdc = yes; then
134   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
135 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
138 if test $ol_cv_header_stdc = yes; then
139   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
140 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
143 if test $ol_cv_header_stdc = yes; then
144   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
145 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h>
146 #ifndef HAVE_EBCDIC
147 #       define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
148 #       define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
149 #else
150 #       define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
151                 || ('j' <= (c) && (c) <= 'r') \
152                 || ('s' <= (c) && (c) <= 'z'))
153 #       define TOUPPER(c)       (ISLOWER(c) ? ((c) | 0x40) : (c))
154 #endif
155 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
156 int main () { int i; for (i = 0; i < 256; i++)
157 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
158 exit (0); }
159 ]])],[],[ol_cv_header_stdc=no],[:])
160 fi])
161 if test $ol_cv_header_stdc = yes; then
162   AC_DEFINE(STDC_HEADERS)
164 ac_cv_header_stdc=disable
167 dnl ====================================================================
168 dnl DNS resolver macros
169 AC_DEFUN([OL_RESOLVER_TRY],
170 [if test $ol_cv_lib_resolver = no ; then
171         AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1],
173         ol_RESOLVER_LIB=ifelse($2,,,$2)
174         ol_LIBS=$LIBS
175         LIBS="$ol_RESOLVER_LIB $LIBS"
177         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
178 #ifdef HAVE_SYS_TYPES_H
179 #       include <sys/types.h>
180 #endif
181 #include <netinet/in.h>
182 #ifdef HAVE_ARPA_NAMESER_H
183 #       include <arpa/nameser.h>
184 #endif
185 #ifdef HAVE_RESOLV_H
186 #       include <resolv.h>
187 #endif
188 ]], [[{
189         int len, status;
190         char *request = NULL;
191         unsigned char reply[64*1024];
192         unsigned char host[64*1024];
193         unsigned char *p;
195 #ifdef NS_HFIXEDSZ
196         /* Bind 8/9 interface */
197         len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply));
198 #else
199         /* Bind 4 interface */
200 # ifndef T_SRV
201 #  define T_SRV 33
202 # endif
203         len = res_query(request, C_IN, T_SRV, reply, sizeof(reply));
204 #endif
205         p = reply;
206 #ifdef NS_HFIXEDSZ
207         /* Bind 8/9 interface */
208         p += NS_HFIXEDSZ;
209 #elif defined(HFIXEDSZ)
210         /* Bind 4 interface w/ HFIXEDSZ */
211         p += HFIXEDSZ;
212 #else
213         /* Bind 4 interface w/o HFIXEDSZ */
214         p += sizeof(HEADER);
215 #endif
216         status = dn_expand( reply, reply+len, p, host, sizeof(host));
217 }]])],[$1=yes],[$1=no])
219         LIBS="$ol_LIBS"
222         if test $$1 = yes ; then
223                 ol_cv_lib_resolver=ifelse($2,,yes,$2)
224         fi
227 dnl --------------------------------------------------------------------
228 dnl Try to locate appropriate library
229 AC_DEFUN([OL_RESOLVER_LINK],
230 [ol_cv_lib_resolver=no
231 OL_RESOLVER_TRY(ol_cv_resolver_none)
232 OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv])
233 OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind])
236 dnl ====================================================================
237 dnl International Components for Unicode (ICU)
238 AC_DEFUN([OL_ICU],
239 [ol_icu=no
240 AC_CHECK_HEADERS( unicode/utypes.h )
241 if test $ac_cv_header_unicode_utypes_h = yes ; then
242         dnl OL_ICULIBS="-licui18n -licuuc -licudata"
243         OL_ICULIBS="-licuuc -licudata"
245         AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [
246                 ol_LIBS="$LIBS"
247                 LIBS="$OL_ICULIBS $LIBS"
248                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
249 #include <unicode/utypes.h>
250 ]], [[
251 (void) u_errorName(0);
252 ]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no])
253                 LIBS="$ol_LIBS"
256         if test $ol_cv_lib_icu != no ; then
257                 ol_icu="$OL_ICULIBS"
258                 AC_DEFINE(HAVE_ICU,1,[define if you actually have ICU])
259         fi
263 dnl ====================================================================
264 dnl Berkeley DB macros
266 dnl --------------------------------------------------------------------
267 dnl Try to link
268 AC_DEFUN([OL_BERKELEY_DB_TRY],
269 [if test $ol_cv_lib_db = no ; then
270         AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
272         ol_DB_LIB=ifelse($2,,,$2)
273         ol_LIBS=$LIBS
274         LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
276         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
277 #ifdef HAVE_DB_185_H
278 # include <db_185.h>
279 #else
280 # include <db.h>
281 #endif
283 #ifndef DB_VERSION_MAJOR
284 # define DB_VERSION_MAJOR 1
285 #endif
287 #ifndef NULL
288 #define NULL ((void*)0)
289 #endif
290 ]], [[
291 #if DB_VERSION_MAJOR > 1
292         {
293                 char *version;
294                 int major, minor, patch;
296                 version = db_version( &major, &minor, &patch );
298                 if( major != DB_VERSION_MAJOR ||
299                         minor < DB_VERSION_MINOR )
300                 {
301                         printf("Berkeley DB version mismatch\n"
302                                 "\theader: %s\n\tlibrary: %s\n",
303                                 DB_VERSION_STRING, version);
304                         return 1;
305                 }
306         }
307 #endif
309 #if DB_VERSION_MAJOR > 2
310         db_env_create( NULL, 0 );
311 #elif DB_VERSION_MAJOR > 1
312         db_appexit( NULL );
313 #else
314         (void) dbopen( NULL, 0, 0, 0, NULL);
315 #endif
316 ]])],[$1=yes],[$1=no])
318         LIBS="$ol_LIBS"
321         if test $$1 = yes ; then
322                 ol_cv_lib_db=ifelse($2,,yes,$2)
323         fi
327 dnl --------------------------------------------------------------------
328 dnl Try to locate appropriate library
329 AC_DEFUN([OL_BERKELEY_DB_LINK],
330 [ol_cv_lib_db=no
332 dnl Determine major version
333 AC_CACHE_CHECK([for Berkeley DB major version], [ol_cv_bdb_major],[
334         ol_cv_bdb_major=0
335         if test $ol_cv_bdb_major = 0 ; then
336                 AC_EGREP_CPP(__db_version, [
337 #include <db.h>
338 #ifndef DB_VERSION_MAJOR
339 #       define DB_VERSION_MAJOR 1
340 #endif
341 #if DB_VERSION_MAJOR == 4
342 __db_version
343 #endif
344                 ], [ol_cv_bdb_major=4], [:])
345         fi
346         if test $ol_cv_bdb_major = 0 ; then
347                 AC_EGREP_CPP(__db_version, [
348 #include <db.h>
349 #ifndef DB_VERSION_MAJOR
350 #       define DB_VERSION_MAJOR 1
351 #endif
352 #if DB_VERSION_MAJOR == 3
353 __db_version
354 #endif
355                 ], [ol_cv_bdb_major=3], [:])
356         fi
357         if test $ol_cv_bdb_major = 0 ; then
358                 AC_EGREP_CPP(__db_version, [
359 #include <db.h>
360 #ifndef DB_VERSION_MAJOR
361 #       define DB_VERSION_MAJOR 1
362 #endif
363 #if DB_VERSION_MAJOR == 2
364 __db_version
365 #endif
366                 ], [ol_cv_bdb_major=2], [:])
367         fi
368         if test $ol_cv_bdb_major = 0 ; then
369                 AC_EGREP_CPP(__db_version, [
370 #include <db.h>
371 #ifndef DB_VERSION_MAJOR
372 #       define DB_VERSION_MAJOR 1
373 #endif
374 #if DB_VERSION_MAJOR == 1
375 __db_version
376 #endif
377                 ], [ol_cv_bdb_major=1], [:])
378         fi
380         if test $ol_cv_bdb_major = 0 ; then
381                 AC_MSG_ERROR([Unknown Berkeley DB major version])
382         fi
385 dnl Determine minor version
386 AC_CACHE_CHECK([for Berkeley DB minor version], [ol_cv_bdb_minor],[
387         ol_cv_bdb_minor=0
388         if test $ol_cv_bdb_minor = 0 ; then
389                 AC_EGREP_CPP(__db_version, [
390 #include <db.h>
391 #ifndef DB_VERSION_MINOR
392 #       define DB_VERSION_MINOR 0
393 #endif
394 #if DB_VERSION_MINOR == 9
395 __db_version
396 #endif
397                 ], [ol_cv_bdb_minor=9], [:])
398         fi
399         if test $ol_cv_bdb_minor = 0 ; then
400                 AC_EGREP_CPP(__db_version, [
401 #include <db.h>
402 #ifndef DB_VERSION_MINOR
403 #       define DB_VERSION_MINOR 0
404 #endif
405 #if DB_VERSION_MINOR == 8
406 __db_version
407 #endif
408                 ], [ol_cv_bdb_minor=8], [:])
409         fi
410         if test $ol_cv_bdb_minor = 0 ; then
411                 AC_EGREP_CPP(__db_version, [
412 #include <db.h>
413 #ifndef DB_VERSION_MINOR
414 #       define DB_VERSION_MINOR 0
415 #endif
416 #if DB_VERSION_MINOR == 7
417 __db_version
418 #endif
419                 ], [ol_cv_bdb_minor=7], [:])
420         fi
421         if test $ol_cv_bdb_minor = 0 ; then
422                 AC_EGREP_CPP(__db_version, [
423 #include <db.h>
424 #ifndef DB_VERSION_MINOR
425 #       define DB_VERSION_MINOR 0
426 #endif
427 #if DB_VERSION_MINOR == 6
428 __db_version
429 #endif
430                 ], [ol_cv_bdb_minor=6], [:])
431         fi
432         if test $ol_cv_bdb_minor = 0 ; then
433                 AC_EGREP_CPP(__db_version, [
434 #include <db.h>
435 #ifndef DB_VERSION_MINOR
436 #       define DB_VERSION_MINOR 0
437 #endif
438 #if DB_VERSION_MINOR == 5
439 __db_version
440 #endif
441                 ], [ol_cv_bdb_minor=5], [:])
442         fi
443         if test $ol_cv_bdb_minor = 0 ; then
444                 AC_EGREP_CPP(__db_version, [
445 #include <db.h>
446 #ifndef DB_VERSION_MINOR
447 #       define DB_VERSION_MINOR 0
448 #endif
449 #if DB_VERSION_MINOR == 4
450 __db_version
451 #endif
452                 ], [ol_cv_bdb_minor=4], [:])
453         fi
454         if test $ol_cv_bdb_minor = 0 ; then
455                 AC_EGREP_CPP(__db_version, [
456 #include <db.h>
457 #ifndef DB_VERSION_MINOR
458 #       define DB_VERSION_MINOR 0
459 #endif
460 #if DB_VERSION_MINOR == 3
461 __db_version
462 #endif
463                 ], [ol_cv_bdb_minor=3], [:])
464         fi
465         if test $ol_cv_bdb_minor = 0 ; then
466                 AC_EGREP_CPP(__db_version, [
467 #include <db.h>
468 #ifndef DB_VERSION_MINOR
469 #       define DB_VERSION_MINOR 0
470 #endif
471 #if DB_VERSION_MINOR == 2
472 __db_version
473 #endif
474                 ], [ol_cv_bdb_minor=2], [:])
475         fi
476         if test $ol_cv_bdb_minor = 0 ; then
477                 AC_EGREP_CPP(__db_version, [
478 #include <db.h>
479 #ifndef DB_VERSION_MINOR
480 #       define DB_VERSION_MINOR 0
481 #endif
482 #if DB_VERSION_MINOR == 1
483 __db_version
484 #endif
485                 ], [ol_cv_bdb_minor=1], [:])
486         fi
489 if test $ol_cv_bdb_major = 4 ; then
490         if test $ol_cv_bdb_minor = 6 ; then
491                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_6,[-ldb-4.6])
492                 OL_BERKELEY_DB_TRY(ol_cv_db_db46,[-ldb46])
493                 OL_BERKELEY_DB_TRY(ol_cv_db_db_46,[-ldb-46])
494                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_6,[-ldb-4-6])
495         elif test $ol_cv_bdb_minor = 5 ; then
496                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_5,[-ldb-4.5])
497                 OL_BERKELEY_DB_TRY(ol_cv_db_db45,[-ldb45])
498                 OL_BERKELEY_DB_TRY(ol_cv_db_db_45,[-ldb-45])
499                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_5,[-ldb-4-5])
500         elif test $ol_cv_bdb_minor = 4 ; then
501                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_4,[-ldb-4.4])
502                 OL_BERKELEY_DB_TRY(ol_cv_db_db44,[-ldb44])
503                 OL_BERKELEY_DB_TRY(ol_cv_db_db_44,[-ldb-44])
504                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_4,[-ldb-4-4])
505         elif test $ol_cv_bdb_minor = 3 ; then
506                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_3,[-ldb-4.3])
507                 OL_BERKELEY_DB_TRY(ol_cv_db_db43,[-ldb43])
508                 OL_BERKELEY_DB_TRY(ol_cv_db_db_43,[-ldb-43])
509                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_3,[-ldb-4-3])
510         elif test $ol_cv_bdb_minor = 2 ; then
511                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_2,[-ldb-4.2])
512                 OL_BERKELEY_DB_TRY(ol_cv_db_db42,[-ldb42])
513                 OL_BERKELEY_DB_TRY(ol_cv_db_db_42,[-ldb-42])
514                 OL_BERKELEY_DB_TRY(ol_cv_db_db_4_2,[-ldb-4-2])
515         fi
516         OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
517         OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
518         OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
520 elif test $ol_cv_bdb_major = 3 ; then
521         OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
522         OL_BERKELEY_DB_TRY(ol_cv_db_db_3,[-ldb-3])
524 elif test $ol_cv_bdb_major = 2 ; then
525         OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
526         OL_BERKELEY_DB_TRY(ol_cv_db_db_2,[-ldb-2])
528 elif test $ol_cv_bdb_major = 1 ; then
529         OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
530         OL_BERKELEY_DB_TRY(ol_cv_db_db_1,[-ldb-1])
532 OL_BERKELEY_DB_TRY(ol_cv_db_none)
535 dnl --------------------------------------------------------------------
536 dnl Check if Berkeley DB version
537 AC_DEFUN([OL_BERKELEY_DB_VERSION],
538 [AC_CACHE_CHECK([for Berkeley DB version match], [ol_cv_berkeley_db_version], [
539         ol_LIBS="$LIBS"
540         LIBS="$LTHREAD_LIBS $LIBS"
541         if test $ol_cv_lib_db != yes ; then
542                 LIBS="$ol_cv_lib_db $LIBS"
543         fi
545         AC_RUN_IFELSE([AC_LANG_SOURCE([[
546 #ifdef HAVE_DB_185_H
547         choke me;
548 #else
549 #include <db.h>
550 #endif
551 #ifndef DB_VERSION_MAJOR
552 # define DB_VERSION_MAJOR 1
553 #endif
554 #ifndef NULL
555 #define NULL ((void *)0)
556 #endif
557 main()
559 #if DB_VERSION_MAJOR > 1
560         char *version;
561         int major, minor, patch;
563         version = db_version( &major, &minor, &patch );
565         if( major != DB_VERSION_MAJOR ||
566                 minor != DB_VERSION_MINOR ||
567                 patch != DB_VERSION_PATCH )
568         {
569                 printf("Berkeley DB version mismatch\n"
570                         "\theader: %s\n\tlibrary: %s\n",
571                         DB_VERSION_STRING, version);
572                 return 1;
573         }
574 #endif
576         return 0;
577 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
579         LIBS="$ol_LIBS"
582         if test $ol_cv_berkeley_db_version = no ; then
583                 AC_MSG_ERROR([Berkeley DB version mismatch])
584         fi
585 ])dnl
587 dnl --------------------------------------------------------------------
588 dnl Check if Berkeley DB supports DB_THREAD
589 AC_DEFUN([OL_BERKELEY_DB_THREAD],
590 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
591         ol_LIBS="$LIBS"
592         LIBS="$LTHREAD_LIBS $LIBS"
593         if test $ol_cv_lib_db != yes ; then
594                 LIBS="$ol_cv_lib_db $LIBS"
595         fi
597         AC_RUN_IFELSE([AC_LANG_SOURCE([[
598 #ifdef HAVE_DB_185_H
599         choke me;
600 #else
601 #include <db.h>
602 #endif
603 #ifndef NULL
604 #define NULL ((void *)0)
605 #endif
606 main()
608         int rc;
609         u_int32_t flags = DB_CREATE |
610 #ifdef DB_PRIVATE
611                 DB_PRIVATE |
612 #endif
613                 DB_THREAD;
615 #if DB_VERSION_MAJOR > 2
616         DB_ENV *env = NULL;
618         rc = db_env_create( &env, 0 );
620         flags |= DB_INIT_MPOOL;
621 #ifdef DB_MPOOL_PRIVATE
622         flags |= DB_MPOOL_PRIVATE;
623 #endif
625         if( rc ) {
626                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
627                 return rc;
628         }
630 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
631         rc = (env->open)( env, NULL, flags, 0 );
632 #else
633         rc = (env->open)( env, NULL, NULL, flags, 0 );
634 #endif
636         if ( rc == 0 ) {
637                 rc = env->close( env, 0 );
638         }
640         if( rc ) {
641                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
642                 return rc;
643         }
645 #else
646         DB_ENV env;
647         memset( &env, '\0', sizeof(env) );
649         rc = db_appinit( NULL, NULL, &env, flags );
651         if( rc == 0 ) {
652                 db_appexit( &env );
653         }
655         unlink("__db_mpool.share");
656         unlink("__db_lock.share");
657 #endif
659         return rc;
660 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
662         LIBS="$ol_LIBS"
665         if test $ol_cv_berkeley_db_thread != no ; then
666                 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
667                         [define if Berkeley DB has DB_THREAD support])
668         fi
669 ])dnl
671 dnl --------------------------------------------------------------------
672 dnl Find any DB
673 AC_DEFUN([OL_BERKELEY_DB],
674 [ol_cv_berkeley_db=no
675 AC_CHECK_HEADERS(db.h)
676 if test $ac_cv_header_db_h = yes; then
677         OL_BERKELEY_DB_LINK
678         if test "$ol_cv_lib_db" != no ; then
679                 ol_cv_berkeley_db=yes
680                 OL_BERKELEY_DB_VERSION
681                 OL_BERKELEY_DB_THREAD
682         fi
685 dnl --------------------------------------------------------------------
686 dnl Check for version compatility with back-bdb
687 AC_DEFUN([OL_BDB_COMPAT],
688 [AC_CACHE_CHECK([Berkeley DB version for BDB/HDB backends], [ol_cv_bdb_compat],[
689         AC_EGREP_CPP(__db_version_compat,[
690 #include <db.h>
692  /* this check could be improved */
693 #ifndef DB_VERSION_MAJOR
694 #       define DB_VERSION_MAJOR 1
695 #endif
696 #ifndef DB_VERSION_MINOR
697 #       define DB_VERSION_MINOR 0
698 #endif
700 /* require 4.2 or later, but exclude 4.3 */
701 #if (DB_VERSION_MAJOR >= 4) && (DB_VERSION_MINOR >= 2) && (DB_VERSION_MINOR !=3)
702         __db_version_compat
703 #endif
704         ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
707 dnl --------------------------------------------------------------------
708 dnl Find old Berkeley DB 1.85/1.86
709 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
710 [AC_CHECK_HEADERS(db_185.h db.h)
711 if test $ac_cv_header_db_185_h = yes || test $ac_cv_header_db_h = yes; then
712         AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
713                 AC_EGREP_CPP(__db_version_1,[
714 #if HAVE_DB_185_H
715 #       include <db_185.h>
716 #else
717 #       include <db.h>
718 #endif
720  /* this check could be improved */
721 #ifndef DB_VERSION_MAJOR
722 #       define DB_VERSION_MAJOR 1
723 #endif
725 #if DB_VERSION_MAJOR == 1 
726         __db_version_1
727 #endif
728 ],      [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
730         if test $ol_cv_header_db1 = yes ; then
731                 OL_BERKELEY_DB_LINK
732                 if test "$ol_cv_lib_db" != no ; then
733                         ol_cv_berkeley_db=yes
734                 fi
735         fi
739 dnl ====================================================================
740 dnl Check POSIX Thread version 
742 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
743 dnl     version of the POSIX.4a Draft that is implemented.
744 dnl     10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
745 dnl     Existence of pthread.h should be tested separately.
747 dnl tests:
748 dnl     pthread_detach() was dropped in Draft 8, it is present
749 dnl             in every other version
750 dnl     PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
751 dnl             PTHREAD_CREATE_JOINABLE after that
752 dnl     pthread_attr_create was renamed to pthread_attr_init in Draft 6.
753 dnl             Draft 6-10 has _init, Draft 4-5 has _create.
754 dnl     pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
755 dnl     PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
756 dnl             interesting to us because we don't try to statically
757 dnl             initialize mutexes. 5-10 has it.
759 dnl Draft 9 and 10 are equivalent for our purposes.
761 AC_DEFUN([OL_POSIX_THREAD_VERSION],
762 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
763         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
764 #               include <pthread.h>
765         ]], [[
766                 int i = PTHREAD_CREATE_JOINABLE;
767         ]])],[
768         AC_EGREP_HEADER(pthread_detach,pthread.h,
769         ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
770         AC_EGREP_CPP(draft7,[
771 #               include <pthread.h>
772 #               ifdef PTHREAD_CREATE_UNDETACHED
773                 draft7
774 #               endif
775         ], ol_cv_pthread_version=7, [
776         AC_EGREP_HEADER(pthread_attr_init,pthread.h,
777         ol_cv_pthread_version=6, [
778         AC_EGREP_CPP(draft5,[
779 #               include <pthread.h>
780 #ifdef          PTHREAD_MUTEX_INITIALIZER
781                 draft5
782 #endif
783         ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
785 ])dnl
787 dnl --------------------------------------------------------------------
788 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
789 /* pthread test headers */
790 #include <pthread.h>
791 #if HAVE_PTHREADS < 7
792 #include <errno.h>
793 #endif
794 #ifndef NULL
795 #define NULL (void*)0
796 #endif
798 static void *task(p)
799         void *p;
801         return (void *) (p == NULL);
804 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
805         /* pthread test function */
806 #ifndef PTHREAD_CREATE_DETACHED
807 #define PTHREAD_CREATE_DETACHED 1
808 #endif
809         pthread_t t;
810         int status;
811         int detach = PTHREAD_CREATE_DETACHED;
813 #if HAVE_PTHREADS > 4
814         /* Final pthreads */
815         pthread_attr_t attr;
817         status = pthread_attr_init(&attr);
818         if( status ) return status;
820 #if HAVE_PTHREADS < 7
821         status = pthread_attr_setdetachstate(&attr, &detach);
822         if( status < 0 ) status = errno;
823 #else
824         status = pthread_attr_setdetachstate(&attr, detach);
825 #endif
826         if( status ) return status;
827         status = pthread_create( &t, &attr, task, NULL );
828 #if HAVE_PTHREADS < 7
829         if( status < 0 ) status = errno;
830 #endif
831         if( status ) return status;
832 #else
833         /* Draft 4 pthreads */
834         status = pthread_create( &t, pthread_attr_default, task, NULL );
835         if( status ) return errno;
837         /* give thread a chance to complete */
838         /* it should remain joinable and hence detachable */
839         sleep( 1 );
841         status = pthread_detach( &t );
842         if( status ) return errno;
843 #endif
845 #ifdef HAVE_LINUX_THREADS
846         pthread_kill_other_threads_np();
847 #endif
849         return 0;
852 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
853 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
855 int main(argc, argv)
856         int argc;
857         char **argv;
859 OL_PTHREAD_TEST_FUNCTION
862 dnl --------------------------------------------------------------------
863 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
864 if test "$ol_link_threads" = no ; then
865         # try $1
866         AC_CACHE_CHECK([for pthread link with $1], [$2], [
867                 # save the flags
868                 ol_LIBS="$LIBS"
869                 LIBS="$1 $LIBS"
871                 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
872                         [$2=yes],
873                         [$2=no],
874                         [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
875                                 OL_PTHREAD_TEST_FUNCTION)],
876                                 [$2=yes], [$2=no])])
878                 # restore the LIBS
879                 LIBS="$ol_LIBS"
880         ])
882         if test $$2 = yes ; then
883                 ol_link_pthreads="$1"
884                 ol_link_threads=posix
885         fi
889 dnl ====================================================================
890 dnl Check GNU Pth pthread Header
892 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
893 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
894 dnl             doesn't exists.  Existance of pthread.h should separately
895 dnl             checked.
896 dnl 
897 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
898         AC_CACHE_CHECK([for GNU Pth pthread.h],
899                 [ol_cv_header_gnu_pth_pthread_h],
900                 [AC_EGREP_CPP(__gnu_pth__,
901                         [#include <pthread.h>
902 #ifdef _POSIX_THREAD_IS_GNU_PTH
903         __gnu_pth__;
904 #endif
906                         [ol_cv_header_gnu_pth_pthread_h=yes],
907                         [ol_cv_header_gnu_pth_pthread_h=no])
908                 ])
909 ])dnl
910 dnl ====================================================================
911 dnl Check for NT Threads
912 AC_DEFUN([OL_NT_THREADS], [
913         AC_CHECK_FUNC(_beginthread)
915         if test $ac_cv_func__beginthread = yes ; then
916                 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
917                 ol_cv_nt_threads=yes
918         fi
920 dnl ====================================================================
921 dnl Check LinuxThreads Header
923 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
924 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
925 dnl             doesn't exists.  Existance of pthread.h should separately
926 dnl             checked.
927 dnl 
928 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
929         AC_CACHE_CHECK([for LinuxThreads pthread.h],
930                 [ol_cv_header_linux_threads],
931                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
932                         [#include <pthread.h>],
933                         [ol_cv_header_linux_threads=yes],
934                         [ol_cv_header_linux_threads=no])
935                 ])
936         if test $ol_cv_header_linux_threads = yes; then
937                 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
938         fi
939 ])dnl
940 dnl --------------------------------------------------------------------
941 dnl     Check LinuxThreads Implementation
943 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
944 dnl     'no' implies pthreads implementation is not LinuxThreads.
945 dnl 
946 AC_DEFUN([OL_SYS_LINUX_THREADS], [
947         AC_CHECK_FUNCS(pthread_kill_other_threads_np)
948         AC_CACHE_CHECK([for LinuxThreads implementation],
949                 [ol_cv_sys_linux_threads],
950                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
951 ])dnl
953 dnl --------------------------------------------------------------------
954 dnl Check LinuxThreads consistency
955 AC_DEFUN([OL_LINUX_THREADS], [
956         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
957         AC_REQUIRE([OL_SYS_LINUX_THREADS])
958         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
959                 if test $ol_cv_header_linux_threads = yes &&
960                    test $ol_cv_sys_linux_threads = yes; then
961                         ol_cv_linux_threads=yes
962                 elif test $ol_cv_header_linux_threads = no &&
963                      test $ol_cv_sys_linux_threads = no; then
964                         ol_cv_linux_threads=no
965                 else
966                         ol_cv_linux_threads=error
967                 fi
968         ])
969 ])dnl
971 dnl ====================================================================
972 dnl Check for POSIX Regex
973 AC_DEFUN([OL_POSIX_REGEX], [
974 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
975         AC_RUN_IFELSE([AC_LANG_SOURCE([[
976 #include <sys/types.h>
977 #include <regex.h>
978 static char *pattern, *string;
979 main()
981         int rc;
982         regex_t re;
984         pattern = "^A";
986         if(regcomp(&re, pattern, 0)) {
987                 return -1;
988         }
989         
990         string = "ALL MATCH";
991         
992         rc = regexec(&re, string, 0, (void*)0, 0);
994         regfree(&re);
996         return rc;
997 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
1000 dnl ====================================================================
1001 dnl Check if toupper() requires islower() to be called first
1002 AC_DEFUN([OL_C_UPPER_LOWER],
1003 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
1004         AC_RUN_IFELSE([AC_LANG_SOURCE([[
1005 #include <ctype.h>
1006 main()
1008         if ('C' == toupper('C'))
1009                 exit(0);
1010         else
1011                 exit(1);
1012 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
1013 if test $ol_cv_c_upper_lower != no ; then
1014         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
1018 dnl ====================================================================
1019 dnl Error string checks
1021 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
1022 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
1023 dnl Reported by Keith Bostic.
1024 AC_DEFUN([OL_SYS_ERRLIST],
1025 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
1026         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1027 #include <stdio.h>
1028 #include <sys/types.h>
1029 #include <errno.h>
1030 #ifdef _WIN32
1031 #include <stdlib.h>
1032 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
1033         ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
1035 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
1036 if test $ol_cv_dcl_sys_errlist = no ; then
1037         AC_DEFINE(DECL_SYS_ERRLIST,1,
1038                 [define if sys_errlist is not declared in stdio.h or errno.h])
1040         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
1041                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])])
1043 if test $ol_cv_have_sys_errlist = yes ; then
1044         AC_DEFINE(HAVE_SYS_ERRLIST,1,
1045                 [define if you actually have sys_errlist in your libs])
1047 ])dnl
1048 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
1049 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
1050         AC_EGREP_CPP(strerror_r,[#include <string.h>],
1051                 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
1053         if test $ol_decl_strerror_r = yes ; then
1054                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[   /* from autoconf 2.59 */
1055                                 char buf[100];
1056                                 char x = *strerror_r (0, buf, sizeof buf);
1057                                 char *p = strerror_r (0, buf, sizeof buf);
1058                         ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
1059         else
1060                 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1061                         main() {
1062                                 char buf[100];
1063                                 buf[0] = 0;
1064                                 strerror_r( 1, buf, sizeof buf );
1065                                 exit( buf[0] == 0 );
1066                         }
1067                         ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
1068         fi
1069         ])
1070 if test $ol_cv_nonposix_strerror_r = yes ; then
1071         AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1,
1072                 [define if strerror_r returns char* instead of int])
1074 ])dnl
1076 AC_DEFUN([OL_STRERROR],
1077 [OL_SYS_ERRLIST dnl TEMPORARY
1078 AC_CHECK_FUNCS(strerror strerror_r)
1079 ol_cv_func_strerror_r=no
1080 if test "${ac_cv_func_strerror_r}" = yes ; then
1081         OL_NONPOSIX_STRERROR_R
1082 elif test "${ac_cv_func_strerror}" = no ; then
1083         OL_SYS_ERRLIST
1085 ])dnl
1086 dnl ====================================================================
1087 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
1088 dnl "int x; int *volatile a = &x; *a = 0;"
1089 dnl     -- borrowed from PDKSH
1090 AC_DEFUN([OL_C_VOLATILE],
1091  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
1092     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
1093       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
1094       *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
1095   if test $ol_cv_c_volatile = yes; then
1096     : 
1097   else
1098     AC_DEFINE(volatile,,[define as empty if volatile is not supported])
1099   fi
1100  ])dnl
1102 dnl ====================================================================
1103 dnl Look for fetch(3)
1104 AC_DEFUN([OL_LIB_FETCH],
1105 [ol_LIBS=$LIBS
1106 LIBS="-lfetch -lcom_err $LIBS"
1107 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
1108         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1109 #include <sys/param.h>
1110 #include <stdio.h>
1111 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
1112 LIBS=$ol_LIBS
1113 if test $ol_cv_lib_fetch != no ; then
1114         ol_link_fetch="-lfetch -lcom_err"
1115         AC_DEFINE(HAVE_FETCH,1,
1116                 [define if you actually have FreeBSD fetch(3)])
1118 ])dnl
1120 dnl ====================================================================
1121 dnl Define inet_aton is available
1122 AC_DEFUN([OL_FUNC_INET_ATON],
1123  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1124     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1125 #ifdef HAVE_SYS_TYPES_H
1126 #       include <sys/types.h>
1127 #endif
1128 #ifdef HAVE_SYS_SOCKET_H
1129 #       include <sys/socket.h>
1130 #       ifdef HAVE_SYS_SELECT_H
1131 #               include <sys/select.h>
1132 #       endif
1133 #       include <netinet/in.h>
1134 #       ifdef HAVE_ARPA_INET_H
1135 #               include <arpa/inet.h>
1136 #       endif
1137 #endif
1138 ]], [[struct in_addr in;
1139 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
1140   if test $ol_cv_func_inet_aton != no; then
1141     AC_DEFINE(HAVE_INET_ATON, 1,
1142                 [define to you inet_aton(3) is available])
1143   fi
1144  ])dnl
1146 dnl ====================================================================
1147 dnl check no of arguments for ctime_r
1148 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
1149  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1150    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer,32);]])],[ol_cv_func_ctime_r_nargs3=yes],[ol_cv_func_ctime_r_nargs3=no])
1152         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer);]])],[ol_cv_func_ctime_r_nargs2=yes],[ol_cv_func_ctime_r_nargs2=no])
1154         if test $ol_cv_func_ctime_r_nargs3 = yes &&
1155            test $ol_cv_func_ctime_r_nargs2 = no ; then
1157                 ol_cv_func_ctime_r_nargs=3
1159         elif test $ol_cv_func_ctime_r_nargs3 = no &&
1160              test $ol_cv_func_ctime_r_nargs2 = yes ; then
1162                 ol_cv_func_ctime_r_nargs=2
1164         else
1165                 ol_cv_func_ctime_r_nargs=0
1166         fi
1167   ])
1169   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1170         AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1171                 [set to the number of arguments ctime_r() expects])
1172   fi
1173 ])dnl
1175 dnl --------------------------------------------------------------------
1176 dnl check return type of ctime_r()
1177 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
1178  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1179    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[extern int (ctime_r)();]])],[ol_cv_func_ctime_r_type="int"],[ol_cv_func_ctime_r_type="charp"])
1180         ])
1181   if test $ol_cv_func_ctime_r_type = "int" ; then
1182         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1183   fi
1184 ])dnl
1185 dnl ====================================================================
1186 dnl check no of arguments for gethostbyname_r
1187 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1188  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1189         ol_cv_func_gethostbyname_r_nargs,
1190         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1191 #include <sys/socket.h>
1192 #include <netinet/in.h>
1193 #include <netdb.h>
1194 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1195                 int bufsize=BUFSIZE;int h_errno;
1196                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1197                         buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1199         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1200 #include <sys/socket.h>
1201 #include <netinet/in.h>
1202 #include <netdb.h>
1203 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1204                 char buffer[BUFSIZE];
1205                 int bufsize=BUFSIZE;int h_errno;
1206                 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1207                         &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1209         if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1210            test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1212                 ol_cv_func_gethostbyname_r_nargs=5
1214         elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1215              test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1217                 ol_cv_func_gethostbyname_r_nargs=6
1219         else
1220                 ol_cv_func_gethostbyname_r_nargs=0
1221         fi
1222   ])
1223   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1224         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1225                 $ol_cv_func_gethostbyname_r_nargs,
1226                 [set to the number of arguments gethostbyname_r() expects])
1227   fi
1228 ])dnl
1230 dnl check no of arguments for gethostbyaddr_r
1231 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1232  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1233         [ol_cv_func_gethostbyaddr_r_nargs],
1234         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1235 #include <sys/socket.h>
1236 #include <netinet/in.h>
1237 #include <netdb.h>
1238 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 
1239             struct in_addr add;
1240             size_t alen=sizeof(struct in_addr);
1241             int bufsize=BUFSIZE;int h_errno;
1242                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1243                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1245         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1246 #include <sys/socket.h>
1247 #include <netinet/in.h>
1248 #include <netdb.h>
1249 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1250                 struct hostent *rhent; char buffer[BUFSIZE]; 
1251                 struct in_addr add;
1252                 size_t alen=sizeof(struct in_addr);
1253                 int bufsize=BUFSIZE;int h_errno;
1254                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1255                         alen, AF_INET, &hent, buffer, bufsize, 
1256                         &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1258         if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1259            test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1261                 ol_cv_func_gethostbyaddr_r_nargs=7
1263         elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1264              test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1266                 ol_cv_func_gethostbyaddr_r_nargs=8
1268         else
1269                 ol_cv_func_gethostbyaddr_r_nargs=0
1270         fi
1271   ])
1272   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1273     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1274                 $ol_cv_func_gethostbyaddr_r_nargs,
1275                 [set to the number of arguments gethostbyaddr_r() expects])
1276   fi
1277 ])dnl
1279 dnl --------------------------------------------------------------------
1280 dnl Check for Cyrus SASL version compatility
1281 AC_DEFUN([OL_SASL_COMPAT],
1282 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1283         AC_EGREP_CPP(__sasl_compat,[
1284 #ifdef HAVE_SASL_SASL_H
1285 #include <sasl/sasl.h>
1286 #else
1287 #include <sasl.h>
1288 #endif
1290 /* Require 2.1.15+ */
1291 #if SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR > 1
1292         char *__sasl_compat = "2.2+ or better okay (we guess)";
1293 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR == 1 \
1294         && SASL_VERSION_STEP >=15
1295         char *__sasl_compat = "2.1.15+ or better okay";
1296 #endif
1297         ],      [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1299 dnl ====================================================================
1300 dnl check for SSL compatibility
1301 AC_DEFUN([OL_SSL_COMPAT],
1302 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1303         [ol_cv_ssl_crl_compat],[
1304                 AC_EGREP_CPP(__ssl_compat,[
1305 #ifdef HAVE_OPENSSL_SSL_H
1306 #include <openssl/ssl.h>
1307 #endif
1309 /* Require 0.9.7d+ */
1310 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1311         char *__ssl_compat = "0.9.7d";
1312 #endif
1313         ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])