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