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