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