configure.ac 27 KB

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