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