neon.m4 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. # Copyright (C) 1998-2009 Joe Orton <[email protected]> -*- autoconf -*-
  2. # Copyright (C) 2004 Aleix Conchillo Flaque <[email protected]>
  3. #
  4. # This file is free software; you may copy and/or distribute it with
  5. # or without modifications, as long as this notice is preserved.
  6. # This software is distributed in the hope that it will be useful, but
  7. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even
  8. # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. # PURPOSE.
  10. # The above license applies to THIS FILE ONLY, the neon library code
  11. # itself may be copied and distributed under the terms of the GNU
  12. # LGPL, see COPYING.LIB for more details
  13. # This file is part of the neon HTTP/WebDAV client library.
  14. # See http://www.webdav.org/neon/ for the latest version.
  15. # Please send any feedback to <[email protected]>
  16. #
  17. # Usage:
  18. #
  19. # NEON_LIBRARY
  20. # or NEON_BUNDLED(srcdir, [ACTIONS-IF-BUNDLED], [ACTIONS-IF-NOT_BUNDLED])
  21. # or NEON_VPATH_BUNDLED(srcdir, builddir,
  22. # [ACTIONS-IF-BUNDLED], [ACTIONS-IF-NOT-BUNDLED])
  23. #
  24. # where srcdir is the location of bundled neon 'src' directory.
  25. # If using a VPATH-enabled build, builddir is the location of the
  26. # build directory corresponding to srcdir.
  27. #
  28. # If a bundled build *is* being used, ACTIONS-IF-BUNDLED will be
  29. # evaluated. These actions should ensure that 'make' is run
  30. # in srcdir, and that one of NEON_NORMAL_BUILD or NEON_LIBTOOL_BUILD
  31. # is called.
  32. #
  33. # After calling one of the above macros, if the NEON_NEED_XML_PARSER
  34. # variable is set to "yes", then you must configure an XML parser
  35. # too. You can do this your own way, or do it easily using the
  36. # NEON_XML_PARSER() macro. Example usage for where we have bundled the
  37. # neon sources in a directory called libneon, and bundled expat
  38. # sources in a directory called 'expat'.
  39. #
  40. # NEON_BUNDLED(libneon, [
  41. # NEON_XML_PARSER(expat)
  42. # NEON_NORMAL_BUILD
  43. # ])
  44. #
  45. # Alternatively, for a simple standalone app with neon as a
  46. # dependancy, use just:
  47. #
  48. # NEON_LIBRARY
  49. #
  50. # and rely on the user installing neon correctly.
  51. #
  52. # You are free to configure an XML parser any other way you like,
  53. # but the end result must be, either expat or libxml will get linked
  54. # in, and HAVE_EXPAT or HAVE_LIBXML is defined appropriately.
  55. #
  56. # To set up the bundled build environment, call
  57. #
  58. # NEON_NORMAL_BUILD
  59. # or
  60. # NEON_LIBTOOL_BUILD
  61. #
  62. # depending on whether you are using libtool to build, or not.
  63. # Both these macros take an optional argument specifying the set
  64. # of object files you wish to build: if the argument is not given,
  65. # all of neon will be built.
  66. AC_DEFUN([NEON_BUNDLED],[
  67. neon_bundled_srcdir=$1
  68. neon_bundled_builddir=$1
  69. NEON_COMMON_BUNDLED([$2], [$3])
  70. ])
  71. AC_DEFUN([NEON_VPATH_BUNDLED],[
  72. neon_bundled_srcdir=$1
  73. neon_bundled_builddir=$2
  74. NEON_COMMON_BUNDLED([$3], [$4])
  75. ])
  76. AC_DEFUN([NEON_COMMON_BUNDLED],[
  77. AC_PREREQ(2.50)
  78. AC_ARG_WITH(included-neon,
  79. AS_HELP_STRING([--with-included-neon], [force use of included neon library]),
  80. [neon_force_included="$withval"], [neon_force_included="no"])
  81. NEON_COMMON
  82. # The colons are here so there is something to evaluate
  83. # in case the argument was not passed.
  84. if test "$neon_force_included" = "yes"; then
  85. :
  86. $1
  87. else
  88. :
  89. $2
  90. fi
  91. ])
  92. dnl Not got any bundled sources:
  93. AC_DEFUN([NEON_LIBRARY],[
  94. AC_PREREQ(2.50)
  95. neon_force_included=no
  96. neon_bundled_srcdir=
  97. neon_bundled_builddir=
  98. NEON_COMMON
  99. ])
  100. AC_DEFUN([NE_DEFINE_VERSIONS], [
  101. NEON_VERSION="${NE_VERSION_MAJOR}.${NE_VERSION_MINOR}.${NE_VERSION_PATCH}${NE_VERSION_TAG}"
  102. AC_DEFINE_UNQUOTED([NEON_VERSION], ["${NEON_VERSION}"],
  103. [Define to be the neon version string])
  104. AC_DEFINE_UNQUOTED([NE_VERSION_MAJOR], [(${NE_VERSION_MAJOR})],
  105. [Define to be neon library major version])
  106. AC_DEFINE_UNQUOTED([NE_VERSION_MINOR], [(${NE_VERSION_MINOR})],
  107. [Define to be neon library minor version])
  108. AC_DEFINE_UNQUOTED([NE_VERSION_PATCH], [(${NE_VERSION_PATCH})],
  109. [Define to be neon library patch version])
  110. ])
  111. AC_DEFUN([NE_VERSIONS_BUNDLED], [
  112. # Define the current versions.
  113. NE_VERSION_MAJOR=0
  114. NE_VERSION_MINOR=31
  115. NE_VERSION_PATCH=1
  116. NE_VERSION_TAG=
  117. # 0.31.x is backwards-compatible to 0.27.x, so AGE=4
  118. NE_LIBTOOL_VERSINFO="31:${NE_VERSION_PATCH}:4"
  119. NE_DEFINE_VERSIONS
  120. ])
  121. dnl Adds an ABI variation tag which will be added to the SONAME of
  122. dnl a shared library. e.g. NE_ADD_ABITAG(FOO)
  123. AC_DEFUN([NE_ADD_ABITAG], [
  124. if test "x${NE_LIBTOOL_RELEASE}y" = "xy"; then
  125. NE_LIBTOOL_RELEASE="$1"
  126. else
  127. NE_LIBTOOL_RELEASE="${NE_LIBTOOL_RELEASE}-$1"
  128. fi
  129. ])
  130. dnl Define the minimum required versions, usage:
  131. dnl NE_REQUIRE_VERSIONS([major-version], [minor-versions])
  132. dnl e.g.
  133. dnl NE_REQUIRE_VERSIONS([0], [24 25])
  134. dnl to require neon 0.24.x or neon 0.25.x.
  135. AC_DEFUN([NE_REQUIRE_VERSIONS], [
  136. m4_define([ne_require_major], [$1])
  137. m4_define([ne_require_minor], [$2])
  138. ])
  139. dnl Check that the external library found in a given location
  140. dnl matches the min. required version (if any). Requires that
  141. dnl NEON_CONFIG be set the the full path of a valid neon-config
  142. dnl script
  143. dnl
  144. dnl Usage:
  145. dnl NEON_CHECK_VERSION(ACTIONS-IF-OKAY, ACTIONS-IF-FAILURE)
  146. dnl
  147. AC_DEFUN([NEON_CHECK_VERSION], [
  148. m4_ifdef([ne_require_major], [
  149. # Check whether the library is of required version
  150. ne_save_LIBS="$LIBS"
  151. ne_save_CFLAGS="$CFLAGS"
  152. CFLAGS="$CFLAGS `$NEON_CONFIG --cflags`"
  153. LIBS="$LIBS `$NEON_CONFIG --libs`"
  154. ne_libver=`$NEON_CONFIG --version | sed -e "s/neon //g"`
  155. # Check whether it's possible to link against neon
  156. AC_CACHE_CHECK([linking against neon], [ne_cv_lib_neon],
  157. [AC_LINK_IFELSE(
  158. [AC_LANG_PROGRAM([[#include <ne_utils.h>]], [[ne_version_match(0, 0);]])],
  159. [ne_cv_lib_neon=yes], [ne_cv_lib_neon=no])])
  160. if test "$ne_cv_lib_neon" = "yes"; then
  161. ne_cv_lib_neonver=no
  162. for v in ne_require_minor; do
  163. case $ne_libver in
  164. ne_require_major.$v.*) ne_cv_lib_neonver=yes ;;
  165. esac
  166. done
  167. fi
  168. ne_goodver=$ne_cv_lib_neonver
  169. LIBS=$ne_save_LIBS
  170. CFLAGS=$ne_save_CFLAGS
  171. ], [
  172. # NE_REQUIRE_VERSIONS not used; presume all versions OK!
  173. ne_goodver=yes
  174. ne_libver="(version unknown)"
  175. ])
  176. if test "$ne_goodver" = "yes"; then
  177. AC_MSG_NOTICE([using neon library $ne_libver])
  178. $1
  179. else
  180. AC_MSG_NOTICE([incompatible neon library version $ne_libver: wanted ne_require_major.ne_require_minor])
  181. $2
  182. fi])
  183. dnl NEON_CHECK_SUPPORT(feature, var, name)
  184. AC_DEFUN([NEON_CHECK_SUPPORT], [
  185. if $NEON_CONFIG --support $1 >/dev/null; then
  186. NE_ENABLE_SUPPORT($2, [$3 is supported by neon])
  187. else
  188. NE_DISABLE_SUPPORT($2, [$3 is not supported by neon])
  189. fi
  190. ])
  191. dnl enable support for feature $1 with define NE_HAVE_$1, message $2
  192. AC_DEFUN([NE_ENABLE_SUPPORT], [
  193. NE_FLAG_$1=yes
  194. AC_SUBST(NE_FLAG_$1)
  195. AC_DEFINE([NE_HAVE_]$1, 1, [Defined if $1 is supported])
  196. m4_if([$2], [],
  197. [ne_$1_message="support enabled"
  198. AC_MSG_NOTICE([$1 support is enabled])],
  199. [ne_$1_message="$2"
  200. AC_MSG_NOTICE([$2])])
  201. ])
  202. dnl Disable support for feature $1, giving message $2
  203. AC_DEFUN([NE_DISABLE_SUPPORT], [
  204. NE_FLAG_$1=no
  205. AC_SUBST(NE_FLAG_$1)
  206. m4_if([$2], [],
  207. [ne_$1_message="not supported"
  208. AC_MSG_NOTICE([$1 support is not enabled])],
  209. [ne_$1_message="$2"
  210. AC_MSG_NOTICE([$2])])
  211. ])
  212. AC_DEFUN([NEON_USE_EXTERNAL], [
  213. # Configure to use an external neon, given a neon-config script
  214. # found at $NEON_CONFIG.
  215. neon_prefix=`$NEON_CONFIG --prefix`
  216. NEON_CHECK_VERSION([
  217. # Pick up CFLAGS and LIBS needed
  218. CFLAGS="$CFLAGS `$NEON_CONFIG --cflags`"
  219. NEON_LIBS="$NEON_LIBS `$NEON_CONFIG --libs`"
  220. # Pick up library version
  221. set dummy `$NEON_CONFIG --version | sed 's/\./ /g'`
  222. NE_VERSION_MAJOR=[$]3; NE_VERSION_MINOR=[$]4; NE_VERSION_PATCH=[$]5
  223. NE_DEFINE_VERSIONS
  224. neon_library_message="library in ${neon_prefix} (${NEON_VERSION})"
  225. neon_xml_parser_message="using whatever neon uses"
  226. NEON_CHECK_SUPPORT([ssl], [SSL], [SSL])
  227. NEON_CHECK_SUPPORT([zlib], [ZLIB], [zlib])
  228. NEON_CHECK_SUPPORT([ipv6], [IPV6], [IPv6])
  229. NEON_CHECK_SUPPORT([lfs], [LFS], [LFS])
  230. NEON_CHECK_SUPPORT([ts_ssl], [TS_SSL], [thread-safe SSL])
  231. neon_got_library=yes
  232. if test $NE_FLAG_LFS = yes; then
  233. NEON_FORMAT(off64_t)
  234. AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF64_T],
  235. [Define to be printf format string for ne_off_t])
  236. else
  237. AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF_T])
  238. fi
  239. ], [neon_got_library=no])
  240. ])
  241. AC_DEFUN([NEON_COMMON],[
  242. AC_REQUIRE([NEON_COMMON_CHECKS])
  243. AC_ARG_WITH(neon,
  244. [ --with-neon[[=DIR]] specify location of neon library],
  245. [case $withval in
  246. yes|no) neon_force_external=$withval; neon_ext_path= ;;
  247. *) neon_force_external=yes; neon_ext_path=$withval ;;
  248. esac;], [
  249. neon_force_external=no
  250. neon_ext_path=
  251. ])
  252. if test "$neon_force_included" = "no"; then
  253. # There is no included neon source directory, or --with-included-neon
  254. # wasn't given (so we're not forced to use it).
  255. # Default to no external neon.
  256. neon_got_library=no
  257. if test "x$neon_ext_path" = "x"; then
  258. AC_PATH_PROG([NEON_CONFIG], neon-config, none)
  259. if test "x${NEON_CONFIG}" = "xnone"; then
  260. AC_MSG_NOTICE([no external neon library found])
  261. elif test -x "${NEON_CONFIG}"; then
  262. NEON_USE_EXTERNAL
  263. else
  264. AC_MSG_NOTICE([ignoring non-executable ${NEON_CONFIG}])
  265. fi
  266. else
  267. AC_MSG_CHECKING([for neon library in $neon_ext_path])
  268. NEON_CONFIG="$neon_ext_path/bin/neon-config"
  269. if test -x ${NEON_CONFIG}; then
  270. AC_MSG_RESULT([found])
  271. NEON_USE_EXTERNAL
  272. else
  273. AC_MSG_RESULT([not found])
  274. # ...will fail since force_external=yes
  275. fi
  276. fi
  277. if test "$neon_got_library" = "no"; then
  278. if test $neon_force_external = yes; then
  279. AC_MSG_ERROR([could not use external neon library])
  280. elif test -n "$neon_bundled_srcdir"; then
  281. # Couldn't find external neon, forced to use bundled sources
  282. neon_force_included="yes"
  283. else
  284. # Couldn't find neon, and don't have bundled sources
  285. AC_MSG_ERROR(could not find neon)
  286. fi
  287. fi
  288. fi
  289. if test "$neon_force_included" = "yes"; then
  290. NE_VERSIONS_BUNDLED
  291. AC_MSG_NOTICE([using bundled neon ($NEON_VERSION)])
  292. NEON_BUILD_BUNDLED="yes"
  293. LIBNEON_SOURCE_CHECKS
  294. CFLAGS="$CFLAGS -I$neon_bundled_srcdir"
  295. NEON_LIBS="-L$neon_bundled_builddir -lneon $NEON_LIBS"
  296. NEON_NEED_XML_PARSER=yes
  297. neon_library_message="included libneon (${NEON_VERSION})"
  298. else
  299. # Don't need to configure an XML parser
  300. NEON_NEED_XML_PARSER=no
  301. NEON_BUILD_BUNDLED=no
  302. fi
  303. AC_SUBST(NEON_BUILD_BUNDLED)
  304. ])
  305. dnl AC_SEARCH_LIBS done differently. Usage:
  306. dnl NE_SEARCH_LIBS(function, libnames, [extralibs], [actions-if-not-found],
  307. dnl [actions-if-found])
  308. dnl Tries to find 'function' by linking against `-lLIB $NEON_LIBS' for each
  309. dnl LIB in libnames. If link fails and 'extralibs' is given, will also
  310. dnl try linking against `-lLIB extralibs $NEON_LIBS`.
  311. dnl Once link succeeds, `-lLIB [extralibs]` is prepended to $NEON_LIBS, and
  312. dnl `actions-if-found' are executed, if given.
  313. dnl If link never succeeds, run `actions-if-not-found', if given, else
  314. dnl give an error and fail configure.
  315. AC_DEFUN([NE_SEARCH_LIBS], [
  316. AC_REQUIRE([NE_CHECK_OS])
  317. AC_CACHE_CHECK([for library containing $1], [ne_cv_libsfor_$1], [
  318. AC_LINK_IFELSE(
  319. [AC_LANG_PROGRAM([], [[$1();]])],
  320. [ne_cv_libsfor_$1="none needed"], [
  321. ne_sl_save_LIBS=$LIBS
  322. ne_cv_libsfor_$1="not found"
  323. for lib in $2; do
  324. # The w32api libraries link using the stdcall calling convention.
  325. case ${lib}-${ne_cv_os_uname} in
  326. ws2_32-MINGW*) ne__code="__stdcall $1();" ;;
  327. *) ne__code="$1();" ;;
  328. esac
  329. LIBS="$ne_sl_save_LIBS -l$lib $NEON_LIBS"
  330. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$ne__code])],
  331. [ne_cv_libsfor_$1="-l$lib"; break])
  332. m4_if($3, [], [], dnl If $3 is specified, then...
  333. [LIBS="$ne_sl_save_LIBS -l$lib $3 $NEON_LIBS"
  334. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$ne__code])],
  335. [ne_cv_libsfor_$1="-l$lib $3"; break])])
  336. done
  337. LIBS=$ne_sl_save_LIBS])])
  338. if test "$ne_cv_libsfor_$1" = "not found"; then
  339. m4_if([$4], [], [AC_MSG_ERROR([could not find library containing $1])], [$4])
  340. elif test "$ne_cv_libsfor_$1" = "none needed"; then
  341. m4_if([$5], [], [:], [$5])
  342. else
  343. NEON_LIBS="$ne_cv_libsfor_$1 $NEON_LIBS"
  344. $5
  345. fi])
  346. dnl Check for presence and suitability of zlib library
  347. AC_DEFUN([NEON_ZLIB], [
  348. AC_ARG_WITH(zlib, AS_HELP_STRING([--without-zlib], [disable zlib support]),
  349. ne_use_zlib=$withval, ne_use_zlib=yes)
  350. if test "$ne_use_zlib" = "yes"; then
  351. AC_CHECK_HEADER(zlib.h, [
  352. AC_CHECK_LIB(z, inflate, [
  353. NEON_LIBS="$NEON_LIBS -lz"
  354. NE_ENABLE_SUPPORT(ZLIB, [zlib support enabled, using -lz])
  355. ], [NE_DISABLE_SUPPORT(ZLIB, [zlib library not found])])
  356. ], [NE_DISABLE_SUPPORT(ZLIB, [zlib header not found])])
  357. else
  358. NE_DISABLE_SUPPORT(ZLIB, [zlib not enabled])
  359. fi
  360. ])
  361. AC_DEFUN([NE_CHECK_OS], [
  362. # Check for Darwin, which needs extra cpp and linker flags.
  363. AC_CACHE_CHECK([for uname], ne_cv_os_uname, [
  364. ne_cv_os_uname=`uname -s 2>/dev/null`
  365. ])
  366. if test "$ne_cv_os_uname" = "Darwin"; then
  367. CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
  368. LDFLAGS="$LDFLAGS -flat_namespace"
  369. # poll has various issues in various Darwin releases
  370. if test x${ac_cv_func_poll+set} != xset; then
  371. ac_cv_func_poll=no
  372. fi
  373. fi
  374. ])
  375. AC_DEFUN([NEON_COMMON_CHECKS], [
  376. # These checks are done whether or not the bundled neon build
  377. # is used.
  378. ifdef([AC_USE_SYSTEM_EXTENSIONS],
  379. [AC_USE_SYSTEM_EXTENSIONS],
  380. [AC_ISC_POSIX])
  381. AC_REQUIRE([AC_PROG_CC])
  382. AC_REQUIRE([AC_C_INLINE])
  383. AC_REQUIRE([AC_C_CONST])
  384. AC_REQUIRE([AC_TYPE_SIZE_T])
  385. AC_REQUIRE([AC_TYPE_OFF_T])
  386. AC_REQUIRE([NE_CHECK_OS])
  387. AC_REQUIRE([AC_PROG_MAKE_SET])
  388. AC_REQUIRE([AC_HEADER_STDC])
  389. AC_CHECK_HEADERS([errno.h stdarg.h string.h stdlib.h sys/uio.h])
  390. NEON_FORMAT(size_t,,u) dnl size_t is unsigned; use %u formats
  391. NEON_FORMAT(off_t)
  392. NEON_FORMAT(ssize_t)
  393. ])
  394. AC_DEFUN([NEON_FORMAT_PREP], [
  395. AC_CHECK_SIZEOF(int)
  396. AC_CHECK_SIZEOF(long)
  397. AC_CHECK_SIZEOF(long long)
  398. if test "$GCC" = "yes"; then
  399. AC_CACHE_CHECK([for gcc -Wformat -Werror sanity], ne_cv_cc_werror, [
  400. # See whether a simple test program will compile without errors.
  401. ne_save_CPPFLAGS=$CPPFLAGS
  402. CPPFLAGS="$CPPFLAGS -Wformat -Werror"
  403. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  404. #include <stdio.h>]], [[int i = 42; printf("%d", i);]])],
  405. [ne_cv_cc_werror=yes], [ne_cv_cc_werror=no])
  406. CPPFLAGS=$ne_save_CPPFLAGS])
  407. ne_fmt_trycompile=$ne_cv_cc_werror
  408. else
  409. ne_fmt_trycompile=no
  410. fi
  411. ])
  412. dnl Check for LFS support
  413. AC_DEFUN([NE_LARGEFILE], [
  414. dnl Need the size of off_t
  415. AC_REQUIRE([NEON_COMMON_CHECKS])
  416. if test -z "$ac_cv_sizeof_off_t"; then
  417. NE_DISABLE_SUPPORT(LFS, [LFS support omitted: off_t size unknown!])
  418. elif test $ac_cv_sizeof_off_t != 4; then
  419. NE_DISABLE_SUPPORT(LFS, [LFS support unnecessary, off_t is not 32-bit])
  420. AC_CHECK_FUNCS([strtoll strtoq], [break])
  421. elif test -z "$ac_cv_sizeof_long_long"; then
  422. NE_DISABLE_SUPPORT(LFS, [LFS support omitted: long long size unknown])
  423. elif test $ac_cv_sizeof_long_long != 8; then
  424. NE_DISABLE_SUPPORT(LFS, [LFS support omitted: long long not 64-bit])
  425. else
  426. ne_save_CPPFLAGS=$CPPFLAGS
  427. CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
  428. AC_CHECK_TYPE(off64_t, [
  429. NEON_FORMAT(off64_t)
  430. ne_lfsok=no
  431. AC_CHECK_FUNCS([strtoll strtoq], [ne_lfsok=yes; break])
  432. AC_CHECK_FUNCS([lseek64 fstat64], [], [ne_lfsok=no; break])
  433. if test x$ne_lfsok = xyes; then
  434. NE_ENABLE_SUPPORT(LFS, [LFS (large file) support enabled])
  435. NEON_CFLAGS="$NEON_CFLAGS -D_LARGEFILE64_SOURCE -DNE_LFS"
  436. ne_save_CPPFLAGS="$CPPFLAGS -DNE_LFS"
  437. else
  438. NE_DISABLE_SUPPORT(LFS,
  439. [LFS support omitted: 64-bit support functions not found])
  440. fi], [NE_DISABLE_SUPPORT(LFS, [LFS support omitted: off64_t type not found])])
  441. CPPFLAGS=$ne_save_CPPFLAGS
  442. fi
  443. if test "$NE_FLAG_LFS" = "yes"; then
  444. AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF64_T],
  445. [Define to be printf format string for ne_off_t])
  446. NE_ADD_ABITAG(LFS)
  447. else
  448. AC_DEFINE_UNQUOTED([NE_FMT_NE_OFF_T], [NE_FMT_OFF_T])
  449. fi
  450. ])
  451. dnl NEON_FORMAT(TYPE[, HEADERS[, [SPECIFIER]])
  452. dnl
  453. dnl This macro finds out which modifier is needed to create a
  454. dnl printf format string suitable for printing integer type TYPE (which
  455. dnl may be an int, long, or long long).
  456. dnl The default specifier is 'd', if SPECIFIER is not given.
  457. dnl TYPE may be defined in HEADERS; sys/types.h is always used first.
  458. AC_DEFUN([NEON_FORMAT], [
  459. AC_REQUIRE([NEON_FORMAT_PREP])
  460. AC_CHECK_SIZEOF($1,, [AC_INCLUDES_DEFAULT
  461. $2])
  462. dnl Work out which specifier character to use
  463. m4_ifdef([ne_spec], [m4_undefine([ne_spec])])
  464. m4_if($#, 3, [m4_define(ne_spec,$3)], [m4_define(ne_spec,d)])
  465. m4_ifdef([ne_cvar], [m4_undefine([ne_cvar])])dnl
  466. m4_define([ne_cvar], m4_translit(ne_cv_fmt_[$1], [ ], [_]))dnl
  467. AC_CACHE_CHECK([how to print $1], [ne_cvar], [
  468. ne_cvar=none
  469. if test $ne_fmt_trycompile = yes; then
  470. oflags="$CPPFLAGS"
  471. # Consider format string mismatches as errors
  472. CPPFLAGS="$CPPFLAGS -Wformat -Werror"
  473. dnl obscured for m4 quoting: "for str in d ld lld; do"
  474. for str in ne_spec l]ne_spec[ ll]ne_spec[; do
  475. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  476. $2
  477. #include <stdio.h>]], [[$1 i = 1; printf("%$str", i);]])],
  478. [ne_cvar=$str; break])
  479. done
  480. CPPFLAGS=$oflags
  481. else
  482. # Best guess. Don't have to be too precise since we probably won't
  483. # get a warning message anyway.
  484. case $ac_cv_sizeof_]m4_translit($1, [ ], [_])[ in
  485. $ac_cv_sizeof_int) ne_cvar="ne_spec" ;;
  486. $ac_cv_sizeof_long) ne_cvar="l]ne_spec[" ;;
  487. $ac_cv_sizeof_long_long) ne_cvar="ll]ne_spec[" ;;
  488. esac
  489. fi
  490. ])
  491. if test "x$ne_cvar" = "xnone"; then
  492. AC_MSG_ERROR([format string for $1 not found])
  493. fi
  494. AC_DEFINE_UNQUOTED([NE_FMT_]m4_translit($1, [a-z ], [A-Z_]), "$ne_cvar",
  495. [Define to be printf format string for $1])
  496. ])
  497. dnl Wrapper for AC_CHECK_FUNCS; uses libraries from $NEON_LIBS.
  498. AC_DEFUN([NE_CHECK_FUNCS], [
  499. ne_cf_save_LIBS=$LIBS
  500. LIBS="$LIBS $NEON_LIBS"
  501. AC_CHECK_FUNCS($@)
  502. LIBS=$ne_cf_save_LIBS])
  503. dnl Checks needed when compiling the neon source.
  504. AC_DEFUN([LIBNEON_SOURCE_CHECKS], [
  505. dnl Run all the normal C language/compiler tests
  506. AC_REQUIRE([NEON_COMMON_CHECKS])
  507. dnl Needed for building the MD5 code.
  508. AC_REQUIRE([AC_C_BIGENDIAN])
  509. dnl Is strerror_r present; if so, which variant
  510. AC_REQUIRE([AC_FUNC_STRERROR_R])
  511. AC_CHECK_HEADERS([sys/time.h limits.h sys/select.h arpa/inet.h libintl.h \
  512. signal.h sys/socket.h netinet/in.h netinet/tcp.h netdb.h sys/poll.h \
  513. sys/limits.h fcntl.h iconv.h],,,
  514. [AC_INCLUDES_DEFAULT
  515. /* netinet/tcp.h requires netinet/in.h on some platforms. */
  516. #ifdef HAVE_NETINET_IN_H
  517. #include <netinet/in.h>
  518. #endif])
  519. AC_REQUIRE([NE_SNPRINTF])
  520. AC_CACHE_CHECK([for timezone global], ne_cv_cc_timezone, [
  521. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  522. #include <time.h>]],
  523. [[time_t t = 0 - timezone; timezone = 1;]])],
  524. ne_cv_cc_timezone=yes, ne_cv_cc_timezone=no)])
  525. if test "$ne_cv_cc_timezone" = "yes"; then
  526. AC_DEFINE([HAVE_TIMEZONE], 1, [Define if the timezone global is available])
  527. fi
  528. dnl Check for large file support
  529. NE_LARGEFILE
  530. AC_REPLACE_FUNCS(strcasecmp)
  531. AC_CHECK_FUNCS(signal setvbuf setsockopt stpcpy poll fcntl getsockopt)
  532. if test "x${ac_cv_func_poll}${ac_cv_header_sys_poll_h}y" = "xyesyesy"; then
  533. AC_DEFINE([NE_USE_POLL], 1, [Define if poll() should be used])
  534. fi
  535. if test "$ac_cv_func_stpcpy" = "yes"; then
  536. AC_CHECK_DECLS(stpcpy)
  537. fi
  538. # Modern AIXes with the "Linux-like" libc have an undeclared stpcpy
  539. AH_BOTTOM([#if defined(HAVE_STPCPY) && defined(HAVE_DECL_STPCPY) && !HAVE_DECL_STPCPY && !defined(stpcpy)
  540. char *stpcpy(char *, const char *);
  541. #endif])
  542. # Unixware 7 can only link gethostbyname with -lnsl -lsocket
  543. # Pick up -lsocket first, then the gethostbyname check will work.
  544. # Haiku requires -lnetwork for socket functions.
  545. NE_SEARCH_LIBS(socket, socket inet ws2_32 network)
  546. # Enable getaddrinfo support if it, gai_strerror and inet_ntop are
  547. # all available.
  548. NE_SEARCH_LIBS(getaddrinfo, nsl,,
  549. [ne_enable_gai=no],
  550. [# HP-UX boxes commonly get into a state where getaddrinfo is present
  551. # but borked: http://marc.theaimsgroup.com/?l=apr-dev&m=107730955207120&w=2
  552. case x`uname -sr 2>/dev/null`y in
  553. xHP-UX*11.[[01]]*y)
  554. AC_MSG_NOTICE([getaddrinfo support disabled on HP-UX 11.0x/11.1x]) ;;
  555. *)
  556. ne_enable_gai=yes
  557. NE_CHECK_FUNCS(gai_strerror getnameinfo inet_ntop inet_pton,,
  558. [ne_enable_gai=no; break]) ;;
  559. esac
  560. ])
  561. if test $ne_enable_gai = yes; then
  562. NE_ENABLE_SUPPORT(IPV6, [IPv6 support is enabled])
  563. AC_DEFINE(USE_GETADDRINFO, 1, [Define if getaddrinfo() should be used])
  564. AC_CACHE_CHECK([for working AI_ADDRCONFIG], [ne_cv_gai_addrconfig], [
  565. AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>
  566. #include <stdlib.h>],
  567. [struct addrinfo hints = {0}, *result;
  568. hints.ai_flags = AI_ADDRCONFIG;
  569. if (getaddrinfo("localhost", NULL, &hints, &result) != 0) return 1;])],
  570. ne_cv_gai_addrconfig=yes, ne_cv_gai_addrconfig=no, ne_cv_gai_addrconfig=no)])
  571. if test $ne_cv_gai_addrconfig = yes; then
  572. AC_DEFINE(USE_GAI_ADDRCONFIG, 1, [Define if getaddrinfo supports AI_ADDRCONFIG])
  573. fi
  574. else
  575. # Checks for non-getaddrinfo() based resolver interfaces.
  576. # QNX has gethostbyname in -lsocket. BeOS only has it in -lbind.
  577. # CygWin/Winsock2 has it in -lws2_32, allegedly.
  578. # Haiku requires -lnetwork for socket functions.
  579. NE_SEARCH_LIBS(gethostbyname, socket nsl bind ws2_32 network)
  580. NE_SEARCH_LIBS(hstrerror, resolv,,[:])
  581. NE_CHECK_FUNCS(hstrerror)
  582. # Older Unixes don't declare h_errno.
  583. AC_CHECK_DECLS(h_errno,,,[#include <netdb.h>])
  584. AC_CHECK_TYPE(in_addr_t,,[
  585. AC_DEFINE([in_addr_t], [unsigned int],
  586. [Define if in_addr_t is not available])], [
  587. #ifdef HAVE_SYS_TYPES_H
  588. # include <sys/types.h>
  589. #endif
  590. #ifdef HAVE_NETINET_IN_H
  591. # include <netinet/in.h>
  592. #endif
  593. ])
  594. fi
  595. AC_CHECK_TYPES(socklen_t,,
  596. # Linux accept(2) says this should be size_t for SunOS 5... gah.
  597. [AC_DEFINE([socklen_t], [int],
  598. [Define if socklen_t is not available])],[
  599. #ifdef HAVE_SYS_TYPES_H
  600. # include <sys/types.h>
  601. #endif
  602. #ifdef HAVE_SYS_SOCKET_H
  603. # include <sys/socket.h>
  604. #endif
  605. ])
  606. AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.__tm_gmtoff],,,
  607. [#include <time.h>])
  608. if test ${ac_cv_member_struct_tm_tm_gmtoff}${ac_cv_member_struct_tm___tm_gmtoff}${ne_cv_cc_timezone} = nonono; then
  609. AC_MSG_WARN([no timezone handling in date parsing on this platform])
  610. fi
  611. ifdef([neon_no_zlib],
  612. [NE_DISABLE_SUPPORT(ZLIB, [zlib not supported])],
  613. [NEON_ZLIB()])
  614. # Conditionally enable ACL support
  615. AC_MSG_CHECKING([whether to enable ACL support in neon])
  616. if test "x$neon_no_acl" = "xyes"; then
  617. AC_MSG_RESULT(no)
  618. else
  619. AC_MSG_RESULT(yes)
  620. NEON_EXTRAOBJS="$NEON_EXTRAOBJS ne_oldacl ne_acl3744"
  621. fi
  622. NEON_SSL()
  623. NEON_GSSAPI()
  624. NEON_LIBPROXY()
  625. AC_SUBST(NEON_CFLAGS)
  626. AC_SUBST(NEON_LIBS)
  627. AC_SUBST(NEON_LTLIBS)
  628. ])
  629. dnl Call to put lib/snprintf.o in LIBOBJS and define HAVE_SNPRINTF_H
  630. dnl if snprintf isn't in libc.
  631. AC_DEFUN([NEON_REPLACE_SNPRINTF], [
  632. # Check for snprintf
  633. AC_CHECK_FUNC(snprintf,,[
  634. AC_DEFINE(HAVE_SNPRINTF_H, 1, [Define if need to include snprintf.h])
  635. AC_LIBOBJ(lib/snprintf)])
  636. ])
  637. dnl turn off webdav, boo hoo.
  638. AC_DEFUN([NEON_WITHOUT_WEBDAV], [
  639. neon_no_webdav=yes
  640. neon_no_acl=yes
  641. NEON_NEED_XML_PARSER=no
  642. neon_xml_parser_message="none needed"
  643. ])
  644. dnl Turn off zlib support
  645. AC_DEFUN([NEON_WITHOUT_ZLIB], [
  646. define(neon_no_zlib, yes)
  647. ])
  648. AC_DEFUN([NEON_WITHOUT_ACL], [
  649. # Turn off ACL support
  650. neon_no_acl=yes
  651. ])
  652. dnl Common macro to NEON_LIBTOOL_BUILD and NEON_NORMAL_BUILD
  653. dnl Sets NEONOBJS appropriately if it has not already been set.
  654. dnl
  655. dnl NOT FOR EXTERNAL USE: use LIBTOOL_BUILD or NORMAL_BUILD.
  656. dnl
  657. AC_DEFUN([NEON_COMMON_BUILD], [
  658. # Using the default set of object files to build.
  659. # Add the extension to EXTRAOBJS
  660. ne="$NEON_EXTRAOBJS"
  661. NEON_EXTRAOBJS=
  662. for o in $ne; do
  663. NEON_EXTRAOBJS="$NEON_EXTRAOBJS $o.$NEON_OBJEXT"
  664. done
  665. # Was DAV support explicitly turned off?
  666. if test "x$neon_no_webdav" = "xyes"; then
  667. # No WebDAV support
  668. NEONOBJS="$NEONOBJS \$(NEON_BASEOBJS)"
  669. NE_DISABLE_SUPPORT(DAV, [WebDAV support is not enabled])
  670. NE_ADD_ABITAG(NODAV)
  671. else
  672. # WebDAV support
  673. NEONOBJS="$NEONOBJS \$(NEON_DAVOBJS)"
  674. NE_ENABLE_SUPPORT(DAV, [WebDAV support is enabled])
  675. fi
  676. AC_SUBST(NEON_TARGET)
  677. AC_SUBST(NEON_OBJEXT)
  678. AC_SUBST(NEONOBJS)
  679. AC_SUBST(NEON_EXTRAOBJS)
  680. AC_SUBST(NEON_LINK_FLAGS)
  681. ])
  682. # The libtoolized build case:
  683. AC_DEFUN([NEON_LIBTOOL_BUILD], [
  684. NEON_TARGET=libneon.la
  685. NEON_OBJEXT=lo
  686. NEON_COMMON_BUILD($#, $*)
  687. ])
  688. dnl Find 'ar' and 'ranlib', fail if ar isn't found.
  689. AC_DEFUN([NE_FIND_AR], [
  690. # Search in /usr/ccs/bin for Solaris
  691. ne_PATH=$PATH:/usr/ccs/bin
  692. AC_PATH_TOOL(AR, ar, notfound, $ne_PATH)
  693. if test "x$AR" = "xnotfound"; then
  694. AC_MSG_ERROR([could not find ar tool])
  695. fi
  696. AC_PATH_TOOL(RANLIB, ranlib, :, $ne_PATH)
  697. ])
  698. # The non-libtool build case:
  699. AC_DEFUN([NEON_NORMAL_BUILD], [
  700. NEON_TARGET=libneon.a
  701. NEON_OBJEXT=o
  702. AC_REQUIRE([NE_FIND_AR])
  703. NEON_COMMON_BUILD($#, $*)
  704. ])
  705. AC_DEFUN([NE_SNPRINTF], [
  706. AC_CHECK_FUNCS(snprintf vsnprintf,,[
  707. ne_save_LIBS=$LIBS
  708. LIBS="$LIBS -lm" # Always need -lm
  709. AC_CHECK_LIB(trio, trio_vsnprintf,
  710. [AC_CHECK_HEADERS(trio.h,,
  711. AC_MSG_ERROR([trio installation problem? libtrio found but not trio.h]))
  712. AC_MSG_NOTICE(using trio printf replacement library)
  713. NEON_LIBS="$NEON_LIBS -ltrio -lm"
  714. AC_DEFINE(HAVE_TRIO, 1, [Use trio printf replacement library])],
  715. [AC_MSG_NOTICE([no vsnprintf/snprintf detected in C library])
  716. AC_MSG_ERROR([Install the trio library from http://daniel.haxx.se/projects/trio/])])
  717. LIBS=$ne_save_LIBS
  718. break
  719. ])])
  720. dnl Usage: NE_CHECK_OPENSSLVER(variable, version-string, version-hex)
  721. dnl Define 'variable' to 'yes' if OpenSSL version is >= version-hex
  722. AC_DEFUN([NE_CHECK_OPENSSLVER], [
  723. AC_CACHE_CHECK([OpenSSL version is >= $2], $1, [
  724. AC_EGREP_CPP(good, [#include <openssl/opensslv.h>
  725. #if OPENSSL_VERSION_NUMBER >= $3
  726. good
  727. #endif], [$1=yes], [$1=no])])])
  728. dnl Less noisy replacement for PKG_CHECK_MODULES
  729. AC_DEFUN([NE_PKG_CONFIG], [
  730. m4_define([ne_cvar], m4_translit(ne_cv_pkg_[$2], [.-], [__]))dnl
  731. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  732. if test "$PKG_CONFIG" = "no"; then
  733. : Not using pkg-config
  734. $4
  735. else
  736. AC_CACHE_CHECK([for $2 pkg-config data], ne_cvar,
  737. [if $PKG_CONFIG $2; then
  738. ne_cvar=yes
  739. else
  740. ne_cvar=no
  741. fi])
  742. if test "$ne_cvar" = "yes"; then
  743. $1_CFLAGS=`$PKG_CONFIG --cflags $2`
  744. $1_LIBS=`$PKG_CONFIG --libs $2`
  745. $1_VERSION=`$PKG_CONFIG --modversion $2`
  746. : Using provided pkg-config data
  747. $3
  748. else
  749. : No pkg-config for $2 provided
  750. $4
  751. fi
  752. fi
  753. m4_undefine([ne_cvar])
  754. ])
  755. dnl Check for an SSL library (GNU TLS or OpenSSL)
  756. AC_DEFUN([NEON_SSL], [
  757. AC_ARG_WITH(ssl,
  758. AS_HELP_STRING([--with-ssl=openssl|gnutls],
  759. [enable SSL support (default OpenSSL)]))
  760. AC_ARG_WITH(egd,
  761. [[ --with-egd[=PATH] enable EGD support [using EGD socket at PATH]]])
  762. AC_ARG_WITH(pakchois,
  763. AS_HELP_STRING([--without-pakchois],
  764. [disable support for PKCS#11 using pakchois]))
  765. case $with_ssl in
  766. /*)
  767. AC_MSG_NOTICE([to use SSL libraries in non-standard locations, try --with-ssl --with-libs=$with_ssl])
  768. AC_MSG_ERROR([--with-ssl does not take a path argument])
  769. ;;
  770. yes|openssl)
  771. NE_PKG_CONFIG(NE_SSL, openssl,
  772. [AC_MSG_NOTICE(using OpenSSL $NE_SSL_VERSION library configuration from pkg-config)
  773. CPPFLAGS="$CPPFLAGS ${NE_SSL_CFLAGS}"
  774. NEON_LIBS="$NEON_LIBS ${NE_SSL_LIBS}"],
  775. [# Either OpenSSL library may require -ldl if built with dynamic engine support
  776. NE_SEARCH_LIBS(RSA_new, crypto, -ldl)
  777. NE_SEARCH_LIBS(SSL_library_init, ssl, -ldl)
  778. NE_SSL_VERSION="(0.9.7 or later)"])
  779. AC_CHECK_HEADERS(openssl/ssl.h openssl/opensslv.h,,
  780. [AC_MSG_ERROR([OpenSSL headers not found, cannot enable SSL support])])
  781. NE_CHECK_OPENSSLVER(ne_cv_lib_ssl097, 0.9.7, 0x00907000L)
  782. NE_CHECK_OPENSSLVER(ne_cv_lib_ssl110, 1.1.0, 0x10100000L)
  783. if test "$ne_cv_lib_ssl110" = "yes"; then
  784. NE_ENABLE_SUPPORT(SSL, [SSL support enabled, using OpenSSL $NE_SSL_VERSION])
  785. elif test "$ne_cv_lib_ssl097" = "yes"; then
  786. # Enable EGD support if using 0.9.7 or newer
  787. AC_MSG_NOTICE([OpenSSL >= 0.9.7; EGD support not needed in neon])
  788. NE_ENABLE_SUPPORT(SSL, [SSL support enabled, using OpenSSL $NE_SSL_VERSION])
  789. NE_CHECK_FUNCS(CRYPTO_set_idptr_callback SSL_SESSION_cmp)
  790. else
  791. # Fail if OpenSSL is older than 0.9.6
  792. NE_CHECK_OPENSSLVER(ne_cv_lib_ssl096, 0.9.6, 0x00906000L)
  793. if test "$ne_cv_lib_ssl096" != "yes"; then
  794. AC_MSG_ERROR([OpenSSL 0.9.6 or later is required])
  795. fi
  796. NE_ENABLE_SUPPORT(SSL, [SSL support enabled, using OpenSSL (0.9.6 or later)])
  797. case "$with_egd" in
  798. yes|no) ne_cv_lib_sslegd=$with_egd ;;
  799. /*) ne_cv_lib_sslegd=yes
  800. AC_DEFINE_UNQUOTED([EGD_PATH], "$with_egd",
  801. [Define to specific EGD socket path]) ;;
  802. *) # Guess whether EGD support is needed
  803. AC_CACHE_CHECK([whether to enable EGD support], [ne_cv_lib_sslegd],
  804. [if test -r /dev/random || test -r /dev/urandom; then
  805. ne_cv_lib_sslegd=no
  806. else
  807. ne_cv_lib_sslegd=yes
  808. fi])
  809. ;;
  810. esac
  811. if test "$ne_cv_lib_sslegd" = "yes"; then
  812. AC_MSG_NOTICE([EGD support enabled for seeding OpenSSL PRNG])
  813. AC_DEFINE([ENABLE_EGD], 1, [Define if EGD should be supported])
  814. fi
  815. fi
  816. AC_DEFINE([HAVE_OPENSSL], 1, [Define if OpenSSL support is enabled])
  817. NEON_EXTRAOBJS="$NEON_EXTRAOBJS ne_openssl"
  818. AC_DEFINE([HAVE_NTLM], 1, [Define if NTLM is supported])
  819. ;;
  820. gnutls)
  821. NE_PKG_CONFIG(NE_SSL, gnutls,
  822. [AC_MSG_NOTICE(using GnuTLS configuration from pkg-config)
  823. CPPFLAGS="$CPPFLAGS ${NE_SSL_CFLAGS}"
  824. NEON_LIBS="$NEON_LIBS ${NE_SSL_LIBS}"
  825. ], [
  826. # Fall back on libgnutls-config script
  827. AC_PATH_PROG(GNUTLS_CONFIG, libgnutls-config, no)
  828. if test "$GNUTLS_CONFIG" = "no"; then
  829. AC_MSG_ERROR([could not find libgnutls-config in \$PATH])
  830. fi
  831. CPPFLAGS="$CPPFLAGS `$GNUTLS_CONFIG --cflags`"
  832. NEON_LIBS="$NEON_LIBS `$GNUTLS_CONFIG --libs`"
  833. NE_SSL_VERSION="`$GNUTLS_CONFIG --version`"
  834. ])
  835. AC_CHECK_HEADER([gnutls/gnutls.h],,
  836. [AC_MSG_ERROR([could not find gnutls/gnutls.h in include path])])
  837. NE_ENABLE_SUPPORT(SSL, [SSL support enabled, using GnuTLS $NE_SSL_VERSION])
  838. NEON_EXTRAOBJS="$NEON_EXTRAOBJS ne_gnutls"
  839. AC_DEFINE([HAVE_GNUTLS], 1, [Define if GnuTLS support is enabled])
  840. # Check for functions in later releases
  841. NE_CHECK_FUNCS([gnutls_session_get_data2 gnutls_x509_dn_get_rdn_ava \
  842. gnutls_certificate_get_issuer \
  843. gnutls_certificate_get_x509_cas \
  844. gnutls_x509_crt_sign2 \
  845. gnutls_certificate_set_retrieve_function2 \
  846. gnutls_privkey_import_ext])
  847. # fail if gnutls_x509_crt_sign2 is not found (it was introduced in 1.2.0, which is required)
  848. if test x${ac_cv_func_gnutls_x509_crt_sign2} != xyes; then
  849. AC_MSG_ERROR([GnuTLS version predates gnutls_x509_crt_sign2, newer version required (at least 1.2.0)])
  850. fi
  851. # Check for iconv support if using the new RDN access functions:
  852. if test ${ac_cv_func_gnutls_x509_dn_get_rdn_ava}X${ac_cv_header_iconv_h} = yesXyes; then
  853. AC_CHECK_FUNCS(iconv)
  854. fi
  855. ;;
  856. *) # Default to off; only create crypto-enabled binaries if requested.
  857. NE_DISABLE_SUPPORT(SSL, [SSL support is not enabled])
  858. NE_DISABLE_SUPPORT(TS_SSL, [Thread-safe SSL support is not enabled])
  859. NEON_EXTRAOBJS="$NEON_EXTRAOBJS ne_stubssl"
  860. ;;
  861. esac
  862. AC_SUBST(NEON_SUPPORTS_SSL)
  863. AC_ARG_WITH(ca-bundle,
  864. AS_HELP_STRING(--with-ca-bundle, specify filename of an SSL CA root bundle),,
  865. with_ca_bundle=no)
  866. case ${NE_FLAG_SSL}-${with_ca_bundle} in
  867. *-no) ;;
  868. yes-*)
  869. AC_DEFINE_UNQUOTED([NE_SSL_CA_BUNDLE], ["${with_ca_bundle}"],
  870. [Define to be filename of an SSL CA root bundle])
  871. AC_MSG_NOTICE([Using ${with_ca_bundle} as default SSL CA bundle])
  872. ;;
  873. esac
  874. AC_ARG_ENABLE(threadsafe-ssl,
  875. AS_HELP_STRING(--enable-threadsafe-ssl=posix,
  876. [enable SSL library thread-safety using POSIX threads: suitable
  877. CC/CFLAGS/LIBS must be used to make the POSIX library interfaces
  878. available]),,
  879. enable_threadsafe_ssl=no)
  880. case ${enable_threadsafe_ssl}X${ne_cv_lib_ssl110} in
  881. *Xyes)
  882. NE_ENABLE_SUPPORT(TS_SSL, [OpenSSL is natively thread-safe])
  883. ;;
  884. posixX*|yesX*)
  885. ne_pthr_ok=yes
  886. AC_CHECK_FUNCS([pthread_mutex_init pthread_mutex_lock],,[ne_pthr_ok=no])
  887. if test "${ne_pthr_ok}" = "no"; then
  888. AC_MSG_ERROR([could not find POSIX mutex interfaces; (try CC="${CC} -pthread"?)])
  889. fi
  890. NE_ENABLE_SUPPORT(TS_SSL, [Thread-safe SSL supported using POSIX threads])
  891. ;;
  892. *)
  893. NE_DISABLE_SUPPORT(TS_SSL, [Thread-safe SSL not supported])
  894. ;;
  895. esac
  896. case ${with_pakchois}X${ac_cv_func_gnutls_privkey_import_ext}Y${ne_cv_lib_ssl097} in
  897. noX*Y*) ;;
  898. *X*Yyes|*XyesY*)
  899. # PKCS#11... ho!
  900. NE_PKG_CONFIG(NE_PK11, pakchois,
  901. [AC_MSG_NOTICE([[using pakchois $NE_PK11_VERSION for PKCS#11 support]])
  902. AC_DEFINE(HAVE_PAKCHOIS, 1, [Define if pakchois library supported])
  903. CPPFLAGS="$CPPFLAGS ${NE_PK11_CFLAGS}"
  904. NEON_LIBS="${NEON_LIBS} ${NE_PK11_LIBS}"],
  905. [AC_MSG_NOTICE([[pakchois library not found; no PKCS#11 support]])])
  906. ;;
  907. esac
  908. ]) dnl -- end defun NEON_SSL
  909. dnl Check for Kerberos installation
  910. AC_DEFUN([NEON_GSSAPI], [
  911. AC_ARG_WITH(gssapi, AS_HELP_STRING(--without-gssapi, disable GSSAPI support))
  912. if test "$with_gssapi" != "no"; then
  913. AC_PATH_PROG([KRB5_CONFIG], krb5-config, none, $PATH:/usr/kerberos/bin)
  914. else
  915. KRB5_CONFIG=none
  916. fi
  917. if test "x$KRB5_CONFIG" != "xnone"; then
  918. ne_save_CPPFLAGS=$CPPFLAGS
  919. ne_save_LIBS=$NEON_LIBS
  920. NEON_LIBS="$NEON_LIBS `${KRB5_CONFIG} --libs gssapi`"
  921. CPPFLAGS="$CPPFLAGS `${KRB5_CONFIG} --cflags gssapi`"
  922. # MIT and Heimdal put gssapi.h in different places
  923. AC_CHECK_HEADERS(gssapi/gssapi.h gssapi.h, [
  924. NE_CHECK_FUNCS(gss_init_sec_context, [
  925. ne_save_CPPFLAGS=$CPPFLAGS
  926. ne_save_LIBS=$NEON_LIBS
  927. AC_MSG_NOTICE([GSSAPI authentication support enabled])
  928. AC_DEFINE(HAVE_GSSAPI, 1, [Define if GSSAPI support is enabled])
  929. AC_CHECK_HEADERS(gssapi/gssapi_generic.h)
  930. # Older versions of MIT Kerberos lack GSS_C_NT_HOSTBASED_SERVICE
  931. AC_CHECK_DECL([GSS_C_NT_HOSTBASED_SERVICE],,
  932. [AC_DEFINE([GSS_C_NT_HOSTBASED_SERVICE], gss_nt_service_name,
  933. [Define if GSS_C_NT_HOSTBASED_SERVICE is not defined otherwise])],
  934. [#ifdef HAVE_GSSAPI_GSSAPI_H
  935. #include <gssapi/gssapi.h>
  936. #else
  937. #include <gssapi.h>
  938. #endif])])
  939. break
  940. ])
  941. CPPFLAGS=$ne_save_CPPFLAGS
  942. NEON_LIBS=$ne_save_LIBS
  943. fi])
  944. AC_DEFUN([NEON_LIBPROXY], [
  945. AC_ARG_WITH(libproxy, AS_HELP_STRING(--without-libproxy, disable libproxy support))
  946. if test "x$with_libproxy" != "xno"; then
  947. NE_PKG_CONFIG(NE_PXY, libproxy-1.0,
  948. [AC_DEFINE(HAVE_LIBPROXY, 1, [Define if libproxy is supported])
  949. CPPFLAGS="$CPPFLAGS $NE_PXY_CFLAGS"
  950. NEON_LIBS="$NEON_LIBS ${NE_PXY_LIBS}"
  951. NE_ENABLE_SUPPORT(LIBPXY, [libproxy support enabled using libproxy $NE_PXY_VERSION])],
  952. [NE_DISABLE_SUPPORT(LIBPXY, [libproxy support not enabled])])
  953. else
  954. NE_DISABLE_SUPPORT(LIBPXY, [libproxy support not enabled])
  955. fi
  956. ])
  957. dnl Adds an --enable-warnings argument to configure to allow enabling
  958. dnl compiler warnings
  959. AC_DEFUN([NEON_WARNINGS],[
  960. AC_REQUIRE([AC_PROG_CC]) dnl so that $GCC is set
  961. AC_ARG_ENABLE(warnings,
  962. AS_HELP_STRING(--enable-warnings, [enable compiler warnings]))
  963. if test "$enable_warnings" = "yes"; then
  964. case $GCC:`uname` in
  965. yes:*)
  966. CFLAGS="$CFLAGS -Wall -Wmissing-declarations -Wshadow -Wreturn-type -Wsign-compare -Wundef -Wpointer-arith -Wbad-function-cast -Wformat-security"
  967. if test -z "$with_ssl" -o "$with_ssl" = "no"; then
  968. # OpenSSL headers fail strict prototypes checks
  969. CFLAGS="$CFLAGS -Wstrict-prototypes"
  970. fi
  971. ;;
  972. no:OSF1) CFLAGS="$CFLAGS -check -msg_disable returnchecks -msg_disable alignment -msg_disable overflow" ;;
  973. no:IRIX) CFLAGS="$CFLAGS -fullwarn" ;;
  974. no:UnixWare) CFLAGS="$CFLAGS -v" ;;
  975. *) AC_MSG_WARN([warning flags unknown for compiler on this platform]) ;;
  976. esac
  977. fi
  978. ])
  979. dnl Adds an --disable-debug argument to configure to allow disabling
  980. dnl debugging messages.
  981. dnl Usage:
  982. dnl NEON_WARNINGS([actions-if-debug-enabled], [actions-if-debug-disabled])
  983. dnl
  984. AC_DEFUN([NEON_DEBUG], [
  985. AC_ARG_ENABLE(debug,
  986. AS_HELP_STRING(--disable-debug,[disable runtime debugging messages]))
  987. # default is to enable debugging
  988. case $enable_debug in
  989. no) AC_MSG_NOTICE([debugging is disabled])
  990. $2 ;;
  991. *) AC_MSG_NOTICE([debugging is enabled])
  992. AC_DEFINE(NE_DEBUGGING, 1, [Define to enable debugging])
  993. $1
  994. ;;
  995. esac])
  996. dnl Macro to optionally enable socks support
  997. AC_DEFUN([NEON_SOCKS], [
  998. ])
  999. AC_DEFUN([NEON_WITH_LIBS], [
  1000. AC_ARG_WITH([libs],
  1001. [[ --with-libs=DIR[:DIR2...] look for support libraries in DIR/{bin,lib,include}]],
  1002. [case $with_libs in
  1003. yes|no) AC_MSG_ERROR([--with-libs must be passed a directory argument]) ;;
  1004. *) ne_save_IFS=$IFS; IFS=:
  1005. for dir in $with_libs; do
  1006. ne_add_CPPFLAGS="$ne_add_CPPFLAGS -I${dir}/include"
  1007. ne_add_LDFLAGS="$ne_add_LDFLAGS -L${dir}/lib"
  1008. ne_add_PATH="${ne_add_PATH}${dir}/bin:"
  1009. PKG_CONFIG_PATH=${PKG_CONFIG_PATH}${PKG_CONFIG_PATH+:}${dir}/lib/pkgconfig
  1010. done
  1011. IFS=$ne_save_IFS
  1012. CPPFLAGS="${ne_add_CPPFLAGS} $CPPFLAGS"
  1013. LDFLAGS="${ne_add_LDFLAGS} $LDFLAGS"
  1014. PATH=${ne_add_PATH}$PATH
  1015. export PKG_CONFIG_PATH ;;
  1016. esac])])
  1017. AC_DEFUN([NEON_I18N], [
  1018. dnl Check for NLS iff libintl.h was detected.
  1019. AC_ARG_ENABLE(nls,
  1020. AS_HELP_STRING(--disable-nls, [disable internationalization support]),,
  1021. [enable_nls=${ac_cv_header_libintl_h}])
  1022. if test x${enable_nls} = xyes; then
  1023. # presume that dgettext() is available if bindtextdomain() is...
  1024. # checking for dgettext() itself is awkward because gcc has a
  1025. # builtin of that function, which confuses AC_CHECK_FUNCS et al.
  1026. NE_SEARCH_LIBS(bindtextdomain, intl, -liconv ,[enable_nls=no])
  1027. NE_CHECK_FUNCS(bind_textdomain_codeset)
  1028. fi
  1029. if test "$enable_nls" = "no"; then
  1030. NE_DISABLE_SUPPORT(I18N, [Internationalization support not enabled])
  1031. else
  1032. NE_ENABLE_SUPPORT(I18N, [Internationalization support enabled])
  1033. eval localedir="${datadir}/locale"
  1034. AC_DEFINE_UNQUOTED([LOCALEDIR], "$localedir",
  1035. [Define to be location of localedir])
  1036. fi
  1037. ])