neon.m4 42 KB

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