]> git.sur5r.net Git - openldap/blob - build/openldap.m4
Suck in latest changes from HEAD
[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,[-ldb])
317 OL_BERKELEY_DB_TRY(ol_cv_db_db3,[-ldb3])
318 OL_BERKELEY_DB_TRY(ol_cv_db_db2,[-ldb2])
319 OL_BERKELEY_DB_TRY(ol_cv_db_db1,[-ldb1])
320 ])
321 dnl
322 dnl --------------------------------------------------------------------
323 dnl Check if Berkeley DB supports DB_THREAD
324 AC_DEFUN([OL_BERKELEY_DB_THREAD],
325 [AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [
326         ol_LIBS="$LIBS"
327         if test $ol_cv_lib_db != yes ; then
328                 LIBS="$ol_cv_lib_db"
329         fi
330
331         AC_TRY_RUN([
332 #ifdef HAVE_DB_185_H
333         choke me;
334 #else
335 #include <db.h>
336 #endif
337 #ifndef NULL
338 #define NULL ((void *)0)
339 #endif
340 main()
341 {
342         int rc;
343         u_int32_t flags = DB_CREATE |
344 #ifdef DB_PRIVATE
345                 DB_PRIVATE |
346 #endif
347                 DB_THREAD;
348
349 #if DB_VERSION_MAJOR > 2
350         DB_ENV *env = NULL;
351
352         rc = db_env_create( &env, 0 );
353
354         flags |= DB_INIT_MPOOL;
355 #ifdef DB_MPOOL_PRIVATE
356         flags |= DB_MPOOL_PRIVATE;
357 #endif
358
359         if( rc ) {
360                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
361                 return rc;
362         }
363
364 #if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1)
365         rc = env->open( env, NULL, flags, 0 );
366 #else
367         rc = env->open( env, NULL, NULL, flags, 0 );
368 #endif
369
370         if ( rc == 0 ) {
371                 rc = env->close( env, 0 );
372         }
373
374         if( rc ) {
375                 printf("BerkeleyDB: %s\n", db_strerror(rc) );
376                 return rc;
377         }
378
379 #else
380         DB_ENV env;
381         memset( &env, '\0', sizeof(env) );
382
383         rc = db_appinit( NULL, NULL, &env, flags );
384
385         if( rc == 0 ) {
386                 db_appexit( &env );
387         }
388
389         unlink("__db_mpool.share");
390         unlink("__db_lock.share");
391 #endif
392
393         return rc;
394 }],
395         [ol_cv_berkeley_db_thread=yes],
396         [ol_cv_berkeley_db_thread=no],
397         [ol_cv_berkeley_db_thread=cross])
398
399         LIBS="$ol_LIBS"
400
401         if test $ol_cv_berkeley_db_thread != no ; then
402                 AC_DEFINE(HAVE_BERKELEY_DB_THREAD, 1,
403                         [define if Berkeley DB has DB_THREAD support])
404         fi
405 ])])dnl
406 dnl
407 dnl --------------------------------------------------------------------
408 dnl Find any DB
409 AC_DEFUN([OL_BERKELEY_DB],
410 [ol_cv_berkeley_db=no
411 AC_CHECK_HEADERS(db.h)
412 if test $ac_cv_header_db_h = yes; then
413         OL_BERKELEY_DB_LINK
414         if test "$ol_cv_lib_db" != no ; then
415                 ol_cv_berkeley_db=yes
416                 OL_BERKELEY_DB_THREAD
417         fi
418 fi
419 ])
420 dnl --------------------------------------------------------------------
421 dnl Check for version compatility with back-bdb
422 AC_DEFUN([OL_BDB_COMPAT],
423 [AC_CACHE_CHECK([Berkeley DB version for BDB backend], [ol_cv_bdb_compat],[
424         AC_EGREP_CPP(__db_version_compat,[
425 #include <db.h>
426
427  /* this check could be improved */
428 #ifndef DB_VERSION_MAJOR
429 #       define DB_VERSION_MAJOR 1
430 #endif
431
432 /* require 4.0 or later */
433 #if DB_VERSION_MAJOR >= 4 
434         __db_version_compat
435 #endif
436         ],      [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])])
437 ])
438
439 dnl --------------------------------------------------------------------
440 dnl Find old Berkeley DB 1.85/1.86
441 AC_DEFUN([OL_BERKELEY_COMPAT_DB],
442 [AC_CHECK_HEADERS(db_185.h db.h)
443 if test $ac_cv_header_db_185_h = yes -o $ac_cv_header_db_h = yes; then
444         AC_CACHE_CHECK([if Berkeley DB header compatibility], [ol_cv_header_db1],[
445                 AC_EGREP_CPP(__db_version_1,[
446 #if HAVE_DB_185_H
447 #       include <db_185.h>
448 #else
449 #       include <db.h>
450 #endif
451
452  /* this check could be improved */
453 #ifndef DB_VERSION_MAJOR
454 #       define DB_VERSION_MAJOR 1
455 #endif
456
457 #if DB_VERSION_MAJOR == 1 
458         __db_version_1
459 #endif
460 ],      [ol_cv_header_db1=yes], [ol_cv_header_db1=no])])
461
462         if test $ol_cv_header_db1 = yes ; then
463                 OL_BERKELEY_DB_LINK
464                 if test "$ol_cv_lib_db" != no ; then
465                         ol_cv_berkeley_db=yes
466                 fi
467         fi
468 fi
469 ])
470 dnl
471 dnl ====================================================================
472 dnl Check if GDBM library exists
473 dnl Check for gdbm_open in standard libraries or -lgdbm
474 dnl
475 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
476 dnl             'yes' implies gdbm_open is in $LIBS
477 dnl
478 dnl uses:
479 dnl             AC_CHECK_FUNC(gdbm_open)
480 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
481 dnl
482 AC_DEFUN([OL_LIB_GDBM],
483 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
484 [       ol_LIBS="$LIBS"
485         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
486                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
487         ])
488         LIBS="$ol_LIBS"
489 ])
490 ])dnl
491 dnl
492 dnl --------------------------------------------------------------------
493 dnl Check if GDBM exists
494 dnl
495 dnl defines ol_cv_gdbm to 'yes' or 'no'
496 dnl 
497 dnl uses:
498 dnl             OL_LIB_GDBM
499 dnl             AC_CHECK_HEADERS(gdbm.h)
500 dnl
501 AC_DEFUN([OL_GDBM],
502 [AC_REQUIRE([OL_LIB_GDBM])
503  AC_CHECK_HEADERS(gdbm.h)
504  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
505         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
506                 ol_cv_gdbm=no
507         else
508                 ol_cv_gdbm=yes
509         fi
510 ])
511  if test $ol_cv_gdbm = yes ; then
512         AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
513  fi
514 ])dnl
515 dnl
516 dnl ====================================================================
517 dnl Check if MDBM library exists
518 dnl Check for mdbm_open in standard libraries or -lmdbm
519 dnl
520 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
521 dnl             'yes' implies mdbm_open is in $LIBS
522 dnl
523 dnl uses:
524 dnl             AC_CHECK_FUNC(mdbm_set_chain)
525 dnl             AC_CHECK_LIB(mdbm,mdbm_set_chain)
526 dnl
527 AC_DEFUN([OL_LIB_MDBM],
528 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
529 [       ol_LIBS="$LIBS"
530         AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
531                 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
532         ])
533         LIBS="$ol_LIBS"
534 ])
535 ])dnl
536 dnl
537 dnl --------------------------------------------------------------------
538 dnl Check if MDBM exists
539 dnl
540 dnl defines ol_cv_mdbm to 'yes' or 'no'
541 dnl 
542 dnl uses:
543 dnl             OL_LIB_MDBM
544 dnl             AC_CHECK_HEADERS(mdbm.h)
545 dnl
546 AC_DEFUN([OL_MDBM],
547 [AC_REQUIRE([OL_LIB_MDBM])
548  AC_CHECK_HEADERS(mdbm.h)
549  AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
550         if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
551                 ol_cv_mdbm=no
552         else
553                 ol_cv_mdbm=yes
554         fi
555 ])
556  if test $ol_cv_mdbm = yes ; then
557         AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
558  fi
559 ])dnl
560 dnl
561 dnl ====================================================================
562 dnl Check if NDBM library exists
563 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
564 dnl
565 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
566 dnl             'yes' implies ndbm_open is in $LIBS
567 dnl
568 dnl uses:
569 dnl             AC_CHECK_FUNC(dbm_open)
570 dnl             AC_CHECK_LIB(ndbm,dbm_open)
571 dnl             AC_CHECK_LIB(dbm,dbm_open)
572 dnl
573 dnl restrictions:
574 dnl             should also check SVR4 case: dbm_open() in -lucb but that
575 dnl             would requiring dealing with -L/usr/ucblib
576 dnl
577 AC_DEFUN([OL_LIB_NDBM],
578 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
579 [       ol_LIBS="$LIBS"
580         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
581                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
582                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
583                                 [ol_cv_lib_ndbm=no])dnl
584                 ])
585         ])
586         LIBS="$ol_LIBS"
587 ])
588 ])dnl
589 dnl
590 dnl --------------------------------------------------------------------
591 dnl Check if NDBM exists
592 dnl
593 dnl defines ol_cv_ndbm to 'yes' or 'no'
594 dnl 
595 dnl uses:
596 dnl             OL_LIB_NDBM
597 dnl             AC_CHECK_HEADERS(ndbm.h)
598 dnl
599 dnl restrictions:
600 dnl             Doesn't handle SVR4 case (see above)
601 dnl
602 AC_DEFUN([OL_NDBM],
603 [AC_REQUIRE([OL_LIB_NDBM])
604  AC_CHECK_HEADERS(ndbm.h)
605  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
606         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
607                 ol_cv_ndbm=no
608         else
609                 ol_cv_ndbm=yes
610         fi
611 ])
612  if test $ol_cv_ndbm = yes ; then
613         AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
614  fi
615 ])dnl
616 dnl
617 dnl ====================================================================
618 dnl Check POSIX Thread version 
619 dnl
620 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
621 dnl     'unknown' implies that the version could not be detected
622 dnl             or that pthreads.h does exist.  Existance of pthreads.h
623 dnl             should be tested separately.
624 dnl
625 AC_DEFUN([OL_POSIX_THREAD_VERSION],
626 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
627         AC_EGREP_CPP(pthread_version_final,[
628 #               include <pthread.h>
629                 /* this check could be improved */
630 #               ifdef PTHREAD_ONCE_INIT
631                         pthread_version_final;
632 #               endif
633         ], ol_pthread_final=yes, ol_pthread_final=no)
634
635         AC_EGREP_CPP(pthread_version_draft4,[
636 #               include <pthread.h>
637                 /* this check could be improved */
638 #               ifdef pthread_once_init
639                         pthread_version_draft4;
640 #               endif
641         ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
642
643         if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
644                 ol_cv_pthread_version=final
645         elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
646                 ol_cv_pthread_version=draft4
647         else
648                 ol_cv_pthread_version=unknown
649         fi
650 ])
651 ])dnl
652 dnl
653 dnl --------------------------------------------------------------------
654 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
655 [/* pthread test headers */
656 #include <pthread.h>
657 #ifndef NULL
658 #define NULL (void*)0
659 #endif
660
661 static void *task(p)
662         void *p;
663 {
664         return (void *) (p == NULL);
665 }
666 ])
667 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
668         /* pthread test function */
669         pthread_t t;
670         int status;
671         int detach = 1;
672
673 #ifdef HAVE_PTHREADS_FINAL
674         /* Final pthreads */
675         pthread_attr_t attr;
676
677         status = pthread_attr_init(&attr);
678         if( status ) return status;
679
680 #if defined( PTHREAD_CREATE_JOINABLE ) || defined( PTHREAD_UNDETACHED )
681         if( !detach ) {
682 #if defined( PTHREAD_CREATE_JOINABLE )
683                 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
684 #else
685                 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED);
686 #endif
687
688 #ifdef PTHREAD_CREATE_DETACHED
689         } else {
690                 status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
691 #endif
692         }
693         if( status ) return status;
694 #endif
695
696         status = pthread_create( &t, &attr, task, NULL );
697         if( status ) return status;
698
699 #if !defined( PTHREAD_CREATE_JOINABLE ) && !defined( PTHREAD_UNDETACHED )
700         if( detach ) {
701                 /* give thread a chance to complete */
702                 /* it should remain joinable and hence detachable */
703                 sleep( 1 );
704
705                 status = pthread_detach( t );
706                 if( status ) return status;
707         }
708 #endif
709
710 #else
711         /* Draft 4 pthreads */
712         status = pthread_create( &t, pthread_attr_default, task, NULL );
713         if( status ) return status;
714
715         if( detach ) {
716                 /* give thread a chance to complete */
717                 /* it should remain joinable and hence detachable */
718                 sleep( 1 );
719
720                 status = pthread_detach( &t );
721                 if( status ) return status;
722         }
723 #endif
724
725 #ifdef HAVE_LINUX_THREADS
726         pthread_kill_other_threads_np();
727 #endif
728
729         return 0;
730 ])
731
732 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
733 [OL_PTHREAD_TEST_INCLUDES
734
735 int main(argc, argv)
736         int argc;
737         char **argv;
738 {
739 OL_PTHREAD_TEST_FUNCTION
740 }
741 ])
742 dnl --------------------------------------------------------------------
743 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
744 if test "$ol_link_threads" = no ; then
745         # try $1
746         AC_CACHE_CHECK([for pthread link with $1], [$2], [
747                 # save the flags
748                 ol_LIBS="$LIBS"
749                 LIBS="$1 $LIBS"
750
751                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
752                         [$2=yes], [$2=no],
753                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
754                                 [$2=yes], [$2=no])])
755
756                 # restore the LIBS
757                 LIBS="$ol_LIBS"
758         ])
759
760         if test $$2 = yes ; then
761                 ol_link_pthreads="$1"
762                 ol_link_threads=posix
763         fi
764 fi
765 ])
766 dnl
767 dnl ====================================================================
768 dnl Check GNU Pth pthread Header
769 dnl
770 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
771 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
772 dnl             doesn't exists.  Existance of pthread.h should separately
773 dnl             checked.
774 dnl 
775 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
776         AC_CACHE_CHECK([for GNU Pth pthread.h],
777                 [ol_cv_header_gnu_pth_pthread_h],
778                 [AC_EGREP_CPP(__gnu_pth__,
779                         [#include <pthread.h>
780 #ifdef _POSIX_THREAD_IS_GNU_PTH
781         __gnu_pth__;
782 #endif
783 ],
784                         [ol_cv_header_gnu_pth_pthread_h=yes],
785                         [ol_cv_header_gnu_pth_pthread_h=no])
786                 ])
787 ])dnl
788 dnl ====================================================================
789 dnl Check for NT Threads
790 AC_DEFUN([OL_NT_THREADS], [
791         AC_CHECK_FUNC(_beginthread)
792
793         if test $ac_cv_func__beginthread = yes ; then
794                 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
795                 ol_cv_nt_threads=yes
796         fi
797 ])
798 dnl ====================================================================
799 dnl Check LinuxThreads Header
800 dnl
801 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
802 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
803 dnl             doesn't exists.  Existance of pthread.h should separately
804 dnl             checked.
805 dnl 
806 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
807         AC_CACHE_CHECK([for LinuxThreads pthread.h],
808                 [ol_cv_header_linux_threads],
809                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
810                         [#include <pthread.h>],
811                         [ol_cv_header_linux_threads=yes],
812                         [ol_cv_header_linux_threads=no])
813                 ])
814         if test $ol_cv_header_linux_threads = yes; then
815                 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
816         fi
817 ])dnl
818 dnl --------------------------------------------------------------------
819 dnl     Check LinuxThreads Implementation
820 dnl
821 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
822 dnl     'no' implies pthreads implementation is not LinuxThreads.
823 dnl 
824 AC_DEFUN([OL_SYS_LINUX_THREADS], [
825         AC_CHECK_FUNCS(pthread_kill_other_threads_np)
826         AC_CACHE_CHECK([for LinuxThreads implementation],
827                 [ol_cv_sys_linux_threads],
828                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
829 ])dnl
830 dnl
831 dnl --------------------------------------------------------------------
832 dnl Check LinuxThreads consistency
833 AC_DEFUN([OL_LINUX_THREADS], [
834         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
835         AC_REQUIRE([OL_SYS_LINUX_THREADS])
836         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
837                 if test $ol_cv_header_linux_threads = yes -a \
838                         $ol_cv_sys_linux_threads = yes; then
839                         ol_cv_linux_threads=yes
840                 elif test $ol_cv_header_linux_threads = no -a \
841                         $ol_cv_sys_linux_threads = no; then
842                         ol_cv_linux_threads=no
843                 else
844                         ol_cv_linux_threads=error
845                 fi
846         ])
847 ])dnl
848 dnl
849 dnl ====================================================================
850 dnl Check for POSIX Regex
851 AC_DEFUN([OL_POSIX_REGEX], [
852 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
853         AC_TRY_RUN([
854 #include <sys/types.h>
855 #include <regex.h>
856 static char *pattern, *string;
857 main()
858 {
859         int rc;
860         regex_t re;
861
862         pattern = "^A";
863
864         if(regcomp(&re, pattern, 0)) {
865                 return -1;
866         }
867         
868         string = "ALL MATCH";
869         
870         rc = regexec(&re, string, 0, (void*)0, 0);
871
872         regfree(&re);
873
874         return rc;
875 }],
876         [ol_cv_c_posix_regex=yes],
877         [ol_cv_c_posix_regex=no],
878         [ol_cv_c_posix_regex=cross])])
879 ])
880 dnl
881 dnl ====================================================================
882 dnl Check if toupper() requires islower() to be called first
883 AC_DEFUN([OL_C_UPPER_LOWER],
884 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
885         AC_TRY_RUN([
886 #include <ctype.h>
887 main()
888 {
889         if ('C' == toupper('C'))
890                 exit(0);
891         else
892                 exit(1);
893 }],
894         [ol_cv_c_upper_lower=no],
895         [ol_cv_c_upper_lower=yes],
896         [ol_cv_c_upper_lower=safe])])
897 if test $ol_cv_c_upper_lower != no ; then
898         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
899 fi
900 ])
901 dnl
902 dnl ====================================================================
903 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
904 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
905 dnl Reported by Keith Bostic.
906 AC_DEFUN([OL_SYS_ERRLIST],
907 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
908         AC_TRY_COMPILE([
909 #include <stdio.h>
910 #include <sys/types.h>
911 #include <errno.h>
912 #ifdef WINNT
913 #include <stdlib.h>
914 #endif ],
915         [char *c = (char *) *sys_errlist],
916         [ol_cv_dcl_sys_errlist=yes
917         ol_cv_have_sys_errlist=yes],
918         [ol_cv_dcl_sys_errlist=no])])
919 #
920 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
921 if test $ol_cv_dcl_sys_errlist = no ; then
922         AC_DEFINE(DECL_SYS_ERRLIST,1,
923                 [define if sys_errlist is not declared in stdio.h or errno.h])
924
925         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
926                 AC_TRY_LINK([#include <errno.h>],
927                         [char *c = (char *) *sys_errlist],
928                         [ol_cv_have_sys_errlist=yes],
929                         [ol_cv_have_sys_errlist=no])])
930 fi
931 if test $ol_cv_have_sys_errlist = yes ; then
932         AC_DEFINE(HAVE_SYS_ERRLIST,1,
933                 [define if you actually have sys_errlist in your libs])
934 fi
935 ])dnl
936 dnl
937 dnl ====================================================================
938 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
939 dnl "int x; int *volatile a = &x; *a = 0;"
940 dnl     -- borrowed from PDKSH
941 AC_DEFUN(OL_C_VOLATILE,
942  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
943     [AC_TRY_COMPILE([int x, y, z;],
944       [volatile int a; int * volatile b = x ? &y : &z;
945       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
946       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
947   if test $ol_cv_c_volatile = yes; then
948     : 
949   else
950     AC_DEFINE(volatile,,[define as empty if volatile is not supported])
951   fi
952  ])dnl
953 dnl
954 dnl ====================================================================
955 dnl Look for fetch(3)
956 AC_DEFUN([OL_LIB_FETCH],
957 [ol_LIBS=$LIBS
958 LIBS="-lfetch -lcom_err $LIBS"
959 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
960         AC_TRY_LINK([
961 #include <sys/param.h>
962 #include <stdio.h>
963 #include <fetch.h>],
964         [struct url *u = fetchParseURL("file:///"); ],
965         [ol_cv_lib_fetch=yes],
966         [ol_cv_lib_fetch=no])])
967 LIBS=$ol_LIBS
968 if test $ol_cv_lib_fetch != no ; then
969         ol_link_fetch="-lfetch -lcom_err"
970         AC_DEFINE(HAVE_FETCH,1,
971                 [define if you actually have FreeBSD fetch(3)])
972 fi
973 ])dnl
974 dnl
975 dnl ====================================================================
976 dnl Define sig_atomic_t if not defined in signal.h
977 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
978  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
979     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
980                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
981   if test $ol_cv_type_sig_atomic_t = no; then
982     AC_DEFINE(sig_atomic_t,int,
983                 [define to atomic type if sig_atomic_t is not available])
984   fi
985  ])dnl
986 dnl
987 dnl ====================================================================
988 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
989 AC_DEFUN(OL_TYPE_SOCKLEN_T,
990  [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
991     [AC_TRY_COMPILE([
992 #ifdef HAVE_SYS_TYPES_H
993 #include <sys/types.h>
994 #endif
995 #ifdef HAVE_SYS_SOCKET_H
996 #include <sys/socket.h>
997 #endif
998 ], [socklen_t len;],
999                 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
1000   if test $ol_cv_type_socklen_t = no; then
1001     AC_DEFINE(socklen_t, int,
1002                 [define to int if socklen_t is not available])
1003   fi
1004  ])dnl
1005 dnl
1006 dnl ====================================================================
1007 dnl Define inet_aton is available
1008 AC_DEFUN(OL_FUNC_INET_ATON,
1009  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
1010     [AC_TRY_LINK([
1011 #ifdef HAVE_SYS_TYPES_H
1012 #       include <sys/types.h>
1013 #endif
1014 #ifdef HAVE_SYS_SOCKET_H
1015 #       include <sys/socket.h>
1016 #       ifdef HAVE_SYS_SELECT_H
1017 #               include <sys/select.h>
1018 #       endif
1019 #       include <netinet/in.h>
1020 #       ifdef HAVE_ARPA_INET_H
1021 #               include <arpa/inet.h>
1022 #       endif
1023 #endif
1024 ], [struct in_addr in;
1025 int rc = inet_aton( "255.255.255.255", &in );],
1026                 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
1027   if test $ol_cv_func_inet_aton != no; then
1028     AC_DEFINE(HAVE_INET_ATON, 1,
1029                 [define to you inet_aton(3) is available])
1030   fi
1031  ])dnl
1032 dnl
1033 dnl ====================================================================
1034 dnl check no of arguments for ctime_r
1035 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
1036  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
1037    [AC_TRY_COMPILE([#include <time.h>],
1038                 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
1039                         ol_cv_func_ctime_r_nargs3=yes,
1040                         ol_cv_func_ctime_r_nargs3=no)
1041
1042         AC_TRY_COMPILE([#include <time.h>],
1043                 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
1044                         ol_cv_func_ctime_r_nargs2=yes,
1045                         ol_cv_func_ctime_r_nargs2=no)
1046
1047         if test $ol_cv_func_ctime_r_nargs3 = yes -a \
1048                 $ol_cv_func_ctime_r_nargs2 = no ; then
1049
1050                 ol_cv_func_ctime_r_nargs=3
1051
1052         elif test $ol_cv_func_ctime_r_nargs3 = no -a \
1053                 $ol_cv_func_ctime_r_nargs2 = yes ; then
1054
1055                 ol_cv_func_ctime_r_nargs=2
1056
1057         else
1058                 ol_cv_func_ctime_r_nargs=0
1059         fi
1060   ])
1061
1062   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
1063         AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
1064                 [set to the number of arguments ctime_r() expects])
1065   fi
1066 ])dnl
1067 dnl
1068 dnl --------------------------------------------------------------------
1069 dnl check return type of ctime_r()
1070 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
1071  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
1072    [AC_TRY_COMPILE([#include <time.h>],
1073                 [extern int (ctime_r)();],
1074                         ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
1075         ])
1076   if test $ol_cv_func_ctime_r_type = "int" ; then
1077         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
1078   fi
1079 ])dnl
1080 dnl ====================================================================
1081 dnl check no of arguments for gethostbyname_r
1082 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
1083  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
1084         ol_cv_func_gethostbyname_r_nargs,
1085         [AC_TRY_COMPILE([#include <sys/types.h>
1086 #include <sys/socket.h>
1087 #include <netinet/in.h>
1088 #include <netdb.h>
1089 #define BUFSIZE (sizeof(struct hostent)+10)],
1090                 [struct hostent hent; char buffer[BUFSIZE];
1091                 int bufsize=BUFSIZE;int h_errno;
1092                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
1093                         buffer, bufsize, &h_errno);],
1094                 ol_cv_func_gethostbyname_r_nargs5=yes, 
1095                 ol_cv_func_gethostbyname_r_nargs5=no)
1096
1097         AC_TRY_COMPILE([#include <sys/types.h>
1098 #include <sys/socket.h>
1099 #include <netinet/in.h>
1100 #include <netdb.h>
1101 #define BUFSIZE (sizeof(struct hostent)+10)],
1102                 [struct hostent hent;struct hostent *rhent;
1103                 char buffer[BUFSIZE];
1104                 int bufsize=BUFSIZE;int h_errno;
1105                 (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
1106                         &rhent, &h_errno);],
1107                 ol_cv_func_gethostbyname_r_nargs6=yes,
1108                 ol_cv_func_gethostbyname_r_nargs6=no)
1109
1110         if test $ol_cv_func_gethostbyname_r_nargs5 = yes -a \
1111                 $ol_cv_func_gethostbyname_r_nargs6 = no ; then
1112
1113                 ol_cv_func_gethostbyname_r_nargs=5
1114
1115         elif test $ol_cv_func_gethostbyname_r_nargs5 = no -a \
1116                 $ol_cv_func_gethostbyname_r_nargs6 = yes ; then
1117
1118                 ol_cv_func_gethostbyname_r_nargs=6
1119
1120         else
1121                 ol_cv_func_gethostbyname_r_nargs=0
1122         fi
1123   ])
1124   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
1125         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
1126                 $ol_cv_func_gethostbyname_r_nargs,
1127                 [set to the number of arguments gethostbyname_r() expects])
1128   fi
1129 ])dnl
1130 dnl
1131 dnl check no of arguments for gethostbyaddr_r
1132 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
1133  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
1134         [ol_cv_func_gethostbyaddr_r_nargs],
1135         [AC_TRY_COMPILE([#include <sys/types.h>
1136 #include <sys/socket.h>
1137 #include <netinet/in.h>
1138 #include <netdb.h>
1139 #define BUFSIZE (sizeof(struct hostent)+10)],
1140            [struct hostent hent; char buffer[BUFSIZE]; 
1141             struct in_addr add;
1142             size_t alen=sizeof(struct in_addr);
1143             int bufsize=BUFSIZE;int h_errno;
1144                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1145                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
1146                 ol_cv_func_gethostbyaddr_r_nargs7=yes,
1147                 ol_cv_func_gethostbyaddr_r_nargs7=no)
1148
1149         AC_TRY_COMPILE([#include <sys/types.h>
1150 #include <sys/socket.h>
1151 #include <netinet/in.h>
1152 #include <netdb.h>
1153 #define BUFSIZE (sizeof(struct hostent)+10)],
1154                 [struct hostent hent;
1155                 struct hostent *rhent; char buffer[BUFSIZE]; 
1156                 struct in_addr add;
1157                 size_t alen=sizeof(struct in_addr);
1158                 int bufsize=BUFSIZE;int h_errno;
1159                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
1160                         alen, AF_INET, &hent, buffer, bufsize, 
1161                         &rhent, &h_errno);],
1162                 ol_cv_func_gethostbyaddr_r_nargs8=yes,
1163                 ol_cv_func_gethostbyaddr_r_nargs8=no)
1164
1165         if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes -a \
1166                 $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then
1167
1168                 ol_cv_func_gethostbyaddr_r_nargs=7
1169
1170         elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no -a \
1171                 $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then
1172
1173                 ol_cv_func_gethostbyaddr_r_nargs=8
1174
1175         else
1176                 ol_cv_func_gethostbyaddr_r_nargs=0
1177         fi
1178   ])
1179   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
1180     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
1181                 $ol_cv_func_gethostbyaddr_r_nargs,
1182                 [set to the number of arguments gethostbyaddr_r() expects])
1183   fi
1184 ])dnl
1185 dnl
1186 dnl --------------------------------------------------------------------
1187 dnl Check for Cyrus SASL version compatility, need 2.1.3 or newer
1188 AC_DEFUN([OL_SASL_COMPAT],
1189 [AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[
1190         AC_EGREP_CPP(__sasl_compat,[
1191 #ifdef HAVE_SASL_SASL_H
1192 #include <sasl/sasl.h>
1193 #else
1194 #include <sasl.h>
1195 #endif
1196
1197 /* require 2.1.3 or later */
1198 #if SASL_VERSION_MAJOR == 1  && SASL_VERSION_MINOR >= 5
1199         char *__sasl_compat = "1.5.x okay";
1200 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR > 1
1201         __sasl_compat "2.2+ or better okay (we guess)";
1202 #elif SASL_VERSION_MAJOR == 2  && SASL_VERSION_MINOR == 1 \
1203         && SASL_VERSION_STEP >=3
1204         __sasl_compat = "2.1.3+ or better okay";
1205 #endif
1206         ],      [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])])
1207 ])