configure.ac 36 KB

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