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