configure.ac 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  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_appletls" == "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. else
  413. AC_DEFINE([USE_INTERNAL_MD], [1], [What message digest implementation to use])
  414. use_md="internal"
  415. fi
  416. fi
  417. fi
  418. fi
  419. fi
  420. # Define variables based on the result of the checks for libraries.
  421. if test "x$have_appletls" = "xyes" || test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  422. have_ssl="yes"
  423. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  424. AM_CONDITIONAL([ENABLE_SSL], true)
  425. else
  426. AM_CONDITIONAL([ENABLE_SSL], false)
  427. fi
  428. AM_CONDITIONAL([HAVE_OSX], [ test "x$have_osx" = "xyes" ])
  429. AM_CONDITIONAL([HAVE_APPLETLS], [ test "x$have_appletls" = "xyes" ])
  430. AM_CONDITIONAL([USE_APPLE_MD], [ test "x$use_md" = "xapple" ])
  431. AM_CONDITIONAL([USE_WINDOWS_MD], [ test "x$use_md" = "xwindows" ])
  432. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  433. AM_CONDITIONAL([HAVE_LIBNETTLE], [ test "x$have_libnettle" = "xyes" ])
  434. AM_CONDITIONAL([USE_LIBNETTLE_MD], [ test "x$use_md" = "xlibnettle"])
  435. AM_CONDITIONAL([HAVE_LIBGMP], [ test "x$have_libgmp" = "xyes" ])
  436. AM_CONDITIONAL([HAVE_LIBGCRYPT], [ test "x$have_libgcrypt" = "xyes" ])
  437. AM_CONDITIONAL([USE_LIBGCRYPT_MD], [ test "x$use_md" = "xlibgcrypt"])
  438. AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
  439. AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
  440. AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
  441. if test "x$use_md" != "x"; then
  442. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
  443. [Define to 1 if message digest support is enabled.])
  444. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  445. enable_message_digest=yes
  446. else
  447. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  448. fi
  449. if test "x$have_libnettle" = "xyes" && test "x$have_libgmp" = "xyes" ||
  450. test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  451. enable_bignum=yes
  452. fi
  453. if test "x$enable_bittorrent" = "xyes" &&
  454. test "x$enable_message_digest" = "xyes" &&
  455. test "x$enable_bignum" = "xyes"; then
  456. AC_DEFINE([ENABLE_BITTORRENT], [1],
  457. [Define to 1 if BitTorrent support is enabled.])
  458. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  459. else
  460. if test "x$enable_bittorrent_requested" = "xyes"; then
  461. ARIA2_FET_NOT_SUPPORTED([bittorrent])
  462. fi
  463. enable_bittorrent=no
  464. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  465. fi
  466. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  467. test "x$enable_metalink" = "xyes"; then
  468. AC_DEFINE([ENABLE_METALINK], [1],
  469. [Define to 1 if Metalink support is enabled.])
  470. AM_CONDITIONAL([ENABLE_METALINK], true)
  471. else
  472. if test "x$enable_metalink_requested" = "xyes"; then
  473. ARIA2_FET_NOT_SUPPORTED([metalink])
  474. fi
  475. enable_metalink=no
  476. AM_CONDITIONAL([ENABLE_METALINK], false)
  477. fi
  478. AM_CONDITIONAL([HAVE_SOME_XMLLIB],
  479. [test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"])
  480. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  481. enable_xml_rpc=yes
  482. fi
  483. if test "x$enable_xml_rpc" = "xyes"; then
  484. AC_DEFINE([ENABLE_XML_RPC], [1],
  485. [Define to 1 if XML-RPC support is enabled.])
  486. fi
  487. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  488. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  489. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  490. if test "x$have_libcares" = "xyes"; then
  491. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  492. [Define to 1 if asynchronous DNS support is enabled.])
  493. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  494. else
  495. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  496. fi
  497. # Set conditional for libz
  498. AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])
  499. # Set conditional for sqlite3
  500. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  501. AC_SEARCH_LIBS([clock_gettime], [rt])
  502. case "$host" in
  503. *solaris*)
  504. AC_SEARCH_LIBS([getaddrinfo], [nsl socket])
  505. ;;
  506. esac
  507. # Checks for header files.
  508. AC_FUNC_ALLOCA
  509. AC_HEADER_STDC
  510. AC_CHECK_HEADERS([argz.h \
  511. arpa/inet.h \
  512. fcntl.h \
  513. float.h \
  514. inttypes.h \
  515. langinfo.h \
  516. libintl.h \
  517. limits.h \
  518. locale.h \
  519. malloc.h \
  520. netdb.h \
  521. netinet/in.h \
  522. netinet/tcp.h \
  523. poll.h \
  524. port.h \
  525. signal.h \
  526. stddef.h \
  527. stdint.h \
  528. stdio_ext.h \
  529. stdlib.h \
  530. string.h \
  531. strings.h \
  532. sys/ioctl.h \
  533. sys/param.h \
  534. sys/signal.h \
  535. sys/socket.h \
  536. sys/time.h \
  537. sys/types.h \
  538. sys/uio.h \
  539. termios.h \
  540. unistd.h \
  541. utime.h \
  542. wchar.h \
  543. ifaddrs.h \
  544. pwd.h])
  545. # Checks for typedefs, structures, and compiler characteristics.
  546. AC_HEADER_STDBOOL
  547. AC_C_CONST
  548. AC_C_INLINE
  549. AC_TYPE_INT16_T
  550. AC_TYPE_INT32_T
  551. AC_TYPE_INT64_T
  552. AC_TYPE_INT8_T
  553. AC_TYPE_MODE_T
  554. AC_TYPE_OFF_T
  555. AC_TYPE_SIZE_T
  556. AC_TYPE_SSIZE_T
  557. AC_HEADER_TIME
  558. AC_STRUCT_TM
  559. AC_TYPE_UINT16_T
  560. AC_TYPE_UINT32_T
  561. AC_TYPE_UINT64_T
  562. AC_TYPE_UINT8_T
  563. AC_TYPE_PID_T
  564. AC_C_VOLATILE
  565. AC_CHECK_TYPES([ptrdiff_t, struct timespec])
  566. AC_C_BIGENDIAN
  567. AC_SYS_LARGEFILE
  568. # Checks for library functions.
  569. AM_GNU_GETTEXT([external])
  570. AM_GNU_GETTEXT_VERSION([0.18])
  571. AC_FUNC_ERROR_AT_LINE
  572. AC_PROG_GCC_TRADITIONAL
  573. AC_FUNC_MEMCMP
  574. AC_FUNC_MKTIME
  575. AC_FUNC_SELECT_ARGTYPES
  576. AC_FUNC_STAT
  577. AC_FUNC_STRFTIME
  578. AC_FUNC_VPRINTF
  579. AC_FUNC_FORK
  580. AC_FUNC_STRTOD
  581. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  582. # OpenWRT) which have mmap and it works in the way we use in aria2.
  583. # Instead use mmap in AC_CHECK_FUNCS list.
  584. AC_CHECK_FUNCS([__argz_count \
  585. __argz_next \
  586. __argz_stringify \
  587. atexit \
  588. ftruncate \
  589. getcwd \
  590. gethostbyaddr \
  591. gethostbyname \
  592. getifaddrs \
  593. getpagesize \
  594. memchr \
  595. memmove \
  596. mempcpy \
  597. memset \
  598. mkdir \
  599. mmap \
  600. munmap \
  601. nl_langinfo \
  602. posix_memalign \
  603. pow \
  604. putenv \
  605. rmdir \
  606. select \
  607. setlocale \
  608. sigaction \
  609. sleep \
  610. socket \
  611. stpcpy \
  612. strcasecmp \
  613. strchr \
  614. strcspn \
  615. strdup \
  616. strerror \
  617. strncasecmp \
  618. strstr \
  619. strtol \
  620. strtoul \
  621. strtoull \
  622. tzset \
  623. unsetenv \
  624. usleep \
  625. utime \
  626. utimes])
  627. dnl Put tcmalloc/jemalloc checks after the posix_memalign check.
  628. dnl These libraries may implement posix_memalign, while the usual CRT may not
  629. dnl (e.g. mingw). Since we aren't including the corresponding library headers
  630. dnl this will lead to undefined posix_memalign() errors when compiling
  631. if test "x$with_tcmalloc_requested" = "xyes" &&
  632. test "x$with_jemalloc_requested" = "xyes"; then
  633. AC_MSG_FAILURE([Cannot use both, tcmalloc and jemalloc!])
  634. fi
  635. if test "x$with_tcmalloc" = "xyes"; then
  636. dnl Important: put malloc libs at the very end.
  637. dnl Only newish versions have a .pc, thus try CHECK_LIB as well.
  638. PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc_minimal], [have_tcmalloc=yes], [have_tcmalloc=no])
  639. if test "x$have_tcmalloc" = "xyes"; then
  640. CPPFLAGS="$TCMALLOC_CFLAGS $CPPFLAGS"
  641. LIBS="$LIBS $TCMALLOC_LIBS"
  642. else
  643. AC_CHECK_LIB([tcmalloc_minimal], [malloc], [have_tcmalloc=yes], [have_tcmalloc=no])
  644. if test "x$have_tcmalloc" = "xyes"; then
  645. LIBS="$LIBS -ltcmalloc_minimal"
  646. else
  647. if test "x$with_tcmalloc_requested" = "xyes"; then
  648. ARIA2_DEP_NOT_MET([tcmalloc_minimal])
  649. fi
  650. fi
  651. fi
  652. fi
  653. if test "x$have_tcmalloc" != "xyes" && test "x$with_jemalloc" = "xyes"; then
  654. dnl Important: put malloc libs at the very end.
  655. dnl Usually jemalloc does not come with a .pc, as the official source does not
  656. dnl generate one.
  657. PKG_CHECK_MODULES([JEMALLOC], [jemalloc], [have_jemalloc=yes], [have_jemalloc=no])
  658. if test "x$have_jemalloc" = "xyes"; then
  659. CPPFLAGS="$JEMALLOC_CFLAGS $CPPFLAGS"
  660. LIBS="$LIBS $JEMALLOC_LIBS"
  661. else
  662. AC_CHECK_LIB([jemalloc], [malloc], [have_jemalloc=yes], [have_jemalloc=no])
  663. if test "x$have_jemalloc" = "xyes"; then
  664. LIBS="$LIBS -ljemalloc"
  665. else
  666. if test "x$with_jemalloc_requested" = "xyes"; then
  667. ARIA2_DEP_NOT_MET([jemalloc (unprefixed)])
  668. fi
  669. fi
  670. fi
  671. fi
  672. if test "x$enable_epoll" = "xyes"; then
  673. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  674. if test "x$have_epoll" = "xyes"; then
  675. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  676. fi
  677. fi
  678. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  679. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  680. ARIA2_CHECK_FALLOCATE
  681. if test "x$have_posix_fallocate" = "xyes" ||
  682. test "x$have_fallocate" = "xyes" ||
  683. test "x$win_build" = "xyes"; then
  684. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  685. [Define to 1 if *_fallocate is available.])
  686. fi
  687. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  688. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  689. || test "x$win_build" = "xyes"])
  690. AC_CHECK_FUNCS([asctime_r],
  691. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  692. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  693. AC_CHECK_FUNCS([basename],
  694. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  695. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  696. AC_CHECK_FUNCS([gai_strerror],
  697. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  698. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  699. AC_CHECK_FUNCS([getaddrinfo],
  700. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  701. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  702. AC_CHECK_FUNCS([gettimeofday],
  703. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  704. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  705. AC_CHECK_FUNCS([localtime_r],
  706. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  707. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  708. AC_CHECK_FUNCS([strptime],
  709. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  710. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  711. AC_CHECK_FUNCS([timegm],
  712. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  713. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  714. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  715. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  716. AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes])
  717. if test "x$have_clock_gettime" != "xyes"; then
  718. AC_CHECK_FUNCS([mach_absolute_time], [have_mach_absolute_time=yes])
  719. fi
  720. AM_CONDITIONAL([HAVE_MACH_ABSOLUTE_TIME],
  721. [test "x$have_mach_absolute_time" = "xyes"])
  722. AC_CHECK_FUNCS([poll], [have_poll=yes])
  723. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  724. case "$host" in
  725. *mingw*)
  726. AM_CONDITIONAL([MINGW_BUILD], true)
  727. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  728. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  729. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  730. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  731. if test "x$have_clock_gettime" != "xyes"; then
  732. AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
  733. fi
  734. ;;
  735. *)
  736. AM_CONDITIONAL([MINGW_BUILD], false)
  737. AM_CONDITIONAL([HAVE_TIMEGETTIME], false)
  738. ;;
  739. esac
  740. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  741. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  742. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  743. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  744. if test "x$have_kqueue" = "xyes"; then
  745. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  746. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  747. #include <sys/types.h>
  748. #include <sys/event.h>
  749. #include <sys/time.h>
  750. ]],
  751. [[
  752. struct kevent event;
  753. event.udata = reinterpret_cast<intptr_t>(&event);
  754. ]])],
  755. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  756. AC_MSG_RESULT([$kevent_udata_intptr_t])
  757. if test "x$kevent_udata_intptr_t" = "xyes"; then
  758. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  759. fi
  760. fi
  761. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  762. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  763. [Define to 1 if struct sockaddr_in has sin_len member.])],
  764. [],
  765. [[
  766. #include <sys/types.h>
  767. #include <sys/socket.h>
  768. #include <netinet/in.h>
  769. ]])
  770. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  771. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  772. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  773. [],
  774. [[
  775. #include <sys/types.h>
  776. #include <sys/socket.h>
  777. #include <netinet/in.h>
  778. ]])
  779. # Check struct option.name is assignable from const char*. struct
  780. # option.name in opensolaris is of type char*. In Linux, it is const
  781. # char*
  782. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  783. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  784. #include <unistd.h>
  785. #include <getopt.h>
  786. ]],
  787. [[
  788. const char* s = "const char";
  789. option op;
  790. op.name = s;
  791. ]])],
  792. [have_option_const_name=yes], [have_option_const_name=no])
  793. AC_MSG_RESULT([$have_option_const_name])
  794. if test "x$have_option_const_name" = "xyes"; then
  795. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  796. fi
  797. AC_CONFIG_SUBDIRS([deps/wslay])
  798. if test "x$enable_message_digest" = "xyes"; then
  799. enable_websocket=yes
  800. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  801. [Define 1 if WebSocket support is enabled.])
  802. WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
  803. AC_SUBST([WSLAY_LIBS])
  804. # $(top_srcdir) for `make distcheck`
  805. CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
  806. fi
  807. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  808. AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
  809. AC_SUBST([bashcompletiondir])
  810. case "$host" in
  811. *android*)
  812. android=yes
  813. LIBS="$LIBS -lstdc++ -lsupc++"
  814. case "$host" in
  815. arm-*)
  816. android_arm=yes
  817. ;;
  818. mipsel-*)
  819. android_mips=yes
  820. ;;
  821. i686-*)
  822. android_x86=yes
  823. ;;
  824. esac
  825. ;;
  826. *)
  827. ;;
  828. esac
  829. AM_CONDITIONAL([ANDROID], [test "x$android" = "xyes"])
  830. AM_CONDITIONAL([ANDROID_ARM], [test "x$android_arm" = "xyes"])
  831. AM_CONDITIONAL([ANDROID_MIPS], [test "x$android_mips" = "xyes"])
  832. AM_CONDITIONAL([ANDROID_X86], [test "x$android_x86" = "xyes"])
  833. if test "x$ARIA2_STATIC" = "xyes"; then
  834. LDFLAGS="$LDFLAGS -all-static -static-libgcc -static-libstdc++"
  835. dnl For non-MinGW build, we need additional libs for static build.
  836. if test "x$win_build" != "xyes"; then
  837. LIBS="$LIBS -lpthread -ldl -lrt"
  838. fi
  839. fi
  840. AC_CONFIG_FILES([Makefile
  841. src/Makefile
  842. src/libaria2.pc
  843. src/includes/Makefile
  844. test/Makefile
  845. po/Makefile.in
  846. lib/Makefile
  847. doc/Makefile
  848. doc/manual-src/Makefile
  849. doc/manual-src/en/Makefile
  850. doc/manual-src/en/conf.py
  851. doc/manual-src/ru/Makefile
  852. doc/manual-src/ru/conf.py
  853. doc/manual-src/pt/Makefile
  854. doc/manual-src/pt/conf.py
  855. deps/Makefile])
  856. AC_OUTPUT
  857. echo " "
  858. echo "Build: $build"
  859. echo "Host: $host"
  860. echo "Target: $target"
  861. echo "Install prefix: $prefix"
  862. echo "CC: $CC"
  863. echo "CXX: $CXX"
  864. echo "CPP: $CPP"
  865. echo "CXXFLAGS: $CXXFLAGS"
  866. echo "CFLAGS: $CFLAGS"
  867. echo "CPPFLAGS: $CPPFLAGS"
  868. echo "LDFLAGS: $LDFLAGS"
  869. echo "LIBS: $LIBS"
  870. echo "DEFS: $DEFS"
  871. echo "LibUV: $have_libuv"
  872. echo "SQLite3: $have_sqlite3"
  873. echo "SSL Support: $have_ssl"
  874. echo "AppleTLS: $have_appletls"
  875. echo "GnuTLS: $have_libgnutls"
  876. echo "OpenSSL: $have_openssl"
  877. echo "CA Bundle: $ca_bundle"
  878. echo "LibXML2: $have_libxml2"
  879. echo "LibExpat: $have_libexpat"
  880. echo "LibCares: $have_libcares"
  881. echo "Zlib: $have_zlib"
  882. echo "Epoll: $have_epoll"
  883. echo "Bittorrent: $enable_bittorrent"
  884. echo "Metalink: $enable_metalink"
  885. echo "XML-RPC: $enable_xml_rpc"
  886. echo "Message Digest: $use_md"
  887. echo "WebSocket: $enable_websocket"
  888. echo "Libaria2: $enable_libaria2"
  889. if test "x$enable_libaria2" = "xyes"; then
  890. echo "Library types: Shared=${enable_shared}, Static=${enable_static}"
  891. fi
  892. echo "bash_completion dir: $bashcompletiondir"
  893. echo "Static build: $ARIA2_STATIC"