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