configure.ac 35 KB

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