1dnl -------------------------------------------------------- -*- autoconf -*- 2dnl Copyright 2000-2005 The Apache Software Foundation or its licensors, as 3dnl applicable. 4dnl 5dnl Licensed under the Apache License, Version 2.0 (the "License"); 6dnl you may not use this file except in compliance with the License. 7dnl You may obtain a copy of the License at 8dnl 9dnl http://www.apache.org/licenses/LICENSE-2.0 10dnl 11dnl Unless required by applicable law or agreed to in writing, software 12dnl distributed under the License is distributed on an "AS IS" BASIS, 13dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14dnl See the License for the specific language governing permissions and 15dnl limitations under the License. 16 17 18dnl 19dnl custom autoconf rules for APRUTIL 20dnl 21 22dnl 23dnl APU_FIND_APR: figure out where APR is located 24dnl 25AC_DEFUN([APU_FIND_APR], [ 26 27 dnl use the find_apr.m4 script to locate APR. sets apr_found and apr_config 28 APR_FIND_APR(,,,[1]) 29 if test "$apr_found" = "no"; then 30 AC_MSG_ERROR(APR could not be located. Please use the --with-apr option.) 31 fi 32 33 APR_BUILD_DIR="`$apr_config --installbuilddir`" 34 35 dnl make APR_BUILD_DIR an absolute directory (we'll need it in the 36 dnl sub-projects in some cases) 37 APR_BUILD_DIR="`cd $APR_BUILD_DIR && pwd`" 38 39 APR_INCLUDES="`$apr_config --includes`" 40 APR_LIBS="`$apr_config --link-libtool --libs`" 41 APR_SO_EXT="`$apr_config --apr-so-ext`" 42 APR_LIB_TARGET="`$apr_config --apr-lib-target`" 43 44 AC_SUBST(APR_INCLUDES) 45 AC_SUBST(APR_LIBS) 46 AC_SUBST(APR_BUILD_DIR) 47]) 48 49 50dnl 51dnl APU_TEST_EXPAT(directory): test if Expat is located in the specified dir 52dnl 53dnl if present: sets expat_include_dir, expat_libs, possibly expat_old 54dnl 55AC_DEFUN([APU_TEST_EXPAT], [ 56 AC_MSG_CHECKING(for Expat in ifelse($2,,$1,$2)) 57 58 expat_libtool="" 59 60 if test -r "$1/lib/expat.h.in"; then 61 dnl Expat 1.95.* distribution 62 expat_include_dir="$1/lib" 63 expat_ldflags="-L$1/lib" 64 expat_libs="-lexpat" 65 expat_libtool="$1/lib/libexpat.la" 66 elif test -r "$1/include/expat.h" -a \ 67 -r "$1/lib/libexpat.la"; then 68 dnl Expat 1.95.* installation (with libtool) 69 expat_include_dir="$1/include" 70 expat_ldflags="-L$1/lib" 71 expat_libs="-lexpat" 72 expat_libtool="$1/lib/libexpat.la" 73 elif test -r "$1/include/expat.h" -a \ 74 -r "$1/lib64/libexpat.la"; then 75 dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool) 76 expat_include_dir="$1/include" 77 expat_ldflags="-L$1/lib64" 78 expat_libs="-lexpat" 79 expat_libtool="$1/lib64/libexpat.la" 80 elif test -r "$1/include/expat.h" -a \ 81 -r "$1/lib/libexpat.a"; then 82 dnl Expat 1.95.* installation (without libtool) 83 dnl FreeBSD textproc/expat2 84 expat_include_dir="$1/include" 85 expat_ldflags="-L$1/lib" 86 expat_libs="-lexpat" 87 elif test -r "$1/xmlparse.h"; then 88 dnl maybe an expat-lite. use this dir for both includes and libs 89 expat_include_dir="$1" 90 expat_ldflags="-L$1" 91 expat_libs="-lexpat" 92 expat_libtool="$1/libexpat.la" 93 expat_old=yes 94 elif test -r "$1/include/xmlparse.h" -a \ 95 -r "$1/lib/libexpat.a"; then 96 dnl previously installed expat 97 expat_include_dir="$1/include" 98 expat_ldflags="-L$1/lib" 99 expat_libs="-lexpat" 100 expat_old=yes 101 elif test -r "$1/include/xml/xmlparse.h" -a \ 102 -r "$1/lib/xml/libexpat.a"; then 103 dnl previously installed expat 104 expat_include_dir="$1/include/xml" 105 expat_ldflags="-L$1/lib" 106 expat_libs="-lexpat" 107 expat_old=yes 108 elif test -r "$1/include/xmltok/xmlparse.h"; then 109 dnl Debian distribution 110 expat_include_dir="$1/include/xmltok" 111 expat_ldflags="-L$1/lib" 112 expat_libs="-lxmlparse -lxmltok" 113 expat_old=yes 114 elif test -r "$1/include/xml/xmlparse.h" -a \ 115 -r "$1/lib/libexpat.a"; then 116 dnl FreeBSD textproc/expat package 117 expat_include_dir="$1/include/xml" 118 expat_ldflags="-L$1/lib" 119 expat_libs="-lexpat" 120 expat_old=yes 121 elif test -r "$1/xmlparse/xmlparse.h"; then 122 dnl Expat 1.0 or 1.1 source directory 123 expat_include_dir="$1/xmlparse" 124 expat_ldflags="-L$1" 125 expat_libs="-lexpat" 126 expat_old=yes 127 fi 128 dnl ### test for installed Expat 1.95.* distros 129 130 if test -n "$expat_include_dir"; then 131 dnl ### more info about what we found there? version? using .la? 132 AC_MSG_RESULT(yes) 133 else 134 AC_MSG_RESULT(no) 135 fi 136]) 137 138 139dnl 140dnl APU_FIND_EXPAT: figure out where EXPAT is located (or use bundled) 141dnl 142AC_DEFUN([APU_FIND_EXPAT], [ 143 144AC_ARG_WITH([expat], 145[ --with-expat=DIR specify Expat location or 'builtin'], [ 146 if test "$withval" = "yes"; then 147 AC_MSG_ERROR([a directory must be specified for --with-expat]) 148 elif test "$withval" = "no"; then 149 AC_MSG_ERROR([Expat cannot be disabled (at this time)]) 150 elif test "$withval" = "builtin"; then 151 abs_expatdir="`cd $srcdir/xml/expat && pwd`" 152 if test -d $abs_expatdir/. -a ! -d xml/expat/.; then 153 $mkdir_p xml/expat 154 fi 155 APU_TEST_EXPAT($abs_expatdir, xml/expat) 156 else 157 abs_expatdir="`cd $withval && pwd`" 158 APU_TEST_EXPAT($abs_expatdir, $withval) 159 if test -z "$expat_include_dir"; then 160 AC_MSG_ERROR([Expat was not found (or recognized) in \"$withval\"]) 161 fi 162 fi 163]) 164 165if test -z "$expat_include_dir"; then 166 for d in /usr /usr/local xml/expat-cvs xml/expat $srcdir/xml/expat ; do 167 APU_TEST_EXPAT($d) 168 if test -n "$expat_include_dir"; then 169 dnl For /usr installs of expat, we can't specify -L/usr/lib 170 if test "$d" = "/usr"; then 171 expat_ldflags="" 172 fi 173 break 174 fi 175 done 176fi 177if test -z "$expat_include_dir"; then 178 AC_MSG_ERROR([could not locate Expat. use --with-expat]) 179fi 180 181dnl If this expat doesn't use libtool natively, we'll mimic it for our 182dnl dependency library generation. 183if test -z "$expat_libtool"; then 184 expat_libtool="$expat_ldflags $expat_libs" 185fi 186 187if test -n "$expat_old"; then 188 AC_DEFINE(APR_HAVE_OLD_EXPAT, 1, [define if Expat 1.0 or 1.1 was found]) 189fi 190 191dnl special-case the bundled distribution (use absolute dirs) 192if test "$expat_include_dir" = "xml/expat/lib" -o "$expat_include_dir" = "xml/expat-cvs/lib"; then 193 bundled_subdir="`echo $expat_include_dir | sed -e 's%/lib%%'`" 194 APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir]) 195 expat_include_dir=$top_builddir/$bundled_subdir/lib 196 expat_ldflags="-L$top_builddir/$bundled_subdir/lib" 197 expat_libs="-lexpat" 198 expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la 199 APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`" 200 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool]) 201else 202if test "$expat_include_dir" = "$abs_srcdir/xml/expat/include" -o "$expat_include_dir" = "$abs_srcdir/xml/expat/lib"; then 203 dnl This is a bit of a hack. This only works because we know that 204 dnl we are working with the bundled version of the software. 205 bundled_subdir="xml/expat" 206 APR_SUBDIR_CONFIG($bundled_subdir, [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir]) 207 expat_include_dir=$top_builddir/$bundled_subdir/lib 208 expat_ldflags="-L$top_builddir/$bundled_subdir/lib" 209 expat_libs="-lexpat" 210 expat_libtool=$top_builddir/$bundled_subdir/lib/libexpat.la 211 APR_XML_SUBDIRS="`echo $bundled_subdir | sed -e 's%xml/%%'`" 212 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libtool]) 213else 214 APR_ADDTO(APRUTIL_EXPORT_LIBS, [$expat_libs]) 215fi 216fi 217APR_XML_DIR=$bundled_subdir 218APR_XML_EXPAT_OLD=$expat_old 219AC_SUBST(APR_XML_SUBDIRS) 220AC_SUBST(APR_XML_DIR) 221AC_SUBST(APR_XML_EXPAT_OLD) 222 223if test "$expat_include_dir" != "/usr/include"; then 224 APR_ADDTO(APRUTIL_INCLUDES, [-I$expat_include_dir]) 225fi 226APR_ADDTO(APRUTIL_LDFLAGS, [$expat_ldflags]) 227APR_ADDTO(APRUTIL_LIBS, [$expat_libtool]) 228]) 229 230 231dnl 232dnl Find a particular LDAP library 233dnl 234AC_DEFUN([APU_FIND_LDAPLIB], [ 235 if test ${apu_has_ldap} != "1"; then 236 ldaplib=$1 237 extralib=$2 238 unset ac_cv_lib_${ldaplib}_ldap_init 239 unset ac_cv_lib_${ldaplib}___ldap_init 240 AC_CHECK_LIB(${ldaplib}, ldap_init, 241 [ 242 APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${ldaplib} ${extralib}]) 243 APR_ADDTO(APRUTIL_LIBS,[-l${ldaplib} ${extralib}]) 244 AC_CHECK_LIB(${ldaplib}, ldapssl_client_init, apu_has_ldapssl_client_init="1", , ${extralib}) 245 AC_CHECK_LIB(${ldaplib}, ldapssl_client_deinit, apu_has_ldapssl_client_deinit="1", , ${extralib}) 246 AC_CHECK_LIB(${ldaplib}, ldapssl_add_trusted_cert, apu_has_ldapssl_add_trusted_cert="1", , ${extralib}) 247 AC_CHECK_LIB(${ldaplib}, ldap_start_tls_s, apu_has_ldap_start_tls_s="1", , ${extralib}) 248 AC_CHECK_LIB(${ldaplib}, ldap_sslinit, apu_has_ldap_sslinit="1", , ${extralib}) 249 AC_CHECK_LIB(${ldaplib}, ldapssl_init, apu_has_ldapssl_init="1", , ${extralib}) 250 AC_CHECK_LIB(${ldaplib}, ldapssl_install_routines, apu_has_ldapssl_install_routines="1", , ${extralib}) 251 apu_has_ldap="1"; 252 ], , ${extralib}) 253 fi 254]) 255 256 257dnl 258dnl APU_FIND_LDAP: figure out where LDAP is located 259dnl 260AC_DEFUN([APU_FIND_LDAP], [ 261 262echo $ac_n "${nl}checking for ldap support..." 263 264apu_has_ldap="0"; 265apu_has_ldapssl_client_init="0" 266apu_has_ldapssl_client_deinit="0" 267apu_has_ldapssl_add_trusted_cert="0" 268apu_has_ldap_start_tls_s="0" 269apu_has_ldapssl_init="0" 270apu_has_ldap_sslinit="0" 271apu_has_ldapssl_install_routines="0" 272apu_has_ldap_openldap="0" 273apu_has_ldap_solaris="0" 274apu_has_ldap_novell="0" 275apu_has_ldap_microsoft="0" 276apu_has_ldap_netscape="0" 277apu_has_ldap_mozilla="0" 278apu_has_ldap_other="0" 279 280AC_ARG_WITH(ldap-include,[ --with-ldap-include=path path to ldap include files with trailing slash]) 281AC_ARG_WITH(ldap-lib,[ --with-ldap-lib=path path to ldap lib file]) 282AC_ARG_WITH(ldap,[ --with-ldap=library ldap library to use], 283 [ 284 save_cppflags="$CPPFLAGS" 285 save_ldflags="$LDFLAGS" 286 save_libs="$LIBS" 287 if test -n "$with_ldap_include"; then 288 CPPFLAGS="$CPPFLAGS -I$with_ldap_include" 289 APR_ADDTO(APRUTIL_INCLUDES, [-I$with_ldap_include]) 290 fi 291 if test -n "$with_ldap_lib"; then 292 LDFLAGS="$LDFLAGS -L$with_ldap_lib" 293 APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib]) 294 fi 295 296 LIBLDAP="$withval" 297 if test "$LIBLDAP" = "yes"; then 298dnl The iPlanet C SDK 5.0 is as yet untested... 299 APU_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50") 300 APU_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3") 301 APU_FIND_LDAPLIB("ldapssl40") 302 APU_FIND_LDAPLIB("ldapssl30") 303 APU_FIND_LDAPLIB("ldapssl20") 304 APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgssapi_krb5") 305 APU_FIND_LDAPLIB("ldapsdk", "-lldapx -lldapssl -lldapgss -lgss -lresolv -lsocket") 306 APU_FIND_LDAPLIB("ldap", "-llber") 307 APU_FIND_LDAPLIB("ldap", "-llber -lresolv") 308 APU_FIND_LDAPLIB("ldap", "-llber -lresolv -lsocket -lnsl") 309 APU_FIND_LDAPLIB("ldap", "-ldl -lpthread") 310 else 311 APU_FIND_LDAPLIB($LIBLDAP) 312 APU_FIND_LDAPLIB($LIBLDAP, "-lresolv") 313 APU_FIND_LDAPLIB($LIBLDAP, "-lresolv -lsocket -lnsl") 314 APU_FIND_LDAPLIB($LIBLDAP, "-ldl -lpthread") 315 fi 316 317 test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library) 318 AC_CHECK_LIB(lber, ber_init) 319 320 AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"]) 321 322 # Solaris has a problem in <ldap.h> which prevents it from 323 # being included by itself. Check for <ldap.h> manually, 324 # including lber.h first. 325 AC_CACHE_CHECK([for ldap.h], [apr_cv_hdr_ldap_h], 326 [AC_TRY_CPP( 327 [#ifdef HAVE_LBER_H 328 #include <lber.h> 329 #endif 330 #include <ldap.h> 331 ], [apr_cv_hdr_ldap_h=yes], [apr_cv_hdr_ldap_h=no])]) 332 if test "$apr_cv_hdr_ldap_h" = "yes"; then 333 ldap_h=["#include <ldap.h>"] 334 AC_DEFINE([HAVE_LDAP_H], 1, [Defined if ldap.h is present]) 335 fi 336 337 AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"]) 338 339 if test "$apr_cv_hdr_ldap_h" = "yes"; then 340 AC_CACHE_CHECK([for LDAP toolkit], 341 [apr_cv_ldap_toolkit], [ 342 if test "x$apr_cv_ldap_toolkit" = "x"; then 343 AC_EGREP_CPP([OpenLDAP], [$lber_h 344 $ldap_h 345 LDAP_VENDOR_NAME], [apu_has_ldap_openldap="1" 346 apr_cv_ldap_toolkit="OpenLDAP"]) 347 fi 348 if test "x$apr_cv_ldap_toolkit" = "x"; then 349 AC_EGREP_CPP([Sun Microsystems Inc.], [$lber_h 350 $ldap_h 351 LDAP_VENDOR_NAME], [apu_has_ldap_solaris="1" 352 apr_cv_ldap_toolkit="Solaris"]) 353 fi 354 if test "x$apr_cv_ldap_toolkit" = "x"; then 355 AC_EGREP_CPP([Novell], [$lber_h 356 $ldap_h 357 LDAP_VENDOR_NAME], [apu_has_ldap_novell="1" 358 apr_cv_ldap_toolkit="Novell"]) 359 fi 360 if test "x$apr_cv_ldap_toolkit" = "x"; then 361 AC_EGREP_CPP([Microsoft Corporation.], [$lber_h 362 $ldap_h 363 LDAP_VENDOR_NAME], [apu_has_ldap_microsoft="1" 364 apr_cv_ldap_toolkit="Microsoft"]) 365 fi 366 if test "x$apr_cv_ldap_toolkit" = "x"; then 367 AC_EGREP_CPP([Netscape Communications Corp.], [$lber_h 368 $ldap_h 369 LDAP_VENDOR_NAME], [apu_has_ldap_netscape="1" 370 apr_cv_ldap_toolkit="Netscape"]) 371 fi 372 if test "x$apr_cv_ldap_toolkit" = "x"; then 373 AC_EGREP_CPP([mozilla.org], [$lber_h 374 $ldap_h 375 LDAP_VENDOR_NAME], [apu_has_ldap_mozilla="1" 376 apr_cv_ldap_toolkit="Mozilla"]) 377 fi 378 if test "x$apr_cv_ldap_toolkit" = "x"; then 379 apu_has_ldap_other="1" 380 apr_cv_ldap_toolkit="unknown" 381 fi 382 ]) 383 fi 384 385 CPPFLAGS=$save_cppflags 386 LDFLAGS=$save_ldflags 387 LIBS=$save_libs 388 ]) 389 390AC_SUBST(ldap_h) 391AC_SUBST(lber_h) 392AC_SUBST(ldap_ssl_h) 393AC_SUBST(apu_has_ldapssl_client_init) 394AC_SUBST(apu_has_ldapssl_client_deinit) 395AC_SUBST(apu_has_ldapssl_add_trusted_cert) 396AC_SUBST(apu_has_ldap_start_tls_s) 397AC_SUBST(apu_has_ldapssl_init) 398AC_SUBST(apu_has_ldap_sslinit) 399AC_SUBST(apu_has_ldapssl_install_routines) 400AC_SUBST(apu_has_ldap) 401AC_SUBST(apu_has_ldap_openldap) 402AC_SUBST(apu_has_ldap_solaris) 403AC_SUBST(apu_has_ldap_novell) 404AC_SUBST(apu_has_ldap_microsoft) 405AC_SUBST(apu_has_ldap_netscape) 406AC_SUBST(apu_has_ldap_mozilla) 407AC_SUBST(apu_has_ldap_other) 408 409]) 410 411dnl 412dnl APU_CHECK_CRYPT_R_STYLE 413dnl 414dnl Decide which of a couple of flavors of crypt_r() is necessary for 415dnl this platform. 416dnl 417AC_DEFUN([APU_CHECK_CRYPT_R_STYLE], [ 418 419AC_CACHE_CHECK([style of crypt_r], apr_cv_crypt_r_style, 420[AC_TRY_COMPILE([#include <crypt.h>], 421 [CRYPTD buffer; 422 crypt_r("passwd", "hash", &buffer);], 423 [apr_cv_crypt_r_style=cryptd], 424 [AC_TRY_COMPILE([#include <crypt.h>], 425 [struct crypt_data buffer; 426 crypt_r("passwd", "hash", &buffer);], 427 [apr_cv_crypt_r_style=struct_crypt_data], 428 [apr_cv_crypt_r_style=none])])]) 429 430if test "$apr_cv_crypt_r_style" = "cryptd"; then 431 AC_DEFINE(CRYPT_R_CRYPTD, 1, [Define if crypt_r has uses CRYPTD]) 432elif test "$apr_cv_crypt_r_style" = "struct_crypt_data"; then 433 AC_DEFINE(CRYPT_R_STRUCT_CRYPT_DATA, 1, [Define if crypt_r uses struct crypt_data]) 434fi 435]) 436