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