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