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