configure.ac 29 KB

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