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