configure.ac 29 KB

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