configure.ac 28 KB

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