configure.ac 38 KB

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