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