1*a25439b6SCy Schubertdnl OpenLDAP Autoconf Macros 2*a25439b6SCy Schubertdnl $OpenLDAP: pkg/ldap/build/openldap.m4,v 1.157.2.10 2010/04/13 20:22:21 kurt Exp $ 3*a25439b6SCy Schubertdnl This work is part of OpenLDAP Software <http://www.openldap.org/>. 4*a25439b6SCy Schubertdnl 5*a25439b6SCy Schubertdnl Copyright 1998-2010 The OpenLDAP Foundation. 6*a25439b6SCy Schubertdnl All rights reserved. 7*a25439b6SCy Schubertdnl 8*a25439b6SCy Schubertdnl Redistribution and use in source and binary forms, with or without 9*a25439b6SCy Schubertdnl modification, are permitted only as authorized by the OpenLDAP 10*a25439b6SCy Schubertdnl Public License. 11*a25439b6SCy Schubertdnl 12*a25439b6SCy Schubertdnl A copy of this license is available in the file LICENSE-OPENLDAP in 13*a25439b6SCy Schubertdnl this directory of the distribution or, alternatively, at 14*a25439b6SCy Schubertdnl <http://www.OpenLDAP.org/license.html>. 15*a25439b6SCy Schubertdnl 16*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 17*a25439b6SCy Schubertdnl Restricted form of AC_ARG_ENABLE that limits user options 18*a25439b6SCy Schubertdnl 19*a25439b6SCy Schubertdnl $1 = option name 20*a25439b6SCy Schubertdnl $2 = help-string 21*a25439b6SCy Schubertdnl $3 = default value (auto). "--" means do not set it by default 22*a25439b6SCy Schubertdnl $4 = allowed values (auto yes no) 23*a25439b6SCy Schubertdnl $5 = overridden default 24*a25439b6SCy SchubertAC_DEFUN([OL_ARG_ENABLE], [# OpenLDAP --enable-$1 25*a25439b6SCy Schubert pushdef([ol_DefVal],ifelse($3,,auto,$3)) 26*a25439b6SCy Schubert AC_ARG_ENABLE($1,ifelse($4,,[$2],[$2] translit([$4],[ ],[|])) ifelse($3,--,,@<:@ol_DefVal@:>@),[ 27*a25439b6SCy Schubert ol_arg=invalid 28*a25439b6SCy Schubert for ol_val in ifelse($4,,[auto yes no],[$4]) ; do 29*a25439b6SCy Schubert if test "$enableval" = "$ol_val" ; then 30*a25439b6SCy Schubert ol_arg="$ol_val" 31*a25439b6SCy Schubert fi 32*a25439b6SCy Schubert done 33*a25439b6SCy Schubert if test "$ol_arg" = "invalid" ; then 34*a25439b6SCy Schubert AC_MSG_ERROR(bad value $enableval for --enable-$1) 35*a25439b6SCy Schubert fi 36*a25439b6SCy Schubert ol_enable_$1="$ol_arg" 37*a25439b6SCy Schubert]ifelse($3,--,,[, 38*a25439b6SCy Schubert[ ol_enable_$1=ifelse($5,,ol_DefVal,[${]$5[:-]ol_DefVal[}])]]))dnl 39*a25439b6SCy Schubertdnl AC_MSG_RESULT([OpenLDAP -enable-$1 $ol_enable_$1]) 40*a25439b6SCy Schubert popdef([ol_DefVal]) 41*a25439b6SCy Schubert# end --enable-$1 42*a25439b6SCy Schubert])dnl 43*a25439b6SCy Schubertdnl 44*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 45*a25439b6SCy Schubertdnl Restricted form of AC_ARG_WITH that limits user options 46*a25439b6SCy Schubertdnl 47*a25439b6SCy Schubertdnl $1 = option name 48*a25439b6SCy Schubertdnl $2 = help-string 49*a25439b6SCy Schubertdnl $3 = default value (no) 50*a25439b6SCy Schubertdnl $4 = allowed values (yes or no) 51*a25439b6SCy SchubertAC_DEFUN([OL_ARG_WITH], [# OpenLDAP --with-$1 52*a25439b6SCy Schubert AC_ARG_WITH($1,[$2 @<:@]ifelse($3,,yes,$3)@:>@,[ 53*a25439b6SCy Schubert ol_arg=invalid 54*a25439b6SCy Schubert for ol_val in ifelse($4,,[yes no],[$4]) ; do 55*a25439b6SCy Schubert if test "$withval" = "$ol_val" ; then 56*a25439b6SCy Schubert ol_arg="$ol_val" 57*a25439b6SCy Schubert fi 58*a25439b6SCy Schubert done 59*a25439b6SCy Schubert if test "$ol_arg" = "invalid" ; then 60*a25439b6SCy Schubert AC_MSG_ERROR(bad value $withval for --with-$1) 61*a25439b6SCy Schubert fi 62*a25439b6SCy Schubert ol_with_$1="$ol_arg" 63*a25439b6SCy Schubert], 64*a25439b6SCy Schubert[ ol_with_$1=ifelse($3,,"no","$3")])dnl 65*a25439b6SCy Schubertdnl AC_MSG_RESULT([OpenLDAP --with-$1 $ol_with_$1]) 66*a25439b6SCy Schubert# end --with-$1 67*a25439b6SCy Schubert])dnl 68*a25439b6SCy Schubertdnl ==================================================================== 69*a25439b6SCy Schubertdnl Check for dependency generation flag 70*a25439b6SCy SchubertAC_DEFUN([OL_MKDEPEND], [# test for make depend flag 71*a25439b6SCy SchubertOL_MKDEP= 72*a25439b6SCy SchubertOL_MKDEP_FLAGS= 73*a25439b6SCy Schubertif test -z "${MKDEP}"; then 74*a25439b6SCy Schubert OL_MKDEP="${CC-cc}" 75*a25439b6SCy Schubert if test -z "${MKDEP_FLAGS}"; then 76*a25439b6SCy Schubert AC_CACHE_CHECK([for ${OL_MKDEP} depend flag], ol_cv_mkdep, [ 77*a25439b6SCy Schubert ol_cv_mkdep=no 78*a25439b6SCy Schubert for flag in "-M" "-xM"; do 79*a25439b6SCy Schubert cat > conftest.c <<EOF 80*a25439b6SCy Schubert noCode; 81*a25439b6SCy SchubertEOF 82*a25439b6SCy Schubert if AC_TRY_COMMAND($OL_MKDEP $flag conftest.c) \ 83*a25439b6SCy Schubert | grep '^conftest\.'"${ac_objext}" >/dev/null 2>&1 84*a25439b6SCy Schubert then 85*a25439b6SCy Schubert if test ! -f conftest."${ac_object}" ; then 86*a25439b6SCy Schubert ol_cv_mkdep=$flag 87*a25439b6SCy Schubert OL_MKDEP_FLAGS="$flag" 88*a25439b6SCy Schubert break 89*a25439b6SCy Schubert fi 90*a25439b6SCy Schubert fi 91*a25439b6SCy Schubert done 92*a25439b6SCy Schubert rm -f conftest* 93*a25439b6SCy Schubert ]) 94*a25439b6SCy Schubert test "$ol_cv_mkdep" = no && OL_MKDEP=":" 95*a25439b6SCy Schubert else 96*a25439b6SCy Schubert cc_cv_mkdep=yes 97*a25439b6SCy Schubert OL_MKDEP_FLAGS="${MKDEP_FLAGS}" 98*a25439b6SCy Schubert fi 99*a25439b6SCy Schubertelse 100*a25439b6SCy Schubert cc_cv_mkdep=yes 101*a25439b6SCy Schubert OL_MKDEP="${MKDEP}" 102*a25439b6SCy Schubert OL_MKDEP_FLAGS="${MKDEP_FLAGS}" 103*a25439b6SCy Schubertfi 104*a25439b6SCy SchubertAC_SUBST(OL_MKDEP) 105*a25439b6SCy SchubertAC_SUBST(OL_MKDEP_FLAGS) 106*a25439b6SCy Schubert]) 107*a25439b6SCy Schubertdnl 108*a25439b6SCy Schubertdnl ==================================================================== 109*a25439b6SCy Schubertdnl Check if system uses EBCDIC instead of ASCII 110*a25439b6SCy SchubertAC_DEFUN([OL_CPP_EBCDIC], [# test for EBCDIC 111*a25439b6SCy SchubertAC_CACHE_CHECK([for EBCDIC],ol_cv_cpp_ebcdic,[ 112*a25439b6SCy Schubert AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 113*a25439b6SCy Schubert#if !('M' == 0xd4) 114*a25439b6SCy Schubert#include <__ASCII__/generate_error.h> 115*a25439b6SCy Schubert#endif 116*a25439b6SCy Schubert]])],[ol_cv_cpp_ebcdic=yes],[ol_cv_cpp_ebcdic=no])]) 117*a25439b6SCy Schubertif test $ol_cv_cpp_ebcdic = yes ; then 118*a25439b6SCy Schubert AC_DEFINE(HAVE_EBCDIC,1, [define if system uses EBCDIC instead of ASCII]) 119*a25439b6SCy Schubertfi 120*a25439b6SCy Schubert]) 121*a25439b6SCy Schubertdnl 122*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 123*a25439b6SCy Schubertdnl Check for MSVC 124*a25439b6SCy SchubertAC_DEFUN([OL_MSVC], 125*a25439b6SCy Schubert[AC_REQUIRE_CPP()dnl 126*a25439b6SCy SchubertAC_CACHE_CHECK([whether we are using MS Visual C++], ol_cv_msvc, 127*a25439b6SCy Schubert[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ 128*a25439b6SCy Schubert#ifndef _MSC_VER 129*a25439b6SCy Schubert#include <__FOO__/generate_error.h> 130*a25439b6SCy Schubert#endif 131*a25439b6SCy Schubert]])],[ol_cv_msvc=yes],[ol_cv_msvc=no])])]) 132*a25439b6SCy Schubert 133*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 134*a25439b6SCy Schubertdnl OpenLDAP version of STDC header check w/ EBCDIC support 135*a25439b6SCy SchubertAC_DEFUN([OL_HEADER_STDC], 136*a25439b6SCy Schubert[AC_REQUIRE_CPP()dnl 137*a25439b6SCy SchubertAC_REQUIRE([OL_CPP_EBCDIC])dnl 138*a25439b6SCy SchubertAC_CACHE_CHECK([for ANSI C header files], ol_cv_header_stdc, 139*a25439b6SCy Schubert[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h> 140*a25439b6SCy Schubert#include <stdarg.h> 141*a25439b6SCy Schubert#include <string.h> 142*a25439b6SCy Schubert#include <float.h>]])],[ol_cv_header_stdc=yes],[ol_cv_header_stdc=no]) 143*a25439b6SCy Schubert 144*a25439b6SCy Schubertif test $ol_cv_header_stdc = yes; then 145*a25439b6SCy Schubert # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 146*a25439b6SCy SchubertAC_EGREP_HEADER(memchr, string.h, , ol_cv_header_stdc=no) 147*a25439b6SCy Schubertfi 148*a25439b6SCy Schubert 149*a25439b6SCy Schubertif test $ol_cv_header_stdc = yes; then 150*a25439b6SCy Schubert # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 151*a25439b6SCy SchubertAC_EGREP_HEADER(free, stdlib.h, , ol_cv_header_stdc=no) 152*a25439b6SCy Schubertfi 153*a25439b6SCy Schubert 154*a25439b6SCy Schubertif test $ol_cv_header_stdc = yes; then 155*a25439b6SCy Schubert # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. 156*a25439b6SCy SchubertAC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h> 157*a25439b6SCy Schubert#ifndef HAVE_EBCDIC 158*a25439b6SCy Schubert# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') 159*a25439b6SCy Schubert# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) 160*a25439b6SCy Schubert#else 161*a25439b6SCy Schubert# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \ 162*a25439b6SCy Schubert || ('j' <= (c) && (c) <= 'r') \ 163*a25439b6SCy Schubert || ('s' <= (c) && (c) <= 'z')) 164*a25439b6SCy Schubert# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) 165*a25439b6SCy Schubert#endif 166*a25439b6SCy Schubert#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) 167*a25439b6SCy Schubertint main () { int i; for (i = 0; i < 256; i++) 168*a25439b6SCy Schubertif (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); 169*a25439b6SCy Schubertexit (0); } 170*a25439b6SCy Schubert]])],[],[ol_cv_header_stdc=no],[:]) 171*a25439b6SCy Schubertfi]) 172*a25439b6SCy Schubertif test $ol_cv_header_stdc = yes; then 173*a25439b6SCy Schubert AC_DEFINE([STDC_HEADERS], [1], [is standard C provided?]) 174*a25439b6SCy Schubertfi 175*a25439b6SCy Schubertac_cv_header_stdc=disable 176*a25439b6SCy Schubert]) 177*a25439b6SCy Schubertdnl 178*a25439b6SCy Schubertdnl ==================================================================== 179*a25439b6SCy Schubertdnl DNS resolver macros 180*a25439b6SCy SchubertAC_DEFUN([OL_RESOLVER_TRY], 181*a25439b6SCy Schubert[if test $ol_cv_lib_resolver = no ; then 182*a25439b6SCy Schubert AC_CACHE_CHECK([for resolver link (]ifelse($2,,default,$2)[)],[$1], 183*a25439b6SCy Schubert[ 184*a25439b6SCy Schubert ol_RESOLVER_LIB=ifelse($2,,,$2) 185*a25439b6SCy Schubert ol_LIBS=$LIBS 186*a25439b6SCy Schubert LIBS="$ol_RESOLVER_LIB $LIBS" 187*a25439b6SCy Schubert 188*a25439b6SCy Schubert AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 189*a25439b6SCy Schubert#ifdef HAVE_SYS_TYPES_H 190*a25439b6SCy Schubert# include <sys/types.h> 191*a25439b6SCy Schubert#endif 192*a25439b6SCy Schubert#include <netinet/in.h> 193*a25439b6SCy Schubert#ifdef HAVE_ARPA_NAMESER_H 194*a25439b6SCy Schubert# include <arpa/nameser.h> 195*a25439b6SCy Schubert#endif 196*a25439b6SCy Schubert#ifdef HAVE_RESOLV_H 197*a25439b6SCy Schubert# include <resolv.h> 198*a25439b6SCy Schubert#endif 199*a25439b6SCy Schubert]], [[{ 200*a25439b6SCy Schubert int len, status; 201*a25439b6SCy Schubert char *request = NULL; 202*a25439b6SCy Schubert unsigned char reply[64*1024]; 203*a25439b6SCy Schubert unsigned char host[64*1024]; 204*a25439b6SCy Schubert unsigned char *p; 205*a25439b6SCy Schubert 206*a25439b6SCy Schubert#ifdef NS_HFIXEDSZ 207*a25439b6SCy Schubert /* Bind 8/9 interface */ 208*a25439b6SCy Schubert len = res_query(request, ns_c_in, ns_t_srv, reply, sizeof(reply)); 209*a25439b6SCy Schubert#else 210*a25439b6SCy Schubert /* Bind 4 interface */ 211*a25439b6SCy Schubert# ifndef T_SRV 212*a25439b6SCy Schubert# define T_SRV 33 213*a25439b6SCy Schubert# endif 214*a25439b6SCy Schubert len = res_query(request, C_IN, T_SRV, reply, sizeof(reply)); 215*a25439b6SCy Schubert#endif 216*a25439b6SCy Schubert p = reply; 217*a25439b6SCy Schubert#ifdef NS_HFIXEDSZ 218*a25439b6SCy Schubert /* Bind 8/9 interface */ 219*a25439b6SCy Schubert p += NS_HFIXEDSZ; 220*a25439b6SCy Schubert#elif defined(HFIXEDSZ) 221*a25439b6SCy Schubert /* Bind 4 interface w/ HFIXEDSZ */ 222*a25439b6SCy Schubert p += HFIXEDSZ; 223*a25439b6SCy Schubert#else 224*a25439b6SCy Schubert /* Bind 4 interface w/o HFIXEDSZ */ 225*a25439b6SCy Schubert p += sizeof(HEADER); 226*a25439b6SCy Schubert#endif 227*a25439b6SCy Schubert status = dn_expand( reply, reply+len, p, host, sizeof(host)); 228*a25439b6SCy Schubert}]])],[$1=yes],[$1=no]) 229*a25439b6SCy Schubert 230*a25439b6SCy Schubert LIBS="$ol_LIBS" 231*a25439b6SCy Schubert]) 232*a25439b6SCy Schubert 233*a25439b6SCy Schubert if test $$1 = yes ; then 234*a25439b6SCy Schubert ol_cv_lib_resolver=ifelse($2,,yes,$2) 235*a25439b6SCy Schubert fi 236*a25439b6SCy Schubertfi 237*a25439b6SCy Schubert]) 238*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 239*a25439b6SCy Schubertdnl Try to locate appropriate library 240*a25439b6SCy SchubertAC_DEFUN([OL_RESOLVER_LINK], 241*a25439b6SCy Schubert[ol_cv_lib_resolver=no 242*a25439b6SCy SchubertOL_RESOLVER_TRY(ol_cv_resolver_none) 243*a25439b6SCy SchubertOL_RESOLVER_TRY(ol_cv_resolver_resolv,[-lresolv]) 244*a25439b6SCy SchubertOL_RESOLVER_TRY(ol_cv_resolver_bind,[-lbind]) 245*a25439b6SCy Schubert]) 246*a25439b6SCy Schubertdnl 247*a25439b6SCy Schubertdnl ==================================================================== 248*a25439b6SCy Schubertdnl International Components for Unicode (ICU) 249*a25439b6SCy SchubertAC_DEFUN([OL_ICU], 250*a25439b6SCy Schubert[ol_icu=no 251*a25439b6SCy SchubertAC_CHECK_HEADERS( unicode/utypes.h ) 252*a25439b6SCy Schubertif test $ac_cv_header_unicode_utypes_h = yes ; then 253*a25439b6SCy Schubert dnl OL_ICULIBS="-licui18n -licuuc -licudata" 254*a25439b6SCy Schubert OL_ICULIBS="-licuuc -licudata" 255*a25439b6SCy Schubert 256*a25439b6SCy Schubert AC_CACHE_CHECK([for ICU libraries], [ol_cv_lib_icu], [ 257*a25439b6SCy Schubert ol_LIBS="$LIBS" 258*a25439b6SCy Schubert LIBS="$OL_ICULIBS $LIBS" 259*a25439b6SCy Schubert AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 260*a25439b6SCy Schubert#include <unicode/utypes.h> 261*a25439b6SCy Schubert]], [[ 262*a25439b6SCy Schubert(void) u_errorName(0); 263*a25439b6SCy Schubert]])],[ol_cv_lib_icu=yes],[ol_cv_lib_icu=no]) 264*a25439b6SCy Schubert LIBS="$ol_LIBS" 265*a25439b6SCy Schubert]) 266*a25439b6SCy Schubert 267*a25439b6SCy Schubert if test $ol_cv_lib_icu != no ; then 268*a25439b6SCy Schubert ol_icu="$OL_ICULIBS" 269*a25439b6SCy Schubert AC_DEFINE([HAVE_ICU], [1], [define if you actually have ICU]) 270*a25439b6SCy Schubert fi 271*a25439b6SCy Schubertfi 272*a25439b6SCy Schubert]) 273*a25439b6SCy Schubertdnl 274*a25439b6SCy Schubertdnl ==================================================================== 275*a25439b6SCy Schubertdnl Berkeley DB macros 276*a25439b6SCy Schubertdnl 277*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 278*a25439b6SCy Schubertdnl Try to link 279*a25439b6SCy SchubertAC_DEFUN([OL_BERKELEY_DB_TRY], 280*a25439b6SCy Schubert[if test $ol_cv_lib_db = no ; then 281*a25439b6SCy Schubert AC_CACHE_CHECK([for Berkeley DB link (]ifelse($2,,default,$2)[)],[$1], 282*a25439b6SCy Schubert[ 283*a25439b6SCy Schubert ol_DB_LIB=ifelse($2,,,$2) 284*a25439b6SCy Schubert ol_LIBS=$LIBS 285*a25439b6SCy Schubert LIBS="$ol_DB_LIB $LTHREAD_LIBS $LIBS" 286*a25439b6SCy Schubert 287*a25439b6SCy Schubert AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 288*a25439b6SCy Schubert#ifdef HAVE_DB_185_H 289*a25439b6SCy Schubert# include <db_185.h> 290*a25439b6SCy Schubert#else 291*a25439b6SCy Schubert# include <db.h> 292*a25439b6SCy Schubert#endif 293*a25439b6SCy Schubert 294*a25439b6SCy Schubert#ifndef DB_VERSION_MAJOR 295*a25439b6SCy Schubert# define DB_VERSION_MAJOR 1 296*a25439b6SCy Schubert#endif 297*a25439b6SCy Schubert 298*a25439b6SCy Schubert#ifndef NULL 299*a25439b6SCy Schubert#define NULL ((void*)0) 300*a25439b6SCy Schubert#endif 301*a25439b6SCy Schubert]], [[ 302*a25439b6SCy Schubert#if DB_VERSION_MAJOR > 2 303*a25439b6SCy Schubert db_env_create( NULL, 0 ); 304*a25439b6SCy Schubert#elif DB_VERSION_MAJOR > 1 305*a25439b6SCy Schubert db_appexit( NULL ); 306*a25439b6SCy Schubert#else 307*a25439b6SCy Schubert (void) dbopen( NULL, 0, 0, 0, NULL); 308*a25439b6SCy Schubert#endif 309*a25439b6SCy Schubert]])],[$1=yes],[$1=no]) 310*a25439b6SCy Schubert 311*a25439b6SCy Schubert LIBS="$ol_LIBS" 312*a25439b6SCy Schubert]) 313*a25439b6SCy Schubert 314*a25439b6SCy Schubert if test $$1 = yes ; then 315*a25439b6SCy Schubert ol_cv_lib_db=ifelse($2,,yes,$2) 316*a25439b6SCy Schubert fi 317*a25439b6SCy Schubertfi 318*a25439b6SCy Schubert]) 319*a25439b6SCy Schubertdnl 320*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 321*a25439b6SCy Schubertdnl Get major and minor version from <db.h> 322*a25439b6SCy SchubertAC_DEFUN([OL_BDB_HEADER_VERSION], 323*a25439b6SCy Schubert[AC_CACHE_CHECK([for Berkeley DB major version in db.h], [ol_cv_bdb_major],[ 324*a25439b6SCy Schubert AC_LANG_CONFTEST([ 325*a25439b6SCy Schubert#include <db.h> 326*a25439b6SCy Schubert#ifndef DB_VERSION_MAJOR 327*a25439b6SCy Schubert# define DB_VERSION_MAJOR 1 328*a25439b6SCy Schubert#endif 329*a25439b6SCy Schubert__db_version DB_VERSION_MAJOR 330*a25439b6SCy Schubert]) 331*a25439b6SCy Schubert set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none 332*a25439b6SCy Schubert ol_cv_bdb_major=${3} 333*a25439b6SCy Schubert]) 334*a25439b6SCy Schubertcase $ol_cv_bdb_major in [[1-9]]*) : ;; *) 335*a25439b6SCy Schubert AC_MSG_ERROR([Unknown Berkeley DB major version in db.h]) ;; 336*a25439b6SCy Schubertesac 337*a25439b6SCy Schubert 338*a25439b6SCy Schubertdnl Determine minor version 339*a25439b6SCy SchubertAC_CACHE_CHECK([for Berkeley DB minor version in db.h], [ol_cv_bdb_minor],[ 340*a25439b6SCy Schubert AC_LANG_CONFTEST([ 341*a25439b6SCy Schubert#include <db.h> 342*a25439b6SCy Schubert#ifndef DB_VERSION_MINOR 343*a25439b6SCy Schubert# define DB_VERSION_MINOR 0 344*a25439b6SCy Schubert#endif 345*a25439b6SCy Schubert__db_version DB_VERSION_MINOR 346*a25439b6SCy Schubert]) 347*a25439b6SCy Schubert set X `eval "$ac_cpp conftest.$ac_ext" | $EGREP __db_version` none none 348*a25439b6SCy Schubert ol_cv_bdb_minor=${3} 349*a25439b6SCy Schubert]) 350*a25439b6SCy Schubertcase $ol_cv_bdb_minor in [[0-9]]*) : ;; *) 351*a25439b6SCy Schubert AC_MSG_ERROR([Unknown Berkeley DB minor version in db.h]) ;; 352*a25439b6SCy Schubertesac 353*a25439b6SCy Schubert]) 354*a25439b6SCy Schubertdnl 355*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 356*a25439b6SCy Schubertdnl Try to locate appropriate library 357*a25439b6SCy SchubertAC_DEFUN([OL_BERKELEY_DB_LINK], 358*a25439b6SCy Schubert[ol_cv_lib_db=no 359*a25439b6SCy Schubert 360*a25439b6SCy Schubertif test $ol_cv_bdb_major = 4 ; then 361*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db_4_dot_m,[-ldb-4.$ol_cv_bdb_minor]) 362*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db4m,[-ldb4$ol_cv_bdb_minor]) 363*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db_4m,[-ldb-4$ol_cv_bdb_minor]) 364*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db_4_m,[-ldb-4-$ol_cv_bdb_minor]) 365*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db_4,[-ldb-4]) 366*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db4,[-ldb4]) 367*a25439b6SCy Schubert OL_BERKELEY_DB_TRY(ol_cv_db_db,[-ldb]) 368*a25439b6SCy Schubertfi 369*a25439b6SCy SchubertOL_BERKELEY_DB_TRY(ol_cv_db_none) 370*a25439b6SCy Schubert]) 371*a25439b6SCy Schubertdnl 372*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 373*a25439b6SCy Schubertdnl Check if Berkeley DB version 374*a25439b6SCy SchubertAC_DEFUN([OL_BERKELEY_DB_VERSION], 375*a25439b6SCy Schubert[AC_CACHE_CHECK([for Berkeley DB library and header version match], [ol_cv_berkeley_db_version], [ 376*a25439b6SCy Schubert ol_LIBS="$LIBS" 377*a25439b6SCy Schubert LIBS="$LTHREAD_LIBS $LIBS" 378*a25439b6SCy Schubert if test $ol_cv_lib_db != yes ; then 379*a25439b6SCy Schubert LIBS="$ol_cv_lib_db $LIBS" 380*a25439b6SCy Schubert fi 381*a25439b6SCy Schubert 382*a25439b6SCy Schubert AC_RUN_IFELSE([AC_LANG_SOURCE([[ 383*a25439b6SCy Schubert#ifdef HAVE_DB_185_H 384*a25439b6SCy Schubert choke me; 385*a25439b6SCy Schubert#else 386*a25439b6SCy Schubert#include <db.h> 387*a25439b6SCy Schubert#endif 388*a25439b6SCy Schubert#ifndef DB_VERSION_MAJOR 389*a25439b6SCy Schubert# define DB_VERSION_MAJOR 1 390*a25439b6SCy Schubert#endif 391*a25439b6SCy Schubert#ifndef NULL 392*a25439b6SCy Schubert#define NULL ((void *)0) 393*a25439b6SCy Schubert#endif 394*a25439b6SCy Schubertmain() 395*a25439b6SCy Schubert{ 396*a25439b6SCy Schubert#if DB_VERSION_MAJOR > 1 397*a25439b6SCy Schubert char *version; 398*a25439b6SCy Schubert int major, minor, patch; 399*a25439b6SCy Schubert 400*a25439b6SCy Schubert version = db_version( &major, &minor, &patch ); 401*a25439b6SCy Schubert 402*a25439b6SCy Schubert if( major != DB_VERSION_MAJOR || 403*a25439b6SCy Schubert minor != DB_VERSION_MINOR || 404*a25439b6SCy Schubert patch != DB_VERSION_PATCH ) 405*a25439b6SCy Schubert { 406*a25439b6SCy Schubert printf("Berkeley DB version mismatch\n" 407*a25439b6SCy Schubert "\theader: %s\n\tlibrary: %s\n", 408*a25439b6SCy Schubert DB_VERSION_STRING, version); 409*a25439b6SCy Schubert return 1; 410*a25439b6SCy Schubert } 411*a25439b6SCy Schubert#endif 412*a25439b6SCy Schubert 413*a25439b6SCy Schubert return 0; 414*a25439b6SCy Schubert}]])],[ol_cv_berkeley_db_version=yes],[ol_cv_berkeley_db_version=no],[ol_cv_berkeley_db_version=cross]) 415*a25439b6SCy Schubert 416*a25439b6SCy Schubert LIBS="$ol_LIBS" 417*a25439b6SCy Schubert]) 418*a25439b6SCy Schubert 419*a25439b6SCy Schubert if test $ol_cv_berkeley_db_version = no ; then 420*a25439b6SCy Schubert AC_MSG_ERROR([Berkeley DB version mismatch]) 421*a25439b6SCy Schubert fi 422*a25439b6SCy Schubert])dnl 423*a25439b6SCy Schubertdnl 424*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 425*a25439b6SCy Schubertdnl Check if Berkeley DB supports DB_THREAD 426*a25439b6SCy SchubertAC_DEFUN([OL_BERKELEY_DB_THREAD], 427*a25439b6SCy Schubert[AC_CACHE_CHECK([for Berkeley DB thread support], [ol_cv_berkeley_db_thread], [ 428*a25439b6SCy Schubert ol_LIBS="$LIBS" 429*a25439b6SCy Schubert LIBS="$LTHREAD_LIBS $LIBS" 430*a25439b6SCy Schubert if test $ol_cv_lib_db != yes ; then 431*a25439b6SCy Schubert LIBS="$ol_cv_lib_db $LIBS" 432*a25439b6SCy Schubert fi 433*a25439b6SCy Schubert 434*a25439b6SCy Schubert AC_RUN_IFELSE([AC_LANG_SOURCE([[ 435*a25439b6SCy Schubert#ifdef HAVE_DB_185_H 436*a25439b6SCy Schubert choke me; 437*a25439b6SCy Schubert#else 438*a25439b6SCy Schubert#include <db.h> 439*a25439b6SCy Schubert#endif 440*a25439b6SCy Schubert#ifndef NULL 441*a25439b6SCy Schubert#define NULL ((void *)0) 442*a25439b6SCy Schubert#endif 443*a25439b6SCy Schubertmain() 444*a25439b6SCy Schubert{ 445*a25439b6SCy Schubert int rc; 446*a25439b6SCy Schubert u_int32_t flags = DB_CREATE | 447*a25439b6SCy Schubert#ifdef DB_PRIVATE 448*a25439b6SCy Schubert DB_PRIVATE | 449*a25439b6SCy Schubert#endif 450*a25439b6SCy Schubert DB_THREAD; 451*a25439b6SCy Schubert 452*a25439b6SCy Schubert#if DB_VERSION_MAJOR > 2 453*a25439b6SCy Schubert DB_ENV *env = NULL; 454*a25439b6SCy Schubert 455*a25439b6SCy Schubert rc = db_env_create( &env, 0 ); 456*a25439b6SCy Schubert 457*a25439b6SCy Schubert flags |= DB_INIT_MPOOL; 458*a25439b6SCy Schubert#ifdef DB_MPOOL_PRIVATE 459*a25439b6SCy Schubert flags |= DB_MPOOL_PRIVATE; 460*a25439b6SCy Schubert#endif 461*a25439b6SCy Schubert 462*a25439b6SCy Schubert if( rc ) { 463*a25439b6SCy Schubert printf("BerkeleyDB: %s\n", db_strerror(rc) ); 464*a25439b6SCy Schubert return rc; 465*a25439b6SCy Schubert } 466*a25439b6SCy Schubert 467*a25439b6SCy Schubert#if (DB_VERSION_MAJOR > 3) || (DB_VERSION_MINOR >= 1) 468*a25439b6SCy Schubert rc = (env->open)( env, NULL, flags, 0 ); 469*a25439b6SCy Schubert#else 470*a25439b6SCy Schubert rc = (env->open)( env, NULL, NULL, flags, 0 ); 471*a25439b6SCy Schubert#endif 472*a25439b6SCy Schubert 473*a25439b6SCy Schubert if ( rc == 0 ) { 474*a25439b6SCy Schubert rc = env->close( env, 0 ); 475*a25439b6SCy Schubert } 476*a25439b6SCy Schubert 477*a25439b6SCy Schubert if( rc ) { 478*a25439b6SCy Schubert printf("BerkeleyDB: %s\n", db_strerror(rc) ); 479*a25439b6SCy Schubert return rc; 480*a25439b6SCy Schubert } 481*a25439b6SCy Schubert 482*a25439b6SCy Schubert#else 483*a25439b6SCy Schubert DB_ENV env; 484*a25439b6SCy Schubert memset( &env, '\0', sizeof(env) ); 485*a25439b6SCy Schubert 486*a25439b6SCy Schubert rc = db_appinit( NULL, NULL, &env, flags ); 487*a25439b6SCy Schubert 488*a25439b6SCy Schubert if( rc == 0 ) { 489*a25439b6SCy Schubert db_appexit( &env ); 490*a25439b6SCy Schubert } 491*a25439b6SCy Schubert 492*a25439b6SCy Schubert unlink("__db_mpool.share"); 493*a25439b6SCy Schubert unlink("__db_lock.share"); 494*a25439b6SCy Schubert#endif 495*a25439b6SCy Schubert 496*a25439b6SCy Schubert return rc; 497*a25439b6SCy Schubert}]])],[ol_cv_berkeley_db_thread=yes],[ol_cv_berkeley_db_thread=no],[ol_cv_berkeley_db_thread=cross]) 498*a25439b6SCy Schubert 499*a25439b6SCy Schubert LIBS="$ol_LIBS" 500*a25439b6SCy Schubert]) 501*a25439b6SCy Schubert 502*a25439b6SCy Schubert if test $ol_cv_berkeley_db_thread != no ; then 503*a25439b6SCy Schubert AC_DEFINE([HAVE_BERKELEY_DB_THREAD], [1], 504*a25439b6SCy Schubert [define if Berkeley DB has DB_THREAD support]) 505*a25439b6SCy Schubert fi 506*a25439b6SCy Schubert])dnl 507*a25439b6SCy Schubertdnl 508*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 509*a25439b6SCy Schubertdnl Find any DB 510*a25439b6SCy SchubertAC_DEFUN([OL_BERKELEY_DB], 511*a25439b6SCy Schubert[ol_cv_berkeley_db=no 512*a25439b6SCy SchubertAC_CHECK_HEADERS(db.h) 513*a25439b6SCy Schubertif test $ac_cv_header_db_h = yes; then 514*a25439b6SCy Schubert OL_BDB_HEADER_VERSION 515*a25439b6SCy Schubert OL_BDB_COMPAT 516*a25439b6SCy Schubert 517*a25439b6SCy Schubert if test $ol_cv_bdb_compat != yes ; then 518*a25439b6SCy Schubert AC_MSG_ERROR([BerkeleyDB version incompatible with BDB/HDB backends]) 519*a25439b6SCy Schubert fi 520*a25439b6SCy Schubert 521*a25439b6SCy Schubert OL_BERKELEY_DB_LINK 522*a25439b6SCy Schubert if test "$ol_cv_lib_db" != no ; then 523*a25439b6SCy Schubert ol_cv_berkeley_db=yes 524*a25439b6SCy Schubert OL_BERKELEY_DB_VERSION 525*a25439b6SCy Schubert OL_BERKELEY_DB_THREAD 526*a25439b6SCy Schubert fi 527*a25439b6SCy Schubertfi 528*a25439b6SCy Schubert]) 529*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 530*a25439b6SCy Schubertdnl Check for version compatility with back-bdb 531*a25439b6SCy SchubertAC_DEFUN([OL_BDB_COMPAT], 532*a25439b6SCy Schubert[AC_CACHE_CHECK([if Berkeley DB version supported by BDB/HDB backends], [ol_cv_bdb_compat],[ 533*a25439b6SCy Schubert AC_EGREP_CPP(__db_version_compat,[ 534*a25439b6SCy Schubert#include <db.h> 535*a25439b6SCy Schubert 536*a25439b6SCy Schubert /* this check could be improved */ 537*a25439b6SCy Schubert#ifndef DB_VERSION_MAJOR 538*a25439b6SCy Schubert# define DB_VERSION_MAJOR 1 539*a25439b6SCy Schubert#endif 540*a25439b6SCy Schubert#ifndef DB_VERSION_MINOR 541*a25439b6SCy Schubert# define DB_VERSION_MINOR 0 542*a25439b6SCy Schubert#endif 543*a25439b6SCy Schubert 544*a25439b6SCy Schubert#define DB_VERSION_MM ((DB_VERSION_MAJOR<<8)|DB_VERSION_MINOR) 545*a25439b6SCy Schubert 546*a25439b6SCy Schubert/* require 4.4 or later */ 547*a25439b6SCy Schubert#if DB_VERSION_MM >= 0x0404 548*a25439b6SCy Schubert __db_version_compat 549*a25439b6SCy Schubert#endif 550*a25439b6SCy Schubert ], [ol_cv_bdb_compat=yes], [ol_cv_bdb_compat=no])]) 551*a25439b6SCy Schubert]) 552*a25439b6SCy Schubert 553*a25439b6SCy Schubertdnl 554*a25439b6SCy Schubertdnl ==================================================================== 555*a25439b6SCy Schubertdnl Check POSIX Thread version 556*a25439b6SCy Schubertdnl 557*a25439b6SCy Schubertdnl defines ol_cv_pthread_version to 4, 5, 6, 7, 8, 10, depending on the 558*a25439b6SCy Schubertdnl version of the POSIX.4a Draft that is implemented. 559*a25439b6SCy Schubertdnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes. 560*a25439b6SCy Schubertdnl Existence of pthread.h should be tested separately. 561*a25439b6SCy Schubertdnl 562*a25439b6SCy Schubertdnl tests: 563*a25439b6SCy Schubertdnl pthread_detach() was dropped in Draft 8, it is present 564*a25439b6SCy Schubertdnl in every other version 565*a25439b6SCy Schubertdnl PTHREAD_CREATE_UNDETACHED is only in Draft 7, it was called 566*a25439b6SCy Schubertdnl PTHREAD_CREATE_JOINABLE after that 567*a25439b6SCy Schubertdnl pthread_attr_create was renamed to pthread_attr_init in Draft 6. 568*a25439b6SCy Schubertdnl Draft 6-10 has _init, Draft 4-5 has _create. 569*a25439b6SCy Schubertdnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it 570*a25439b6SCy Schubertdnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not 571*a25439b6SCy Schubertdnl interesting to us because we don't try to statically 572*a25439b6SCy Schubertdnl initialize mutexes. 5-10 has it. 573*a25439b6SCy Schubertdnl 574*a25439b6SCy Schubertdnl Draft 9 and 10 are equivalent for our purposes. 575*a25439b6SCy Schubertdnl 576*a25439b6SCy SchubertAC_DEFUN([OL_POSIX_THREAD_VERSION], 577*a25439b6SCy Schubert[AC_CACHE_CHECK([POSIX thread version],[ol_cv_pthread_version],[ 578*a25439b6SCy Schubert AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 579*a25439b6SCy Schubert# include <pthread.h> 580*a25439b6SCy Schubert ]], [[ 581*a25439b6SCy Schubert int i = PTHREAD_CREATE_JOINABLE; 582*a25439b6SCy Schubert ]])],[ 583*a25439b6SCy Schubert AC_EGREP_HEADER(pthread_detach,pthread.h, 584*a25439b6SCy Schubert ol_cv_pthread_version=10, ol_cv_pthread_version=8)],[ 585*a25439b6SCy Schubert AC_EGREP_CPP(draft7,[ 586*a25439b6SCy Schubert# include <pthread.h> 587*a25439b6SCy Schubert# ifdef PTHREAD_CREATE_UNDETACHED 588*a25439b6SCy Schubert draft7 589*a25439b6SCy Schubert# endif 590*a25439b6SCy Schubert ], ol_cv_pthread_version=7, [ 591*a25439b6SCy Schubert AC_EGREP_HEADER(pthread_attr_init,pthread.h, 592*a25439b6SCy Schubert ol_cv_pthread_version=6, [ 593*a25439b6SCy Schubert AC_EGREP_CPP(draft5,[ 594*a25439b6SCy Schubert# include <pthread.h> 595*a25439b6SCy Schubert#ifdef PTHREAD_MUTEX_INITIALIZER 596*a25439b6SCy Schubert draft5 597*a25439b6SCy Schubert#endif 598*a25439b6SCy Schubert ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ]) ]) ]) 599*a25439b6SCy Schubert]) 600*a25439b6SCy Schubert])dnl 601*a25439b6SCy Schubertdnl 602*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 603*a25439b6SCy SchubertAC_DEFUN([OL_PTHREAD_TEST_INCLUDES], [[ 604*a25439b6SCy Schubert/* pthread test headers */ 605*a25439b6SCy Schubert#include <pthread.h> 606*a25439b6SCy Schubert#if HAVE_PTHREADS < 7 607*a25439b6SCy Schubert#include <errno.h> 608*a25439b6SCy Schubert#endif 609*a25439b6SCy Schubert#ifndef NULL 610*a25439b6SCy Schubert#define NULL (void*)0 611*a25439b6SCy Schubert#endif 612*a25439b6SCy Schubert 613*a25439b6SCy Schubertstatic void *task(p) 614*a25439b6SCy Schubert void *p; 615*a25439b6SCy Schubert{ 616*a25439b6SCy Schubert return (void *) (p == NULL); 617*a25439b6SCy Schubert} 618*a25439b6SCy Schubert]]) 619*a25439b6SCy SchubertAC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[ 620*a25439b6SCy Schubert /* pthread test function */ 621*a25439b6SCy Schubert#ifndef PTHREAD_CREATE_DETACHED 622*a25439b6SCy Schubert#define PTHREAD_CREATE_DETACHED 1 623*a25439b6SCy Schubert#endif 624*a25439b6SCy Schubert pthread_t t; 625*a25439b6SCy Schubert int status; 626*a25439b6SCy Schubert int detach = PTHREAD_CREATE_DETACHED; 627*a25439b6SCy Schubert 628*a25439b6SCy Schubert#if HAVE_PTHREADS > 4 629*a25439b6SCy Schubert /* Final pthreads */ 630*a25439b6SCy Schubert pthread_attr_t attr; 631*a25439b6SCy Schubert 632*a25439b6SCy Schubert status = pthread_attr_init(&attr); 633*a25439b6SCy Schubert if( status ) return status; 634*a25439b6SCy Schubert 635*a25439b6SCy Schubert#if HAVE_PTHREADS < 7 636*a25439b6SCy Schubert status = pthread_attr_setdetachstate(&attr, &detach); 637*a25439b6SCy Schubert if( status < 0 ) status = errno; 638*a25439b6SCy Schubert#else 639*a25439b6SCy Schubert status = pthread_attr_setdetachstate(&attr, detach); 640*a25439b6SCy Schubert#endif 641*a25439b6SCy Schubert if( status ) return status; 642*a25439b6SCy Schubert status = pthread_create( &t, &attr, task, NULL ); 643*a25439b6SCy Schubert#if HAVE_PTHREADS < 7 644*a25439b6SCy Schubert if( status < 0 ) status = errno; 645*a25439b6SCy Schubert#endif 646*a25439b6SCy Schubert if( status ) return status; 647*a25439b6SCy Schubert#else 648*a25439b6SCy Schubert /* Draft 4 pthreads */ 649*a25439b6SCy Schubert status = pthread_create( &t, pthread_attr_default, task, NULL ); 650*a25439b6SCy Schubert if( status ) return errno; 651*a25439b6SCy Schubert 652*a25439b6SCy Schubert /* give thread a chance to complete */ 653*a25439b6SCy Schubert /* it should remain joinable and hence detachable */ 654*a25439b6SCy Schubert sleep( 1 ); 655*a25439b6SCy Schubert 656*a25439b6SCy Schubert status = pthread_detach( &t ); 657*a25439b6SCy Schubert if( status ) return errno; 658*a25439b6SCy Schubert#endif 659*a25439b6SCy Schubert 660*a25439b6SCy Schubert#ifdef HAVE_LINUX_THREADS 661*a25439b6SCy Schubert pthread_kill_other_threads_np(); 662*a25439b6SCy Schubert#endif 663*a25439b6SCy Schubert 664*a25439b6SCy Schubert return 0; 665*a25439b6SCy Schubert]]) 666*a25439b6SCy Schubert 667*a25439b6SCy SchubertAC_DEFUN([OL_PTHREAD_TEST_PROGRAM], [ 668*a25439b6SCy SchubertAC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES 669*a25439b6SCy Schubert 670*a25439b6SCy Schubertint main(argc, argv) 671*a25439b6SCy Schubert int argc; 672*a25439b6SCy Schubert char **argv; 673*a25439b6SCy Schubert{ 674*a25439b6SCy SchubertOL_PTHREAD_TEST_FUNCTION 675*a25439b6SCy Schubert} 676*a25439b6SCy Schubert])]) 677*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 678*a25439b6SCy SchubertAC_DEFUN([OL_PTHREAD_TRY], [# Pthread try link: $1 ($2) 679*a25439b6SCy Schubertif test "$ol_link_threads" = no ; then 680*a25439b6SCy Schubert # try $1 681*a25439b6SCy Schubert AC_CACHE_CHECK([for pthread link with $1], [$2], [ 682*a25439b6SCy Schubert # save the flags 683*a25439b6SCy Schubert ol_LIBS="$LIBS" 684*a25439b6SCy Schubert LIBS="$1 $LIBS" 685*a25439b6SCy Schubert 686*a25439b6SCy Schubert AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM], 687*a25439b6SCy Schubert [$2=yes], 688*a25439b6SCy Schubert [$2=no], 689*a25439b6SCy Schubert [AC_LINK_IFELSE([AC_LANG_PROGRAM(OL_PTHREAD_TEST_INCLUDES, 690*a25439b6SCy Schubert OL_PTHREAD_TEST_FUNCTION)], 691*a25439b6SCy Schubert [$2=yes], [$2=no])]) 692*a25439b6SCy Schubert 693*a25439b6SCy Schubert # restore the LIBS 694*a25439b6SCy Schubert LIBS="$ol_LIBS" 695*a25439b6SCy Schubert ]) 696*a25439b6SCy Schubert 697*a25439b6SCy Schubert if test $$2 = yes ; then 698*a25439b6SCy Schubert ol_link_pthreads="$1" 699*a25439b6SCy Schubert ol_link_threads=posix 700*a25439b6SCy Schubert fi 701*a25439b6SCy Schubertfi 702*a25439b6SCy Schubert]) 703*a25439b6SCy Schubertdnl 704*a25439b6SCy Schubertdnl ==================================================================== 705*a25439b6SCy Schubertdnl Check GNU Pth pthread Header 706*a25439b6SCy Schubertdnl 707*a25439b6SCy Schubertdnl defines ol_cv_header linux_threads to 'yes' or 'no' 708*a25439b6SCy Schubertdnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h 709*a25439b6SCy Schubertdnl doesn't exists. Existance of pthread.h should separately 710*a25439b6SCy Schubertdnl checked. 711*a25439b6SCy Schubertdnl 712*a25439b6SCy SchubertAC_DEFUN([OL_HEADER_GNU_PTH_PTHREAD_H], [ 713*a25439b6SCy Schubert AC_CACHE_CHECK([for GNU Pth pthread.h], 714*a25439b6SCy Schubert [ol_cv_header_gnu_pth_pthread_h], 715*a25439b6SCy Schubert [AC_EGREP_CPP(__gnu_pth__, 716*a25439b6SCy Schubert [#include <pthread.h> 717*a25439b6SCy Schubert#ifdef _POSIX_THREAD_IS_GNU_PTH 718*a25439b6SCy Schubert __gnu_pth__; 719*a25439b6SCy Schubert#endif 720*a25439b6SCy Schubert], 721*a25439b6SCy Schubert [ol_cv_header_gnu_pth_pthread_h=yes], 722*a25439b6SCy Schubert [ol_cv_header_gnu_pth_pthread_h=no]) 723*a25439b6SCy Schubert ]) 724*a25439b6SCy Schubert])dnl 725*a25439b6SCy Schubertdnl ==================================================================== 726*a25439b6SCy Schubertdnl Check for NT Threads 727*a25439b6SCy SchubertAC_DEFUN([OL_NT_THREADS], [ 728*a25439b6SCy Schubert AC_CHECK_FUNC(_beginthread) 729*a25439b6SCy Schubert 730*a25439b6SCy Schubert if test $ac_cv_func__beginthread = yes ; then 731*a25439b6SCy Schubert AC_DEFINE([HAVE_NT_THREADS], [1], [if you have NT Threads]) 732*a25439b6SCy Schubert ol_cv_nt_threads=yes 733*a25439b6SCy Schubert fi 734*a25439b6SCy Schubert]) 735*a25439b6SCy Schubertdnl ==================================================================== 736*a25439b6SCy Schubertdnl Check LinuxThreads Header 737*a25439b6SCy Schubertdnl 738*a25439b6SCy Schubertdnl defines ol_cv_header linux_threads to 'yes' or 'no' 739*a25439b6SCy Schubertdnl 'no' implies pthreads.h is not LinuxThreads or pthreads.h 740*a25439b6SCy Schubertdnl doesn't exists. Existance of pthread.h should separately 741*a25439b6SCy Schubertdnl checked. 742*a25439b6SCy Schubertdnl 743*a25439b6SCy SchubertAC_DEFUN([OL_HEADER_LINUX_THREADS], [ 744*a25439b6SCy Schubert AC_CACHE_CHECK([for LinuxThreads pthread.h], 745*a25439b6SCy Schubert [ol_cv_header_linux_threads], 746*a25439b6SCy Schubert [AC_EGREP_CPP(pthread_kill_other_threads_np, 747*a25439b6SCy Schubert [#include <pthread.h>], 748*a25439b6SCy Schubert [ol_cv_header_linux_threads=yes], 749*a25439b6SCy Schubert [ol_cv_header_linux_threads=no]) 750*a25439b6SCy Schubert ]) 751*a25439b6SCy Schubert if test $ol_cv_header_linux_threads = yes; then 752*a25439b6SCy Schubert AC_DEFINE([HAVE_LINUX_THREADS], [1], [if you have LinuxThreads]) 753*a25439b6SCy Schubert fi 754*a25439b6SCy Schubert])dnl 755*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 756*a25439b6SCy Schubertdnl Check LinuxThreads Implementation 757*a25439b6SCy Schubertdnl 758*a25439b6SCy Schubertdnl defines ol_cv_sys_linux_threads to 'yes' or 'no' 759*a25439b6SCy Schubertdnl 'no' implies pthreads implementation is not LinuxThreads. 760*a25439b6SCy Schubertdnl 761*a25439b6SCy SchubertAC_DEFUN([OL_SYS_LINUX_THREADS], [ 762*a25439b6SCy Schubert AC_CHECK_FUNCS(pthread_kill_other_threads_np) 763*a25439b6SCy Schubert AC_CACHE_CHECK([for LinuxThreads implementation], 764*a25439b6SCy Schubert [ol_cv_sys_linux_threads], 765*a25439b6SCy Schubert [ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np]) 766*a25439b6SCy Schubert])dnl 767*a25439b6SCy Schubertdnl 768*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 769*a25439b6SCy Schubertdnl Check LinuxThreads consistency 770*a25439b6SCy SchubertAC_DEFUN([OL_LINUX_THREADS], [ 771*a25439b6SCy Schubert AC_REQUIRE([OL_HEADER_LINUX_THREADS]) 772*a25439b6SCy Schubert AC_REQUIRE([OL_SYS_LINUX_THREADS]) 773*a25439b6SCy Schubert AC_CACHE_CHECK([for LinuxThreads consistency], [ol_cv_linux_threads], [ 774*a25439b6SCy Schubert if test $ol_cv_header_linux_threads = yes && 775*a25439b6SCy Schubert test $ol_cv_sys_linux_threads = yes; then 776*a25439b6SCy Schubert ol_cv_linux_threads=yes 777*a25439b6SCy Schubert elif test $ol_cv_header_linux_threads = no && 778*a25439b6SCy Schubert test $ol_cv_sys_linux_threads = no; then 779*a25439b6SCy Schubert ol_cv_linux_threads=no 780*a25439b6SCy Schubert else 781*a25439b6SCy Schubert ol_cv_linux_threads=error 782*a25439b6SCy Schubert fi 783*a25439b6SCy Schubert ]) 784*a25439b6SCy Schubert])dnl 785*a25439b6SCy Schubertdnl 786*a25439b6SCy Schubertdnl ==================================================================== 787*a25439b6SCy Schubertdnl Check for POSIX Regex 788*a25439b6SCy SchubertAC_DEFUN([OL_POSIX_REGEX], [ 789*a25439b6SCy SchubertAC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[ 790*a25439b6SCy Schubert AC_RUN_IFELSE([AC_LANG_SOURCE([[ 791*a25439b6SCy Schubert#include <sys/types.h> 792*a25439b6SCy Schubert#include <regex.h> 793*a25439b6SCy Schubertstatic char *pattern, *string; 794*a25439b6SCy Schubertmain() 795*a25439b6SCy Schubert{ 796*a25439b6SCy Schubert int rc; 797*a25439b6SCy Schubert regex_t re; 798*a25439b6SCy Schubert 799*a25439b6SCy Schubert pattern = "^A"; 800*a25439b6SCy Schubert 801*a25439b6SCy Schubert if(regcomp(&re, pattern, 0)) { 802*a25439b6SCy Schubert return -1; 803*a25439b6SCy Schubert } 804*a25439b6SCy Schubert 805*a25439b6SCy Schubert string = "ALL MATCH"; 806*a25439b6SCy Schubert 807*a25439b6SCy Schubert rc = regexec(&re, string, 0, (void*)0, 0); 808*a25439b6SCy Schubert 809*a25439b6SCy Schubert regfree(&re); 810*a25439b6SCy Schubert 811*a25439b6SCy Schubert return rc; 812*a25439b6SCy Schubert}]])],[ol_cv_c_posix_regex=yes],[ol_cv_c_posix_regex=no],[ol_cv_c_posix_regex=cross])]) 813*a25439b6SCy Schubert]) 814*a25439b6SCy Schubertdnl 815*a25439b6SCy Schubertdnl ==================================================================== 816*a25439b6SCy Schubertdnl Check if toupper() requires islower() to be called first 817*a25439b6SCy SchubertAC_DEFUN([OL_C_UPPER_LOWER], 818*a25439b6SCy Schubert[AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[ 819*a25439b6SCy Schubert AC_RUN_IFELSE([AC_LANG_SOURCE([[ 820*a25439b6SCy Schubert#include <ctype.h> 821*a25439b6SCy Schubertmain() 822*a25439b6SCy Schubert{ 823*a25439b6SCy Schubert if ('C' == toupper('C')) 824*a25439b6SCy Schubert exit(0); 825*a25439b6SCy Schubert else 826*a25439b6SCy Schubert exit(1); 827*a25439b6SCy Schubert}]])],[ol_cv_c_upper_lower=no],[ol_cv_c_upper_lower=yes],[ol_cv_c_upper_lower=safe])]) 828*a25439b6SCy Schubertif test $ol_cv_c_upper_lower != no ; then 829*a25439b6SCy Schubert AC_DEFINE([C_UPPER_LOWER], [1], [define if toupper() requires islower()]) 830*a25439b6SCy Schubertfi 831*a25439b6SCy Schubert]) 832*a25439b6SCy Schubertdnl 833*a25439b6SCy Schubertdnl ==================================================================== 834*a25439b6SCy Schubertdnl Error string checks 835*a25439b6SCy Schubertdnl 836*a25439b6SCy Schubertdnl Check for declaration of sys_errlist in one of stdio.h and errno.h. 837*a25439b6SCy Schubertdnl Declaration of sys_errlist on BSD4.4 interferes with our declaration. 838*a25439b6SCy Schubertdnl Reported by Keith Bostic. 839*a25439b6SCy SchubertAC_DEFUN([OL_SYS_ERRLIST], 840*a25439b6SCy Schubert[AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[ 841*a25439b6SCy Schubert AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 842*a25439b6SCy Schubert#include <stdio.h> 843*a25439b6SCy Schubert#include <sys/types.h> 844*a25439b6SCy Schubert#include <errno.h> 845*a25439b6SCy Schubert#ifdef _WIN32 846*a25439b6SCy Schubert#include <stdlib.h> 847*a25439b6SCy Schubert#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes 848*a25439b6SCy Schubert ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])]) 849*a25439b6SCy Schubert# 850*a25439b6SCy Schubert# It's possible (for near-UNIX clones) that sys_errlist doesn't exist 851*a25439b6SCy Schubertif test $ol_cv_dcl_sys_errlist = no ; then 852*a25439b6SCy Schubert AC_DEFINE([DECL_SYS_ERRLIST], [1], 853*a25439b6SCy Schubert [define if sys_errlist is not declared in stdio.h or errno.h]) 854*a25439b6SCy Schubert 855*a25439b6SCy Schubert AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[ 856*a25439b6SCy Schubert 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])]) 857*a25439b6SCy Schubertfi 858*a25439b6SCy Schubertif test $ol_cv_have_sys_errlist = yes ; then 859*a25439b6SCy Schubert AC_DEFINE([HAVE_SYS_ERRLIST], [1], 860*a25439b6SCy Schubert [define if you actually have sys_errlist in your libs]) 861*a25439b6SCy Schubertfi 862*a25439b6SCy Schubert])dnl 863*a25439b6SCy SchubertAC_DEFUN([OL_NONPOSIX_STRERROR_R], 864*a25439b6SCy Schubert[AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[ 865*a25439b6SCy Schubert AC_EGREP_CPP(strerror_r,[#include <string.h>], 866*a25439b6SCy Schubert ol_decl_strerror_r=yes, ol_decl_strerror_r=no)dnl 867*a25439b6SCy Schubert 868*a25439b6SCy Schubert if test $ol_decl_strerror_r = yes ; then 869*a25439b6SCy Schubert AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ /* from autoconf 2.59 */ 870*a25439b6SCy Schubert char buf[100]; 871*a25439b6SCy Schubert char x = *strerror_r (0, buf, sizeof buf); 872*a25439b6SCy Schubert char *p = strerror_r (0, buf, sizeof buf); 873*a25439b6SCy Schubert ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no]) 874*a25439b6SCy Schubert else 875*a25439b6SCy Schubert AC_RUN_IFELSE([AC_LANG_SOURCE([[ 876*a25439b6SCy Schubert main() { 877*a25439b6SCy Schubert char buf[100]; 878*a25439b6SCy Schubert buf[0] = 0; 879*a25439b6SCy Schubert strerror_r( 1, buf, sizeof buf ); 880*a25439b6SCy Schubert exit( buf[0] == 0 ); 881*a25439b6SCy Schubert } 882*a25439b6SCy Schubert ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no]) 883*a25439b6SCy Schubert fi 884*a25439b6SCy Schubert ]) 885*a25439b6SCy Schubertif test $ol_cv_nonposix_strerror_r = yes ; then 886*a25439b6SCy Schubert AC_DEFINE([HAVE_NONPOSIX_STRERROR_R], [1], 887*a25439b6SCy Schubert [define if strerror_r returns char* instead of int]) 888*a25439b6SCy Schubertfi 889*a25439b6SCy Schubert])dnl 890*a25439b6SCy Schubertdnl 891*a25439b6SCy SchubertAC_DEFUN([OL_STRERROR], 892*a25439b6SCy Schubert[OL_SYS_ERRLIST dnl TEMPORARY 893*a25439b6SCy SchubertAC_CHECK_FUNCS(strerror strerror_r) 894*a25439b6SCy Schubertol_cv_func_strerror_r=no 895*a25439b6SCy Schubertif test "${ac_cv_func_strerror_r}" = yes ; then 896*a25439b6SCy Schubert OL_NONPOSIX_STRERROR_R 897*a25439b6SCy Schubertelif test "${ac_cv_func_strerror}" = no ; then 898*a25439b6SCy Schubert OL_SYS_ERRLIST 899*a25439b6SCy Schubertfi 900*a25439b6SCy Schubert])dnl 901*a25439b6SCy Schubertdnl ==================================================================== 902*a25439b6SCy Schubertdnl Early MIPS compilers (used in Ultrix 4.2) don't like 903*a25439b6SCy Schubertdnl "int x; int *volatile a = &x; *a = 0;" 904*a25439b6SCy Schubertdnl -- borrowed from PDKSH 905*a25439b6SCy SchubertAC_DEFUN([OL_C_VOLATILE], 906*a25439b6SCy Schubert [AC_CACHE_CHECK(if compiler understands volatile, ol_cv_c_volatile, 907*a25439b6SCy Schubert [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x, y, z;]], [[volatile int a; int * volatile b = x ? &y : &z; 908*a25439b6SCy Schubert /* Older MIPS compilers (eg., in Ultrix 4.2) don't like *b = 0 */ 909*a25439b6SCy Schubert *b = 0;]])],[ol_cv_c_volatile=yes],[ol_cv_c_volatile=no])]) 910*a25439b6SCy Schubert if test $ol_cv_c_volatile = yes; then 911*a25439b6SCy Schubert : 912*a25439b6SCy Schubert else 913*a25439b6SCy Schubert AC_DEFINE([volatile], [], [define as empty if volatile is not supported]) 914*a25439b6SCy Schubert fi 915*a25439b6SCy Schubert ])dnl 916*a25439b6SCy Schubertdnl 917*a25439b6SCy Schubertdnl ==================================================================== 918*a25439b6SCy Schubertdnl Look for fetch(3) 919*a25439b6SCy SchubertAC_DEFUN([OL_LIB_FETCH], 920*a25439b6SCy Schubert[ol_LIBS=$LIBS 921*a25439b6SCy SchubertLIBS="-lfetch -lcom_err $LIBS" 922*a25439b6SCy SchubertAC_CACHE_CHECK([fetch(3) library],ol_cv_lib_fetch,[ 923*a25439b6SCy Schubert AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 924*a25439b6SCy Schubert#ifdef HAVE_SYS_PARAM_H 925*a25439b6SCy Schubert#include <sys/param.h> 926*a25439b6SCy Schubert#endif 927*a25439b6SCy Schubert#include <stdio.h> 928*a25439b6SCy Schubert#include <fetch.h>]], [[struct url *u = fetchParseURL("file:///"); ]])],[ol_cv_lib_fetch=yes],[ol_cv_lib_fetch=no])]) 929*a25439b6SCy SchubertLIBS=$ol_LIBS 930*a25439b6SCy Schubertif test $ol_cv_lib_fetch != no ; then 931*a25439b6SCy Schubert ol_link_fetch="-lfetch -lcom_err" 932*a25439b6SCy Schubert AC_DEFINE([HAVE_FETCH], [1], 933*a25439b6SCy Schubert [define if you actually have FreeBSD fetch(3)]) 934*a25439b6SCy Schubertfi 935*a25439b6SCy Schubert])dnl 936*a25439b6SCy Schubertdnl 937*a25439b6SCy Schubertdnl ==================================================================== 938*a25439b6SCy Schubertdnl Define inet_aton is available 939*a25439b6SCy SchubertAC_DEFUN([OL_FUNC_INET_ATON], 940*a25439b6SCy Schubert [AC_CACHE_CHECK([for inet_aton()], ol_cv_func_inet_aton, 941*a25439b6SCy Schubert [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 942*a25439b6SCy Schubert#ifdef HAVE_SYS_TYPES_H 943*a25439b6SCy Schubert# include <sys/types.h> 944*a25439b6SCy Schubert#endif 945*a25439b6SCy Schubert#ifdef HAVE_SYS_SOCKET_H 946*a25439b6SCy Schubert# include <sys/socket.h> 947*a25439b6SCy Schubert# ifdef HAVE_SYS_SELECT_H 948*a25439b6SCy Schubert# include <sys/select.h> 949*a25439b6SCy Schubert# endif 950*a25439b6SCy Schubert# include <netinet/in.h> 951*a25439b6SCy Schubert# ifdef HAVE_ARPA_INET_H 952*a25439b6SCy Schubert# include <arpa/inet.h> 953*a25439b6SCy Schubert# endif 954*a25439b6SCy Schubert#endif 955*a25439b6SCy Schubert]], [[struct in_addr in; 956*a25439b6SCy Schubertint rc = inet_aton( "255.255.255.255", &in );]])],[ol_cv_func_inet_aton=yes],[ol_cv_func_inet_aton=no])]) 957*a25439b6SCy Schubert if test $ol_cv_func_inet_aton != no; then 958*a25439b6SCy Schubert AC_DEFINE(HAVE_INET_ATON, 1, 959*a25439b6SCy Schubert [define to you inet_aton(3) is available]) 960*a25439b6SCy Schubert fi 961*a25439b6SCy Schubert ])dnl 962*a25439b6SCy Schubertdnl 963*a25439b6SCy Schubertdnl ==================================================================== 964*a25439b6SCy Schubertdnl check no of arguments for ctime_r 965*a25439b6SCy SchubertAC_DEFUN([OL_FUNC_CTIME_R_NARGS], 966*a25439b6SCy Schubert [AC_CACHE_CHECK(number of arguments of ctime_r, ol_cv_func_ctime_r_nargs, 967*a25439b6SCy Schubert [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]) 968*a25439b6SCy Schubert 969*a25439b6SCy Schubert 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]) 970*a25439b6SCy Schubert 971*a25439b6SCy Schubert if test $ol_cv_func_ctime_r_nargs3 = yes && 972*a25439b6SCy Schubert test $ol_cv_func_ctime_r_nargs2 = no ; then 973*a25439b6SCy Schubert 974*a25439b6SCy Schubert ol_cv_func_ctime_r_nargs=3 975*a25439b6SCy Schubert 976*a25439b6SCy Schubert elif test $ol_cv_func_ctime_r_nargs3 = no && 977*a25439b6SCy Schubert test $ol_cv_func_ctime_r_nargs2 = yes ; then 978*a25439b6SCy Schubert 979*a25439b6SCy Schubert ol_cv_func_ctime_r_nargs=2 980*a25439b6SCy Schubert 981*a25439b6SCy Schubert else 982*a25439b6SCy Schubert ol_cv_func_ctime_r_nargs=0 983*a25439b6SCy Schubert fi 984*a25439b6SCy Schubert ]) 985*a25439b6SCy Schubert 986*a25439b6SCy Schubert if test $ol_cv_func_ctime_r_nargs -gt 1 ; then 987*a25439b6SCy Schubert AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs, 988*a25439b6SCy Schubert [set to the number of arguments ctime_r() expects]) 989*a25439b6SCy Schubert fi 990*a25439b6SCy Schubert])dnl 991*a25439b6SCy Schubertdnl 992*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 993*a25439b6SCy Schubertdnl check return type of ctime_r() 994*a25439b6SCy SchubertAC_DEFUN([OL_FUNC_CTIME_R_TYPE], 995*a25439b6SCy Schubert [AC_CACHE_CHECK(return type of ctime_r, ol_cv_func_ctime_r_type, 996*a25439b6SCy Schubert [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"]) 997*a25439b6SCy Schubert ]) 998*a25439b6SCy Schubert if test $ol_cv_func_ctime_r_type = "int" ; then 999*a25439b6SCy Schubert AC_DEFINE(CTIME_R_RETURNS_INT,1, [define if ctime_r() returns int]) 1000*a25439b6SCy Schubert fi 1001*a25439b6SCy Schubert])dnl 1002*a25439b6SCy Schubertdnl ==================================================================== 1003*a25439b6SCy Schubertdnl check no of arguments for gethostbyname_r 1004*a25439b6SCy SchubertAC_DEFUN([OL_FUNC_GETHOSTBYNAME_R_NARGS], 1005*a25439b6SCy Schubert [AC_CACHE_CHECK(number of arguments of gethostbyname_r, 1006*a25439b6SCy Schubert ol_cv_func_gethostbyname_r_nargs, 1007*a25439b6SCy Schubert [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1008*a25439b6SCy Schubert#include <sys/socket.h> 1009*a25439b6SCy Schubert#include <netinet/in.h> 1010*a25439b6SCy Schubert#include <netdb.h> 1011*a25439b6SCy Schubert#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 1012*a25439b6SCy Schubert int bufsize=BUFSIZE;int h_errno; 1013*a25439b6SCy Schubert (void)gethostbyname_r("segovia.cs.purdue.edu", &hent, 1014*a25439b6SCy Schubert buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs5=yes],[ol_cv_func_gethostbyname_r_nargs5=no]) 1015*a25439b6SCy Schubert 1016*a25439b6SCy Schubert AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1017*a25439b6SCy Schubert#include <sys/socket.h> 1018*a25439b6SCy Schubert#include <netinet/in.h> 1019*a25439b6SCy Schubert#include <netdb.h> 1020*a25439b6SCy Schubert#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent;struct hostent *rhent; 1021*a25439b6SCy Schubert char buffer[BUFSIZE]; 1022*a25439b6SCy Schubert int bufsize=BUFSIZE;int h_errno; 1023*a25439b6SCy Schubert (void)gethostbyname_r("localhost", &hent, buffer, bufsize, 1024*a25439b6SCy Schubert &rhent, &h_errno);]])],[ol_cv_func_gethostbyname_r_nargs6=yes],[ol_cv_func_gethostbyname_r_nargs6=no]) 1025*a25439b6SCy Schubert 1026*a25439b6SCy Schubert if test $ol_cv_func_gethostbyname_r_nargs5 = yes && 1027*a25439b6SCy Schubert test $ol_cv_func_gethostbyname_r_nargs6 = no ; then 1028*a25439b6SCy Schubert 1029*a25439b6SCy Schubert ol_cv_func_gethostbyname_r_nargs=5 1030*a25439b6SCy Schubert 1031*a25439b6SCy Schubert elif test $ol_cv_func_gethostbyname_r_nargs5 = no && 1032*a25439b6SCy Schubert test $ol_cv_func_gethostbyname_r_nargs6 = yes ; then 1033*a25439b6SCy Schubert 1034*a25439b6SCy Schubert ol_cv_func_gethostbyname_r_nargs=6 1035*a25439b6SCy Schubert 1036*a25439b6SCy Schubert else 1037*a25439b6SCy Schubert ol_cv_func_gethostbyname_r_nargs=0 1038*a25439b6SCy Schubert fi 1039*a25439b6SCy Schubert ]) 1040*a25439b6SCy Schubert if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then 1041*a25439b6SCy Schubert AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS, 1042*a25439b6SCy Schubert $ol_cv_func_gethostbyname_r_nargs, 1043*a25439b6SCy Schubert [set to the number of arguments gethostbyname_r() expects]) 1044*a25439b6SCy Schubert fi 1045*a25439b6SCy Schubert])dnl 1046*a25439b6SCy Schubertdnl 1047*a25439b6SCy Schubertdnl check no of arguments for gethostbyaddr_r 1048*a25439b6SCy SchubertAC_DEFUN([OL_FUNC_GETHOSTBYADDR_R_NARGS], 1049*a25439b6SCy Schubert [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r, 1050*a25439b6SCy Schubert [ol_cv_func_gethostbyaddr_r_nargs], 1051*a25439b6SCy Schubert [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1052*a25439b6SCy Schubert#include <sys/socket.h> 1053*a25439b6SCy Schubert#include <netinet/in.h> 1054*a25439b6SCy Schubert#include <netdb.h> 1055*a25439b6SCy Schubert#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; char buffer[BUFSIZE]; 1056*a25439b6SCy Schubert struct in_addr add; 1057*a25439b6SCy Schubert size_t alen=sizeof(struct in_addr); 1058*a25439b6SCy Schubert int bufsize=BUFSIZE;int h_errno; 1059*a25439b6SCy Schubert (void)gethostbyaddr_r( (void *)&(add.s_addr), 1060*a25439b6SCy Schubert alen, AF_INET, &hent, buffer, bufsize, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs7=yes],[ol_cv_func_gethostbyaddr_r_nargs7=no]) 1061*a25439b6SCy Schubert 1062*a25439b6SCy Schubert AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 1063*a25439b6SCy Schubert#include <sys/socket.h> 1064*a25439b6SCy Schubert#include <netinet/in.h> 1065*a25439b6SCy Schubert#include <netdb.h> 1066*a25439b6SCy Schubert#define BUFSIZE (sizeof(struct hostent)+10)]], [[struct hostent hent; 1067*a25439b6SCy Schubert struct hostent *rhent; char buffer[BUFSIZE]; 1068*a25439b6SCy Schubert struct in_addr add; 1069*a25439b6SCy Schubert size_t alen=sizeof(struct in_addr); 1070*a25439b6SCy Schubert int bufsize=BUFSIZE;int h_errno; 1071*a25439b6SCy Schubert (void)gethostbyaddr_r( (void *)&(add.s_addr), 1072*a25439b6SCy Schubert alen, AF_INET, &hent, buffer, bufsize, 1073*a25439b6SCy Schubert &rhent, &h_errno);]])],[ol_cv_func_gethostbyaddr_r_nargs8=yes],[ol_cv_func_gethostbyaddr_r_nargs8=no]) 1074*a25439b6SCy Schubert 1075*a25439b6SCy Schubert if test $ol_cv_func_gethostbyaddr_r_nargs7 = yes && 1076*a25439b6SCy Schubert test $ol_cv_func_gethostbyaddr_r_nargs8 = no ; then 1077*a25439b6SCy Schubert 1078*a25439b6SCy Schubert ol_cv_func_gethostbyaddr_r_nargs=7 1079*a25439b6SCy Schubert 1080*a25439b6SCy Schubert elif test $ol_cv_func_gethostbyaddr_r_nargs7 = no && 1081*a25439b6SCy Schubert test $ol_cv_func_gethostbyaddr_r_nargs8 = yes ; then 1082*a25439b6SCy Schubert 1083*a25439b6SCy Schubert ol_cv_func_gethostbyaddr_r_nargs=8 1084*a25439b6SCy Schubert 1085*a25439b6SCy Schubert else 1086*a25439b6SCy Schubert ol_cv_func_gethostbyaddr_r_nargs=0 1087*a25439b6SCy Schubert fi 1088*a25439b6SCy Schubert ]) 1089*a25439b6SCy Schubert if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then 1090*a25439b6SCy Schubert AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS, 1091*a25439b6SCy Schubert $ol_cv_func_gethostbyaddr_r_nargs, 1092*a25439b6SCy Schubert [set to the number of arguments gethostbyaddr_r() expects]) 1093*a25439b6SCy Schubert fi 1094*a25439b6SCy Schubert])dnl 1095*a25439b6SCy Schubertdnl 1096*a25439b6SCy Schubertdnl -------------------------------------------------------------------- 1097*a25439b6SCy Schubertdnl Check for Cyrus SASL version compatility 1098*a25439b6SCy SchubertAC_DEFUN([OL_SASL_COMPAT], 1099*a25439b6SCy Schubert[AC_CACHE_CHECK([Cyrus SASL library version], [ol_cv_sasl_compat],[ 1100*a25439b6SCy Schubert AC_EGREP_CPP(__sasl_compat,[ 1101*a25439b6SCy Schubert#ifdef HAVE_SASL_SASL_H 1102*a25439b6SCy Schubert#include <sasl/sasl.h> 1103*a25439b6SCy Schubert#else 1104*a25439b6SCy Schubert#include <sasl.h> 1105*a25439b6SCy Schubert#endif 1106*a25439b6SCy Schubert 1107*a25439b6SCy Schubert/* Require 2.1.15+ */ 1108*a25439b6SCy Schubert#if SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR > 1 1109*a25439b6SCy Schubert char *__sasl_compat = "2.2+ or better okay (we guess)"; 1110*a25439b6SCy Schubert#elif SASL_VERSION_MAJOR == 2 && SASL_VERSION_MINOR == 1 \ 1111*a25439b6SCy Schubert && SASL_VERSION_STEP >=15 1112*a25439b6SCy Schubert char *__sasl_compat = "2.1.15+ or better okay"; 1113*a25439b6SCy Schubert#endif 1114*a25439b6SCy Schubert ], [ol_cv_sasl_compat=yes], [ol_cv_sasl_compat=no])]) 1115*a25439b6SCy Schubert]) 1116*a25439b6SCy Schubertdnl ==================================================================== 1117*a25439b6SCy Schubertdnl check for SSL compatibility 1118*a25439b6SCy SchubertAC_DEFUN([OL_SSL_COMPAT], 1119*a25439b6SCy Schubert[AC_CACHE_CHECK([OpenSSL library version (CRL checking capability)], 1120*a25439b6SCy Schubert [ol_cv_ssl_crl_compat],[ 1121*a25439b6SCy Schubert AC_EGREP_CPP(__ssl_compat,[ 1122*a25439b6SCy Schubert#ifdef HAVE_OPENSSL_SSL_H 1123*a25439b6SCy Schubert#include <openssl/ssl.h> 1124*a25439b6SCy Schubert#endif 1125*a25439b6SCy Schubert 1126*a25439b6SCy Schubert/* Require 0.9.7d+ */ 1127*a25439b6SCy Schubert#if OPENSSL_VERSION_NUMBER >= 0x0090704fL 1128*a25439b6SCy Schubert char *__ssl_compat = "0.9.7d"; 1129*a25439b6SCy Schubert#endif 1130*a25439b6SCy Schubert ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])]) 1131*a25439b6SCy Schubert]) 1132