configure.ac 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  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"; then
  294. AC_DEFINE([HAVE_LIBEXPAT], [1], [Define to 1 if you have libexpat.])
  295. elif test "x$with_libexpat_requested" = "xyes"; then
  296. ARIA2_DEP_NOT_MET([libexpat])
  297. fi
  298. fi
  299. have_sqlite3=no
  300. if test "x$with_sqlite3" = "xyes"; then
  301. PKG_CHECK_MODULES([SQLITE3],[sqlite3],[have_sqlite3=yes],[have_sqlite3=no])
  302. if test "x$have_sqlite3" = "xyes"; then
  303. AC_DEFINE([HAVE_SQLITE3], [1], [Define to 1 if you have sqlite3.])
  304. save_LIBS=$LIBS
  305. LIBS="$SQLITE3_LIBS $LIBS"
  306. AC_CHECK_FUNCS([sqlite3_open_v2])
  307. LIBS=$save_LIBS
  308. else
  309. AC_MSG_WARN([$SQLITE3_PKG_ERRORS])
  310. if test "x$with_sqlite3_requested" = "xyes"; then
  311. ARIA2_DEP_NOT_MET([sqlite3])
  312. fi
  313. fi
  314. fi
  315. case "$host" in
  316. *darwin*)
  317. have_osx="yes"
  318. ;;
  319. *mingw*)
  320. AC_CHECK_HEADERS([windows.h \
  321. winsock2.h \
  322. ws2tcpip.h \
  323. mmsystem.h \
  324. io.h \
  325. iphlpapi.h\
  326. winioctl.h \
  327. share.h], [], [],
  328. [[
  329. #ifdef HAVE_WS2TCPIP_H
  330. # include <ws2tcpip.h>
  331. #endif
  332. #ifdef HAVE_WINSOCK2_H
  333. # include <winsock2.h>
  334. #endif
  335. #ifdef HAVE_WINDOWS_H
  336. # include <windows.h>
  337. #endif
  338. ]])
  339. ;;
  340. esac
  341. if test "x$enable_ssl" != "xyes"; then
  342. with_appletls=no
  343. with_wintls=no
  344. with_libnettle=no
  345. with_libgcrypt=no
  346. with_gnutls=no
  347. with_openssl=no
  348. fi
  349. have_appletls=no
  350. if test "x$with_appletls" = "xyes"; then
  351. AC_MSG_CHECKING([whether to enable Mac OS X native SSL/TLS])
  352. if test "x$have_osx" = "xyes"; then
  353. AC_DEFINE([HAVE_APPLETLS], [1], [Define to 1 if you have Apple TLS])
  354. APPLETLS_LDFLAGS="-framework CoreFoundation -framework Security"
  355. AC_SUBST([APPLETLS_LDFLAGS])
  356. have_appletls="yes"
  357. have_ssl=yes
  358. have_nativetls=yes
  359. AC_MSG_RESULT(yes)
  360. else
  361. AC_MSG_RESULT(no)
  362. if test "x$with_appletls_requested" = "xyes"; then
  363. ARIA2_DEP_NOT_MET([appletls])
  364. fi
  365. fi
  366. fi
  367. have_wintls=no
  368. if test "x$with_wintls" = "xyes"; then
  369. AC_HAVE_LIBRARY([crypt32],[have_wintls_libs=yes],[have_wintls_libs=no])
  370. AC_HAVE_LIBRARY([secur32],[have_wintls_libs=$have_wintls_libs],[have_wintls_libs=no])
  371. AC_HAVE_LIBRARY([advapi32],[have_wintls_libs=$have_wintls_libs],[have_wintls_libs=no])
  372. AC_CHECK_HEADER([wincrypt.h], [have_wintls_headers=yes], [have_wintls_headers=no], [[
  373. #ifdef HAVE_WINDOWS_H
  374. # include <windows.h>
  375. #endif
  376. ]])
  377. AC_CHECK_HEADER([security.h], [have_wintls_headers=$have_wintls_headers], [have_wintls_headers=no], [[
  378. #ifdef HAVE_WINDOWS_H
  379. # include <windows.h>
  380. #endif
  381. #ifndef SECURITY_WIN32
  382. #define SECURITY_WIN32 1
  383. #endif
  384. ]])
  385. if test "x$have_wintls_libs" = "xyes" &&
  386. test "x$have_wintls_headers" = "xyes"; then
  387. AC_DEFINE([SECURITY_WIN32], [1], [Use security.h in WIN32 mode])
  388. WINTLS_LIBS="-lcrypt32 -lsecur32 -ladvapi32"
  389. AC_SUBST([WINTLS_LIBS])
  390. have_wintls=yes
  391. have_ssl=yes
  392. have_nativetls=yes
  393. else
  394. have_wintls=no
  395. fi
  396. if test "x$have_wintls" != "xyes"; then
  397. if test "x$with_wintls_requested" = "xyes"; then
  398. ARIA2_DEP_NOT_MET([wintls])
  399. fi
  400. fi
  401. fi
  402. have_libgnutls=no
  403. if test "x$with_gnutls" = "xyes" && test "x$have_ssl" != "xyes"; then
  404. # gnutls >= 2.8 doesn't have libgnutls-config anymore. We require
  405. # 2.2.0 because we use gnutls_priority_set_direct()
  406. PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.2.0],
  407. [have_libgnutls=yes], [have_libgnutls=no])
  408. if test "x$have_libgnutls" = "xyes"; then
  409. have_ssl=yes
  410. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  411. save_LIBS=$LIBS
  412. LIBS="$LIBGNUTLS_LIBS $LIBS"
  413. AC_CHECK_FUNCS([gnutls_certificate_set_x509_system_trust])
  414. LIBS=$save_LIBS
  415. else
  416. AC_MSG_WARN([$LIBGNUTLS_PKG_ERRORS])
  417. if test "x$with_gnutls_requested" = "xyes"; then
  418. ARIA2_DEP_NOT_MET([gnutls])
  419. fi
  420. fi
  421. fi
  422. have_openssl=no
  423. if test "x$with_openssl" = "xyes" && test "x$have_ssl" != "xyes"; then
  424. PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],
  425. [have_openssl=yes], [have_openssl=no])
  426. if test "x$have_openssl" = "xyes"; then
  427. have_ssl=yes
  428. AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if you have openssl.])
  429. save_LIBS=$LIBS
  430. LIBS="$OPENSSL_LIBS $LIBS"
  431. AC_CHECK_FUNCS([EVP_DigestInit_ex], [have_digestinit_ex=yes])
  432. if test "x$have_digestinit_ex" = "x"; then
  433. AC_DEFINE([HAVE_OLD_OPENSSL], [1], [Define to 1 if you have old openssl.])
  434. fi
  435. AC_CHECK_FUNCS([EVP_sha224])
  436. AC_CHECK_FUNCS([EVP_sha256])
  437. AC_CHECK_FUNCS([EVP_sha384])
  438. AC_CHECK_FUNCS([EVP_sha512])
  439. LIBS=$save_LIBS
  440. else
  441. AC_MSG_WARN([$OPENSSL_PKG_ERRORS])
  442. if test "x$with_openssl_requested" = "xyes"; then
  443. ARIA2_DEP_NOT_MET([openssl])
  444. fi
  445. fi
  446. fi
  447. have_libnettle=no
  448. have_libgmp=no
  449. have_libgcrypt=no
  450. if test "x$have_openssl" != "xyes"; then
  451. if test "x$with_libnettle" = "xyes" &&
  452. test "x$have_nativetls" != "xyes"; then
  453. PKG_CHECK_MODULES([LIBNETTLE], [nettle],
  454. [have_libnettle=yes], [have_libnettle=no])
  455. if test "x$have_libnettle" = "xyes"; then
  456. AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if you have libnettle.])
  457. elif test "x$with_libnettle_requested" = "xyes"; then
  458. ARIA2_DEP_NOT_MET([nettle])
  459. fi
  460. fi
  461. if test "x$with_libgmp" = "xyes" &&
  462. (test "x$have_libnettle" = "xyes" ||
  463. test "x$have_nativetls" = "xyes") &&
  464. test "x$enable_bittorrent" = "xyes"; then
  465. AC_CHECK_LIB([gmp], [__gmpz_init], [have_libgmp=yes], [have_libgmp=no])
  466. if test "x$have_libgmp" = "xyes"; then
  467. LIBGMP_CFLAGS=
  468. LIBGMP_LIBS=-lgmp
  469. AC_SUBST([LIBGMP_CFLAGS])
  470. AC_SUBST([LIBGMP_LIBS])
  471. AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have libgmp.])
  472. save_LIBS=$LIBS
  473. LIBS="$LIBGMP_LIBS $LIBS"
  474. AC_CHECK_FUNCS([__gmpz_powm_sec], [have_mpz_powm_sec=yes])
  475. LIBS=$save_LIBS
  476. if test "x$have_mpz_powm_sec" = "xyes"; then
  477. AC_DEFINE([HAVE_GMP_SEC], [1], [Define to 1 if you have a GMP with sec functions.])
  478. fi
  479. else
  480. AC_MSG_WARN([libgmp not found])
  481. if test "x$with_libgmp_requested" = "xyes"; then
  482. ARIA2_DEP_NOT_MET([libgmp])
  483. fi
  484. fi
  485. fi
  486. if test "x$with_libgcrypt" = "xyes" &&
  487. test "x$have_nativetls" != "xyes" &&
  488. test "x$have_libnettle" != "xyes"; then
  489. m4_ifdef([AM_PATH_LIBGCRYPT], [AM_PATH_LIBGCRYPT([1.2.4], [have_libgcrypt=yes])], [
  490. AC_MSG_WARN([configure was generated without libgcrypt detection. libgcrypt detection is disabled])
  491. LIBGCRYPT_CFLAGS=
  492. LIBGCRYPT_LIBS=
  493. AC_SUBST([LIBGCRYPT_CFLAGS])
  494. AC_SUBST([LIBGCRYPT_LIBS])
  495. ])
  496. if test "x$have_libgcrypt" = "xyes"; then
  497. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  498. fi
  499. fi
  500. fi
  501. have_libssh2=no
  502. if test "x$with_libssh2" = "xyes"; then
  503. PKG_CHECK_MODULES([LIBSSH2], [libssh2], [have_libssh2=yes], [have_libssh2=no])
  504. if test "x$have_libssh2" = "xyes"; then
  505. AC_DEFINE([HAVE_LIBSSH2], [1], [Define to 1 if you have libssh2.])
  506. else
  507. AC_MSG_WARN([$LIBSSH2_PKG_ERRORS])
  508. if test "x$with_libssh2_requested" = "xyes"; then
  509. ARIA2_DEP_NOT_MET([libssh2])
  510. fi
  511. fi
  512. fi
  513. have_libcares=no
  514. if test "x$with_libcares" = "xyes"; then
  515. PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.0], [have_libcares=yes],
  516. [have_libcares=no])
  517. if test "x$have_libcares" = "xyes"; then
  518. AC_DEFINE([HAVE_LIBCARES], [1], [Define to 1 if you have libcares.])
  519. save_LIBS=$LIBS
  520. save_CPPFLAGS=$CPPFLAGS
  521. LIBS="$LIBCARES_LIBS $LIBS"
  522. CPPFLAGS="$LIBCARES_CFLAGS $CPPFLAGS"
  523. AC_CHECK_TYPES([ares_addr_node], [], [], [[#include <ares.h>]])
  524. AC_CHECK_FUNCS([ares_set_servers])
  525. LIBS=$save_LIBS
  526. CPPFLAGS=$save_CPPFLAGS
  527. # -DCARES_STATICLIB is appended by pkg-config file libcares.pc
  528. else
  529. AC_MSG_WARN([$LIBCARES_PKG_ERRORS])
  530. if test "x$with_libcares_requested" = "xyes"; then
  531. ARIA2_DEP_NOT_MET([libcares])
  532. fi
  533. fi
  534. fi
  535. use_md=""
  536. if test "x$have_appletls" = "xyes"; then
  537. use_md="apple"
  538. AC_DEFINE([USE_APPLE_MD], [1], [What message digest implementation to use])
  539. else
  540. if test "x$have_libnettle" = "xyes"; then
  541. AC_DEFINE([USE_LIBNETTLE_MD], [1], [What message digest implementation to use])
  542. use_md="libnettle"
  543. else
  544. if test "x$have_libgcrypt" = "xyes"; then
  545. AC_DEFINE([USE_LIBGCRYPT_MD], [1], [What message digest implementation to use])
  546. use_md="libgcrypt"
  547. else
  548. if test "x$have_openssl" = "xyes"; then
  549. AC_DEFINE([USE_OPENSSL_MD], [1], [What message digest implementation to use])
  550. use_md="openssl"
  551. else
  552. AC_DEFINE([USE_INTERNAL_MD], [1], [What message digest implementation to use])
  553. use_md="internal"
  554. fi
  555. fi
  556. fi
  557. fi
  558. # Define variables based on the result of the checks for libraries.
  559. if test "x$have_ssl" = "xyes"; then
  560. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  561. AM_CONDITIONAL([ENABLE_SSL], true)
  562. else
  563. have_ssl="no"
  564. AM_CONDITIONAL([ENABLE_SSL], false)
  565. fi
  566. AM_CONDITIONAL([HAVE_OSX], [ test "x$have_osx" = "xyes" ])
  567. AM_CONDITIONAL([HAVE_APPLETLS], [ test "x$have_appletls" = "xyes" ])
  568. AM_CONDITIONAL([HAVE_WINTLS], [ test "x$have_wintls" = "xyes" ])
  569. AM_CONDITIONAL([USE_APPLE_MD], [ test "x$use_md" = "xapple" ])
  570. AM_CONDITIONAL([USE_WINDOWS_MD], [ test "x$use_md" = "xwindows" ])
  571. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  572. AM_CONDITIONAL([HAVE_LIBNETTLE], [ test "x$have_libnettle" = "xyes" ])
  573. AM_CONDITIONAL([USE_LIBNETTLE_MD], [ test "x$use_md" = "xlibnettle"])
  574. AM_CONDITIONAL([HAVE_LIBGMP], [ test "x$have_libgmp" = "xyes" ])
  575. AM_CONDITIONAL([HAVE_LIBGCRYPT], [ test "x$have_libgcrypt" = "xyes" ])
  576. AM_CONDITIONAL([USE_LIBGCRYPT_MD], [ test "x$use_md" = "xlibgcrypt"])
  577. AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
  578. AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
  579. AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
  580. if test "x$have_libgmp" = "xyes" ||
  581. test "x$have_libgcrypt" = "xyes" ||
  582. test "x$have_openssl" = "xyes"; then
  583. AM_CONDITIONAL([USE_INTERNAL_BIGNUM], false)
  584. else
  585. AC_DEFINE([USE_INTERNAL_BIGNUM], [1], [Define to 1 if internal BIGNUM support is enabled.])
  586. AM_CONDITIONAL([USE_INTERNAL_BIGNUM], true)
  587. fi
  588. if test "x$have_libnettle" = "xyes" ||
  589. test "x$have_libgcrypt" = "xyes" ||
  590. test "x$have_openssl" = "xyes"; then
  591. AM_CONDITIONAL([USE_INTERNAL_ARC4], false)
  592. else
  593. AC_DEFINE([USE_INTERNAL_ARC4], [1], [Define to 1 if internal ARC4 support is enabled.])
  594. AM_CONDITIONAL([USE_INTERNAL_ARC4], true)
  595. fi
  596. if test "x$enable_bittorrent" = "xyes"; then
  597. AC_DEFINE([ENABLE_BITTORRENT], [1],
  598. [Define to 1 if BitTorrent support is enabled.])
  599. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  600. else
  601. if test "x$enable_bittorrent_requested" = "xyes"; then
  602. ARIA2_FET_NOT_SUPPORTED([bittorrent])
  603. fi
  604. enable_bittorrent=no
  605. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  606. fi
  607. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  608. test "x$enable_metalink" = "xyes"; then
  609. AC_DEFINE([ENABLE_METALINK], [1],
  610. [Define to 1 if Metalink support is enabled.])
  611. AM_CONDITIONAL([ENABLE_METALINK], true)
  612. else
  613. if test "x$enable_metalink_requested" = "xyes"; then
  614. ARIA2_FET_NOT_SUPPORTED([metalink])
  615. fi
  616. enable_metalink=no
  617. AM_CONDITIONAL([ENABLE_METALINK], false)
  618. fi
  619. AM_CONDITIONAL([HAVE_SOME_XMLLIB],
  620. [test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"])
  621. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  622. enable_xml_rpc=yes
  623. else
  624. enable_xml_rpc=no
  625. fi
  626. if test "x$enable_xml_rpc" = "xyes"; then
  627. AC_DEFINE([ENABLE_XML_RPC], [1],
  628. [Define to 1 if XML-RPC support is enabled.])
  629. fi
  630. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  631. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  632. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  633. if test "x$have_libcares" = "xyes"; then
  634. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  635. [Define to 1 if asynchronous DNS support is enabled.])
  636. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  637. else
  638. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  639. fi
  640. # Set conditional for libz
  641. AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])
  642. # Set conditional for sqlite3
  643. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  644. # Set conditional for libssh2
  645. AM_CONDITIONAL([HAVE_LIBSSH2], [test "x$have_libssh2" = "xyes"])
  646. case "$host" in
  647. *solaris*)
  648. save_LIBS=$LIBS
  649. LIBS=
  650. AC_SEARCH_LIBS([getaddrinfo], [nsl socket], [], [$save_LIBS])
  651. EXTRALIBS="$LIBS $EXTRALIBS"
  652. LIBS=$save_LIBS
  653. ;;
  654. esac
  655. # Checks for header files.
  656. AC_FUNC_ALLOCA
  657. AC_HEADER_STDC
  658. AC_CHECK_HEADERS([argz.h \
  659. arpa/inet.h \
  660. fcntl.h \
  661. float.h \
  662. inttypes.h \
  663. langinfo.h \
  664. libintl.h \
  665. limits.h \
  666. locale.h \
  667. malloc.h \
  668. netdb.h \
  669. netinet/in.h \
  670. netinet/tcp.h \
  671. poll.h \
  672. port.h \
  673. signal.h \
  674. stddef.h \
  675. stdint.h \
  676. stdio_ext.h \
  677. stdlib.h \
  678. string.h \
  679. strings.h \
  680. sys/ioctl.h \
  681. sys/param.h \
  682. sys/resource.h \
  683. sys/signal.h \
  684. sys/socket.h \
  685. sys/time.h \
  686. sys/types.h \
  687. sys/uio.h \
  688. sys/utsname.h \
  689. termios.h \
  690. unistd.h \
  691. utime.h \
  692. wchar.h \
  693. ifaddrs.h \
  694. pwd.h])
  695. # Checks for typedefs, structures, and compiler characteristics.
  696. AC_HEADER_STDBOOL
  697. AC_C_CONST
  698. AC_C_INLINE
  699. AC_TYPE_INT16_T
  700. AC_TYPE_INT32_T
  701. AC_TYPE_INT64_T
  702. AC_TYPE_INT8_T
  703. AC_TYPE_MODE_T
  704. AC_TYPE_OFF_T
  705. AC_TYPE_SIZE_T
  706. AC_TYPE_SSIZE_T
  707. AC_HEADER_TIME
  708. AC_STRUCT_TM
  709. AC_TYPE_UINT16_T
  710. AC_TYPE_UINT32_T
  711. AC_TYPE_UINT64_T
  712. AC_TYPE_UINT8_T
  713. AC_TYPE_PID_T
  714. AC_C_VOLATILE
  715. AC_CHECK_TYPES([ptrdiff_t])
  716. AC_CHECK_TYPE([struct timespec], [have_timespec=yes], [have_timespec=no])
  717. AC_C_BIGENDIAN
  718. AC_SYS_LARGEFILE
  719. if test "x$have_timespec" = "xyes"; then
  720. AC_DEFINE([HAVE_A2_STRUCT_TIMESPEC], [1],
  721. [Define to 1 if the system has the type `struct timespec'.])
  722. fi
  723. # Checks for library functions.
  724. AM_GNU_GETTEXT([external])
  725. AM_GNU_GETTEXT_VERSION([0.18])
  726. AC_FUNC_ERROR_AT_LINE
  727. AC_PROG_GCC_TRADITIONAL
  728. AC_FUNC_MEMCMP
  729. AC_FUNC_MKTIME
  730. AC_FUNC_SELECT_ARGTYPES
  731. AC_FUNC_STAT
  732. AC_FUNC_STRFTIME
  733. AC_FUNC_VPRINTF
  734. AC_FUNC_FORK
  735. AC_FUNC_STRTOD
  736. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  737. # OpenWRT) which have mmap and it works in the way we use in aria2.
  738. # Instead use mmap in AC_CHECK_FUNCS list.
  739. AC_CHECK_FUNCS([__argz_count \
  740. __argz_next \
  741. __argz_stringify \
  742. atexit \
  743. ftruncate \
  744. getcwd \
  745. gethostbyaddr \
  746. gethostbyname \
  747. getifaddrs \
  748. getpagesize \
  749. getrandom \
  750. memchr \
  751. memmove \
  752. mempcpy \
  753. memset \
  754. mkdir \
  755. mmap \
  756. munmap \
  757. nl_langinfo \
  758. posix_fadvise \
  759. posix_memalign \
  760. pow \
  761. putenv \
  762. rmdir \
  763. select \
  764. setlocale \
  765. sigaction \
  766. sleep \
  767. socket \
  768. stpcpy \
  769. strcasecmp \
  770. strchr \
  771. strcspn \
  772. strdup \
  773. strerror \
  774. strncasecmp \
  775. strstr \
  776. strtol \
  777. strtoul \
  778. strtoull \
  779. tzset \
  780. unsetenv \
  781. usleep \
  782. utime \
  783. utimes])
  784. AC_MSG_CHECKING([for getrandom linux syscall interface])
  785. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  786. #include <sys/syscall.h>
  787. #include <linux/random.h>
  788. ]],
  789. [[
  790. int x = GRND_NONBLOCK;
  791. int y = (int)SYS_getrandom;
  792. ]])],
  793. [have_getrandom_interface=yes
  794. AC_DEFINE([HAVE_GETRANDOM_INTERFACE], [1], [Define to 1 if getrandom linux syscall interface is available.])],
  795. [have_getrandom_interface=no])
  796. AC_MSG_RESULT([$have_getrandom_interface])
  797. AM_CONDITIONAL([HAVE_GETRANDOM_INTERFACE], [test "x$have_getrandom_interface" = "xyes"])
  798. dnl Put tcmalloc/jemalloc checks after the posix_memalign check.
  799. dnl These libraries may implement posix_memalign, while the usual CRT may not
  800. dnl (e.g. mingw). Since we aren't including the corresponding library headers
  801. dnl this will lead to undefined posix_memalign() errors when compiling
  802. if test "x$with_tcmalloc_requested" = "xyes" &&
  803. test "x$with_jemalloc_requested" = "xyes"; then
  804. AC_MSG_FAILURE([Cannot use both, tcmalloc and jemalloc!])
  805. fi
  806. have_tcmalloc=no
  807. if test "x$with_tcmalloc" = "xyes"; then
  808. dnl Important: put malloc libs at the very end.
  809. dnl Only newish versions have a .pc, thus try CHECK_LIB as well.
  810. PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc_minimal], [have_tcmalloc=yes], [have_tcmalloc=no])
  811. if test "x$have_tcmalloc" != "xyes"; then
  812. AC_CHECK_LIB([tcmalloc_minimal], [malloc], [have_tcmalloc=yes], [have_tcmalloc=no])
  813. if test "x$have_tcmalloc" = "xyes"; then
  814. TCMALLOC_CFLAGS=
  815. TCMALLOC_LIBS="-ltcmalloc_minimal"
  816. AC_SUBST([TCMALLOC_CFLAGS])
  817. AC_SUBST([TCMALLOC_LIBS])
  818. else
  819. if test "x$with_tcmalloc_requested" = "xyes"; then
  820. ARIA2_DEP_NOT_MET([tcmalloc_minimal])
  821. fi
  822. fi
  823. fi
  824. fi
  825. have_jemalloc=no
  826. if test "x$with_jemalloc" = "xyes"; then
  827. dnl Important: put malloc libs at the very end.
  828. dnl Usually jemalloc does not come with a .pc, as the official source does not
  829. dnl generate one.
  830. PKG_CHECK_MODULES([JEMALLOC], [jemalloc], [have_jemalloc=yes], [have_jemalloc=no])
  831. if test "x$have_jemalloc" != "xyes"; then
  832. AC_CHECK_LIB([jemalloc], [malloc], [have_jemalloc=yes], [have_jemalloc=no])
  833. if test "x$have_jemalloc" = "xyes"; then
  834. JEMALLOC_CFLAGS=
  835. JEMALLOC_LIBS="-ljemalloc"
  836. AC_SUBST([JEMALLOC_CFLAGS])
  837. AC_SUBST([JEMALLOC_LIBS])
  838. else
  839. if test "x$with_jemalloc_requested" = "xyes"; then
  840. ARIA2_DEP_NOT_MET([jemalloc (unprefixed)])
  841. fi
  842. fi
  843. fi
  844. fi
  845. have_epoll=no
  846. if test "x$enable_epoll" = "xyes"; then
  847. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  848. if test "x$have_epoll" = "xyes"; then
  849. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  850. fi
  851. fi
  852. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  853. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  854. ARIA2_CHECK_FALLOCATE
  855. if test "x$have_posix_fallocate" = "xyes" ||
  856. test "x$have_fallocate" = "xyes" ||
  857. test "x$have_osx" = "xyes" ||
  858. test "x$win_build" = "xyes"; then
  859. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  860. [Define to 1 if *_fallocate is available.])
  861. fi
  862. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  863. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  864. || test "x$have_osx" = "xyes" || test "x$win_build" = "xyes"])
  865. # mingw needs this
  866. save_CPPFLAGS=$CPPFLAGS
  867. CPPFLAGS="$CPPFLAGS $EXTRACPPFLAGS"
  868. AC_MSG_CHECKING([for asctime_r])
  869. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  870. #include <time.h>
  871. ]], [[
  872. struct tm r; char *c;
  873. asctime_r(&r, c);
  874. ]])],
  875. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)
  876. AC_MSG_RESULT([yes])
  877. AC_DEFINE([HAVE_ASCTIME_R], [1], [Define to 1 if you have the `asctime_r' function or macro.])],
  878. [AC_MSG_RESULT([no])
  879. AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  880. AC_MSG_CHECKING([for localtime_r])
  881. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  882. #include <time.h>
  883. ]], [[
  884. time_t t; struct tm r;
  885. localtime_r(&t, &r);
  886. ]])],
  887. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)
  888. AC_MSG_RESULT([yes])
  889. AC_DEFINE([HAVE_LOCALTIME_R], [1], [Define to 1 if you have the `localtime_r' function or macro.])],
  890. [AC_MSG_RESULT([no])
  891. AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  892. CPPFLAGS=$save_CPPFLAGS
  893. AC_CHECK_FUNCS([basename],
  894. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  895. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  896. AC_CHECK_FUNCS([gai_strerror],
  897. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  898. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  899. AC_CHECK_FUNCS([getaddrinfo],
  900. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  901. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  902. AC_CHECK_FUNCS([gettimeofday],
  903. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  904. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  905. AC_CHECK_FUNCS([strptime],
  906. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  907. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  908. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  909. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  910. AC_CHECK_FUNCS([poll], [have_poll=yes])
  911. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  912. case "$host" in
  913. *mingw*)
  914. AM_CONDITIONAL([MINGW_BUILD], true)
  915. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  916. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  917. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  918. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  919. ;;
  920. *)
  921. AM_CONDITIONAL([MINGW_BUILD], false)
  922. ;;
  923. esac
  924. case "$host" in
  925. *android*)
  926. # timegm is not declared with Android NDK r12b
  927. AM_CONDITIONAL([HAVE_TIMEGM], false)
  928. ;;
  929. *)
  930. AC_CHECK_FUNCS([timegm],
  931. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  932. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  933. ;;
  934. esac
  935. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  936. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  937. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  938. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  939. if test "x$have_kqueue" = "xyes"; then
  940. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  941. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  942. #include <sys/types.h>
  943. #include <sys/event.h>
  944. #include <sys/time.h>
  945. ]],
  946. [[
  947. struct kevent event;
  948. event.udata = reinterpret_cast<intptr_t>(&event);
  949. ]])],
  950. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  951. AC_MSG_RESULT([$kevent_udata_intptr_t])
  952. if test "x$kevent_udata_intptr_t" = "xyes"; then
  953. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  954. fi
  955. fi
  956. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  957. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  958. [Define to 1 if struct sockaddr_in has sin_len member.])],
  959. [],
  960. [[
  961. #include <sys/types.h>
  962. #include <sys/socket.h>
  963. #include <netinet/in.h>
  964. ]])
  965. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  966. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  967. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  968. [],
  969. [[
  970. #include <sys/types.h>
  971. #include <sys/socket.h>
  972. #include <netinet/in.h>
  973. ]])
  974. # Check struct option.name is assignable from const char*. struct
  975. # option.name in opensolaris is of type char*. In Linux, it is const
  976. # char*
  977. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  978. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  979. #include <unistd.h>
  980. #include <getopt.h>
  981. ]],
  982. [[
  983. const char* s = "const char";
  984. option op;
  985. op.name = s;
  986. ]])],
  987. [have_option_const_name=yes], [have_option_const_name=no])
  988. AC_MSG_RESULT([$have_option_const_name])
  989. if test "x$have_option_const_name" = "xyes"; then
  990. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  991. fi
  992. if test "x$enable_websocket" = "xyes"; then
  993. AC_CONFIG_SUBDIRS([deps/wslay])
  994. enable_websocket=yes
  995. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  996. [Define 1 if WebSocket support is enabled.])
  997. # $(top_srcdir) for `make distcheck`
  998. WSLAY_CFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes"
  999. WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
  1000. AC_SUBST([WSLAY_CFLAGS])
  1001. AC_SUBST([WSLAY_LIBS])
  1002. fi
  1003. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  1004. AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
  1005. AC_SUBST([bashcompletiondir])
  1006. case "$host" in
  1007. *android*)
  1008. android=yes
  1009. LIBS="$LIBS -lstdc++ -lsupc++"
  1010. case "$host" in
  1011. arm-*)
  1012. android_arm=yes
  1013. ;;
  1014. mipsel-*)
  1015. android_mips=yes
  1016. ;;
  1017. i686-*)
  1018. android_x86=yes
  1019. ;;
  1020. esac
  1021. ;;
  1022. *)
  1023. ;;
  1024. esac
  1025. AM_CONDITIONAL([ANDROID], [test "x$android" = "xyes"])
  1026. AM_CONDITIONAL([ANDROID_ARM], [test "x$android_arm" = "xyes"])
  1027. AM_CONDITIONAL([ANDROID_MIPS], [test "x$android_mips" = "xyes"])
  1028. AM_CONDITIONAL([ANDROID_X86], [test "x$android_x86" = "xyes"])
  1029. if test "x$ARIA2_STATIC" = "xyes"; then
  1030. # -static-libgcc and -static-libstdc++ are linker flags and not for
  1031. # libtool.
  1032. EXTRALDFLAGS="$EXTRALDFLAGS -all-static"
  1033. dnl For non-MinGW build, we need additional libs for static build.
  1034. case "$host" in
  1035. *mingw*|*msvc*|*darwin*)
  1036. ;;
  1037. *)
  1038. EXTRALIBS="$EXTRALIBS -lpthread -ldl -lrt"
  1039. ;;
  1040. esac
  1041. fi
  1042. if test "x$win_build" = "xyes" && test "x$enable_libaria2" = "xyes"; then
  1043. # Creating dll needs this
  1044. EXTRALDFLAGS="$EXTRALDFLAGS -no-undefined"
  1045. fi
  1046. AC_SUBST([EXTRACFLAGS])
  1047. AC_SUBST([EXTRACXXFLAGS])
  1048. AC_SUBST([EXTRACPPFLAGS])
  1049. AC_SUBST([EXTRALDFLAGS])
  1050. AC_SUBST([EXTRALIBS])
  1051. save_CXXFLAGS=$CXXFLAGS
  1052. CXXFLAGS=
  1053. if test "x$enable_werror" = "xyes"; then
  1054. AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
  1055. AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
  1056. AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
  1057. fi
  1058. WARNCXXFLAGS=$CXXFLAGS
  1059. CXXFLAGS=$save_CXXFLAGS
  1060. AC_SUBST([WARNCXXFLAGS])
  1061. AC_CONFIG_FILES([Makefile
  1062. src/Makefile
  1063. src/libaria2.pc
  1064. src/includes/Makefile
  1065. test/Makefile
  1066. po/Makefile.in
  1067. lib/Makefile
  1068. doc/Makefile
  1069. doc/manual-src/Makefile
  1070. doc/manual-src/en/Makefile
  1071. doc/manual-src/en/conf.py
  1072. doc/manual-src/ru/Makefile
  1073. doc/manual-src/ru/conf.py
  1074. doc/manual-src/pt/Makefile
  1075. doc/manual-src/pt/conf.py
  1076. deps/Makefile])
  1077. AC_OUTPUT
  1078. AC_MSG_NOTICE([summary of build options:
  1079. Build: $build
  1080. Host: $host
  1081. Target: $target
  1082. Install prefix: $prefix
  1083. CC: $CC
  1084. CXX: $CXX
  1085. CPP: $CPP
  1086. CXXFLAGS: $CXXFLAGS
  1087. CFLAGS: $CFLAGS
  1088. CPPFLAGS: $CPPFLAGS
  1089. LDFLAGS: $LDFLAGS
  1090. LIBS: $LIBS
  1091. DEFS: $DEFS
  1092. CXX1XCXXFLAGS: $CXX1XCXXFLAGS
  1093. EXTRACXXFLAGS: $EXTRACXXFLAGS
  1094. EXTRACFLAGS: $EXTRACFLAGS
  1095. EXTRACPPFLAGS: $EXTRACPPFLAGS
  1096. EXTRALDFLAGS: $EXTRALDFLAGS
  1097. EXTRALIBS: $EXTRALIBS
  1098. WARNCXXFLAGS: $WARNCXXFLAGS
  1099. LibUV: $have_libuv (CFLAGS='$LIBUV_CFLAGS' LIBS='$LIBUV_LIBS')
  1100. SQLite3: $have_sqlite3 (CFLAGS='$SQLITE3_CFLAGS' LIBS='$SQLITE3_LIBS')
  1101. SSL Support: $have_ssl
  1102. AppleTLS: $have_appletls (LDFLAGS='$APPLETLS_LDFLAGS')
  1103. WinTLS: $have_wintls (LIBS='$WINTLS_LIBS')
  1104. GnuTLS: $have_libgnutls (CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS')
  1105. OpenSSL: $have_openssl (CFLAGS='$OPENSSL_CFLAGS' LIBS='$OPENSSL_LIBS')
  1106. CA Bundle: $ca_bundle
  1107. LibNettle: $have_libnettle (CFLAGS='$LIBNETTLE_CFLAGS' LIBS='$LIBNETTLE_LIBS')
  1108. LibGmp: $have_libgmp (CFLAGS='$LIBGMP_CFLAGS' LIBS='$LIBGMP_LIBS')
  1109. LibGcrypt: $have_libgcrypt (CFLAGS='$LIBGCRYPT_CFLAGS' LIBS='$LIBGCRYPT_LIBS')
  1110. LibXML2: $have_libxml2 (CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS')
  1111. LibExpat: $have_libexpat (CFLAGS='$EXPAT_CFLAGS' LIBS='$EXPAT_LIBS')
  1112. LibCares: $have_libcares (CFLAGS='$LIBCARES_CFLAGS' LIBS='$LIBCARES_LIBS')
  1113. Zlib: $have_zlib (CFLAGS='$ZLIB_CFLAGS' LIBS='$ZLIB_LIBS')
  1114. Libssh2: $have_libssh2 (CFLAGS='$LIBSSH2_CFLAGS' LIBS='$LIBSSH2_LIBS')
  1115. Tcmalloc: $have_tcmalloc (CFLAGS='$TCMALLOC_CFLAGS' LIBS='$TCMALLOC_LIBS')
  1116. Jemalloc: $have_jemalloc (CFLAGS='$JEMALLOC_CFLAGS' LIBS='$JEMALLOC_LIBS')
  1117. Epoll: $have_epoll
  1118. Bittorrent: $enable_bittorrent
  1119. Metalink: $enable_metalink
  1120. XML-RPC: $enable_xml_rpc
  1121. Message Digest: $use_md
  1122. WebSocket: $enable_websocket (CFLAGS='$WSLAY_CFLAGS' LIBS='$WSLAY_LIBS')
  1123. Libaria2: $enable_libaria2 (shared=${enable_shared} static=${enable_static})
  1124. bash_completion dir: $bashcompletiondir
  1125. Static build: $ARIA2_STATIC
  1126. ])