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