configure.ac 29 KB

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