configure.ac 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ([2.67])
  5. LT_PREREQ([2.2.6])
  6. AC_INIT([aria2],[1.17.0],[t-tujikawa@users.sourceforge.net],[aria2],[http://aria2.sourceforge.net/])
  7. AC_USE_SYSTEM_EXTENSIONS
  8. LT_INIT([disable-static])
  9. dnl See versioning rule:
  10. dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
  11. AC_SUBST(LT_CURRENT, 0)
  12. AC_SUBST(LT_REVISION, 0)
  13. AC_SUBST(LT_AGE, 0)
  14. AC_CONFIG_MACRO_DIR([m4])
  15. AC_CANONICAL_HOST
  16. AC_CANONICAL_TARGET
  17. AM_INIT_AUTOMAKE()
  18. AM_PATH_CPPUNIT(1.10.2)
  19. AC_CONFIG_SRCDIR([src/a2io.h])
  20. AC_CONFIG_HEADERS([config.h])
  21. case "$host" in
  22. *mingw*)
  23. win_build=yes
  24. LIBS="$LIBS -lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi"
  25. ;;
  26. esac
  27. AC_DEFINE_UNQUOTED([TARGET], ["$target"], [Define target-type])
  28. # Checks for arguments.
  29. ARIA2_ARG_WITHOUT([libuv])
  30. ARIA2_ARG_WITHOUT([appletls])
  31. ARIA2_ARG_WITHOUT([gnutls])
  32. ARIA2_ARG_WITHOUT([libnettle])
  33. ARIA2_ARG_WITHOUT([libgmp])
  34. ARIA2_ARG_WITHOUT([libgcrypt])
  35. ARIA2_ARG_WITHOUT([openssl])
  36. ARIA2_ARG_WITHOUT([sqlite3])
  37. ARIA2_ARG_WITHOUT([libxml2])
  38. ARIA2_ARG_WITHOUT([libexpat])
  39. ARIA2_ARG_WITHOUT([libcares])
  40. ARIA2_ARG_WITHOUT([libz])
  41. ARIA2_ARG_WITH([tcmalloc])
  42. ARIA2_ARG_WITH([jemalloc])
  43. ARIA2_ARG_DISABLE([bittorrent])
  44. ARIA2_ARG_DISABLE([metalink])
  45. ARIA2_ARG_DISABLE([epoll])
  46. ARIA2_ARG_ENABLE([libaria2])
  47. AC_ARG_WITH([ca-bundle],
  48. AS_HELP_STRING([--with-ca-bundle=FILE],[Use FILE as default CA bundle.]),
  49. [ca_bundle=$withval], [ca_bundle=""])
  50. AC_ARG_WITH([bashcompletiondir],
  51. AS_HELP_STRING([--with-bashcompletiondir=DIR],
  52. [Directory to install bash_completion file]),
  53. [bashcompletiondir=$withval], [bashcompletiondir=$docdir/bash_completion])
  54. AC_ARG_VAR([ARIA2_STATIC], [Set 'yes' to build a statically linked aria2])
  55. # Checks for programs.
  56. AC_PROG_CXX
  57. AC_PROG_CC
  58. AC_PROG_INSTALL
  59. AC_PROG_MKDIR_P
  60. AC_PROG_YACC
  61. AM_PROG_AS
  62. AC_CHECK_TOOL([AR], [ar], [:])
  63. if test "x$AR" = "x:"; then
  64. AC_MSG_FAILURE([ar is not found in the system.])
  65. fi
  66. AC_SUBST([AR])
  67. AC_PATH_PROG([A2X], [a2x])
  68. AC_SUBST([A2X])
  69. AM_CONDITIONAL([HAVE_A2X], [ test "x$A2X" != "x" ])
  70. AC_PATH_PROG([ASCIIDOC], [asciidoc])
  71. AC_SUBST([ASCIIDOC])
  72. AM_CONDITIONAL([HAVE_ASCIIDOC], [ test "x$ASCIIDOC" != "x" ])
  73. # Setting language choice
  74. AC_LANG([C++])
  75. # Check pkg-config is available
  76. PKG_PROG_PKG_CONFIG([0.20])
  77. # Check static build is requested
  78. if test "x$ARIA2_STATIC" = "xyes"; then
  79. case "$host" in
  80. i686*mingw*)
  81. dnl Define _USE_32BIT_TIME_T because 32bit library of MinGW-w64
  82. dnl does not implement many 64bit version functions.
  83. CPPFLAGS="-D_USE_32BIT_TIME_T $CPPFLAGS"
  84. ;;
  85. esac
  86. # Make pkg-config produce static linking variables
  87. PKG_CONFIG="$PKG_CONFIG --static"
  88. else
  89. dnl Make variable empty to avoid confusion
  90. ARIA2_STATIC=
  91. fi
  92. # Checks for libraries.
  93. # Check availability of libz
  94. if test "x$with_libz" = "xyes"; then
  95. PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
  96. if test "x$have_zlib" = "xyes"; then
  97. LIBS="$ZLIB_LIBS $LIBS"
  98. CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS"
  99. else
  100. AC_MSG_WARN([$ZLIB_PKG_ERRORS])
  101. AC_CHECK_LIB([z], [zlibVersion], [have_zlib=yes], [have_zlib=no])
  102. if test "x$have_zlib" = "xyes"; then
  103. LIBS="-lz $LIBS"
  104. elif test "x$with_libz_requested" = "xyes"; then
  105. ARIA2_DEP_NOT_MET([libz])
  106. fi
  107. fi
  108. if test "x$have_zlib" = "xyes"; then
  109. AC_DEFINE([HAVE_ZLIB], [1], [Define to 1 if you have zlib.])
  110. # Android NDK arch-mips contains gzbuffer symbol but it is missing
  111. # in zlib.h
  112. AC_CHECK_DECL([gzbuffer], [have_decl_gzbuffer=yes], [],
  113. [[#include <zlib.h>]])
  114. if test "x$have_decl_gzbuffer" = "xyes"; then
  115. AC_CHECK_FUNC([gzbuffer])
  116. fi
  117. AC_CHECK_FUNCS([gzsetparams])
  118. fi
  119. fi
  120. if test "x$with_libuv" = "xyes"; then
  121. case "$host" in
  122. *mingw*|*msvc*)
  123. old_CPPFLAGS=$CPPFLAGS
  124. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
  125. AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [
  126. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  127. break;
  128. ], [have_libuv=no])
  129. if test "x$have_libuv" != "xyes"; then
  130. CPPFLAGS=$old_CPPFLAGS
  131. fi
  132. ;;
  133. *darwin*)
  134. old_LDFLAGS=$LDFLAGS
  135. LDFLAGS="$LDFLAGS -framework Foundation -framework CoreServices -framework ApplicationServices"
  136. old_LIBS=$LIBS
  137. LIBS="$LIBS -lm"
  138. AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [
  139. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  140. break;
  141. ], [have_libuv=no])
  142. if test "x$have_libuv" != "xyes"; then
  143. LDFLAGS=$old_LDFLAGS
  144. LIBS=$old_LIBS
  145. fi
  146. ;;
  147. *)
  148. dnl Yeah, sucks that luv does not bring a pkg-config or config-tool
  149. AC_MSG_CHECKING([for libuv])
  150. for combo in "" "-lrt" "-ldl -lrt" "-ldl -lrt -lpthread" "-lkvm"; do
  151. old_LIBS=$LIBS
  152. LIBS="-luv $combo $LIBS -lm"
  153. AC_LINK_IFELSE([AC_LANG_SOURCE([
  154. extern "C" int uv_poll_init_socket(void);
  155. int main() { return uv_poll_init_socket(); }
  156. ])], [
  157. AC_MSG_RESULT(-luv $combo -lm)
  158. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  159. break;
  160. ], [have_libuv=no])
  161. if test "x$have_libuv" = "xyes"; then
  162. break;
  163. else
  164. LIBS=$old_LIBS
  165. fi
  166. done
  167. if test "x$have_libuv" != "xyes"; then
  168. AC_MSG_RESULT("no")
  169. fi
  170. ;;
  171. esac
  172. if test "x$have_libuv" = "xyes"; then
  173. AC_DEFINE([HAVE_LIBUV], [1], [Define to 1 if you have libuv.])
  174. elif test "x$with_libuv_requested" = "xyes"; then
  175. ARIA2_DEP_NOT_MET([libuv])
  176. fi
  177. fi
  178. AM_CONDITIONAL([HAVE_LIBUV], [test "x$have_libuv" = "xyes"])
  179. if test "x$with_libxml2" = "xyes"; then
  180. AM_PATH_XML2([2.6.24], [have_libxml2=yes])
  181. if test "x$have_libxml2" = "xyes"; then
  182. AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
  183. LIBS="$XML_LIBS $LIBS"
  184. CPPFLAGS="$XML_CPPFLAGS $CPPFLAGS"
  185. elif test "x$with_libxml2_requested" = "xyes"; then
  186. ARIA2_DEP_NOT_MET([libxml2])
  187. fi
  188. fi
  189. if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
  190. AM_PATH_LIBEXPAT
  191. if test "x$have_libexpat" = "xyes"; then
  192. LIBS="$EXPAT_LIBS $LIBS"
  193. CPPFLAGS="$EXPAT_CFLAGS $CPPFLAGS"
  194. elif test "x$with_libexpat_requested" = "xyes"; then
  195. ARIA2_DEP_NOT_MET([libexpat])
  196. fi
  197. fi
  198. if test "x$with_sqlite3" = "xyes"; then
  199. PKG_CHECK_MODULES([SQLITE3],[sqlite3],[have_sqlite3=yes],[have_sqlite3=no])
  200. if test "x$have_sqlite3" = "xyes"; then
  201. AC_DEFINE([HAVE_SQLITE3], [1], [Define to 1 if you have sqlite3.])
  202. LIBS="$SQLITE3_LIBS $LIBS"
  203. CPPFLAGS="$SQLITE3_CFLAGS $CPPFLAGS"
  204. AC_CHECK_FUNCS([sqlite3_open_v2])
  205. else
  206. AC_MSG_WARN([$SQLITE3_PKG_ERRORS])
  207. if test "x$with_sqlite3_requested" = "xyes"; then
  208. ARIA2_DEP_NOT_MET([sqlite3])
  209. fi
  210. fi
  211. fi
  212. case "$host" in
  213. *darwin*)
  214. have_osx="yes"
  215. ;;
  216. esac
  217. if test "x$with_appletls" = "xyes"; then
  218. AC_MSG_CHECKING([whether to enable Mac OS X native SSL/TLS])
  219. if test "x$have_osx" = "xyes"; then
  220. AC_DEFINE([HAVE_APPLETLS], [1], [Define to 1 if you have Apple TLS])
  221. LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Security"
  222. have_appletls="yes"
  223. AC_MSG_RESULT(yes)
  224. else
  225. AC_MSG_RESULT(no)
  226. if test "x$with_appletls_requested" = "xyes"; then
  227. ARIA2_DEP_NOT_MET([appletls])
  228. fi
  229. fi
  230. fi
  231. if test "x$with_gnutls" = "xyes" && test "x$have_appletls" != "xyes"; then
  232. # gnutls >= 2.8 doesn't have libgnutls-config anymore. We require
  233. # 2.2.0 because we use gnutls_priority_set_direct()
  234. PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.2.0],
  235. [have_libgnutls=yes], [have_libgnutls=no])
  236. if test "x$have_libgnutls" = "xyes"; then
  237. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  238. LIBS="$LIBGNUTLS_LIBS $LIBS"
  239. CPPFLAGS="$LIBGNUTLS_CFLAGS $CPPFLAGS"
  240. AC_CHECK_FUNCS([gnutls_certificate_set_x509_system_trust])
  241. else
  242. AC_MSG_WARN([$LIBGNUTLS_PKG_ERRORS])
  243. if test "x$with_gnutls_requested" = "xyes"; then
  244. ARIA2_DEP_NOT_MET([gnutls])
  245. fi
  246. fi
  247. fi
  248. if test "x$with_openssl" = "xyes" && test "x$have_appletls" != "xyes" && test "x$have_libgnutls" != "xyes"; then
  249. PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],
  250. [have_openssl=yes], [have_openssl=no])
  251. if test "x$have_openssl" = "xyes"; then
  252. AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if you have openssl.])
  253. LIBS="$OPENSSL_LIBS $LIBS"
  254. CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS"
  255. AC_CHECK_FUNCS([EVP_DigestInit_ex], [have_digestinit_ex=yes])
  256. if test "x$have_digestinit_ex" = "x"; then
  257. AC_DEFINE([HAVE_OLD_OPENSSL], [1], [Define to 1 if you have old openssl.])
  258. fi
  259. AC_CHECK_FUNCS([EVP_sha224])
  260. AC_CHECK_FUNCS([EVP_sha256])
  261. AC_CHECK_FUNCS([EVP_sha384])
  262. AC_CHECK_FUNCS([EVP_sha512])
  263. else
  264. AC_MSG_WARN([$OPENSSL_PKG_ERRORS])
  265. if test "x$with_openssl_requested" = "xyes"; then
  266. ARIA2_DEP_NOT_MET([openssl])
  267. fi
  268. fi
  269. fi
  270. if test "x$have_openssl" != "xyes"; then
  271. if test "x$with_libnettle" = "xyes"; then
  272. AC_SEARCH_LIBS([nettle_sha1_init], [nettle],
  273. [have_libnettle=yes], [have_libnettle=no])
  274. if test "x$have_libnettle" = "xyes"; then
  275. AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if you have libnettle.])
  276. fi
  277. fi
  278. if test "x$with_libgmp" = "xyes" &&
  279. test "x$have_libnettle" = "xyes" &&
  280. test "x$enable_bittorrent" = "xyes"; then
  281. AC_SEARCH_LIBS([__gmpz_init], [gmp], [have_libgmp=yes], [have_libgmp=no])
  282. if test "x$have_libgmp" = "xyes"; then
  283. AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have libgmp.])
  284. fi
  285. fi
  286. if test "x$with_libgcrypt" = "xyes" &&
  287. test "x$have_libnettle" != "xyes"; then
  288. AM_PATH_LIBGCRYPT([1.2.4], [have_libgcrypt=yes])
  289. if test "x$have_libgcrypt" = "xyes"; then
  290. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  291. LIBS="$LIBGCRYPT_LIBS $LIBS"
  292. CPPFLAGS="$LIBGCRYPT_CFLAGS $CPPFLAGS"
  293. fi
  294. fi
  295. fi
  296. if test "x$with_libcares" = "xyes"; then
  297. PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.0], [have_libcares=yes],
  298. [have_libcares=no])
  299. if test "x$have_libcares" = "xyes"; then
  300. AC_DEFINE([HAVE_LIBCARES], [1], [Define to 1 if you have libcares.])
  301. LIBS="$LIBCARES_LIBS $LIBS"
  302. CPPFLAGS="$LIBCARES_CFLAGS $CPPFLAGS"
  303. AC_CHECK_TYPES([ares_addr_node], [], [], [[#include <ares.h>]])
  304. AC_CHECK_FUNCS([ares_set_servers])
  305. if test "x$ARIA2_STATIC" = "xyes"; then
  306. CPPFLAGS="-DCARES_STATICLIB $CPPFLAGS"
  307. fi
  308. else
  309. AC_MSG_WARN([$LIBCARES_PKG_ERRORS])
  310. if test "x$with_libcares_requested" = "xyes"; then
  311. ARIA2_DEP_NOT_MET([libcares])
  312. fi
  313. fi
  314. fi
  315. use_md=""
  316. if test "x$have_osx" == "xyes"; then
  317. use_md="apple"
  318. AC_DEFINE([USE_APPLE_MD], [1], [What message digest implementation to use])
  319. else
  320. if test "x$have_libnettle" = "xyes"; then
  321. AC_DEFINE([USE_LIBNETTLE_MD], [1], [What message digest implementation to use])
  322. use_md="libnettle"
  323. else
  324. if test "x$have_libgcrypt" = "xyes"; then
  325. AC_DEFINE([USE_LIBGCRYPT_MD], [1], [What message digest implementation to use])
  326. use_md="libgcrypt"
  327. else
  328. if test "x$have_openssl" = "xyes"; then
  329. AC_DEFINE([USE_OPENSSL_MD], [1], [What message digest implementation to use])
  330. use_md="openssl"
  331. fi
  332. fi
  333. fi
  334. fi
  335. # Define variables based on the result of the checks for libraries.
  336. if test "x$have_appletls" = "xyes" || test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  337. have_ssl="yes"
  338. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  339. AM_CONDITIONAL([ENABLE_SSL], true)
  340. AC_SUBST([ca_bundle])
  341. else
  342. AM_CONDITIONAL([ENABLE_SSL], false)
  343. fi
  344. AM_CONDITIONAL([HAVE_OSX], [ test "x$have_osx" = "xyes" ])
  345. AM_CONDITIONAL([HAVE_APPLETLS], [ test "x$have_appletls" = "xyes" ])
  346. AM_CONDITIONAL([USE_APPLE_MD], [ test "x$use_md" = "xapple" ])
  347. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  348. AM_CONDITIONAL([HAVE_LIBNETTLE], [ test "x$have_libnettle" = "xyes" ])
  349. AM_CONDITIONAL([USE_LIBNETTLE_MD], [ test "x$use_md" = "xlibnettle"])
  350. AM_CONDITIONAL([HAVE_LIBGMP], [ test "x$have_libgmp" = "xyes" ])
  351. AM_CONDITIONAL([HAVE_LIBGCRYPT], [ test "x$have_libgcrypt" = "xyes" ])
  352. AM_CONDITIONAL([USE_LIBGCRYPT_MD], [ test "x$use_md" = "xlibgcrypt"])
  353. AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
  354. AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
  355. if test "x$use_md" != "x"; then
  356. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
  357. [Define to 1 if message digest support is enabled.])
  358. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  359. enable_message_digest=yes
  360. else
  361. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  362. fi
  363. if test "x$have_libnettle" = "xyes" && test "x$have_libgmp" = "xyes" ||
  364. test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  365. enable_bignum=yes
  366. fi
  367. if test "x$enable_bittorrent" = "xyes" &&
  368. test "x$enable_message_digest" = "xyes" &&
  369. test "x$enable_bignum" = "xyes"; then
  370. AC_DEFINE([ENABLE_BITTORRENT], [1],
  371. [Define to 1 if BitTorrent support is enabled.])
  372. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  373. else
  374. if test "x$enable_bittorrent_requested" = "xyes"; then
  375. ARIA2_FET_NOT_SUPPORTED([bittorrent])
  376. fi
  377. enable_bittorrent=no
  378. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  379. fi
  380. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  381. test "x$enable_metalink" = "xyes"; then
  382. AC_DEFINE([ENABLE_METALINK], [1],
  383. [Define to 1 if Metalink support is enabled.])
  384. AM_CONDITIONAL([ENABLE_METALINK], true)
  385. else
  386. if test "x$enable_metalink_requested" = "xyes"; then
  387. ARIA2_FET_NOT_SUPPORTED([metalink])
  388. fi
  389. enable_metalink=no
  390. AM_CONDITIONAL([ENABLE_METALINK], false)
  391. fi
  392. AM_CONDITIONAL([HAVE_SOME_XMLLIB],
  393. [test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"])
  394. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  395. enable_xml_rpc=yes
  396. fi
  397. if test "x$enable_xml_rpc" = "xyes"; then
  398. AC_DEFINE([ENABLE_XML_RPC], [1],
  399. [Define to 1 if XML-RPC support is enabled.])
  400. fi
  401. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  402. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  403. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  404. if test "x$have_libcares" = "xyes"; then
  405. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  406. [Define to 1 if asynchronous DNS support is enabled.])
  407. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  408. else
  409. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  410. fi
  411. # Set conditional for libz
  412. AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])
  413. # Set conditional for sqlite3
  414. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  415. AC_SEARCH_LIBS([clock_gettime], [rt])
  416. case "$host" in
  417. *solaris*)
  418. AC_SEARCH_LIBS([getaddrinfo], [nsl socket])
  419. ;;
  420. esac
  421. # Checks for header files.
  422. AC_FUNC_ALLOCA
  423. AC_HEADER_STDC
  424. case "$host" in
  425. *mingw*)
  426. AC_CHECK_HEADERS([windows.h \
  427. winsock2.h \
  428. ws2tcpip.h \
  429. mmsystem.h \
  430. io.h \
  431. iphlpapi.h\
  432. winioctl.h \
  433. share.h], [], [],
  434. [[
  435. #ifdef HAVE_WS2TCPIP_H
  436. # include <ws2tcpip.h>
  437. #endif
  438. #ifdef HAVE_WINSOCK2_H
  439. # include <winsock2.h>
  440. #endif
  441. #ifdef HAVE_WINDOWS_H
  442. # include <windows.h>
  443. #endif
  444. ]])
  445. ;;
  446. esac
  447. AC_CHECK_HEADERS([argz.h \
  448. arpa/inet.h \
  449. fcntl.h \
  450. float.h \
  451. inttypes.h \
  452. langinfo.h \
  453. libintl.h \
  454. limits.h \
  455. locale.h \
  456. malloc.h \
  457. netdb.h \
  458. netinet/in.h \
  459. netinet/tcp.h \
  460. poll.h \
  461. port.h \
  462. signal.h \
  463. stddef.h \
  464. stdint.h \
  465. stdio_ext.h \
  466. stdlib.h \
  467. string.h \
  468. strings.h \
  469. sys/ioctl.h \
  470. sys/param.h \
  471. sys/signal.h \
  472. sys/socket.h \
  473. sys/time.h \
  474. sys/types.h \
  475. sys/uio.h \
  476. termios.h \
  477. unistd.h \
  478. utime.h \
  479. wchar.h \
  480. ifaddrs.h \
  481. pwd.h])
  482. # Checks for typedefs, structures, and compiler characteristics.
  483. AC_HEADER_STDBOOL
  484. AC_C_CONST
  485. AC_C_INLINE
  486. AC_TYPE_INT16_T
  487. AC_TYPE_INT32_T
  488. AC_TYPE_INT64_T
  489. AC_TYPE_INT8_T
  490. AC_TYPE_MODE_T
  491. AC_TYPE_OFF_T
  492. AC_TYPE_SIZE_T
  493. AC_TYPE_SSIZE_T
  494. AC_HEADER_TIME
  495. AC_STRUCT_TM
  496. AC_TYPE_UINT16_T
  497. AC_TYPE_UINT32_T
  498. AC_TYPE_UINT64_T
  499. AC_TYPE_UINT8_T
  500. AC_TYPE_PID_T
  501. AC_C_VOLATILE
  502. AC_CHECK_TYPES([ptrdiff_t, struct timespec])
  503. AC_C_BIGENDIAN
  504. AC_SYS_LARGEFILE
  505. # Checks for library functions.
  506. AM_GNU_GETTEXT
  507. AM_GNU_GETTEXT_VERSION([0.18])
  508. AC_FUNC_ERROR_AT_LINE
  509. AC_PROG_GCC_TRADITIONAL
  510. AC_FUNC_MEMCMP
  511. AC_FUNC_MKTIME
  512. AC_FUNC_SELECT_ARGTYPES
  513. AC_FUNC_STAT
  514. AC_FUNC_STRFTIME
  515. AC_FUNC_VPRINTF
  516. AC_FUNC_FORK
  517. AC_FUNC_STRTOD
  518. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  519. # OpenWRT) which have mmap and it works in the way we use in aria2.
  520. # Instead use mmap in AC_CHECK_FUNCS list.
  521. AC_CHECK_FUNCS([__argz_count \
  522. __argz_next \
  523. __argz_stringify \
  524. atexit \
  525. ftruncate \
  526. getcwd \
  527. gethostbyaddr \
  528. gethostbyname \
  529. getifaddrs \
  530. getpagesize \
  531. memchr \
  532. memmove \
  533. mempcpy \
  534. memset \
  535. mkdir \
  536. mmap \
  537. munmap \
  538. nl_langinfo \
  539. posix_memalign \
  540. pow \
  541. putenv \
  542. rmdir \
  543. select \
  544. setlocale \
  545. sigaction \
  546. sleep \
  547. socket \
  548. stpcpy \
  549. strcasecmp \
  550. strchr \
  551. strcspn \
  552. strdup \
  553. strerror \
  554. strncasecmp \
  555. strstr \
  556. strtol \
  557. strtoul \
  558. strtoull \
  559. tzset \
  560. unsetenv \
  561. usleep \
  562. utime \
  563. utimes])
  564. dnl Put tcmalloc/jemalloc checks after the posix_memalign check.
  565. dnl These libraries may implement posix_memalign, while the usual CRT may not
  566. dnl (e.g. mingw). Since we aren't including the corresponding library headers
  567. dnl this will lead to undefined posix_memalign() errors when compiling
  568. if test "x$with_tcmalloc_requested" = "xyes" &&
  569. test "x$with_jemalloc_requested" = "xyes"; then
  570. AC_MSG_FAILURE([Cannot use both, tcmalloc and jemalloc!])
  571. fi
  572. if test "x$with_tcmalloc" = "xyes"; then
  573. dnl Important: put malloc libs at the very end.
  574. dnl Only newish versions have a .pc, thus try CHECK_LIB as well.
  575. PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc_minimal], [have_tcmalloc=yes], [have_tcmalloc=no])
  576. if test "x$have_tcmalloc" = "xyes"; then
  577. CPPFLAGS="$TCMALLOC_CFLAGS $CPPFLAGS"
  578. LIBS="$LIBS $TCMALLOC_LIBS"
  579. else
  580. AC_CHECK_LIB([tcmalloc_minimal], [malloc], [have_tcmalloc=yes], [have_tcmalloc=no])
  581. if test "x$have_tcmalloc" = "xyes"; then
  582. LIBS="$LIBS -ltcmalloc_minimal"
  583. else
  584. if test "x$with_tcmalloc_requested" = "xyes"; then
  585. ARIA2_DEP_NOT_MET([tcmalloc_minimal])
  586. fi
  587. fi
  588. fi
  589. fi
  590. if test "x$have_tcmalloc" != "xyes" && test "x$with_jemalloc" = "xyes"; then
  591. dnl Important: put malloc libs at the very end.
  592. dnl Usually jemalloc does not come with a .pc, as the official source does not
  593. dnl generate one.
  594. PKG_CHECK_MODULES([JEMALLOC], [jemalloc], [have_jemalloc=yes], [have_jemalloc=no])
  595. if test "x$have_jemalloc" = "xyes"; then
  596. CPPFLAGS="$JEMALLOC_CFLAGS $CPPFLAGS"
  597. LIBS="$LIBS $JEMALLOC_LIBS"
  598. else
  599. AC_CHECK_LIB([jemalloc], [malloc], [have_jemalloc=yes], [have_jemalloc=no])
  600. if test "x$have_jemalloc" = "xyes"; then
  601. LIBS="$LIBS -ljemalloc"
  602. else
  603. if test "x$with_jemalloc_requested" = "xyes"; then
  604. ARIA2_DEP_NOT_MET([jemalloc (unprefixed)])
  605. fi
  606. fi
  607. fi
  608. fi
  609. if test "x$enable_epoll" = "xyes"; then
  610. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  611. if test "x$have_epoll" = "xyes"; then
  612. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  613. fi
  614. fi
  615. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  616. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  617. ARIA2_CHECK_FALLOCATE
  618. if test "x$have_posix_fallocate" = "xyes" ||
  619. test "x$have_fallocate" = "xyes" ||
  620. test "x$win_build" = "xyes"; then
  621. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  622. [Define to 1 if *_fallocate is available.])
  623. fi
  624. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  625. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  626. || test "x$win_build" = "xyes"])
  627. AC_CHECK_FUNCS([asctime_r],
  628. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  629. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  630. AC_CHECK_FUNCS([basename],
  631. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  632. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  633. AC_CHECK_FUNCS([gai_strerror],
  634. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  635. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  636. AC_CHECK_FUNCS([getaddrinfo],
  637. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  638. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  639. AC_CHECK_FUNCS([gettimeofday],
  640. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  641. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  642. AC_CHECK_FUNCS([localtime_r],
  643. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  644. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  645. AC_CHECK_FUNCS([strptime],
  646. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  647. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  648. AC_CHECK_FUNCS([timegm],
  649. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  650. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  651. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  652. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  653. AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes])
  654. if test "x$have_clock_gettime" != "xyes"; then
  655. AC_CHECK_FUNCS([mach_absolute_time], [have_mach_absolute_time=yes])
  656. fi
  657. AM_CONDITIONAL([HAVE_MACH_ABSOLUTE_TIME],
  658. [test "x$have_mach_absolute_time" = "xyes"])
  659. AC_CHECK_FUNCS([poll], [have_poll=yes])
  660. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  661. case "$host" in
  662. *mingw*)
  663. AM_CONDITIONAL([MINGW_BUILD], true)
  664. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  665. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  666. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  667. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  668. if test "x$have_clock_gettime" != "xyes"; then
  669. AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
  670. fi
  671. ;;
  672. *)
  673. AM_CONDITIONAL([MINGW_BUILD], false)
  674. AM_CONDITIONAL([HAVE_TIMEGETTIME], false)
  675. ;;
  676. esac
  677. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  678. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  679. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  680. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  681. if test "x$have_kqueue" = "xyes"; then
  682. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  683. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  684. #include <sys/types.h>
  685. #include <sys/event.h>
  686. #include <sys/time.h>
  687. ]],
  688. [[
  689. struct kevent event;
  690. event.udata = reinterpret_cast<intptr_t>(&event);
  691. ]])],
  692. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  693. AC_MSG_RESULT([$kevent_udata_intptr_t])
  694. if test "x$kevent_udata_intptr_t" = "xyes"; then
  695. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  696. fi
  697. fi
  698. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  699. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  700. [Define to 1 if struct sockaddr_in has sin_len member.])],
  701. [],
  702. [[
  703. #include <sys/types.h>
  704. #include <sys/socket.h>
  705. #include <netinet/in.h>
  706. ]])
  707. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  708. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  709. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  710. [],
  711. [[
  712. #include <sys/types.h>
  713. #include <sys/socket.h>
  714. #include <netinet/in.h>
  715. ]])
  716. # Check struct option.name is assignable from const char*. struct
  717. # option.name in opensolaris is of type char*. In Linux, it is const
  718. # char*
  719. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  720. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  721. #include <unistd.h>
  722. #include <getopt.h>
  723. ]],
  724. [[
  725. const char* s = "const char";
  726. option op;
  727. op.name = s;
  728. ]])],
  729. [have_option_const_name=yes], [have_option_const_name=no])
  730. AC_MSG_RESULT([$have_option_const_name])
  731. if test "x$have_option_const_name" = "xyes"; then
  732. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  733. fi
  734. AC_CONFIG_SUBDIRS([deps/wslay])
  735. if test "x$enable_message_digest" = "xyes"; then
  736. enable_websocket=yes
  737. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  738. [Define 1 if WebSocket support is enabled.])
  739. WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
  740. AC_SUBST([WSLAY_LIBS])
  741. # $(top_srcdir) for `make distcheck`
  742. CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
  743. fi
  744. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  745. AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
  746. AC_SUBST([bashcompletiondir])
  747. case "$host" in
  748. *android*)
  749. LIBS="$LIBS -lstdc++ -lsupc++"
  750. case "$host" in
  751. arm-*)
  752. android_arm=yes
  753. ;;
  754. mipsel-*)
  755. android_mips=yes
  756. ;;
  757. i686-*)
  758. android_x86=yes
  759. ;;
  760. esac
  761. ;;
  762. *)
  763. ;;
  764. esac
  765. AM_CONDITIONAL([ANDROID_ARM], [test "x$android_arm" = "xyes"])
  766. AM_CONDITIONAL([ANDROID_MIPS], [test "x$android_mips" = "xyes"])
  767. AM_CONDITIONAL([ANDROID_X86], [test "x$android_x86" = "xyes"])
  768. if test "x$ARIA2_STATIC" = "xyes"; then
  769. LDFLAGS="$LDFLAGS -all-static -static-libgcc -static-libstdc++"
  770. dnl For non-MinGW build, we need additional libs for static build.
  771. if test "x$win_build" != "xyes"; then
  772. LIBS="$LIBS -lpthread -ldl -lrt"
  773. fi
  774. fi
  775. AC_CONFIG_FILES([Makefile
  776. src/Makefile
  777. src/libaria2.pc
  778. src/includes/Makefile
  779. test/Makefile
  780. po/Makefile.in
  781. intl/Makefile
  782. lib/Makefile
  783. doc/Makefile
  784. doc/manual-src/Makefile
  785. doc/manual-src/en/Makefile
  786. doc/manual-src/en/conf.py
  787. doc/manual-src/ru/Makefile
  788. doc/manual-src/ru/conf.py
  789. doc/manual-src/pt/Makefile
  790. doc/manual-src/pt/conf.py
  791. deps/Makefile])
  792. AC_OUTPUT
  793. echo " "
  794. echo "Build: $build"
  795. echo "Host: $host"
  796. echo "Target: $target"
  797. echo "Install prefix: $prefix"
  798. echo "CC: $CC"
  799. echo "CXX: $CXX"
  800. echo "CPP: $CPP"
  801. echo "CXXFLAGS: $CXXFLAGS"
  802. echo "CFLAGS: $CFLAGS"
  803. echo "CPPFLAGS: $CPPFLAGS"
  804. echo "LDFLAGS: $LDFLAGS"
  805. echo "LIBS: $LIBS"
  806. echo "DEFS: $DEFS"
  807. echo "LibUV: $have_libuv"
  808. echo "SQLite3: $have_sqlite3"
  809. echo "SSL Support: $have_ssl"
  810. echo "AppleTLS: $have_appletls"
  811. echo "GnuTLS: $have_libgnutls"
  812. echo "OpenSSL: $have_openssl"
  813. echo "CA Bundle: $ca_bundle"
  814. echo "LibXML2: $have_libxml2"
  815. echo "LibExpat: $have_libexpat"
  816. echo "LibCares: $have_libcares"
  817. echo "Zlib: $have_zlib"
  818. echo "Epoll: $have_epoll"
  819. echo "Bittorrent: $enable_bittorrent"
  820. echo "Metalink: $enable_metalink"
  821. echo "XML-RPC: $enable_xml_rpc"
  822. echo "Message Digest: $enable_message_digest"
  823. echo "WebSocket: $enable_websocket"
  824. echo "Libaria2: $enable_libaria2"
  825. if test "x$enable_libaria2" = "xyes"; then
  826. echo "Library types: Shared=${enable_shared}, Static=${enable_static}"
  827. fi
  828. echo "bash_completion dir: $bashcompletiondir"
  829. echo "Static build: $ARIA2_STATIC"