1dnl OpenLDAP Autoconf Macros 2dnl $OpenLDAP$ 3dnl This work is part of OpenLDAP Software <http://www.openldap.org/>. 4dnl 5dnl Copyright 1998-2021 The OpenLDAP Foundation. 6dnl All rights reserved. 7dnl 8dnl Redistribution and use in source and binary forms, with or without 9dnl modification, are permitted only as authorized by the OpenLDAP 10dnl Public License. 11dnl 12dnl A copy of this license is available in the file LICENSE in the 13dnl top-level directory of the distribution or, alternatively, at 14dnl <http://www.OpenLDAP.org/license.html>. 15dnl 16dnl -------------------------------------------------------------------- 17dnl Restricted form of AC_ARG_ENABLE that limits user options 18dnl 19dnl $1 = option name 20dnl $2 = help-string 21dnl $3 = default value (auto). "--" means do not set it by default 22dnl $4 = allowed values (auto yes no) 23dnl $5 = overridden default 24AC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1 25 pushdef([ol_DefVal],ifelse($3,,auto,$3)) 26 AC_ARG_ENABLE($1,ifelse($4,,[$2],[$2] translit([$4],[ ],[|])) ifelse($3,--,,@<:@ol_DefVal@:>@),[ 27 ol_arg=invalid 28 for ol_val in ifelse($4,,[auto yes no],[$4]) ; do 29 if test "$enableval" = "$ol_val" ; then 30 ol_arg="$ol_val" 31 fi 32 done 33 if test "$ol_arg" = "invalid" ; then 34 AC_MSG_ERROR(bad value $enableval for --enable-$1) 35 fi 36 ol_enable_$1="$ol_arg" 37]ifelse($3,--,,[, 38[ ol_enable_$1=ifelse($5,,ol_DefVal,[${]$5[:-]ol_DefVal[}])]]))dnl 39dnl AC_MSG_RESULT([OpenLDAP -enable-$1 $ol_enable_$1]) 40 popdef([ol_DefVal]) 41# end --enable-$1 42])dnl 43dnl 44dnl -------------------------------------------------------------------- 45dnl Restricted form of AC_ARG_WITH that limits user options 46dnl 47dnl $1 = option name 48dnl $2 = help-string 49dnl $3 = default value (no) 50dnl $4 = allowed values (yes or no) 51AC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1 52 AC_ARG_WITH($1,[$2 @<:@]ifelse($3,,yes,$3)@:>@,[ 53 ol_arg=invalid 54 for ol_val in ifelse($4,,[yes no],[$4]) ; do 55 if test "$withval" = "$ol_val" ; then 56 ol_arg="$ol_val" 57 fi 58 done 59 if test "$ol_arg" = "invalid" ; then 60 AC_MSG_ERROR(bad value $withval for --with-$1) 61 fi 62 ol_with_$1="$ol_arg" 63], 64[ ol_with_$1=ifelse($3,,"no","$3")])dnl 65dnl AC_MSG_RESULT([OpenLDAP --with-$1 $ol_with_$1]) 66# end --with-$1 67])dnl 68dnl ==================================================================== 69dnl Check for dependency generation flag 70AC_DEFUN([OL_MKDEPEND], [# test for make depend flag 71OL_MKDEP= 72OL_MKDEP_FLAGS= 73if test -z "${MKDEP}"; then 74 OL_MKDEP="${CC-cc}" 75 if test -z "${MKDEP_FLAGS}"; then 76 AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [ 77 ol_cv_mkdep=no 78 for flag in "-M" "-xM"; do 79 cat > conftest.c <<EOF 80 noCode; 81EOF 82 if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \ 83 | grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1 84 then 85 if test ! -f conftest."${ac_object}" ; then 86 ol_cv_mkdep=$flag 87 OL_MKDEP_FLAGS="$flag" 88 break 89 fi 90 fi 91 done 92 rm -f conftest* 93 ]) 94 test "$ol_cv_mkdep" = no && OL_MKDEP=":" 95 else 96 cc_cv_mkdep=yes 97 OL_MKDEP_FLAGS="${MKDEP_FLAGS}" 98 fi 99else 100 cc_cv_mkdep=yes 101 OL_MKDEP="${MKDEP}" 102 OL_MKDEP_FLAGS="${MKDEP_FLAGS}" 103fi 104AC_SUBST(OL_MKDEP) 105AC_SUBST(OL_MKDEP_FLAGS) 106]) 107dnl 108dnl ==================================================================== 109dnl Check if system uses EBCDIC instead of ASCII 110AC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC 111AC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[ 112 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 113#if !('M' == 0xd4) 114#include <__ASCII__/generate_error.h> 115#endif 116]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])]) 117if test $ol_cv_cpp_ebcdic = yes ; then 118 AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII]) 119fi 120]) 121dnl 122dnl -------------------------------------------------------------------- 123dnl Check for MSVC 124AC_DEFUN([OL_MSVC], 125[AC_REQUIRE_CPP()dnl 126AC_CACHE_CHECK([whether we are using MS Visual C++], ol_cv_msvc, 127[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 128#ifndef _MSC_VER 129#include <__FOO__/generate_error.h> 130#endif 131]])],[ol_cv_msvc=yes],[ol_cv_msvc=no])])]) 132 133dnl -------------------------------------------------------------------- 134dnl OpenLDAP version of STDC header check w/ EBCDIC support 135AC_DEFUN([OL_HEADER_STDC], 136[AC_REQUIRE_CPP()dnl 137AC_REQUIRE([OL_CPP_EBCDIC])dnl 138AC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc, 139[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h> 140#include <stdarg.h> 141#include <string.h> 142#include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no]) 143 144if test $ol_cv_header_stdc = yes; then 145 # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 146AC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no) 147fi 148 149if test $ol_cv_header_stdc = yes; then 150 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 151AC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no) 152fi 153 154if test $ol_cv_header_stdc = yes; then 155 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. 156AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h> 157#ifndef HAVE_EBCDIC 158# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') 159# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) 160#else 161# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ 162 || ('j' <= (c) && (c) <= 'r') \ 163 || ('s' <= (c) && (c) <= 'z')) 164# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) 165#endif 166#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) 167int main () { int i; for (i = 0; i < 256; i++) 168if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); 169exit (0); } 170]])],[],[ol_cv_header_stdc=no],[:]) 171fi]) 172if test $ol_cv_header_stdc = yes; then 173 AC_DEFINE(STDC_HEADERS) 174fi 175ac_cv_header_stdc=disable 176]) 177dnl 178dnl ==================================================================== 179dnl DNS resolver macros 180AC_DEFUN([OL_RESOLVER_TRY], 181[if test $ol_cv_lib_resolver = no ; then 182 AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1], 183[ 184 ol_RESOLVER_LIB=ifelse($2,,,$2) 185 ol_LIBS=$LIBS 186 LIBS="$ol_RESOLVER_LIB $LIBS" 187 188 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 189#ifdef HAVE_SYS_TYPES_H 190# include <sys/types.h> 191#endif 192#include <netinet/in.h> 193#ifdef HAVE_ARPA_NAMESER_H 194# include <arpa/nameser.h> 195#endif 196#ifdef HAVE_RESOLV_H 197# include <resolv.h> 198#endif 199]], [[{ 200 int len, status; 201 char *request = NULL; 202 unsigned char reply[64*1024]; 203 unsigned char host[64*1024]; 204 unsigned char *p; 205 206#ifdef NS_HFIXEDSZ 207 /* Bind 8/9 interface */ 208 len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply)); 209#else 210 /* Bind 4 interface */ 211# ifndef T_SRV 212# define T_SRV 33 213# endif 214 len = res_query(request, C_IN, T_SRV, reply, sizeof(reply)); 215#endif 216 p = reply; 217#ifdef NS_HFIXEDSZ 218 /* Bind 8/9 interface */ 219 p += NS_HFIXEDSZ; 220#elif defined(HFIXEDSZ) 221 /* Bind 4 interface w/ HFIXEDSZ */ 222 p += HFIXEDSZ; 223#else 224 /* Bind 4 interface w/o HFIXEDSZ */ 225 p += sizeof(HEADER); 226#endif 227 status = dn_expand( reply, reply+len, p, host, sizeof(host)); 228}]])],[$1=yes],[$1=no]) 229 230 LIBS="$ol_LIBS" 231]) 232 233 if test $$1 = yes ; then 234 ol_cv_lib_resolver=ifelse($2,,yes,$2) 235 fi 236fi 237]) 238dnl -------------------------------------------------------------------- 239dnl Try to locate appropriate library 240AC_DEFUN([OL_RESOLVER_LINK], 241[ol_cv_lib_resolver=no 242OL_RESOLVER_TRY(ol_cv_resolver_none) 243OL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv]) 244OL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind]) 245]) 246dnl 247dnl ==================================================================== 248dnl Check POSIX Thread version 249dnl 250dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the 251dnl version of the POSIX.4a Draft that is implemented. 252dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes. 253dnl Existence of pthread.h should be tested separately. 254dnl 255dnl tests: 256dnl pthread_detach() was dropped in Draft 8, it is present 257dnl in every other version 258dnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called 259dnl PTHREAD_CREATE_JOINABLE after that 260dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6. 261dnl Draft 6-10 has _init, Draft 4-5 has _create. 262dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it 263dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not 264dnl interesting to us because we don't try to statically 265dnl initialize mutexes. 5-10 has it. 266dnl 267dnl Draft 9 and 10 are equivalent for our purposes. 268dnl 269AC_DEFUN([OL_POSIX_THREAD_VERSION], 270[AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[ 271 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 272# include <pthread.h> 273 ]], [[ 274 int i = PTHREAD_CREATE_JOINABLE; 275 ]])],[ 276 AC_EGREP_HEADER(pthread_detach,pthread.h, 277 ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[ 278 AC_EGREP_CPP(draft7,[ 279# include <pthread.h> 280# ifdef PTHREAD_CREATE_UNDETACHED 281 draft7 282# endif 283 ], ol_cv_pthread_version=7, [ 284 AC_EGREP_HEADER(pthread_attr_init,pthread.h, 285 ol_cv_pthread_version=6, [ 286 AC_EGREP_CPP(draft5,[ 287# include <pthread.h> 288#ifdef PTHREAD_MUTEX_INITIALIZER 289 draft5 290#endif 291 ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ]) 292]) 293])dnl 294dnl 295dnl -------------------------------------------------------------------- 296AC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[ 297/* pthread test headers */ 298#include <pthread.h> 299#if HAVE_PTHREADS < 7 300#include <errno.h> 301#endif 302#ifndef NULL 303#define NULL (void*)0 304#endif 305 306static void *task(p) 307 void *p; 308{ 309 return (void *) (p == NULL); 310} 311]]) 312AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[ 313 /* pthread test function */ 314#ifndef PTHREAD_CREATE_DETACHED 315#define PTHREAD_CREATE_DETACHED 1 316#endif 317 pthread_t t; 318 int status; 319 int detach = PTHREAD_CREATE_DETACHED; 320 321#if HAVE_PTHREADS > 4 322 /* Final pthreads */ 323 pthread_attr_t attr; 324 325 status = pthread_attr_init(&attr); 326 if( status ) return status; 327 328#if HAVE_PTHREADS < 7 329 status = pthread_attr_setdetachstate(&attr, &detach); 330 if( status < 0 ) status = errno; 331#else 332 status = pthread_attr_setdetachstate(&attr, detach); 333#endif 334 if( status ) return status; 335 status = pthread_create( &t, &attr, task, NULL ); 336#if HAVE_PTHREADS < 7 337 if( status < 0 ) status = errno; 338#endif 339 if( status ) return status; 340#else 341 /* Draft 4 pthreads */ 342 status = pthread_create( &t, pthread_attr_default, task, NULL ); 343 if( status ) return errno; 344 345 /* give thread a chance to complete */ 346 /* it should remain joinable and hence detachable */ 347 sleep( 1 ); 348 349 status = pthread_detach( &t ); 350 if( status ) return errno; 351#endif 352 353#ifdef HAVE_LINUX_THREADS 354 pthread_kill_other_threads_np(); 355#endif 356 357 return 0; 358]]) 359 360AC_DEFUN([OL_PTHREAD_TEST_PROGRAM], 361[AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES 362 363int main(argc, argv) 364 int argc; 365 char **argv; 366{ 367OL_PTHREAD_TEST_FUNCTION 368} 369])]) 370dnl -------------------------------------------------------------------- 371AC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2) 372if test "$ol_link_threads" = no ; then 373 # try $1 374 AC_CACHE_CHECK([for pthread link with $1], [$2], [ 375 # save the flags 376 ol_LIBS="$LIBS" 377 LIBS="$1 $LIBS" 378 379 AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM], 380 [$2=yes], 381 [$2=no], 382 [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES, 383 OL_PTHREAD_TEST_FUNCTION)], 384 [$2=yes], [$2=no])]) 385 386 # restore the LIBS 387 LIBS="$ol_LIBS" 388 ]) 389 390 if test $$2 = yes ; then 391 ol_link_pthreads="$1" 392 ol_link_threads=posix 393 fi 394fi 395]) 396dnl 397dnl ==================================================================== 398dnl Check GNU Pth pthread Header 399dnl 400dnl defines ol_cv_header linux_threads to 'yes' or 'no' 401dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h 402dnl doesn't exist. Existence of pthread.h should separately 403dnl checked. 404dnl 405AC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [ 406 AC_CACHE_CHECK([for GNU Pth pthread.h], 407 [ol_cv_header_gnu_pth_pthread_h], 408 [AC_EGREP_CPP(__gnu_pth__, 409 [#include <pthread.h> 410#ifdef _POSIX_THREAD_IS_GNU_PTH 411 __gnu_pth__; 412#endif 413], 414 [ol_cv_header_gnu_pth_pthread_h=yes], 415 [ol_cv_header_gnu_pth_pthread_h=no]) 416 ]) 417])dnl 418dnl ==================================================================== 419dnl Check for NT Threads 420AC_DEFUN([OL_NT_THREADS], [ 421 AC_CHECK_FUNC(_beginthread) 422 423 if test $ac_cv_func__beginthread = yes ; then 424 AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads]) 425 ol_cv_nt_threads=yes 426 fi 427]) 428dnl ==================================================================== 429dnl Check LinuxThreads Header 430dnl 431dnl defines ol_cv_header linux_threads to 'yes' or 'no' 432dnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h 433dnl doesn't exist. Existence of pthread.h should separately 434dnl checked. 435dnl 436AC_DEFUN([OL_HEADER_LINUX_THREADS], [ 437 AC_CACHE_CHECK([for LinuxThreads pthread.h], 438 [ol_cv_header_linux_threads], 439 [AC_EGREP_CPP(pthread_kill_other_threads_np, 440 [#include <pthread.h>], 441 [ol_cv_header_linux_threads=yes], 442 [ol_cv_header_linux_threads=no]) 443 ]) 444 if test $ol_cv_header_linux_threads = yes; then 445 AC_DEFINE(HAVE_LINUX_THREADS,1,[if you have LinuxThreads]) 446 fi 447])dnl 448dnl -------------------------------------------------------------------- 449dnl Check LinuxThreads Implementation 450dnl 451dnl defines ol_cv_sys_linux_threads to 'yes' or 'no' 452dnl 'no' implies pthreads implementation is not LinuxThreads. 453dnl 454AC_DEFUN([OL_SYS_LINUX_THREADS], [ 455 AC_CHECK_FUNCS(pthread_kill_other_threads_np) 456 AC_CACHE_CHECK([for LinuxThreads implementation], 457 [ol_cv_sys_linux_threads], 458 [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np]) 459])dnl 460dnl 461dnl -------------------------------------------------------------------- 462dnl Check LinuxThreads consistency 463AC_DEFUN([OL_LINUX_THREADS], [ 464 AC_REQUIRE([OL_HEADER_LINUX_THREADS]) 465 AC_REQUIRE([OL_SYS_LINUX_THREADS]) 466 AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [ 467 if test $ol_cv_header_linux_threads = yes && 468 test $ol_cv_sys_linux_threads = yes; then 469 ol_cv_linux_threads=yes 470 elif test $ol_cv_header_linux_threads = no && 471 test $ol_cv_sys_linux_threads = no; then 472 ol_cv_linux_threads=no 473 else 474 ol_cv_linux_threads=error 475 fi 476 ]) 477])dnl 478dnl 479dnl ==================================================================== 480dnl Check for POSIX Regex 481AC_DEFUN([OL_POSIX_REGEX], [ 482AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[ 483 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 484#include <sys/types.h> 485#include <regex.h> 486static char *pattern, *string; 487main() 488{ 489 int rc; 490 regex_t re; 491 492 pattern = "^A"; 493 494 if(regcomp(&re, pattern, 0)) { 495 return -1; 496 } 497 498 string = "ALL MATCH"; 499 500 rc = regexec(&re, string, 0, (void*)0, 0); 501 502 regfree(&re); 503 504 return rc; 505}]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])]) 506]) 507dnl 508dnl ==================================================================== 509dnl Check if toupper() requires islower() to be called first 510AC_DEFUN([OL_C_UPPER_LOWER], 511[AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[ 512 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 513#include <ctype.h> 514main() 515{ 516 if ('C' == toupper('C')) 517 exit(0); 518 else 519 exit(1); 520}]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])]) 521if test $ol_cv_c_upper_lower != no ; then 522 AC_DEFINE(C_UPPER_LOWER,1, [define if toupper() requires islower()]) 523fi 524]) 525dnl 526dnl ==================================================================== 527dnl Error string checks 528dnl 529dnl Check for declaration of sys_errlist in one of stdio.h and errno.h. 530dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration. 531dnl Reported by Keith Bostic. 532AC_DEFUN([OL_SYS_ERRLIST], 533[AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[ 534 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])]) 535if test $ol_cv_have_sys_errlist = yes ; then 536 AC_DEFINE(HAVE_SYS_ERRLIST,1, 537 [define if you actually have sys_errlist in your libs]) 538 AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[ 539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 540#include <stdio.h> 541#include <sys/types.h> 542#include <errno.h> 543#ifdef _WIN32 544#include <stdlib.h> 545#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes], 546 [ol_cv_dcl_sys_errlist=no])]) 547# 548 # It's possible (for near-UNIX clones) that sys_errlist doesn't exist 549 if test $ol_cv_dcl_sys_errlist = no ; then 550 AC_DEFINE(DECL_SYS_ERRLIST,1, 551 [define if sys_errlist is not declared in stdio.h or errno.h]) 552 fi 553fi 554])dnl 555dnl 556dnl ==================================================================== 557dnl glibc supplies a non-standard strerror_r if _GNU_SOURCE is defined. 558dnl It's actually preferable to the POSIX version, if available. 559AC_DEFUN([OL_NONPOSIX_STRERROR_R], 560[AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[ 561 AC_EGREP_CPP(strerror_r,[#include <string.h>], 562 ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl 563 564 if test $ol_decl_strerror_r = yes ; then 565 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */ 566 char buf[100]; 567 char x = *strerror_r (0, buf, sizeof buf); 568 char *p = strerror_r (0, buf, sizeof buf); 569 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no]) 570 else 571 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 572 main() { 573 char buf[100]; 574 buf[0] = 0; 575 strerror_r( 1, buf, sizeof buf ); 576 exit( buf[0] == 0 ); 577 } 578 ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no],[ol_cv_nonposix_strerror_r=no]) 579 fi 580 ]) 581if test $ol_cv_nonposix_strerror_r = yes ; then 582 AC_DEFINE(HAVE_NONPOSIX_STRERROR_R,1, 583 [define if strerror_r returns char* instead of int]) 584fi 585])dnl 586dnl 587AC_DEFUN([OL_STRERROR], 588[AC_CHECK_FUNCS(strerror strerror_r) 589ol_cv_func_strerror_r=no 590if test "${ac_cv_func_strerror_r}" = yes ; then 591 OL_NONPOSIX_STRERROR_R 592elif test "${ac_cv_func_strerror}" = no ; then 593 OL_SYS_ERRLIST 594fi 595])dnl 596dnl ==================================================================== 597dnl Early MIPS compilers (used in Ultrix 4.2) don't like 598dnl "int x; int *volatile a = &x; *a = 0;" 599dnl -- borrowed from PDKSH 600AC_DEFUN([OL_C_VOLATILE], 601 [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile, 602 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z; 603 /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */ 604 *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])]) 605 if test $ol_cv_c_volatile = yes; then 606 : 607 else 608 AC_DEFINE(volatile,,[define as empty if volatile is not supported]) 609 fi 610 ])dnl 611dnl 612dnl ==================================================================== 613dnl Look for fetch(3) 614AC_DEFUN([OL_LIB_FETCH], 615[ol_LIBS=$LIBS 616LIBS="-lfetch $LIBS" 617AC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[ 618 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 619#ifdef HAVE_SYS_PARAM_H 620#include <sys/param.h> 621#endif 622#include <stdio.h> 623#include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])]) 624LIBS=$ol_LIBS 625if test $ol_cv_lib_fetch != no ; then 626 ol_link_fetch="-lfetch" 627 AC_DEFINE(HAVE_FETCH,1, 628 [define if you actually have FreeBSD fetch(3)]) 629fi 630])dnl 631dnl 632dnl ==================================================================== 633dnl Define inet_aton is available 634AC_DEFUN([OL_FUNC_INET_ATON], 635 [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton, 636 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 637#ifdef HAVE_SYS_TYPES_H 638# include <sys/types.h> 639#endif 640#ifdef HAVE_SYS_SOCKET_H 641# include <sys/socket.h> 642# ifdef HAVE_SYS_SELECT_H 643# include <sys/select.h> 644# endif 645# include <netinet/in.h> 646# ifdef HAVE_ARPA_INET_H 647# include <arpa/inet.h> 648# endif 649#endif 650]], [[struct in_addr in; 651int rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])]) 652 if test $ol_cv_func_inet_aton != no; then 653 AC_DEFINE(HAVE_INET_ATON, 1, 654 [define to you inet_aton(3) is available]) 655 fi 656 ])dnl 657dnl 658dnl ==================================================================== 659dnl check no of arguments for ctime_r 660AC_DEFUN([OL_FUNC_CTIME_R_NARGS], 661 [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs, 662 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer,32);]])],[ol_cv_func_ctime_r_nargs3=yes],[ol_cv_func_ctime_r_nargs3=no]) 663 664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[time_t ti; char *buffer; ctime_r(&ti,buffer);]])],[ol_cv_func_ctime_r_nargs2=yes],[ol_cv_func_ctime_r_nargs2=no]) 665 666 if test $ol_cv_func_ctime_r_nargs3 = yes && 667 test $ol_cv_func_ctime_r_nargs2 = no ; then 668 669 ol_cv_func_ctime_r_nargs=3 670 671 elif test $ol_cv_func_ctime_r_nargs3 = no && 672 test $ol_cv_func_ctime_r_nargs2 = yes ; then 673 674 ol_cv_func_ctime_r_nargs=2 675 676 else 677 ol_cv_func_ctime_r_nargs=0 678 fi 679 ]) 680 681 if test $ol_cv_func_ctime_r_nargs -gt 1 ; then 682 AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs, 683 [set to the number of arguments ctime_r() expects]) 684 fi 685])dnl 686dnl 687dnl -------------------------------------------------------------------- 688dnl check return type of ctime_r() 689AC_DEFUN([OL_FUNC_CTIME_R_TYPE], 690 [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type, 691 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[extern int (ctime_r)();]])],[ol_cv_func_ctime_r_type="int"],[ol_cv_func_ctime_r_type="charp"]) 692 ]) 693 if test $ol_cv_func_ctime_r_type = "int" ; then 694 AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int]) 695 fi 696])dnl 697dnl ==================================================================== 698dnl check no of arguments for gethostbyname_r 699AC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS], 700 [AC_CACHE_CHECK(number of arguments of gethostbyname_r, 701 ol_cv_func_gethostbyname_r_nargs, 702 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 703#include <sys/socket.h> 704#include <netinet/in.h> 705#include <netdb.h> 706#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 707 int bufsize=BUFSIZE;int h_errno; 708 (void)gethostbyname_r("segovia.cs.purdue.edu", &hent, 709 buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no]) 710 711 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 712#include <sys/socket.h> 713#include <netinet/in.h> 714#include <netdb.h> 715#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent; 716 char buffer[BUFSIZE]; 717 int bufsize=BUFSIZE;int h_errno; 718 (void)gethostbyname_r("localhost", &hent, buffer, bufsize, 719 &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no]) 720 721 if test $ol_cv_func_gethostbyname_r_nargs5 = yes && 722 test $ol_cv_func_gethostbyname_r_nargs6 = no ; then 723 724 ol_cv_func_gethostbyname_r_nargs=5 725 726 elif test $ol_cv_func_gethostbyname_r_nargs5 = no && 727 test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then 728 729 ol_cv_func_gethostbyname_r_nargs=6 730 731 else 732 ol_cv_func_gethostbyname_r_nargs=0 733 fi 734 ]) 735 if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then 736 AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS, 737 $ol_cv_func_gethostbyname_r_nargs, 738 [set to the number of arguments gethostbyname_r() expects]) 739 fi 740])dnl 741dnl 742dnl check no of arguments for gethostbyaddr_r 743AC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS], 744 [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r, 745 [ol_cv_func_gethostbyaddr_r_nargs], 746 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 747#include <sys/socket.h> 748#include <netinet/in.h> 749#include <netdb.h> 750#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 751 struct in_addr add; 752 size_t alen=sizeof(struct in_addr); 753 int bufsize=BUFSIZE;int h_errno; 754 (void)gethostbyaddr_r( (void *)&(add.s_addr), 755 alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no]) 756 757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 758#include <sys/socket.h> 759#include <netinet/in.h> 760#include <netdb.h> 761#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; 762 struct hostent *rhent; char buffer[BUFSIZE]; 763 struct in_addr add; 764 size_t alen=sizeof(struct in_addr); 765 int bufsize=BUFSIZE;int h_errno; 766 (void)gethostbyaddr_r( (void *)&(add.s_addr), 767 alen, AF_INET, &hent, buffer, bufsize, 768 &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no]) 769 770 if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes && 771 test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then 772 773 ol_cv_func_gethostbyaddr_r_nargs=7 774 775 elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no && 776 test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then 777 778 ol_cv_func_gethostbyaddr_r_nargs=8 779 780 else 781 ol_cv_func_gethostbyaddr_r_nargs=0 782 fi 783 ]) 784 if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then 785 AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS, 786 $ol_cv_func_gethostbyaddr_r_nargs, 787 [set to the number of arguments gethostbyaddr_r() expects]) 788 fi 789])dnl 790dnl 791dnl -------------------------------------------------------------------- 792dnl Check for Cyrus SASL version compatibility 793AC_DEFUN([OL_SASL_COMPAT], 794[AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[ 795 AC_EGREP_CPP(__sasl_compat,[ 796#ifdef HAVE_SASL_SASL_H 797#include <sasl/sasl.h> 798#else 799#include <sasl.h> 800#endif 801 802/* Require 2.1.15+ */ 803#if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1 804 char *__sasl_compat = "2.2+ or better okay (we guess)"; 805#elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \ 806 && SASL_VERSION_STEP >=15 807 char *__sasl_compat = "2.1.15+ or better okay"; 808#endif 809 ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])]) 810]) 811