]> git.sur5r.net Git - openldap/blob - build/openldap.m4
d9e3d7ef5b1eaa706894b3a28c49d881c945393d
[openldap] / build / openldap.m4
1 dnl Copyright 1998 The OpenLDAP Foundation,  All Rights Reserved.
2 dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
3 dnl
4 dnl OpenLDAP Autoconf Macros
5 dnl
6 dnl builtin(include, build/libtool.m4)dnl
7 dnl --------------------------------------------------------------------
8 dnl Restricted form of AC_ARG_ENABLE that limits user options
9 dnl
10 dnl $1 = option name
11 dnl $2 = help-string
12 dnl $3 = default value  (auto)
13 dnl $4 = allowed values (auto yes no)
14 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
15         AC_ARG_ENABLE($1,[$2 (]ifelse($3,,auto,$3)[)],[
16         ol_arg=invalid
17         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
18                 if test "$enableval" = "$ol_val" ; then
19                         ol_arg="$ol_val"
20                 fi
21         done
22         if test "$ol_arg" = "invalid" ; then
23                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
24         fi
25         ol_enable_$1="$ol_arg"
26 ],
27 [       ol_enable_$1=ifelse($3,,"auto","$3")])dnl
28 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
29 # end --enable-$1
30 ])dnl
31 dnl
32 dnl --------------------------------------------------------------------
33 dnl Restricted form of AC_ARG_WITH that limits user options
34 dnl
35 dnl $1 = option name
36 dnl $2 = help-string
37 dnl $3 = default value (no)
38 dnl $4 = allowed values (yes or no)
39 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
40         AC_ARG_WITH($1,[$2 (]ifelse($3,,yes,$3)[)],[
41         ol_arg=invalid
42         for ol_val in ifelse($4,,[yes no],[$4]) ; do
43                 if test "$withval" = "$ol_val" ; then
44                         ol_arg="$ol_val"
45                 fi
46         done
47         if test "$ol_arg" = "invalid" ; then
48                 AC_MSG_ERROR(bad value $withval for --with-$1)
49         fi
50         ol_with_$1="$ol_arg"
51 ],
52 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
53 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
54 # end --with-$1
55 ])dnl
56 dnl
57 dnl ====================================================================
58 dnl check if hard links are supported.
59 dnl
60 AC_DEFUN([OL_PROG_LN_H], [# test for ln hardlink support
61 AC_MSG_CHECKING(whether ln works)
62 AC_CACHE_VAL(ol_cv_prog_LN_H,
63 [rm -f conftest.src conftest.dst
64 echo "conftest" > conftest.src
65 if ln conftest.src conftest.dst 2>/dev/null
66 then
67   ol_cv_prog_LN_H="ln"
68 else
69   ol_cv_prog_LN_H="cp"
70 fi
71 rm -f conftest.src conftest.dst
72 ])dnl
73 LN_H="$ol_cv_prog_LN_H"
74 if test "$ol_cv_prog_LN_H" = "ln"; then
75         AC_MSG_RESULT(yes)
76 else
77         AC_MSG_RESULT(no)
78 fi
79 AC_SUBST(LN_H)dnl
80 ])dnl
81 dnl
82 dnl ====================================================================
83 dnl Check if system uses EBCDIC instead of ASCII
84 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
85 AC_MSG_CHECKING([for EBCDIC])
86 AC_CACHE_VAL(ol_cv_cpp_ebcdic,[
87         AC_TRY_CPP([
88 #if !('M' == 0xd4)
89 #include <__ASCII__/generate_error.h>
90 #endif
91 ],
92         [ol_cv_cpp_ebcdic=yes],
93         [ol_cv_cpp_ebcdic=no])])
94 AC_MSG_RESULT($ol_cv_cpp_ebcdic)
95 if test $ol_cv_cpp_ebcdic != no ; then
96         AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
97 fi
98 ])
99 dnl
100 dnl --------------------------------------------------------------------
101 dnl OpenLDAP version of STDC header check w/ EBCDIC support
102 AC_DEFUN(OL_HEADER_STDC,
103 [AC_REQUIRE_CPP()dnl
104 AC_REQUIRE([OL_CPP_EBCDIC])
105 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
106 [AC_TRY_CPP([#include <stdlib.h>
107 #include <stdarg.h>
108 #include <string.h>
109 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
110
111 if test $ol_cv_header_stdc = yes; then
112   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
113 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
114 fi
115
116 if test $ol_cv_header_stdc = yes; then
117   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
118 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
119 fi
120
121 if test $ol_cv_header_stdc = yes; then
122   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
123 AC_TRY_RUN([#include <ctype.h>
124 #ifndef HAVE_EBCDIC
125 #       define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
126 #       define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
127 #else
128 #       define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
129                 || ('j' <= (c) && (c) <= 'r') \
130                 || ('s' <= (c) && (c) <= 'z'))
131 #       define TOUPPER(c)       (ISLOWER(c) ? ((c) | 0x40) : (c))
132 #endif
133 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
134 int main () { int i; for (i = 0; i < 256; i++)
135 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
136 exit (0); }
137 ], , ol_cv_header_stdc=no, :)
138 fi])
139 if test $ol_cv_header_stdc = yes; then
140   AC_DEFINE(STDC_HEADERS)
141 fi
142 ac_cv_header_stdc=disable
143 ])
144 dnl
145 dnl ====================================================================
146 dnl Check if db.h is Berkeley DB2
147 dnl
148 dnl defines ol_cv_header_db2 to 'yes' or 'no'
149 dnl
150 dnl uses:
151 dnl             AC_CHECK_HEADERS(db.h)
152 dnl
153 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
154 [AC_CHECK_HEADERS(db.h)
155 if test $ac_cv_header_db_h = yes ; then
156         AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
157                 AC_EGREP_CPP(__db_version_2,[
158 #                       include <db.h>
159                         /* this check could be improved */
160 #                       ifdef DB_VERSION_MAJOR
161 #                               if DB_VERSION_MAJOR == 2
162                                         __db_version_2
163 #                               endif
164 #                       endif
165                 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
166 else
167         ol_cv_header_db2=no
168 fi
169 ])dnl
170 dnl --------------------------------------------------------------------
171 dnl Check if Berkeley DB2 library exists
172 dnl Check for dbopen in standard libraries or -ldb
173 dnl
174 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
175 dnl
176 dnl uses:
177 dnl             AC_CHECK_LIB(db,db_open)
178 dnl
179 AC_DEFUN([OL_LIB_BERKELEY_DB2],
180 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
181 [       ol_LIBS="$LIBS"
182         AC_CHECK_LIB(db,db_open,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
183         LIBS="$ol_LIBS"
184 ])
185 ])dnl
186 dnl
187 dnl --------------------------------------------------------------------
188 dnl Check if Berkeley db2 exists
189 dnl
190 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
191 dnl 
192 dnl uses:
193 dnl             OL_LIB_BERKELEY_DB2
194 dnl             OL_HEADER_BERKELEY_DB2
195 dnl
196 AC_DEFUN([OL_BERKELEY_DB2],
197 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
198  AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
199  AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
200         if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
201                 ol_cv_berkeley_db2=no
202         else
203                 ol_cv_berkeley_db2=yes
204         fi
205 ])
206  if test $ol_cv_berkeley_db2 = yes ; then
207         AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
208  fi
209 ])dnl
210 dnl
211 dnl ====================================================================
212 dnl Check for db.h/db_185.h is Berkeley DB
213 dnl
214 dnl defines ol_cv_header_db to 'yes' or 'no'
215 dnl
216 dnl uses:
217 dnl             OL_HEADER_BERKELEY_DB2
218 dnl             AC_CHECK_HEADERS(db_185.h)
219 dnl
220 AC_DEFUN([OL_HEADER_BERKELEY_DB],
221 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
222 AC_CHECK_HEADERS(db_185.h)
223 if test "$ol_cv_header_db2" = yes ; then
224         dnl db.h is db2! 
225
226         ol_cv_header_db=$ac_cv_header_db_185_h
227 else
228         ol_cv_header_db=$ac_cv_header_db_h
229 fi
230 ])dnl
231 dnl
232 dnl --------------------------------------------------------------------
233 dnl Check if Berkeley DB library exists
234 dnl Check for dbopen in standard libraries or -ldb
235 dnl
236 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
237 dnl             'yes' implies dbopen is in $LIBS
238 dnl
239 dnl uses:
240 dnl             AC_CHECK_FUNC(dbopen)
241 dnl             AC_CHECK_LIB(db,dbopen)
242 dnl
243 AC_DEFUN([OL_LIB_BERKELEY_DB],
244 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
245 [       ol_LIBS="$LIBS"
246         AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
247                 AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],[ol_cv_lib_db=no])
248         ])
249         LIBS="$ol_LIBS"
250 ])
251 ])dnl
252 dnl
253 dnl --------------------------------------------------------------------
254 dnl Check if Berkeley DB exists
255 dnl
256 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
257 dnl 
258 dnl uses:
259 dnl             OL_LIB_BERKELEY_DB
260 dnl             OL_HEADER_BERKELEY_DB
261 dnl
262 AC_DEFUN([OL_BERKELEY_DB],
263 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
264  AC_REQUIRE([OL_HEADER_BERKELEY_DB])
265  AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
266         if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
267                 ol_cv_berkeley_db=no
268         else
269                 ol_cv_berkeley_db=yes
270         fi
271 ])
272  if test $ol_cv_berkeley_db = yes ; then
273         AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
274  fi
275 ])dnl
276 dnl
277 dnl ====================================================================
278 dnl Check if GDBM library exists
279 dnl Check for gdbm_open in standard libraries or -lgdbm
280 dnl
281 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
282 dnl             'yes' implies gdbm_open is in $LIBS
283 dnl
284 dnl uses:
285 dnl             AC_CHECK_FUNC(gdbm_open)
286 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
287 dnl
288 AC_DEFUN([OL_LIB_GDBM],
289 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
290 [       ol_LIBS="$LIBS"
291         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
292                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
293         ])
294         LIBS="$ol_LIBS"
295 ])
296 ])dnl
297 dnl
298 dnl --------------------------------------------------------------------
299 dnl Check if GDBM exists
300 dnl
301 dnl defines ol_cv_gdbm to 'yes' or 'no'
302 dnl 
303 dnl uses:
304 dnl             OL_LIB_GDBM
305 dnl             AC_CHECK_HEADERS(gdbm.h)
306 dnl
307 AC_DEFUN([OL_GDBM],
308 [AC_REQUIRE([OL_LIB_GDBM])
309  AC_CHECK_HEADERS(gdbm.h)
310  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
311         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
312                 ol_cv_gdbm=no
313         else
314                 ol_cv_gdbm=yes
315         fi
316 ])
317  if test $ol_cv_gdbm = yes ; then
318         AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
319  fi
320 ])dnl
321 dnl
322 dnl ====================================================================
323 dnl Check if NDBM library exists
324 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
325 dnl
326 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
327 dnl             'yes' implies ndbm_open is in $LIBS
328 dnl
329 dnl uses:
330 dnl             AC_CHECK_FUNC(dbm_open)
331 dnl             AC_CHECK_LIB(ndbm,dbm_open)
332 dnl             AC_CHECK_LIB(dbm,dbm_open)
333 dnl
334 dnl restrictions:
335 dnl             should also check SVR4 case: dbm_open() in -lucb but that
336 dnl             would requiring dealing with -L/usr/ucblib
337 dnl
338 AC_DEFUN([OL_LIB_NDBM],
339 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
340 [       ol_LIBS="$LIBS"
341         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
342                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
343                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
344                                 [ol_cv_lib_ndbm=no])dnl
345                 ])
346         ])
347         LIBS="$ol_LIBS"
348 ])
349 ])dnl
350 dnl
351 dnl --------------------------------------------------------------------
352 dnl Check if NDBM exists
353 dnl
354 dnl defines ol_cv_ndbm to 'yes' or 'no'
355 dnl 
356 dnl uses:
357 dnl             OL_LIB_NDBM
358 dnl             AC_CHECK_HEADERS(ndbm.h)
359 dnl
360 dnl restrictions:
361 dnl             Doesn't handle SVR4 case (see above)
362 dnl
363 AC_DEFUN([OL_NDBM],
364 [AC_REQUIRE([OL_LIB_NDBM])
365  AC_CHECK_HEADERS(ndbm.h)
366  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
367         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
368                 ol_cv_ndbm=no
369         else
370                 ol_cv_ndbm=yes
371         fi
372 ])
373  if test $ol_cv_ndbm = yes ; then
374         AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
375  fi
376 ])dnl
377 dnl
378 dnl ====================================================================
379 dnl Check POSIX Thread version 
380 dnl
381 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
382 dnl     'unknown' implies that the version could not be detected
383 dnl             or that pthreads.h does exist.  Existance of pthreads.h
384 dnl             should be tested separately.
385 dnl
386 AC_DEFUN([OL_POSIX_THREAD_VERSION],
387 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
388         AC_EGREP_CPP(pthread_version_final,[
389 #               include <pthread.h>
390                 /* this check could be improved */
391 #               ifdef PTHREAD_ONCE_INIT
392                         pthread_version_final
393 #               endif
394         ], ol_pthread_final=yes, ol_pthread_final=no)
395
396         AC_EGREP_CPP(pthread_version_draft4,[
397 #               include <pthread.h>
398                 /* this check could be improved */
399 #               ifdef pthread_once_init
400                         pthread_version_draft4
401 #               endif
402         ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
403
404         if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
405                 ol_cv_pthread_version=final
406         elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
407                 ol_cv_pthread_version=draft4
408         else
409                 ol_cv_pthread_version=unknown
410         fi
411 ])
412 ])dnl
413 dnl
414 dnl --------------------------------------------------------------------
415 dnl Check LinuxThread
416 dnl
417 dnl defines ol_cv_linux_threads to 'yes' or 'no'
418 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
419 dnl             doesn't exists.  Existance of pthread.h should separately
420 dnl             checked.
421 dnl 
422 AC_DEFUN([OL_LINUX_THREADS],
423 [
424 AC_CACHE_CHECK([for LinuxThreads], [ol_cv_linux_threads], [
425         res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
426         if test "$res" -gt 0 ; then
427                 ol_cv_linux_threads=yes
428         else
429                 ol_cv_linux_threads=no
430         fi
431 ])
432 ])dnl
433 dnl
434 dnl ====================================================================
435 dnl Check if toupper() requires islower() to be called first
436 AC_DEFUN([OL_C_UPPER_LOWER],
437 [
438 AC_MSG_CHECKING([if toupper() requires islower()])
439 AC_CACHE_VAL(ol_cv_c_upper_lower,[
440         AC_TRY_RUN([
441 #include <ctype.h>
442 main()
443 {
444         if ('C' == toupper('C'))
445                 exit(0);
446         else
447                 exit(1);
448 }],
449         [ol_cv_c_upper_lower=no],
450         [ol_cv_c_upper_lower=yes],
451         [ol_cv_c_upper_lower=safe])])
452 AC_MSG_RESULT($ol_cv_c_upper_lower)
453 if test $ol_cv_c_upper_lower != no ; then
454         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
455 fi
456 ])
457 dnl
458 dnl ====================================================================
459 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
460 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
461 dnl Reported by Keith Bostic.
462 AC_DEFUN([OL_SYS_ERRLIST],
463 [
464 AC_MSG_CHECKING([declaration of sys_errlist])
465 AC_CACHE_VAL(ol_cv_dcl_sys_errlist,[
466         AC_TRY_COMPILE([
467 #include <stdio.h>
468 #include <sys/types.h>
469 #include <errno.h> ],
470         [char *c = (char *) *sys_errlist],
471         [ol_cv_dcl_sys_errlist=yes],
472         [ol_cv_dcl_sys_errlist=no])])
473 AC_MSG_RESULT($ol_cv_dcl_sys_errlist)
474 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
475 if test $ol_cv_dcl_sys_errlist = no ; then
476         AC_DEFINE(DECL_SYS_ERRLIST,1,
477                 [define if sys_errlist is not declared in stdio.h or errno.h])
478         AC_MSG_CHECKING([existence of sys_errlist])
479         AC_CACHE_VAL(ol_cv_have_sys_errlist,[
480                 AC_TRY_LINK([#include <errno.h>],
481                         [char *c = (char *) *sys_errlist],
482                         [ol_cv_have_sys_errlist=yes],
483                         [ol_cv_have_sys_errlist=no])])
484         AC_MSG_RESULT($ol_cv_have_sys_errlist)
485         if test $ol_cv_have_sys_errlist = yes ; then
486                 AC_DEFINE(HAVE_SYS_ERRLIST,1,
487                         [define if you actually have sys_errlist in your libs])
488         fi
489 fi
490 ])dnl
491 dnl
492 dnl ====================================================================
493 dnl Check to see if we should not declare strdup if we have it
494 dnl
495 AC_DEFUN([OL_DECL_STRDUP],
496 [
497 AC_MSG_CHECKING([strdup declaration])
498 AC_CACHE_VAL(ol_cv_dcl_strdup,[
499         AC_TRY_COMPILE([
500 #include <string.h> ],
501         [extern char *strdup();],
502         [ol_cv_dcl_strdup=yes],
503         [ol_cv_dcl_strdup=no])])
504 AC_MSG_RESULT($ol_cv_dcl_strdup)
505 if test $ol_cv_dcl_strdup = yes ; then
506         AC_DEFINE(DECL_STRDUP,1,
507                 [define if you have strdup() but it's not declared])
508 fi
509 ])dnl
510
511 dnl ====================================================================
512 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
513 dnl "int x; int *volatile a = &x; *a = 0;"
514 dnl     -- borrowed from PDKSH
515 AC_DEFUN(OL_C_VOLATILE,
516  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
517     [AC_TRY_COMPILE([int x, y, z;],
518       [volatile int a; int * volatile b = x ? &y : &z;
519       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
520       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
521   if test $ol_cv_c_volatile = yes; then
522     : 
523   else
524     AC_DEFINE(volatile,)
525   fi
526  ])dnl
527 dnl
528 dnl ====================================================================
529 dnl Define sig_atomic_t if not defined in signal.h
530 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
531  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
532     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
533                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
534   if test $ol_cv_type_sig_atomic_t = no; then
535     AC_DEFINE(sig_atomic_t, int)
536   fi
537  ])dnl
538 dnl
539 dnl ====================================================================
540 dnl check no of arguments for ctime_r
541 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
542  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
543    [AC_TRY_COMPILE([#include <time.h>],
544                 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
545                         ol_cv_func_ctime_r_nargs=3,
546                         [AC_TRY_COMPILE([#include <time.h>],
547                                 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
548                                         ol_cv_func_ctime_r_nargs=2,
549                                         ol_cv_func_ctime_r_nargs=0)])])
550   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
551     AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
552                 [set to the number of arguments ctime_r() expects])
553   fi
554 ])dnl
555 dnl
556 dnl --------------------------------------------------------------------
557 dnl check return type of ctime_r()
558 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
559  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
560    [AC_TRY_COMPILE([#include <time.h>],
561                 [int ctime_r();],
562                         ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
563         ])
564   if test $ol_cv_func_ctime_r_type = "int" ; then
565         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
566   fi
567 ])dnl
568 dnl ====================================================================
569 dnl check no of arguments for gethostbyname_r
570 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
571  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
572         ol_cv_func_gethostbyname_r_nargs,
573         [AC_TRY_COMPILE([#include <sys/types.h>
574 #include <sys/socket.h>
575 #include <netinet/in.h>
576 #include <netdb.h>
577 #define BUFSIZE (sizeof(struct hostent)+10)],
578                 [struct hostent hent; char buffer[BUFSIZE];
579                 int bufsize=BUFSIZE;int h_errno;
580                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
581                         buffer, bufsize, &h_errno);],
582                 ol_cv_func_gethostbyname_r_nargs=5, 
583                 [AC_TRY_COMPILE([#include <sys/types.h>
584 #include <sys/socket.h>
585 #include <netinet/in.h>
586 #include <netdb.h>
587 #define BUFSIZE (sizeof(struct hostent)+10)],
588                         [struct hostent hent;struct hostent *rhent;
589                         char buffer[BUFSIZE];
590                         int bufsize=BUFSIZE;int h_errno;
591                         (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
592                                 &rhent, &h_errno);],
593                         ol_cv_func_gethostbyname_r_nargs=6,
594                         ol_cv_func_gethostbyname_r_nargs=0)])])
595   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
596         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
597                 $ol_cv_func_gethostbyname_r_nargs,
598                 [set to the number of arguments gethostbyname_r() expects])
599   fi
600 ])dnl
601 dnl
602 dnl check no of arguments for gethostbyaddr_r
603 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
604  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
605         [ol_cv_func_gethostbyaddr_r_nargs],
606         [AC_TRY_COMPILE([#include <sys/types.h>
607 #include <sys/socket.h>
608 #include <netinet/in.h>
609 #include <netdb.h>
610 #define BUFSIZE (sizeof(struct hostent)+10)],
611            [struct hostent hent; char buffer[BUFSIZE]; 
612             struct in_addr add;
613             size_t alen=sizeof(struct in_addr);
614             int bufsize=BUFSIZE;int h_errno;
615                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
616                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
617                 ol_cv_func_gethostbyaddr_r_nargs=7,
618                 [AC_TRY_COMPILE([#include <sys/types.h>
619 #include <sys/socket.h>
620 #include <netinet/in.h>
621 #include <netdb.h>
622 #define BUFSIZE (sizeof(struct hostent)+10)],
623                         [struct hostent hent;
624                         struct hostent *rhent; char buffer[BUFSIZE]; 
625                         struct in_addr add;
626                         size_t alen=sizeof(struct in_addr);
627                         int bufsize=BUFSIZE;int h_errno;
628                         (void)gethostbyaddr_r( (void *)&(add.s_addr),
629                                 alen, AF_INET, &hent, buffer, bufsize, 
630                                 &rhent, &h_errno);],
631                         ol_cv_func_gethostbyaddr_r_nargs=8,
632                         ol_cv_func_gethostbyaddr_r_nargs=0)])])
633   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
634     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
635                 $ol_cv_func_gethostbyaddr_r_nargs,
636                 [set to the number of arguments gethostbyaddr_r() expects])
637   fi
638 ])dnl
639 dnl