configure.ac 29 KB

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