configure.ac 26 KB

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