configure.ac 27 KB

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