]> CyberLeo.Net >> Repos - FreeBSD/releng/10.1.git/blob - contrib/ntp/sntp/m4/openldap.m4
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.1.git] / contrib / ntp / sntp / m4 / openldap.m4
1 dnl OpenLDAP Autoconf Macros
2 dnl $OpenLDAP: pkg/ldap/build/openldap.m4,v 1.157.2.10 2010/04/13 20:22:21 kurt Exp $
3 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 dnl
5 dnl Copyright 1998-2010 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-OPENLDAP in
13 dnl this directory of the distribution or, alternatively, at
14 dnl <http://www.OpenLDAP.org/license.html>.
15 dnl
16 dnl --------------------------------------------------------------------
17 dnl Restricted form of AC_ARG_ENABLE that limits user options
18 dnl
19 dnl $1 = option name
20 dnl $2 = help-string
21 dnl $3 = default value  (auto).  "--" means do not set it by default
22 dnl $4 = allowed values (auto yes no)
23 dnl $5 = overridden default
24 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
25         pushdef([ol_DefVal],ifelse($3,,auto,$3))
26         AC_ARG_ENABLE($1,ifelse($4,,[$2],[$2] translit([$4],[ ],[|])) ifelse($3,--,,@<:@ol_DefVal@:>@),[
27         ol_arg=invalid
28         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
29                 if test "$enableval" = "$ol_val" ; then
30                         ol_arg="$ol_val"
31                 fi
32         done
33         if test "$ol_arg" = "invalid" ; then
34                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
35         fi
36         ol_enable_$1="$ol_arg"
37 ]ifelse($3,--,,[,
38 [       ol_enable_$1=ifelse($5,,ol_DefVal,[${]$5[:-]ol_DefVal[}])]]))dnl
39 dnl AC_MSG_RESULT([OpenLDAP -enable-$1 $ol_enable_$1])
40         popdef([ol_DefVal])
41 # end --enable-$1
42 ])dnl
43 dnl
44 dnl --------------------------------------------------------------------
45 dnl Restricted form of AC_ARG_WITH that limits user options
46 dnl
47 dnl $1 = option name
48 dnl $2 = help-string
49 dnl $3 = default value (no)
50 dnl $4 = allowed values (yes or no)
51 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
52         AC_ARG_WITH($1,[$2 @<:@]ifelse($3,,yes,$3)@:>@,[
53         ol_arg=invalid
54         for ol_val in ifelse($4,,[yes no],[$4]) ; do
55                 if test "$withval" = "$ol_val" ; then
56                         ol_arg="$ol_val"
57                 fi
58         done
59         if test "$ol_arg" = "invalid" ; then
60                 AC_MSG_ERROR(bad value $withval for --with-$1)
61         fi
62         ol_with_$1="$ol_arg"
63 ],
64 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
65 dnl AC_MSG_RESULT([OpenLDAP --with-$1 $ol_with_$1])
66 # end --with-$1
67 ])dnl
68 dnl ====================================================================
69 dnl Check for dependency generation flag
70 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
71 OL_MKDEP=
72 OL_MKDEP_FLAGS=
73 if test -z "${MKDEP}"; then
74         OL_MKDEP="${CC-cc}"
75         if test -z "${MKDEP_FLAGS}"; then
76                 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
77                         ol_cv_mkdep=no
78                         for flag in "-M" "-xM"; do
79                                 cat > conftest.c <<EOF
80  noCode;
81 EOF
82                                 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
83                                         | grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
84                                 then
85                                         if test ! -f conftest."${ac_object}" ; then
86                                                 ol_cv_mkdep=$flag
87                                                 OL_MKDEP_FLAGS="$flag"
88                                                 break
89                                         fi
90                                 fi
91                         done
92                         rm -f conftest*
93                 ])
94                 test "$ol_cv_mkdep" = no && OL_MKDEP=":"
95         else
96                 cc_cv_mkdep=yes
97                 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
98         fi
99 else
100         cc_cv_mkdep=yes
101         OL_MKDEP="${MKDEP}"
102         OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
103 fi
104 AC_SUBST(OL_MKDEP)
105 AC_SUBST(OL_MKDEP_FLAGS)
106 ])
107 dnl
108 dnl ====================================================================
109 dnl Check if system uses EBCDIC instead of ASCII
110 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
111 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
112         AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
113 #if !('M' == 0xd4)
114 #include <__ASCII__/generate_error.h>
115 #endif
116 ]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])])
117 if test $ol_cv_cpp_ebcdic = yes ; then
118         AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
119 fi
120 ])
121 dnl
122 dnl --------------------------------------------------------------------
123 dnl Check for MSVC
124 AC_DEFUN([OL_MSVC],
125 [AC_REQUIRE_CPP()dnl
126 AC_CACHE_CHECK([whether we are using MS Visual C++], ol_cv_msvc,
127 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
128 #ifndef _MSC_VER
129 #include <__FOO__/generate_error.h>
130 #endif
131 ]])],[ol_cv_msvc=yes],[ol_cv_msvc=no])])])
132
133 dnl --------------------------------------------------------------------
134 dnl OpenLDAP version of STDC header check w/ EBCDIC support
135 AC_DEFUN([OL_HEADER_STDC],
136 [AC_REQUIRE_CPP()dnl
137 AC_REQUIRE([OL_CPP_EBCDIC])dnl
138 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
139 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
140 #include <stdarg.h>
141 #include <string.h>
142 #include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no])
143
144 if test $ol_cv_header_stdc = yes; then
145   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
146 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
147 fi
148
149 if test $ol_cv_header_stdc = yes; then
150   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
151 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
152 fi
153
154 if test $ol_cv_header_stdc = yes; then
155   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
156 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h>
157 #ifndef HAVE_EBCDIC
158 #       define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
159 #       define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
160 #else
161 #       define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
162                 || ('j' <= (c) && (c) <= 'r') \
163                 || ('s' <= (c) && (c) <= 'z'))
164 #       define TOUPPER(c)       (ISLOWER(c) ? ((c) | 0x40) : (c))
165 #endif
166 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
167 int main () { int i; for (i = 0; i < 256; i++)
168 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
169 exit (0); }
170 ]])],[],[ol_cv_header_stdc=no],[:])
171 fi])
172 if test $ol_cv_header_stdc = yes; then
173   AC_DEFINE([STDC_HEADERS], [1], [is standard C provided?])
174 fi
175 ac_cv_header_stdc=disable
176 ])
177 dnl
178 dnl ====================================================================
179 dnl DNS resolver macros
180 AC_DEFUN([OL_RESOLVER_TRY],
181 [if test $ol_cv_lib_resolver = no ; then
182         AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1],
183 [
184         ol_RESOLVER_LIB=ifelse($2,,,$2)
185         ol_LIBS=$LIBS
186         LIBS="$ol_RESOLVER_LIB $LIBS"
187
188         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
189 #ifdef HAVE_SYS_TYPES_H
190 #       include <sys/types.h>
191 #endif
192 #include <netinet/in.h>
193 #ifdef HAVE_ARPA_NAMESER_H
194 #       include <arpa/nameser.h>
195 #endif
196 #ifdef HAVE_RESOLV_H
197 #       include <resolv.h>
198 #endif
199 ]], [[{
200         int len, status;
201         char *request = NULL;
202         unsigned char reply[64*1024];
203         unsigned char host[64*1024];
204         unsigned char *p;
205
206 #ifdef NS_HFIXEDSZ
207         /* Bind 8/9 interface */
208         len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply));
209 #else
210         /* Bind 4 interface */
211 # ifndef T_SRV
212 #  define T_SRV 33
213 # endif
214         len = res_query(request, C_IN, T_SRV, reply, sizeof(reply));
215 #endif
216         p = reply;
217 #ifdef NS_HFIXEDSZ
218         /* Bind 8/9 interface */
219         p += NS_HFIXEDSZ;
220 #elif defined(HFIXEDSZ)
221         /* Bind 4 interface w/ HFIXEDSZ */
222         p += HFIXEDSZ;
223 #else
224         /* Bind 4 interface w/o HFIXEDSZ */
225         p += sizeof(HEADER);
226 #endif
227         status = dn_expand( reply, reply+len, p, host, sizeof(host));
228 }]])],[$1=yes],[$1=no])
229
230         LIBS="$ol_LIBS"
231 ])
232
233         if test $$1 = yes ; then
234                 ol_cv_lib_resolver=ifelse($2,,yes,$2)
235         fi
236 fi
237 ])
238 dnl --------------------------------------------------------------------
239 dnl Try to locate appropriate library
240 AC_DEFUN([OL_RESOLVER_LINK],
241 [ol_cv_lib_resolver=no
242 OL_RESOLVER_TRY(ol_cv_resolver_none)
243 OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv])
244 OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind])
245 ])
246 dnl
247 dnl ====================================================================
248 dnl International Components for Unicode (ICU)
249 AC_DEFUN([OL_ICU],
250 [ol_icu=no
251 AC_CHECK_HEADERS( unicode/utypes.h )
252 if test $ac_cv_header_unicode_utypes_h = yes ; then
253         dnl OL_ICULIBS="-licui18n -licuuc -licudata"
254         OL_ICULIBS="-licuuc -licudata"
255
256         AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [
257                 ol_LIBS="$LIBS"
258                 LIBS="$OL_ICULIBS $LIBS"
259                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
260 #include <unicode/utypes.h>
261 ]], [[
262 (void) u_errorName(0);
263 ]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no])
264                 LIBS="$ol_LIBS"
265 ])
266
267         if test $ol_cv_lib_icu != no ; then
268                 ol_icu="$OL_ICULIBS"
269                 AC_DEFINE([HAVE_ICU], [1], [define if you actually have ICU])
270         fi
271 fi
272 ])
273 dnl
274 dnl ====================================================================
275 dnl Berkeley DB macros
276 dnl
277 dnl --------------------------------------------------------------------
278 dnl Try to link
279 AC_DEFUN([OL_BERKELEY_DB_TRY],
280 [if test $ol_cv_lib_db = no ; then
281         AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1],
282 [
283         ol_DB_LIB=ifelse($2,,,$2)
284         ol_LIBS=$LIBS
285         LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS"
286
287         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
288 #ifdef HAVE_DB_185_H
289 # include <db_185.h>
290 #else
291 # include <db.h>
292 #endif
293
294 #ifndef DB_VERSION_MAJOR
295 # define DB_VERSION_MAJOR 1
296 #endif
297
298 #ifndef NULL
299 #define NULL ((void*)0)
300 #endif
301 ]], [[
302 #if DB_VERSION_MAJOR > 2
303         db_env_create( NULL, 0 );
304 #elif DB_VERSION_MAJOR > 1
305         db_appexit( NULL );
306 #else
307         (void) dbopen( NULL, 0, 0, 0, NULL);
308 #endif
309 ]])],[$1=yes],[$1=no])
310
311         LIBS="$ol_LIBS"
312 ])
313
314         if test $$1 = yes ; then
315                 ol_cv_lib_db=ifelse($2,,yes,$2)
316         fi
317 fi
318 ])
319 dnl
320 dnl --------------------------------------------------------------------
321 dnl Get major and minor version from <db.h>
322 AC_DEFUN([OL_BDB_HEADER_VERSION],
323 [AC_CACHE_CHECK([for Berkeley DB major version in db.h], [ol_cv_bdb_major],[
324         AC_LANG_CONFTEST([
325 #include <db.h>
326 #ifndef DB_VERSION_MAJOR
327 #       define DB_VERSION_MAJOR 1
328 #endif
329 __db_version DB_VERSION_MAJOR
330 ])
331         set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
332         ol_cv_bdb_major=${3}
333 ])
334 case $ol_cv_bdb_major in [[1-9]]*) : ;; *)
335         AC_MSG_ERROR([Unknown Berkeley DB major version in db.h]) ;;
336 esac
337
338 dnl Determine minor version
339 AC_CACHE_CHECK([for Berkeley DB minor version in db.h], [ol_cv_bdb_minor],[
340         AC_LANG_CONFTEST([
341 #include <db.h>
342 #ifndef DB_VERSION_MINOR
343 #       define DB_VERSION_MINOR 0
344 #endif
345 __db_version DB_VERSION_MINOR
346 ])
347         set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none
348         ol_cv_bdb_minor=${3}
349 ])
350 case $ol_cv_bdb_minor in [[0-9]]*) : ;; *)
351         AC_MSG_ERROR([Unknown Berkeley DB minor version in db.h]) ;;
352 esac
353 ])
354 dnl
355 dnl --------------------------------------------------------------------
356 dnl Try to locate appropriate library
357 AC_DEFUN([OL_BERKELEY_DB_LINK],
358 [ol_cv_lib_db=no
359
360 if test $ol_cv_bdb_major = 4 ; then
361         OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor])
362         OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor])
363         OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor])
364         OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor])
365         OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4])
366         OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4])
367         OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb])
368 fi
369 OL_BERKELEY_DB_TRY(ol_cv_db_none)
370 ])
371 dnl
372 dnl --------------------------------------------------------------------
373 dnl Check if Berkeley DB version
374 AC_DEFUN([OL_BERKELEY_DB_VERSION],
375 [AC_CACHE_CHECK([for Berkeley DB library and header version match], [ol_cv_berkeley_db_version], [
376         ol_LIBS="$LIBS"
377         LIBS="$LTHREAD_LIBS $LIBS"
378         if test $ol_cv_lib_db != yes ; then
379                 LIBS="$ol_cv_lib_db $LIBS"
380         fi
381
382         AC_RUN_IFELSE([AC_LANG_SOURCE([[
383 #ifdef HAVE_DB_185_H
384         choke me;
385 #else
386 #include <db.h>
387 #endif
388 #ifndef DB_VERSION_MAJOR
389 # define DB_VERSION_MAJOR 1
390 #endif
391 #ifndef NULL
392 #define NULL ((void *)0)
393 #endif
394 main()
395 {
396 #if DB_VERSION_MAJOR > 1
397         char *version;
398         int major, minor, patch;
399
400         version = db_version( &major, &minor, &patch );
401
402         if( major != DB_VERSION_MAJOR ||
403                 minor != DB_VERSION_MINOR ||
404                 patch != DB_VERSION_PATCH )
405         {
406                 printf("Berkeley DB version mismatch\n"
407                         "\theader: %s\n\tlibrary: %s\n",
408                         DB_VERSION_STRING, version);
409                 return 1;
410         }
411 #endif
412
413         return 0;
414 }]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross])
415
416         LIBS="$ol_LIBS"
417 ])
418
419         if test $ol_cv_berkeley_db_version = no ; then
420                 AC_MSG_ERROR([Berkeley DB version mismatch])
421         fi
422 ])dnl
423 dnl
424 dnl --------------------------------------------------------------------
425 dnl Check if Berkeley DB supports DB_THREAD
426 AC_DEFUN([OL_BERKELEY_DB_THREAD],
427 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
428         ol_LIBS="$LIBS"
429         LIBS="$LTHREAD_LIBS $LIBS"
430         if test $ol_cv_lib_db != yes ; then
431                 LIBS="$ol_cv_lib_db $LIBS"
432         fi
433
434         AC_RUN_IFELSE([AC_LANG_SOURCE([[
435 #ifdef HAVE_DB_185_H
436         choke me;
437 #else
438 #include <db.h>
439 #endif
440 #ifndef NULL
441 #define NULL ((void *)0)
442 #endif
443 main()
444 {
445         int rc;
446         u_int32_t flags = DB_CREATE |
447 #ifdef DB_PRIVATE
448                 DB_PRIVATE |
449 #endif
450                 DB_THREAD;
451
452 #if DB_VERSION_MAJOR > 2
453         DB_ENV *env = NULL;
454
455         rc = db_env_create( &env, 0 );
456
457         flags |= DB_INIT_MPOOL;
458 #ifdef DB_MPOOL_PRIVATE
459         flags |= DB_MPOOL_PRIVATE;
460 #endif
461
462         if( rc ) {
463                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
464                 return rc;
465         }
466
467 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
468         rc = (env->open)( env, NULL, flags, 0 );
469 #else
470         rc = (env->open)( env, NULL, NULL, flags, 0 );
471 #endif
472
473         if ( rc == 0 ) {
474                 rc = env->close( env, 0 );
475         }
476
477         if( rc ) {
478                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
479                 return rc;
480         }
481
482 #else
483         DB_ENV env;
484         memset( &env, '\0', sizeof(env) );
485
486         rc = db_appinit( NULL, NULL, &env, flags );
487
488         if( rc == 0 ) {
489                 db_appexit( &env );
490         }
491
492         unlink("__db_mpool.share");
493         unlink("__db_lock.share");
494 #endif
495
496         return rc;
497 }]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross])
498
499         LIBS="$ol_LIBS"
500 ])
501
502         if test $ol_cv_berkeley_db_thread != no ; then
503                 AC_DEFINE([HAVE_BERKELEY_DB_THREAD], [1],
504                         [define if Berkeley DB has DB_THREAD support])
505         fi
506 ])dnl
507 dnl
508 dnl --------------------------------------------------------------------
509 dnl Find any DB
510 AC_DEFUN([OL_BERKELEY_DB],
511 [ol_cv_berkeley_db=no
512 AC_CHECK_HEADERS(db.h)
513 if test $ac_cv_header_db_h = yes; then
514         OL_BDB_HEADER_VERSION
515         OL_BDB_COMPAT
516
517         if test $ol_cv_bdb_compat != yes ; then
518                 AC_MSG_ERROR([BerkeleyDB version incompatible with BDB/HDB backends])
519         fi
520
521         OL_BERKELEY_DB_LINK
522         if test "$ol_cv_lib_db" != no ; then
523                 ol_cv_berkeley_db=yes
524                 OL_BERKELEY_DB_VERSION
525                 OL_BERKELEY_DB_THREAD
526         fi
527 fi
528 ])
529 dnl --------------------------------------------------------------------
530 dnl Check for version compatility with back-bdb
531 AC_DEFUN([OL_BDB_COMPAT],
532 [AC_CACHE_CHECK([if Berkeley DB version supported by BDB/HDB backends], [ol_cv_bdb_compat],[
533         AC_EGREP_CPP(__db_version_compat,[
534 #include <db.h>
535
536  /* this check could be improved */
537 #ifndef DB_VERSION_MAJOR
538 #       define DB_VERSION_MAJOR 1
539 #endif
540 #ifndef DB_VERSION_MINOR
541 #       define DB_VERSION_MINOR 0
542 #endif
543
544 #define DB_VERSION_MM   ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR)
545
546 /* require 4.4 or later */
547 #if DB_VERSION_MM >= 0x0404
548         __db_version_compat
549 #endif
550         ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
551 ])
552
553 dnl
554 dnl ====================================================================
555 dnl Check POSIX Thread version 
556 dnl
557 dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the
558 dnl     version of the POSIX.4a Draft that is implemented.
559 dnl     10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
560 dnl     Existence of pthread.h should be tested separately.
561 dnl
562 dnl tests:
563 dnl     pthread_detach() was dropped in Draft 8, it is present
564 dnl             in every other version
565 dnl     PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called
566 dnl             PTHREAD_CREATE_JOINABLE after that
567 dnl     pthread_attr_create was renamed to pthread_attr_init in Draft 6.
568 dnl             Draft 6-10 has _init, Draft 4-5 has _create.
569 dnl     pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
570 dnl     PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
571 dnl             interesting to us because we don't try to statically
572 dnl             initialize mutexes. 5-10 has it.
573 dnl
574 dnl Draft 9 and 10 are equivalent for our purposes.
575 dnl
576 AC_DEFUN([OL_POSIX_THREAD_VERSION],
577 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
578         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
579 #               include <pthread.h>
580         ]], [[
581                 int i = PTHREAD_CREATE_JOINABLE;
582         ]])],[
583         AC_EGREP_HEADER(pthread_detach,pthread.h,
584         ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[
585         AC_EGREP_CPP(draft7,[
586 #               include <pthread.h>
587 #               ifdef PTHREAD_CREATE_UNDETACHED
588                 draft7
589 #               endif
590         ], ol_cv_pthread_version=7, [
591         AC_EGREP_HEADER(pthread_attr_init,pthread.h,
592         ol_cv_pthread_version=6, [
593         AC_EGREP_CPP(draft5,[
594 #               include <pthread.h>
595 #ifdef          PTHREAD_MUTEX_INITIALIZER
596                 draft5
597 #endif
598         ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ])
599 ])
600 ])dnl
601 dnl
602 dnl --------------------------------------------------------------------
603 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[
604 /* pthread test headers */
605 #include <pthread.h>
606 #if HAVE_PTHREADS < 7
607 #include <errno.h>
608 #endif
609 #ifndef NULL
610 #define NULL (void*)0
611 #endif
612
613 static void *task(p)
614         void *p;
615 {
616         return (void *) (p == NULL);
617 }
618 ]])
619 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[
620         /* pthread test function */
621 #ifndef PTHREAD_CREATE_DETACHED
622 #define PTHREAD_CREATE_DETACHED 1
623 #endif
624         pthread_t t;
625         int status;
626         int detach = PTHREAD_CREATE_DETACHED;
627
628 #if HAVE_PTHREADS > 4
629         /* Final pthreads */
630         pthread_attr_t attr;
631
632         status = pthread_attr_init(&attr);
633         if( status ) return status;
634
635 #if HAVE_PTHREADS < 7
636         status = pthread_attr_setdetachstate(&attr, &detach);
637         if( status < 0 ) status = errno;
638 #else
639         status = pthread_attr_setdetachstate(&attr, detach);
640 #endif
641         if( status ) return status;
642         status = pthread_create( &t, &attr, task, NULL );
643 #if HAVE_PTHREADS < 7
644         if( status < 0 ) status = errno;
645 #endif
646         if( status ) return status;
647 #else
648         /* Draft 4 pthreads */
649         status = pthread_create( &t, pthread_attr_default, task, NULL );
650         if( status ) return errno;
651
652         /* give thread a chance to complete */
653         /* it should remain joinable and hence detachable */
654         sleep( 1 );
655
656         status = pthread_detach( &t );
657         if( status ) return errno;
658 #endif
659
660 #ifdef HAVE_LINUX_THREADS
661         pthread_kill_other_threads_np();
662 #endif
663
664         return 0;
665 ]])
666
667 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM], [
668 AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES
669
670 int main(argc, argv)
671         int argc;
672         char **argv;
673 {
674 OL_PTHREAD_TEST_FUNCTION
675 }
676 ])])
677 dnl --------------------------------------------------------------------
678 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
679 if test "$ol_link_threads" = no ; then
680         # try $1
681         AC_CACHE_CHECK([for pthread link with $1], [$2], [
682                 # save the flags
683                 ol_LIBS="$LIBS"
684                 LIBS="$1 $LIBS"
685
686                 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
687                         [$2=yes],
688                         [$2=no],
689                         [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES,
690                                 OL_PTHREAD_TEST_FUNCTION)],
691                                 [$2=yes], [$2=no])])
692
693                 # restore the LIBS
694                 LIBS="$ol_LIBS"
695         ])
696
697         if test $$2 = yes ; then
698                 ol_link_pthreads="$1"
699                 ol_link_threads=posix
700         fi
701 fi
702 ])
703 dnl
704 dnl ====================================================================
705 dnl Check GNU Pth pthread Header
706 dnl
707 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
708 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
709 dnl             doesn't exists.  Existance of pthread.h should separately
710 dnl             checked.
711 dnl 
712 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
713         AC_CACHE_CHECK([for GNU Pth pthread.h],
714                 [ol_cv_header_gnu_pth_pthread_h],
715                 [AC_EGREP_CPP(__gnu_pth__,
716                         [#include <pthread.h>
717 #ifdef _POSIX_THREAD_IS_GNU_PTH
718         __gnu_pth__;
719 #endif
720 ],
721                         [ol_cv_header_gnu_pth_pthread_h=yes],
722                         [ol_cv_header_gnu_pth_pthread_h=no])
723                 ])
724 ])dnl
725 dnl ====================================================================
726 dnl Check for NT Threads
727 AC_DEFUN([OL_NT_THREADS], [
728         AC_CHECK_FUNC(_beginthread)
729
730         if test $ac_cv_func__beginthread = yes ; then
731                 AC_DEFINE([HAVE_NT_THREADS], [1], [if you have NT Threads])
732                 ol_cv_nt_threads=yes
733         fi
734 ])
735 dnl ====================================================================
736 dnl Check LinuxThreads Header
737 dnl
738 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
739 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
740 dnl             doesn't exists.  Existance of pthread.h should separately
741 dnl             checked.
742 dnl 
743 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
744         AC_CACHE_CHECK([for LinuxThreads pthread.h],
745                 [ol_cv_header_linux_threads],
746                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
747                         [#include <pthread.h>],
748                         [ol_cv_header_linux_threads=yes],
749                         [ol_cv_header_linux_threads=no])
750                 ])
751         if test $ol_cv_header_linux_threads = yes; then
752                 AC_DEFINE([HAVE_LINUX_THREADS], [1], [if you have LinuxThreads])
753         fi
754 ])dnl
755 dnl --------------------------------------------------------------------
756 dnl     Check LinuxThreads Implementation
757 dnl
758 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
759 dnl     'no' implies pthreads implementation is not LinuxThreads.
760 dnl 
761 AC_DEFUN([OL_SYS_LINUX_THREADS], [
762         AC_CHECK_FUNCS(pthread_kill_other_threads_np)
763         AC_CACHE_CHECK([for LinuxThreads implementation],
764                 [ol_cv_sys_linux_threads],
765                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
766 ])dnl
767 dnl
768 dnl --------------------------------------------------------------------
769 dnl Check LinuxThreads consistency
770 AC_DEFUN([OL_LINUX_THREADS], [
771         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
772         AC_REQUIRE([OL_SYS_LINUX_THREADS])
773         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
774                 if test $ol_cv_header_linux_threads = yes &&
775                    test $ol_cv_sys_linux_threads = yes; then
776                         ol_cv_linux_threads=yes
777                 elif test $ol_cv_header_linux_threads = no &&
778                      test $ol_cv_sys_linux_threads = no; then
779                         ol_cv_linux_threads=no
780                 else
781                         ol_cv_linux_threads=error
782                 fi
783         ])
784 ])dnl
785 dnl
786 dnl ====================================================================
787 dnl Check for POSIX Regex
788 AC_DEFUN([OL_POSIX_REGEX], [
789 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
790         AC_RUN_IFELSE([AC_LANG_SOURCE([[
791 #include <sys/types.h>
792 #include <regex.h>
793 static char *pattern, *string;
794 main()
795 {
796         int rc;
797         regex_t re;
798
799         pattern = "^A";
800
801         if(regcomp(&re, pattern, 0)) {
802                 return -1;
803         }
804         
805         string = "ALL MATCH";
806         
807         rc = regexec(&re, string, 0, (void*)0, 0);
808
809         regfree(&re);
810
811         return rc;
812 }]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])])
813 ])
814 dnl
815 dnl ====================================================================
816 dnl Check if toupper() requires islower() to be called first
817 AC_DEFUN([OL_C_UPPER_LOWER],
818 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
819         AC_RUN_IFELSE([AC_LANG_SOURCE([[
820 #include <ctype.h>
821 main()
822 {
823         if ('C' == toupper('C'))
824                 exit(0);
825         else
826                 exit(1);
827 }]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])])
828 if test $ol_cv_c_upper_lower != no ; then
829         AC_DEFINE([C_UPPER_LOWER], [1], [define if toupper() requires islower()])
830 fi
831 ])
832 dnl
833 dnl ====================================================================
834 dnl Error string checks
835 dnl
836 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
837 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
838 dnl Reported by Keith Bostic.
839 AC_DEFUN([OL_SYS_ERRLIST],
840 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
841         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
842 #include <stdio.h>
843 #include <sys/types.h>
844 #include <errno.h>
845 #ifdef _WIN32
846 #include <stdlib.h>
847 #endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
848         ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
849 #
850 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
851 if test $ol_cv_dcl_sys_errlist = no ; then
852         AC_DEFINE([DECL_SYS_ERRLIST], [1],
853                 [define if sys_errlist is not declared in stdio.h or errno.h])
854
855         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
856                 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])])
857 fi
858 if test $ol_cv_have_sys_errlist = yes ; then
859         AC_DEFINE([HAVE_SYS_ERRLIST], [1],
860                 [define if you actually have sys_errlist in your libs])
861 fi
862 ])dnl
863 AC_DEFUN([OL_NONPOSIX_STRERROR_R],
864 [AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
865         AC_EGREP_CPP(strerror_r,[#include <string.h>],
866                 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl
867
868         if test $ol_decl_strerror_r = yes ; then
869                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[   /* from autoconf 2.59 */
870                                 char buf[100];
871                                 char x = *strerror_r (0, buf, sizeof buf);
872                                 char *p = strerror_r (0, buf, sizeof buf);
873                         ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no])
874         else
875                 AC_RUN_IFELSE([AC_LANG_SOURCE([[
876                         main() {
877                                 char buf[100];
878                                 buf[0] = 0;
879                                 strerror_r( 1, buf, sizeof buf );
880                                 exit( buf[0] == 0 );
881                         }
882                         ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
883         fi
884         ])
885 if test $ol_cv_nonposix_strerror_r = yes ; then
886         AC_DEFINE([HAVE_NONPOSIX_STRERROR_R], [1],
887                 [define if strerror_r returns char* instead of int])
888 fi
889 ])dnl
890 dnl
891 AC_DEFUN([OL_STRERROR],
892 [OL_SYS_ERRLIST dnl TEMPORARY
893 AC_CHECK_FUNCS(strerror strerror_r)
894 ol_cv_func_strerror_r=no
895 if test "${ac_cv_func_strerror_r}" = yes ; then
896         OL_NONPOSIX_STRERROR_R
897 elif test "${ac_cv_func_strerror}" = no ; then
898         OL_SYS_ERRLIST
899 fi
900 ])dnl
901 dnl ====================================================================
902 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
903 dnl "int x; int *volatile a = &x; *a = 0;"
904 dnl     -- borrowed from PDKSH
905 AC_DEFUN([OL_C_VOLATILE],
906  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
907     [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z;
908       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
909       *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])])
910   if test $ol_cv_c_volatile = yes; then
911     : 
912   else
913     AC_DEFINE([volatile], [], [define as empty if volatile is not supported])
914   fi
915  ])dnl
916 dnl
917 dnl ====================================================================
918 dnl Look for fetch(3)
919 AC_DEFUN([OL_LIB_FETCH],
920 [ol_LIBS=$LIBS
921 LIBS="-lfetch -lcom_err $LIBS"
922 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
923         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
924 #ifdef HAVE_SYS_PARAM_H
925 #include <sys/param.h>
926 #endif
927 #include <stdio.h>
928 #include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])])
929 LIBS=$ol_LIBS
930 if test $ol_cv_lib_fetch != no ; then
931         ol_link_fetch="-lfetch -lcom_err"
932         AC_DEFINE([HAVE_FETCH], [1],
933                 [define if you actually have FreeBSD fetch(3)])
934 fi
935 ])dnl
936 dnl
937 dnl ====================================================================
938 dnl Define inet_aton is available
939 AC_DEFUN([OL_FUNC_INET_ATON],
940  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
941     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
942 #ifdef HAVE_SYS_TYPES_H
943 #       include <sys/types.h>
944 #endif
945 #ifdef HAVE_SYS_SOCKET_H
946 #       include <sys/socket.h>
947 #       ifdef HAVE_SYS_SELECT_H
948 #               include <sys/select.h>
949 #       endif
950 #       include <netinet/in.h>
951 #       ifdef HAVE_ARPA_INET_H
952 #               include <arpa/inet.h>
953 #       endif
954 #endif
955 ]], [[struct in_addr in;
956 int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])])
957   if test $ol_cv_func_inet_aton != no; then
958     AC_DEFINE(HAVE_INET_ATON, 1,
959                 [define to you inet_aton(3) is available])
960   fi
961  ])dnl
962 dnl
963 dnl ====================================================================
964 dnl check no of arguments for ctime_r
965 AC_DEFUN([OL_FUNC_CTIME_R_NARGS],
966  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
967    [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])
968
969         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])
970
971         if test $ol_cv_func_ctime_r_nargs3 = yes &&
972            test $ol_cv_func_ctime_r_nargs2 = no ; then
973
974                 ol_cv_func_ctime_r_nargs=3
975
976         elif test $ol_cv_func_ctime_r_nargs3 = no &&
977              test $ol_cv_func_ctime_r_nargs2 = yes ; then
978
979                 ol_cv_func_ctime_r_nargs=2
980
981         else
982                 ol_cv_func_ctime_r_nargs=0
983         fi
984   ])
985
986   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
987         AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
988                 [set to the number of arguments ctime_r() expects])
989   fi
990 ])dnl
991 dnl
992 dnl --------------------------------------------------------------------
993 dnl check return type of ctime_r()
994 AC_DEFUN([OL_FUNC_CTIME_R_TYPE],
995  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
996    [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"])
997         ])
998   if test $ol_cv_func_ctime_r_type = "int" ; then
999         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1000   fi
1001 ])dnl
1002 dnl ====================================================================
1003 dnl check no of arguments for gethostbyname_r
1004 AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS],
1005  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1006         ol_cv_func_gethostbyname_r_nargs,
1007         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1008 #include <sys/socket.h>
1009 #include <netinet/in.h>
1010 #include <netdb.h>
1011 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE];
1012                 int bufsize=BUFSIZE;int h_errno;
1013                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1014                         buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no])
1015
1016         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1017 #include <sys/socket.h>
1018 #include <netinet/in.h>
1019 #include <netdb.h>
1020 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent;
1021                 char buffer[BUFSIZE];
1022                 int bufsize=BUFSIZE;int h_errno;
1023                 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1024                         &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no])
1025
1026         if test $ol_cv_func_gethostbyname_r_nargs5 = yes &&
1027            test $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1028
1029                 ol_cv_func_gethostbyname_r_nargs=5
1030
1031         elif test $ol_cv_func_gethostbyname_r_nargs5 = no &&
1032              test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1033
1034                 ol_cv_func_gethostbyname_r_nargs=6
1035
1036         else
1037                 ol_cv_func_gethostbyname_r_nargs=0
1038         fi
1039   ])
1040   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1041         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1042                 $ol_cv_func_gethostbyname_r_nargs,
1043                 [set to the number of arguments gethostbyname_r() expects])
1044   fi
1045 ])dnl
1046 dnl
1047 dnl check no of arguments for gethostbyaddr_r
1048 AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS],
1049  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1050         [ol_cv_func_gethostbyaddr_r_nargs],
1051         [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1052 #include <sys/socket.h>
1053 #include <netinet/in.h>
1054 #include <netdb.h>
1055 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 
1056             struct in_addr add;
1057             size_t alen=sizeof(struct in_addr);
1058             int bufsize=BUFSIZE;int h_errno;
1059                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1060                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no])
1061
1062         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1063 #include <sys/socket.h>
1064 #include <netinet/in.h>
1065 #include <netdb.h>
1066 #define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;
1067                 struct hostent *rhent; char buffer[BUFSIZE]; 
1068                 struct in_addr add;
1069                 size_t alen=sizeof(struct in_addr);
1070                 int bufsize=BUFSIZE;int h_errno;
1071                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1072                         alen, AF_INET, &hent, buffer, bufsize, 
1073                         &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no])
1074
1075         if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes &&
1076            test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1077
1078                 ol_cv_func_gethostbyaddr_r_nargs=7
1079
1080         elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no &&
1081              test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1082
1083                 ol_cv_func_gethostbyaddr_r_nargs=8
1084
1085         else
1086                 ol_cv_func_gethostbyaddr_r_nargs=0
1087         fi
1088   ])
1089   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1090     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1091                 $ol_cv_func_gethostbyaddr_r_nargs,
1092                 [set to the number of arguments gethostbyaddr_r() expects])
1093   fi
1094 ])dnl
1095 dnl
1096 dnl --------------------------------------------------------------------
1097 dnl Check for Cyrus SASL version compatility
1098 AC_DEFUN([OL_SASL_COMPAT],
1099 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1100         AC_EGREP_CPP(__sasl_compat,[
1101 #ifdef HAVE_SASL_SASL_H
1102 #include <sasl/sasl.h>
1103 #else
1104 #include <sasl.h>
1105 #endif
1106
1107 /* Require 2.1.15+ */
1108 #if SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR > 1
1109         char *__sasl_compat = "2.2+ or better okay (we guess)";
1110 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR == 1 \
1111         && SASL_VERSION_STEP >=15
1112         char *__sasl_compat = "2.1.15+ or better okay";
1113 #endif
1114         ],      [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1115 ])
1116 dnl ====================================================================
1117 dnl check for SSL compatibility
1118 AC_DEFUN([OL_SSL_COMPAT],
1119 [AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)],
1120         [ol_cv_ssl_crl_compat],[
1121                 AC_EGREP_CPP(__ssl_compat,[
1122 #ifdef HAVE_OPENSSL_SSL_H
1123 #include <openssl/ssl.h>
1124 #endif
1125
1126 /* Require 0.9.7d+ */
1127 #if OPENSSL_VERSION_NUMBER >= 0x0090704fL
1128         char *__ssl_compat = "0.9.7d";
1129 #endif
1130         ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])
1131 ])