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