configure.ac 28 KB

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