configure.ac 30 KB

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