]> git.sur5r.net Git - openldap/blob - build/openldap.m4
s/Id/OpenLDAP/ in RCSids
[openldap] / build / openldap.m4
1 dnl $OpenLDAP$
2 dnl
3 dnl Copyright 1998-1999 The OpenLDAP Foundation,  All Rights Reserved.
4 dnl COPYING RESTRICTIONS APPLY, See COPYRIGHT file
5 dnl
6 dnl OpenLDAP Autoconf Macros
7 dnl
8 dnl --------------------------------------------------------------------
9 dnl Restricted form of AC_ARG_ENABLE that limits user options
10 dnl
11 dnl $1 = option name
12 dnl $2 = help-string
13 dnl $3 = default value  (auto)
14 dnl $4 = allowed values (auto yes no)
15 AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1
16         AC_ARG_ENABLE($1,[$2 (]ifelse($3,,auto,$3)[)],[
17         ol_arg=invalid
18         for ol_val in ifelse($4,,[auto yes no],[$4]) ; do
19                 if test "$enableval" = "$ol_val" ; then
20                         ol_arg="$ol_val"
21                 fi
22         done
23         if test "$ol_arg" = "invalid" ; then
24                 AC_MSG_ERROR(bad value $enableval for --enable-$1)
25         fi
26         ol_enable_$1="$ol_arg"
27 ],
28 [       ol_enable_$1=ifelse($3,,"auto","$3")])dnl
29 dnl AC_VERBOSE(OpenLDAP -enable-$1 $ol_enable_$1)
30 # end --enable-$1
31 ])dnl
32 dnl
33 dnl --------------------------------------------------------------------
34 dnl Restricted form of AC_ARG_WITH that limits user options
35 dnl
36 dnl $1 = option name
37 dnl $2 = help-string
38 dnl $3 = default value (no)
39 dnl $4 = allowed values (yes or no)
40 AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1
41         AC_ARG_WITH($1,[$2 (]ifelse($3,,yes,$3)[)],[
42         ol_arg=invalid
43         for ol_val in ifelse($4,,[yes no],[$4]) ; do
44                 if test "$withval" = "$ol_val" ; then
45                         ol_arg="$ol_val"
46                 fi
47         done
48         if test "$ol_arg" = "invalid" ; then
49                 AC_MSG_ERROR(bad value $withval for --with-$1)
50         fi
51         ol_with_$1="$ol_arg"
52 ],
53 [       ol_with_$1=ifelse($3,,"no","$3")])dnl
54 dnl AC_VERBOSE(OpenLDAP --with-$1 $ol_with_$1)
55 # end --with-$1
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 for dependency generation flag
85 AC_DEFUN([OL_MKDEPEND], [# test for make depend flag
86 OL_MKDEP=
87 OL_MKDEP_FLAGS=
88 if test -z "${MKDEP}"; then
89         OL_MKDEP="${CC-cc}"
90         if test -z "${MKDEP_FLAGS}"; then
91                 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [
92                         ol_cv_mkdep=no
93                         for flag in "-M" "-xM"; do
94                                 cat > conftest.c <<EOF
95  noCode;
96 EOF
97                                 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \
98                                         | egrep '^conftest\.'"${ac_objext}" >/dev/null 2>&1
99                                 then
100                                         if test ! -f conftest."${ac_object}" ; then
101                                                 ol_cv_mkdep=$flag
102                                                 OL_MKDEP_FLAGS="$flag"
103                                                 break
104                                         fi
105                                 fi
106                         done
107                         rm -f conftest*
108                 ])
109         else
110                 cc_cv_mkdep=yes
111                 OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
112         fi
113 else
114         cc_cv_mkdep=yes
115         OL_MKDEP="${MKDEP}"
116         OL_MKDEP_FLAGS="${MKDEP_FLAGS}"
117 fi
118 AC_SUBST(OL_MKDEP)
119 AC_SUBST(OL_MKDEP_FLAGS)
120 ])
121 dnl
122 dnl ====================================================================
123 dnl Check if system uses EBCDIC instead of ASCII
124 AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC
125 AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[
126         AC_TRY_CPP([
127 #if !('M' == 0xd4)
128 #include <__ASCII__/generate_error.h>
129 #endif
130 ],
131         [ol_cv_cpp_ebcdic=yes],
132         [ol_cv_cpp_ebcdic=no])])
133 if test $ol_cv_cpp_ebcdic = yes ; then
134         AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII])
135 fi
136 ])
137 dnl
138 dnl --------------------------------------------------------------------
139 dnl OpenLDAP version of STDC header check w/ EBCDIC support
140 AC_DEFUN(OL_HEADER_STDC,
141 [AC_REQUIRE_CPP()dnl
142 AC_REQUIRE([OL_CPP_EBCDIC])dnl
143 AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc,
144 [AC_TRY_CPP([#include <stdlib.h>
145 #include <stdarg.h>
146 #include <string.h>
147 #include <float.h>], ol_cv_header_stdc=yes, ol_cv_header_stdc=no)
148
149 if test $ol_cv_header_stdc = yes; then
150   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
151 AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no)
152 fi
153
154 if test $ol_cv_header_stdc = yes; then
155   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
156 AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no)
157 fi
158
159 if test $ol_cv_header_stdc = yes; then
160   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
161 AC_TRY_RUN([#include <ctype.h>
162 #ifndef HAVE_EBCDIC
163 #       define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
164 #       define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
165 #else
166 #       define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
167                 || ('j' <= (c) && (c) <= 'r') \
168                 || ('s' <= (c) && (c) <= 'z'))
169 #       define TOUPPER(c)       (ISLOWER(c) ? ((c) | 0x40) : (c))
170 #endif
171 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
172 int main () { int i; for (i = 0; i < 256; i++)
173 if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
174 exit (0); }
175 ], , ol_cv_header_stdc=no, :)
176 fi])
177 if test $ol_cv_header_stdc = yes; then
178   AC_DEFINE(STDC_HEADERS)
179 fi
180 ac_cv_header_stdc=disable
181 ])
182 dnl
183 dnl ====================================================================
184 dnl Check if struct passwd has pw_gecos
185 AC_DEFUN([OL_STRUCT_PASSWD_PW_GECOS], [# test for pw_gecos in struct passwd
186 AC_CACHE_CHECK([struct passwd for pw_gecos],ol_cv_struct_passwd_pw_gecos,[
187         AC_TRY_COMPILE([#include <pwd.h>],[
188         struct passwd pwd;
189         pwd.pw_gecos = pwd.pw_name;
190 ],
191         [ol_cv_struct_passwd_pw_gecos=yes],
192         [ol_cv_struct_passwd_pw_gecos=no])])
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 struct passwd has pw_passwd
200 AC_DEFUN([OL_STRUCT_PASSWD_PW_PASSWD], [# test for pw_passwd in struct passwd
201 AC_CACHE_CHECK([struct passwd for pw_passwd],ol_cv_struct_passwd_pw_passwd,[
202         AC_TRY_COMPILE([#include <pwd.h>],[
203         struct passwd pwd;
204         pwd.pw_passwd = pwd.pw_name;
205 ],
206         [ol_cv_struct_passwd_pw_passwd=yes],
207         [ol_cv_struct_passwd_pw_passwd=no])])
208 if test $ol_cv_struct_passwd_pw_passwd = yes ; then
209         AC_DEFINE(HAVE_PW_PASSWD,1, [define if struct passwd has pw_passwd])
210 fi
211 ])
212 dnl
213 dnl ====================================================================
214 dnl Check if db.h is Berkeley DB2
215 dnl
216 dnl defines ol_cv_header_db2 to 'yes' or 'no'
217 dnl
218 dnl uses:
219 dnl             AC_CHECK_HEADERS(db.h)
220 dnl
221 AC_DEFUN([OL_HEADER_BERKELEY_DB2],
222 [AC_CHECK_HEADERS(db.h)
223 if test $ac_cv_header_db_h = yes ; then
224         AC_CACHE_CHECK([if db.h is DB2], [ol_cv_header_db2],[
225                 AC_EGREP_CPP(__db_version_2,[
226 #                       include <db.h>
227                         /* this check could be improved */
228 #                       ifdef DB_VERSION_MAJOR
229 #                               if DB_VERSION_MAJOR == 2
230                                         __db_version_2
231 #                               endif
232 #                       endif
233                 ], ol_cv_header_db2=yes, ol_cv_header_db2=no)])
234 else
235         ol_cv_header_db2=no
236 fi
237 ])dnl
238 dnl --------------------------------------------------------------------
239 dnl Check if Berkeley DB2 library exists
240 dnl Check for dbopen in standard libraries or -ldb
241 dnl
242 dnl defines ol_cv_lib_db2 to '-ldb' or 'no'
243 dnl
244 dnl uses:
245 dnl             AC_CHECK_LIB(db,db_open)
246 dnl
247 AC_DEFUN([OL_LIB_BERKELEY_DB2],
248 [AC_CACHE_CHECK([for DB2 library], [ol_cv_lib_db2],
249 [       ol_LIBS="$LIBS"
250         AC_CHECK_LIB(db,db_open,[ol_cv_lib_db2=-ldb],[ol_cv_lib_db2=no])
251         LIBS="$ol_LIBS"
252 ])
253 ])dnl
254 dnl
255 dnl --------------------------------------------------------------------
256 dnl Check if Berkeley db2 exists
257 dnl
258 dnl defines ol_cv_berkeley_db2 to 'yes' or 'no'
259 dnl 
260 dnl uses:
261 dnl             OL_LIB_BERKELEY_DB2
262 dnl             OL_HEADER_BERKELEY_DB2
263 dnl
264 AC_DEFUN([OL_BERKELEY_DB2],
265 [AC_REQUIRE([OL_LIB_BERKELEY_DB2])
266  AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
267  AC_CACHE_CHECK([for Berkeley DB2], [ol_cv_berkeley_db2], [
268         if test "$ol_cv_lib_db2" = no -o "$ol_cv_header_db2" = no ; then
269                 ol_cv_berkeley_db2=no
270         else
271                 ol_cv_berkeley_db2=yes
272         fi
273 ])
274  if test $ol_cv_berkeley_db2 = yes ; then
275         AC_DEFINE(HAVE_BERKELEY_DB2,1, [define if Berkeley DBv2 is available])
276  fi
277 ])dnl
278 dnl
279 dnl ====================================================================
280 dnl Check for db.h/db_185.h is Berkeley DB
281 dnl
282 dnl defines ol_cv_header_db to 'yes' or 'no'
283 dnl
284 dnl uses:
285 dnl             OL_HEADER_BERKELEY_DB2
286 dnl             AC_CHECK_HEADERS(db_185.h)
287 dnl
288 AC_DEFUN([OL_HEADER_BERKELEY_DB],
289 [AC_REQUIRE([OL_HEADER_BERKELEY_DB2])
290 AC_CHECK_HEADERS(db_185.h)
291 if test "$ol_cv_header_db2" = yes ; then
292         dnl db.h is db2! 
293
294         ol_cv_header_db=$ac_cv_header_db_185_h
295 else
296         ol_cv_header_db=$ac_cv_header_db_h
297 fi
298 ])dnl
299 dnl
300 dnl --------------------------------------------------------------------
301 dnl Check if Berkeley DB library exists
302 dnl Check for dbopen in standard libraries or -ldb
303 dnl
304 dnl defines ol_cv_lib_db to 'yes' or '-ldb' or 'no'
305 dnl             'yes' implies dbopen is in $LIBS
306 dnl
307 dnl uses:
308 dnl             AC_CHECK_FUNC(dbopen)
309 dnl             AC_CHECK_LIB(db,dbopen)
310 dnl
311 AC_DEFUN([OL_LIB_BERKELEY_DB],
312 [AC_CACHE_CHECK([for Berkeley DB library], [ol_cv_lib_db],
313 [
314         AC_CHECK_HEADERS(db1/db.h)
315         ol_LIBS="$LIBS"
316         AC_CHECK_FUNC(dbopen,[ol_cv_lib_db=yes], [
317                 AC_CHECK_LIB(db1,dbopen,[ol_cv_lib_db=-ldb1],[
318                         AC_CHECK_LIB(db,dbopen,[ol_cv_lib_db=-ldb],
319                         [ol_cv_lib_db=no])
320                 ])
321         ])
322         LIBS="$ol_LIBS"
323 ])
324 ])dnl
325 dnl
326 dnl --------------------------------------------------------------------
327 dnl Check if Berkeley DB exists
328 dnl
329 dnl defines ol_cv_berkeley_db to 'yes' or 'no'
330 dnl 
331 dnl uses:
332 dnl             OL_LIB_BERKELEY_DB
333 dnl             OL_HEADER_BERKELEY_DB
334 dnl
335 AC_DEFUN([OL_BERKELEY_DB],
336 [AC_REQUIRE([OL_LIB_BERKELEY_DB])
337  AC_REQUIRE([OL_HEADER_BERKELEY_DB])
338  AC_CACHE_CHECK([for Berkeley DB], [ol_cv_berkeley_db], [
339         if test "$ol_cv_lib_db" = no -o "$ol_cv_header_db" = no ; then
340                 ol_cv_berkeley_db=no
341         else
342                 ol_cv_berkeley_db=yes
343         fi
344 ])
345  if test $ol_cv_berkeley_db = yes ; then
346         AC_DEFINE(HAVE_BERKELEY_DB,1, [define if Berkeley DB is available])
347  fi
348 ])dnl
349 dnl
350 dnl ====================================================================
351 dnl Check if GDBM library exists
352 dnl Check for gdbm_open in standard libraries or -lgdbm
353 dnl
354 dnl defines ol_cv_lib_gdbm to 'yes' or '-lgdbm' or 'no'
355 dnl             'yes' implies gdbm_open is in $LIBS
356 dnl
357 dnl uses:
358 dnl             AC_CHECK_FUNC(gdbm_open)
359 dnl             AC_CHECK_LIB(gdbm,gdbm_open)
360 dnl
361 AC_DEFUN([OL_LIB_GDBM],
362 [AC_CACHE_CHECK(for GDBM library, [ol_cv_lib_gdbm],
363 [       ol_LIBS="$LIBS"
364         AC_CHECK_FUNC(gdbm_open,[ol_cv_lib_gdbm=yes], [
365                 AC_CHECK_LIB(gdbm,gdbm_open,[ol_cv_lib_gdbm=-lgdbm],[ol_cv_lib_gdbm=no])
366         ])
367         LIBS="$ol_LIBS"
368 ])
369 ])dnl
370 dnl
371 dnl --------------------------------------------------------------------
372 dnl Check if GDBM exists
373 dnl
374 dnl defines ol_cv_gdbm to 'yes' or 'no'
375 dnl 
376 dnl uses:
377 dnl             OL_LIB_GDBM
378 dnl             AC_CHECK_HEADERS(gdbm.h)
379 dnl
380 AC_DEFUN([OL_GDBM],
381 [AC_REQUIRE([OL_LIB_GDBM])
382  AC_CHECK_HEADERS(gdbm.h)
383  AC_CACHE_CHECK(for db, [ol_cv_gdbm], [
384         if test $ol_cv_lib_gdbm = no -o $ac_cv_header_gdbm_h = no ; then
385                 ol_cv_gdbm=no
386         else
387                 ol_cv_gdbm=yes
388         fi
389 ])
390  if test $ol_cv_gdbm = yes ; then
391         AC_DEFINE(HAVE_GDBM,1, [define if GNU DBM is available])
392  fi
393 ])dnl
394 dnl
395 dnl ====================================================================
396 dnl Check if MDBM library exists
397 dnl Check for mdbm_open in standard libraries or -lmdbm
398 dnl
399 dnl defines ol_cv_lib_mdbm to 'yes' or '-lmdbm' or 'no'
400 dnl             'yes' implies mdbm_open is in $LIBS
401 dnl
402 dnl uses:
403 dnl             AC_CHECK_FUNC(mdbm_set_chain)
404 dnl             AC_CHECK_LIB(mdbm,mdbm_set_chain)
405 dnl
406 AC_DEFUN([OL_LIB_MDBM],
407 [AC_CACHE_CHECK(for MDBM library, [ol_cv_lib_mdbm],
408 [       ol_LIBS="$LIBS"
409         AC_CHECK_FUNC(mdbm_set_chain,[ol_cv_lib_mdbm=yes], [
410                 AC_CHECK_LIB(mdbm,mdbm_set_chain,[ol_cv_lib_mdbm=-lmdbm],[ol_cv_lib_mdbm=no])
411         ])
412         LIBS="$ol_LIBS"
413 ])
414 ])dnl
415 dnl
416 dnl --------------------------------------------------------------------
417 dnl Check if MDBM exists
418 dnl
419 dnl defines ol_cv_mdbm to 'yes' or 'no'
420 dnl 
421 dnl uses:
422 dnl             OL_LIB_MDBM
423 dnl             AC_CHECK_HEADERS(mdbm.h)
424 dnl
425 AC_DEFUN([OL_MDBM],
426 [AC_REQUIRE([OL_LIB_MDBM])
427  AC_CHECK_HEADERS(mdbm.h)
428  AC_CACHE_CHECK(for db, [ol_cv_mdbm], [
429         if test $ol_cv_lib_mdbm = no -o $ac_cv_header_mdbm_h = no ; then
430                 ol_cv_mdbm=no
431         else
432                 ol_cv_mdbm=yes
433         fi
434 ])
435  if test $ol_cv_mdbm = yes ; then
436         AC_DEFINE(HAVE_MDBM,1, [define if MDBM is available])
437  fi
438 ])dnl
439 dnl
440 dnl ====================================================================
441 dnl Check if NDBM library exists
442 dnl Check for dbm_open in standard libraries or -lndbm or -ldbm
443 dnl
444 dnl defines ol_cv_lib_ndbm to 'yes' or '-lndbm' or -ldbm or 'no'
445 dnl             'yes' implies ndbm_open is in $LIBS
446 dnl
447 dnl uses:
448 dnl             AC_CHECK_FUNC(dbm_open)
449 dnl             AC_CHECK_LIB(ndbm,dbm_open)
450 dnl             AC_CHECK_LIB(dbm,dbm_open)
451 dnl
452 dnl restrictions:
453 dnl             should also check SVR4 case: dbm_open() in -lucb but that
454 dnl             would requiring dealing with -L/usr/ucblib
455 dnl
456 AC_DEFUN([OL_LIB_NDBM],
457 [AC_CACHE_CHECK(for NDBM library, [ol_cv_lib_ndbm],
458 [       ol_LIBS="$LIBS"
459         AC_CHECK_FUNC(dbm_open,[ol_cv_lib_ndbm=yes], [
460                 AC_CHECK_LIB(ndbm,dbm_open,[ol_cv_lib_ndbm=-lndbm], [
461                         AC_CHECK_LIB(dbm,dbm_open,[ol_cv_lib_ndbm=-ldbm],
462                                 [ol_cv_lib_ndbm=no])dnl
463                 ])
464         ])
465         LIBS="$ol_LIBS"
466 ])
467 ])dnl
468 dnl
469 dnl --------------------------------------------------------------------
470 dnl Check if NDBM exists
471 dnl
472 dnl defines ol_cv_ndbm to 'yes' or 'no'
473 dnl 
474 dnl uses:
475 dnl             OL_LIB_NDBM
476 dnl             AC_CHECK_HEADERS(ndbm.h)
477 dnl
478 dnl restrictions:
479 dnl             Doesn't handle SVR4 case (see above)
480 dnl
481 AC_DEFUN([OL_NDBM],
482 [AC_REQUIRE([OL_LIB_NDBM])
483  AC_CHECK_HEADERS(ndbm.h)
484  AC_CACHE_CHECK(for db, [ol_cv_ndbm], [
485         if test $ol_cv_lib_ndbm = no -o $ac_cv_header_ndbm_h = no ; then
486                 ol_cv_ndbm=no
487         else
488                 ol_cv_ndbm=yes
489         fi
490 ])
491  if test $ol_cv_ndbm = yes ; then
492         AC_DEFINE(HAVE_NDBM,1, [define if NDBM is available])
493  fi
494 ])dnl
495 dnl
496 dnl ====================================================================
497 dnl Check POSIX Thread version 
498 dnl
499 dnl defines ol_cv_posix_version to 'final' or 'draft' or 'unknown'
500 dnl     'unknown' implies that the version could not be detected
501 dnl             or that pthreads.h does exist.  Existance of pthreads.h
502 dnl             should be tested separately.
503 dnl
504 AC_DEFUN([OL_POSIX_THREAD_VERSION],
505 [AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[
506         AC_EGREP_CPP(pthread_version_final,[
507 #               include <pthread.h>
508                 /* this check could be improved */
509 #               ifdef PTHREAD_ONCE_INIT
510                         pthread_version_final
511 #               endif
512         ], ol_pthread_final=yes, ol_pthread_final=no)
513
514         AC_EGREP_CPP(pthread_version_draft4,[
515 #               include <pthread.h>
516                 /* this check could be improved */
517 #               ifdef pthread_once_init
518                         pthread_version_draft4
519 #               endif
520         ], ol_pthread_draft4=yes, ol_pthread_draft4=no)
521
522         if test $ol_pthread_final = yes -a $ol_pthread_draft4 = no; then
523                 ol_cv_pthread_version=final
524         elif test $ol_pthread_final = no -a $ol_pthread_draft4 = yes; then
525                 ol_cv_pthread_version=draft4
526         else
527                 ol_cv_pthread_version=unknown
528         fi
529 ])
530 ])dnl
531 dnl
532 dnl --------------------------------------------------------------------
533 AC_DEFUN([OL_PTHREAD_TEST_INCLUDES],
534 [/* pthread test headers */
535 #include <pthread.h>
536 #ifndef NULL
537 #define NULL (void*)0
538 #endif
539
540 static void *task(p)
541         void *p;
542 {
543         return (void *) (p == NULL);
544 }
545 ])
546 AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[
547         /* pthread test function */
548         pthread_t t;
549         int status;
550
551         /* make sure pthread_create() isn't just a stub */
552 #if HAVE_PTHREADS_D4
553         status = pthread_create(&t, pthread_attr_default, task, NULL);
554 #else
555         status = pthread_create(&t, NULL, task, NULL);
556 #endif
557
558         if( status ) exit( status );
559
560         /* make sure pthread_detach() isn't just a stub */
561 #if HAVE_PTHREADS_D4
562         status = pthread_detach( &t );
563 #else
564         status = pthread_detach( t );
565 #endif
566
567 #ifdef HAVE_LINUX_THREADS
568         pthread_kill_other_threads_np();
569 #endif
570
571         exit( status );
572 ])
573
574 AC_DEFUN([OL_PTHREAD_TEST_PROGRAM],
575 [OL_PTHREAD_TEST_INCLUDES
576
577 int main(argc, argv)
578         int argc;
579         char **argv;
580 {
581 OL_PTHREAD_TEST_FUNCTION
582 }
583 ])
584 dnl --------------------------------------------------------------------
585 AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2)
586 if test "$ol_link_threads" = no ; then
587         # try $1
588         AC_CACHE_CHECK([for pthread link with $1], [$2], [
589                 # save the flags
590                 ol_LIBS="$LIBS"
591                 LIBS="$1 $LIBS"
592
593                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
594                         [$2=yes], [$2=no],
595                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
596                                 [$2=yes], [$2=no])])
597
598                 # restore the LIBS
599                 LIBS="$ol_LIBS"
600         ])
601
602         if test $$2 = yes ; then
603                 ol_link_pthreads="$1"
604                 ol_link_threads=posix
605         fi
606 fi
607 ])
608 dnl
609 dnl ====================================================================
610 dnl Check GNU Pth pthread Header
611 dnl
612 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
613 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
614 dnl             doesn't exists.  Existance of pthread.h should separately
615 dnl             checked.
616 dnl 
617 AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [
618         AC_CACHE_CHECK([for GNU Pth pthread.h],
619                 [ol_cv_header_gnu_pth_pthread_h],
620                 [AC_EGREP_CPP(__gnu_pth__,
621                         [#include <pthread.h>
622 #ifdef _POSIX_THREAD_IS_GNU_PTH
623         __gnu_pth__
624 #endif
625 ],
626                         [ol_cv_header_gnu_pth_pthread_h=yes],
627                         [ol_cv_header_gnu_pth_pthread_h=no])
628                 ])
629 ])dnl
630 dnl ====================================================================
631 dnl Check LinuxThreads Header
632 dnl
633 dnl defines ol_cv_header linux_threads to 'yes' or 'no'
634 dnl             'no' implies pthreads.h is not LinuxThreads or pthreads.h
635 dnl             doesn't exists.  Existance of pthread.h should separately
636 dnl             checked.
637 dnl 
638 AC_DEFUN([OL_HEADER_LINUX_THREADS], [
639         AC_CACHE_CHECK([for LinuxThreads pthread.h],
640                 [ol_cv_header_linux_threads],
641                 [AC_EGREP_CPP(pthread_kill_other_threads_np,
642                         [#include <pthread.h>],
643                         [ol_cv_header_linux_threads=yes],
644                         [ol_cv_header_linux_threads=no])
645                 ])
646         if test $ol_cv_header_linux_threads = yes; then
647                 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads])
648         fi
649 ])dnl
650 dnl --------------------------------------------------------------------
651 dnl     Check LinuxThreads Implementation
652 dnl
653 dnl     defines ol_cv_sys_linux_threads to 'yes' or 'no'
654 dnl     'no' implies pthreads implementation is not LinuxThreads.
655 dnl 
656 AC_DEFUN([OL_SYS_LINUX_THREADS], [
657         AC_CHECK_FUNC(pthread_kill_other_threads_np)
658         AC_CACHE_CHECK([for LinuxThreads implementation],
659                 [ol_cv_sys_linux_threads],
660                 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np])
661 ])dnl
662 dnl
663 dnl --------------------------------------------------------------------
664 dnl Check LinuxThreads consistency
665 AC_DEFUN([OL_LINUX_THREADS], [
666         AC_REQUIRE([OL_HEADER_LINUX_THREADS])
667         AC_REQUIRE([OL_SYS_LINUX_THREADS])
668         AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [
669                 if test $ol_cv_header_linux_threads = yes -a \
670                         $ol_cv_sys_linux_threads = yes; then
671                         ol_cv_linux_threads=yes
672                 elif test $ol_cv_header_linux_threads = no -a \
673                         $ol_cv_sys_linux_threads = no; then
674                         ol_cv_linux_threads=no
675                 else
676                         ol_cv_linux_threads=error
677                 fi
678         ])
679 ])dnl
680 dnl
681 dnl ====================================================================
682 dnl Check for POSIX Regex
683 AC_DEFUN([OL_POSIX_REGEX], [
684 AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[
685         AC_TRY_RUN([
686 #include <sys/types.h>
687 #include <regex.h>
688 static char *pattern, *string;
689 main()
690 {
691         int rc;
692         regex_t re;
693
694         pattern = "^A";
695
696         if(regcomp(&re, pattern, 0)) {
697                 return -1;
698         }
699         
700         string = "ALL MATCH";
701         
702         rc = regexec(&re, string, 0, (void*)0, 0);
703
704         regfree(&re);
705
706         return rc;
707 }],
708         [ol_cv_c_posix_regex=yes],
709         [ol_cv_c_posix_regex=no],
710         [ol_cv_c_posix_regex=cross])])
711 ])
712 dnl
713 dnl ====================================================================
714 dnl Check if toupper() requires islower() to be called first
715 AC_DEFUN([OL_C_UPPER_LOWER],
716 [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[
717         AC_TRY_RUN([
718 #include <ctype.h>
719 main()
720 {
721         if ('C' == toupper('C'))
722                 exit(0);
723         else
724                 exit(1);
725 }],
726         [ol_cv_c_upper_lower=no],
727         [ol_cv_c_upper_lower=yes],
728         [ol_cv_c_upper_lower=safe])])
729 if test $ol_cv_c_upper_lower != no ; then
730         AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()])
731 fi
732 ])
733 dnl
734 dnl ====================================================================
735 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
736 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
737 dnl Reported by Keith Bostic.
738 AC_DEFUN([OL_SYS_ERRLIST],
739 [AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
740         AC_TRY_COMPILE([
741 #include <stdio.h>
742 #include <sys/types.h>
743 #include <errno.h> ],
744         [char *c = (char *) *sys_errlist],
745         [ol_cv_dcl_sys_errlist=yes
746         ol_cv_have_sys_errlist=yes],
747         [ol_cv_dcl_sys_errlist=no])])
748 #
749 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist
750 if test $ol_cv_dcl_sys_errlist = no ; then
751         AC_DEFINE(DECL_SYS_ERRLIST,1,
752                 [define if sys_errlist is not declared in stdio.h or errno.h])
753
754         AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
755                 AC_TRY_LINK([#include <errno.h>],
756                         [char *c = (char *) *sys_errlist],
757                         [ol_cv_have_sys_errlist=yes],
758                         [ol_cv_have_sys_errlist=no])])
759 fi
760 if test $ol_cv_have_sys_errlist = yes ; then
761         AC_DEFINE(HAVE_SYS_ERRLIST,1,
762                 [define if you actually have sys_errlist in your libs])
763 fi
764 ])dnl
765 dnl
766 dnl ====================================================================
767 dnl Early MIPS compilers (used in Ultrix 4.2) don't like
768 dnl "int x; int *volatile a = &x; *a = 0;"
769 dnl     -- borrowed from PDKSH
770 AC_DEFUN(OL_C_VOLATILE,
771  [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile,
772     [AC_TRY_COMPILE([int x, y, z;],
773       [volatile int a; int * volatile b = x ? &y : &z;
774       /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */
775       *b = 0;], ol_cv_c_volatile=yes, ol_cv_c_volatile=no)])
776   if test $ol_cv_c_volatile = yes; then
777     : 
778   else
779     AC_DEFINE(volatile,,[define as empty if volatile is not supported])
780   fi
781  ])dnl
782 dnl
783 dnl ====================================================================
784 dnl Look for fetch(3)
785 AC_DEFUN([OL_LIB_FETCH],
786 [ol=$LIBS
787 LIBS="-lfetch -lcom_err $LIBS"
788 AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[
789         AC_TRY_LINK([
790 #include <sys/param.h>
791 #include <stdio.h>
792 #include <fetch.h>],
793         [struct url *u = fetchParseURL("file:///"); ],
794         [ol_cv_lib_fetch=yes],
795         [ol_cv_lib_fetch=no])])
796 LIBS=$ol_LIBS
797 if test $ol_cv_lib_fetch != no ; then
798         ol_link_fetch="-lfetch -lcom_err"
799         AC_DEFINE(HAVE_FETCH,1,
800                 [define if you actually have FreeBSD fetch(3)])
801 fi
802 ])dnl
803 dnl
804 dnl ====================================================================
805 dnl Define sig_atomic_t if not defined in signal.h
806 AC_DEFUN(OL_TYPE_SIG_ATOMIC_T,
807  [AC_CACHE_CHECK(for sig_atomic_t, ol_cv_type_sig_atomic_t,
808     [AC_TRY_COMPILE([#include <signal.h>], [sig_atomic_t atomic;],
809                 ol_cv_type_sig_atomic_t=yes, ol_cv_type_sig_atomic_t=no)])
810   if test $ol_cv_type_sig_atomic_t = no; then
811     AC_DEFINE(sig_atomic_t,int,
812                 [define to atomic type if sig_atomic_t is not available])
813   fi
814  ])dnl
815 dnl
816 dnl ====================================================================
817 dnl Define socklen_t if not defined in sys/types.h or sys/socket.h
818 AC_DEFUN(OL_TYPE_SOCKLEN_T,
819  [AC_CACHE_CHECK(for socklen_t, ol_cv_type_socklen_t,
820     [AC_TRY_COMPILE([
821 #ifdef HAVE_SYS_TYPES_H
822 #include <sys/types.h>
823 #endif
824 #ifdef HAVE_SYS_SOCKET_H
825 #include <sys/socket.h>
826 #endif
827 ], [socklen_t len;],
828                 ol_cv_type_socklen_t=yes, ol_cv_type_socklen_t=no)])
829   if test $ol_cv_type_socklen_t = no; then
830     AC_DEFINE(socklen_t, int,
831                 [define to int if socklen_t is not available])
832   fi
833  ])dnl
834 dnl
835 dnl ====================================================================
836 dnl Define inet_aton is available
837 AC_DEFUN(OL_FUNC_INET_ATON,
838  [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton,
839     [AC_TRY_LINK([
840 #ifdef HAVE_SYS_TYPES_H
841 #       include <sys/types.h>
842 #endif
843 #ifdef HAVE_SYS_SOCKET_H
844 #       include <sys/socket.h>
845 #       ifdef HAVE_SYS_SELECT_H
846 #               include <sys/select.h>
847 #       endif
848 #       include <netinet/in.h>
849 #       ifdef HAVE_ARPA_INET_H
850 #               include <arpa/inet.h>
851 #       endif
852 #endif
853 ], [struct in_addr in;
854 int rc = inet_aton( "255.255.255.255", &in );],
855                 ol_cv_func_inet_aton=yes, ol_cv_func_inet_aton=no)])
856   if test $ol_cv_func_inet_aton != no; then
857     AC_DEFINE(HAVE_INET_ATON, 1,
858                 [define to you inet_aton(3) is available])
859   fi
860  ])dnl
861 dnl
862 dnl ====================================================================
863 dnl check no of arguments for ctime_r
864 AC_DEFUN(OL_FUNC_CTIME_R_NARGS,
865  [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs,
866    [AC_TRY_COMPILE([#include <time.h>],
867                 [time_t ti; char *buffer; ctime_r(&ti,buffer,32);],
868                         ol_cv_func_ctime_r_nargs=3,
869                         [AC_TRY_COMPILE([#include <time.h>],
870                                 [time_t ti; char *buffer; ctime_r(&ti,buffer);],
871                                         ol_cv_func_ctime_r_nargs=2,
872                                         ol_cv_func_ctime_r_nargs=0)])])
873   if test $ol_cv_func_ctime_r_nargs -gt 1 ; then
874     AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs,
875                 [set to the number of arguments ctime_r() expects])
876   fi
877 ])dnl
878 dnl
879 dnl --------------------------------------------------------------------
880 dnl check return type of ctime_r()
881 AC_DEFUN(OL_FUNC_CTIME_R_TYPE,
882  [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type,
883    [AC_TRY_COMPILE([#include <time.h>],
884                 [extern int (ctime_r)();],
885                         ol_cv_func_ctime_r_type="int", ol_cv_func_ctime_r_type="charp")
886         ])
887   if test $ol_cv_func_ctime_r_type = "int" ; then
888         AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int])
889   fi
890 ])dnl
891 dnl ====================================================================
892 dnl check no of arguments for gethostbyname_r
893 AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
894  [AC_CACHE_CHECK(number of arguments of gethostbyname_r,
895         ol_cv_func_gethostbyname_r_nargs,
896         [AC_TRY_COMPILE([#include <sys/types.h>
897 #include <sys/socket.h>
898 #include <netinet/in.h>
899 #include <netdb.h>
900 #define BUFSIZE (sizeof(struct hostent)+10)],
901                 [struct hostent hent; char buffer[BUFSIZE];
902                 int bufsize=BUFSIZE;int h_errno;
903                 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent,
904                         buffer, bufsize, &h_errno);],
905                 ol_cv_func_gethostbyname_r_nargs=5, 
906                 [AC_TRY_COMPILE([#include <sys/types.h>
907 #include <sys/socket.h>
908 #include <netinet/in.h>
909 #include <netdb.h>
910 #define BUFSIZE (sizeof(struct hostent)+10)],
911                         [struct hostent hent;struct hostent *rhent;
912                         char buffer[BUFSIZE];
913                         int bufsize=BUFSIZE;int h_errno;
914                         (void)gethostbyname_r("localhost", &hent, buffer, bufsize,
915                                 &rhent, &h_errno);],
916                         ol_cv_func_gethostbyname_r_nargs=6,
917                         ol_cv_func_gethostbyname_r_nargs=0)])])
918   if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
919         AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS,
920                 $ol_cv_func_gethostbyname_r_nargs,
921                 [set to the number of arguments gethostbyname_r() expects])
922   fi
923 ])dnl
924 dnl
925 dnl check no of arguments for gethostbyaddr_r
926 AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
927  [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r,
928         [ol_cv_func_gethostbyaddr_r_nargs],
929         [AC_TRY_COMPILE([#include <sys/types.h>
930 #include <sys/socket.h>
931 #include <netinet/in.h>
932 #include <netdb.h>
933 #define BUFSIZE (sizeof(struct hostent)+10)],
934            [struct hostent hent; char buffer[BUFSIZE]; 
935             struct in_addr add;
936             size_t alen=sizeof(struct in_addr);
937             int bufsize=BUFSIZE;int h_errno;
938                 (void)gethostbyaddr_r( (void *)&(add.s_addr),
939                         alen, AF_INET, &hent, buffer, bufsize, &h_errno);],
940                 ol_cv_func_gethostbyaddr_r_nargs=7,
941                 [AC_TRY_COMPILE([#include <sys/types.h>
942 #include <sys/socket.h>
943 #include <netinet/in.h>
944 #include <netdb.h>
945 #define BUFSIZE (sizeof(struct hostent)+10)],
946                         [struct hostent hent;
947                         struct hostent *rhent; char buffer[BUFSIZE]; 
948                         struct in_addr add;
949                         size_t alen=sizeof(struct in_addr);
950                         int bufsize=BUFSIZE;int h_errno;
951                         (void)gethostbyaddr_r( (void *)&(add.s_addr),
952                                 alen, AF_INET, &hent, buffer, bufsize, 
953                                 &rhent, &h_errno);],
954                         ol_cv_func_gethostbyaddr_r_nargs=8,
955                         ol_cv_func_gethostbyaddr_r_nargs=0)])])
956   if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
957     AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS,
958                 $ol_cv_func_gethostbyaddr_r_nargs,
959                 [set to the number of arguments gethostbyaddr_r() expects])
960   fi
961 ])dnl
962 dnl