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