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