configure.ac 27 KB

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