apu-conf.m4 15 KB

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