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