configure.ac 38 KB

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