configure.ac 28 KB

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