configure.ac 37 KB

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