configure.ac 28 KB

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