neon.m4 39 KB

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