configure.ac 38 KB

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