configure.ac 30 KB

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