configure.ac 29 KB

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