configure.ac 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  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_PROG_EGREP
  591. AC_CHECK_HEADERS([argz.h \
  592. arpa/inet.h \
  593. fcntl.h \
  594. float.h \
  595. inttypes.h \
  596. langinfo.h \
  597. libintl.h \
  598. limits.h \
  599. locale.h \
  600. malloc.h \
  601. netdb.h \
  602. netinet/in.h \
  603. netinet/tcp.h \
  604. poll.h \
  605. port.h \
  606. signal.h \
  607. stddef.h \
  608. stdint.h \
  609. stdio_ext.h \
  610. stdlib.h \
  611. string.h \
  612. strings.h \
  613. sys/ioctl.h \
  614. sys/param.h \
  615. sys/resource.h \
  616. sys/signal.h \
  617. sys/socket.h \
  618. sys/time.h \
  619. sys/types.h \
  620. sys/uio.h \
  621. sys/utsname.h \
  622. termios.h \
  623. unistd.h \
  624. utime.h \
  625. wchar.h \
  626. ifaddrs.h \
  627. pwd.h])
  628. # Checks for typedefs, structures, and compiler characteristics.
  629. AC_HEADER_STDBOOL
  630. AC_C_CONST
  631. AC_C_INLINE
  632. AC_TYPE_INT16_T
  633. AC_TYPE_INT32_T
  634. AC_TYPE_INT64_T
  635. AC_TYPE_INT8_T
  636. AC_TYPE_MODE_T
  637. AC_TYPE_OFF_T
  638. AC_TYPE_SIZE_T
  639. AC_TYPE_SSIZE_T
  640. AC_CHECK_HEADERS_ONCE([sys/time.h])
  641. AC_STRUCT_TM
  642. AC_TYPE_UINT16_T
  643. AC_TYPE_UINT32_T
  644. AC_TYPE_UINT64_T
  645. AC_TYPE_UINT8_T
  646. AC_TYPE_PID_T
  647. AC_C_VOLATILE
  648. AC_CHECK_TYPES([ptrdiff_t])
  649. AC_CHECK_TYPE([struct timespec], [have_timespec=yes], [have_timespec=no])
  650. AC_C_BIGENDIAN
  651. AC_SYS_LARGEFILE
  652. if test "x$have_timespec" = "xyes"; then
  653. AC_DEFINE([HAVE_A2_STRUCT_TIMESPEC], [1],
  654. [Define to 1 if the system has the type `struct timespec'.])
  655. fi
  656. # Checks for library functions.
  657. AM_GNU_GETTEXT([external])
  658. AM_GNU_GETTEXT_VERSION([0.18])
  659. AC_FUNC_ERROR_AT_LINE
  660. AC_PROG_GCC_TRADITIONAL
  661. AC_FUNC_MEMCMP
  662. AC_FUNC_MKTIME
  663. AC_FUNC_SELECT_ARGTYPES
  664. AC_FUNC_STAT
  665. AC_FUNC_STRFTIME
  666. AC_FUNC_VPRINTF
  667. AC_FUNC_FORK
  668. AC_FUNC_STRTOD
  669. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  670. # OpenWRT) which have mmap and it works in the way we use in aria2.
  671. # Instead use mmap in AC_CHECK_FUNCS list.
  672. AC_CHECK_FUNCS([__argz_count \
  673. __argz_next \
  674. __argz_stringify \
  675. atexit \
  676. ftruncate \
  677. getcwd \
  678. gethostbyaddr \
  679. gethostbyname \
  680. getifaddrs \
  681. getpagesize \
  682. memchr \
  683. memmove \
  684. mempcpy \
  685. memset \
  686. mkdir \
  687. mmap \
  688. munmap \
  689. nl_langinfo \
  690. posix_fadvise \
  691. posix_memalign \
  692. pow \
  693. putenv \
  694. rmdir \
  695. select \
  696. setlocale \
  697. sigaction \
  698. sleep \
  699. socket \
  700. stpcpy \
  701. strcasecmp \
  702. strchr \
  703. strcspn \
  704. strdup \
  705. strerror \
  706. strncasecmp \
  707. strstr \
  708. strtol \
  709. strtoul \
  710. strtoull \
  711. tzset \
  712. unsetenv \
  713. usleep \
  714. utime \
  715. utimes])
  716. dnl Put tcmalloc/jemalloc checks after the posix_memalign check.
  717. dnl These libraries may implement posix_memalign, while the usual CRT may not
  718. dnl (e.g. mingw). Since we aren't including the corresponding library headers
  719. dnl this will lead to undefined posix_memalign() errors when compiling
  720. if test "x$with_tcmalloc_requested" = "xyes" &&
  721. test "x$with_jemalloc_requested" = "xyes"; then
  722. AC_MSG_FAILURE([Cannot use both, tcmalloc and jemalloc!])
  723. fi
  724. have_tcmalloc=no
  725. if test "x$with_tcmalloc" = "xyes"; then
  726. dnl Important: put malloc libs at the very end.
  727. dnl Only newish versions have a .pc, thus try CHECK_LIB as well.
  728. PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc_minimal], [have_tcmalloc=yes], [have_tcmalloc=no])
  729. if test "x$have_tcmalloc" != "xyes"; then
  730. AC_CHECK_LIB([tcmalloc_minimal], [malloc], [have_tcmalloc=yes], [have_tcmalloc=no])
  731. if test "x$have_tcmalloc" = "xyes"; then
  732. TCMALLOC_CFLAGS=
  733. TCMALLOC_LIBS="-ltcmalloc_minimal"
  734. AC_SUBST([TCMALLOC_CFLAGS])
  735. AC_SUBST([TCMALLOC_LIBS])
  736. else
  737. if test "x$with_tcmalloc_requested" = "xyes"; then
  738. ARIA2_DEP_NOT_MET([tcmalloc_minimal])
  739. fi
  740. fi
  741. fi
  742. fi
  743. have_jemalloc=no
  744. if test "x$with_jemalloc" = "xyes"; then
  745. dnl Important: put malloc libs at the very end.
  746. dnl Usually jemalloc does not come with a .pc, as the official source does not
  747. dnl generate one.
  748. PKG_CHECK_MODULES([JEMALLOC], [jemalloc], [have_jemalloc=yes], [have_jemalloc=no])
  749. if test "x$have_jemalloc" != "xyes"; then
  750. AC_CHECK_LIB([jemalloc], [malloc], [have_jemalloc=yes], [have_jemalloc=no])
  751. if test "x$have_jemalloc" = "xyes"; then
  752. JEMALLOC_CFLAGS=
  753. JEMALLOC_LIBS="-ljemalloc"
  754. AC_SUBST([JEMALLOC_CFLAGS])
  755. AC_SUBST([JEMALLOC_LIBS])
  756. else
  757. if test "x$with_jemalloc_requested" = "xyes"; then
  758. ARIA2_DEP_NOT_MET([jemalloc (unprefixed)])
  759. fi
  760. fi
  761. fi
  762. fi
  763. have_epoll=no
  764. if test "x$enable_epoll" = "xyes"; then
  765. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  766. if test "x$have_epoll" = "xyes"; then
  767. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  768. fi
  769. fi
  770. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  771. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  772. ARIA2_CHECK_FALLOCATE
  773. if test "x$have_posix_fallocate" = "xyes" ||
  774. test "x$have_fallocate" = "xyes" ||
  775. test "x$have_osx" = "xyes" ||
  776. test "x$win_build" = "xyes"; then
  777. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  778. [Define to 1 if *_fallocate is available.])
  779. fi
  780. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  781. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  782. || test "x$have_osx" = "xyes" || test "x$win_build" = "xyes"])
  783. # mingw needs this
  784. save_CPPFLAGS=$CPPFLAGS
  785. CPPFLAGS="$CPPFLAGS $EXTRACPPFLAGS"
  786. AC_MSG_CHECKING([for asctime_r])
  787. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  788. #include <time.h>
  789. ]], [[
  790. struct tm r; char *c;
  791. asctime_r(&r, c);
  792. ]])],
  793. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)
  794. AC_MSG_RESULT([yes])
  795. AC_DEFINE([HAVE_ASCTIME_R], [1], [Define to 1 if you have the `asctime_r' function or macro.])],
  796. [AC_MSG_RESULT([no])
  797. AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  798. AC_MSG_CHECKING([for localtime_r])
  799. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  800. #include <time.h>
  801. ]], [[
  802. time_t t; struct tm r;
  803. localtime_r(&t, &r);
  804. ]])],
  805. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)
  806. AC_MSG_RESULT([yes])
  807. AC_DEFINE([HAVE_LOCALTIME_R], [1], [Define to 1 if you have the `localtime_r' function or macro.])],
  808. [AC_MSG_RESULT([no])
  809. AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  810. CPPFLAGS=$save_CPPFLAGS
  811. AC_CHECK_FUNCS([basename],
  812. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  813. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  814. AC_CHECK_FUNCS([gai_strerror],
  815. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  816. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  817. AC_CHECK_FUNCS([getaddrinfo],
  818. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  819. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  820. AC_CHECK_FUNCS([gettimeofday],
  821. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  822. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  823. AC_CHECK_FUNCS([strptime],
  824. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  825. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  826. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  827. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  828. AC_CHECK_FUNCS([poll], [have_poll=yes])
  829. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  830. case "$host" in
  831. *mingw*)
  832. AM_CONDITIONAL([MINGW_BUILD], true)
  833. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  834. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  835. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  836. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  837. ;;
  838. *)
  839. AM_CONDITIONAL([MINGW_BUILD], false)
  840. ;;
  841. esac
  842. case "$host" in
  843. *android*)
  844. # timegm is not declared with Android NDK r12b
  845. AM_CONDITIONAL([HAVE_TIMEGM], false)
  846. ;;
  847. *)
  848. AC_CHECK_FUNCS([timegm],
  849. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  850. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  851. ;;
  852. esac
  853. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  854. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  855. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  856. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  857. if test "x$have_kqueue" = "xyes"; then
  858. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  859. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  860. #include <sys/types.h>
  861. #include <sys/event.h>
  862. #include <sys/time.h>
  863. ]],
  864. [[
  865. struct kevent event;
  866. event.udata = reinterpret_cast<intptr_t>(&event);
  867. ]])],
  868. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  869. AC_MSG_RESULT([$kevent_udata_intptr_t])
  870. if test "x$kevent_udata_intptr_t" = "xyes"; then
  871. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  872. fi
  873. fi
  874. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  875. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  876. [Define to 1 if struct sockaddr_in has sin_len member.])],
  877. [],
  878. [[
  879. #include <sys/types.h>
  880. #include <sys/socket.h>
  881. #include <netinet/in.h>
  882. ]])
  883. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  884. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  885. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  886. [],
  887. [[
  888. #include <sys/types.h>
  889. #include <sys/socket.h>
  890. #include <netinet/in.h>
  891. ]])
  892. # Check struct option.name is assignable from const char*. struct
  893. # option.name in opensolaris is of type char*. In Linux, it is const
  894. # char*
  895. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  896. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  897. #include <unistd.h>
  898. #include <getopt.h>
  899. ]],
  900. [[
  901. const char* s = "const char";
  902. option op;
  903. op.name = s;
  904. ]])],
  905. [have_option_const_name=yes], [have_option_const_name=no])
  906. AC_MSG_RESULT([$have_option_const_name])
  907. if test "x$have_option_const_name" = "xyes"; then
  908. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  909. fi
  910. if test "x$enable_websocket" = "xyes"; then
  911. AC_CONFIG_SUBDIRS([deps/wslay])
  912. enable_websocket=yes
  913. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  914. [Define 1 if WebSocket support is enabled.])
  915. # $(top_srcdir) for `make distcheck`
  916. WSLAY_CFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes"
  917. WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
  918. AC_SUBST([WSLAY_CFLAGS])
  919. AC_SUBST([WSLAY_LIBS])
  920. fi
  921. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  922. AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
  923. AC_SUBST([bashcompletiondir])
  924. if test "x$ARIA2_STATIC" = "xyes"; then
  925. # -static-libgcc and -static-libstdc++ are linker flags and not for
  926. # libtool.
  927. EXTRALDFLAGS="$EXTRALDFLAGS -all-static"
  928. dnl For non-MinGW build, we need additional libs for static build.
  929. case "$host" in
  930. *mingw*|*msvc*|*darwin*)
  931. ;;
  932. *)
  933. EXTRALIBS="$EXTRALIBS -lpthread -ldl -lrt"
  934. ;;
  935. esac
  936. fi
  937. if test "x$win_build" = "xyes" && test "x$enable_libaria2" = "xyes"; then
  938. # Creating dll needs this
  939. EXTRALDFLAGS="$EXTRALDFLAGS -no-undefined"
  940. fi
  941. AC_SUBST([EXTRACFLAGS])
  942. AC_SUBST([EXTRACXXFLAGS])
  943. AC_SUBST([EXTRACPPFLAGS])
  944. AC_SUBST([EXTRALDFLAGS])
  945. AC_SUBST([EXTRALIBS])
  946. save_CXXFLAGS=$CXXFLAGS
  947. CXXFLAGS=
  948. if test "x$enable_werror" = "xyes"; then
  949. AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
  950. AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
  951. AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
  952. fi
  953. WARNCXXFLAGS=$CXXFLAGS
  954. CXXFLAGS=$save_CXXFLAGS
  955. AC_SUBST([WARNCXXFLAGS])
  956. AC_CONFIG_FILES([Makefile
  957. src/Makefile
  958. src/libaria2.pc
  959. src/includes/Makefile
  960. test/Makefile
  961. po/Makefile.in
  962. lib/Makefile
  963. doc/Makefile
  964. doc/manual-src/Makefile
  965. doc/manual-src/en/Makefile
  966. doc/manual-src/en/conf.py
  967. doc/manual-src/ru/Makefile
  968. doc/manual-src/ru/conf.py
  969. doc/manual-src/pt/Makefile
  970. doc/manual-src/pt/conf.py
  971. deps/Makefile])
  972. AC_OUTPUT
  973. AC_MSG_NOTICE([summary of build options:
  974. Build: $build
  975. Host: $host
  976. Target: $target
  977. Install prefix: $prefix
  978. CC: $CC
  979. CXX: $CXX
  980. CPP: $CPP
  981. CXXFLAGS: $CXXFLAGS
  982. CFLAGS: $CFLAGS
  983. CPPFLAGS: $CPPFLAGS
  984. LDFLAGS: $LDFLAGS
  985. LIBS: $LIBS
  986. DEFS: $DEFS
  987. CXX1XCXXFLAGS: $CXX1XCXXFLAGS
  988. EXTRACXXFLAGS: $EXTRACXXFLAGS
  989. EXTRACFLAGS: $EXTRACFLAGS
  990. EXTRACPPFLAGS: $EXTRACPPFLAGS
  991. EXTRALDFLAGS: $EXTRALDFLAGS
  992. EXTRALIBS: $EXTRALIBS
  993. WARNCXXFLAGS: $WARNCXXFLAGS
  994. LibUV: $have_libuv (CFLAGS='$LIBUV_CFLAGS' LIBS='$LIBUV_LIBS')
  995. SQLite3: $have_sqlite3 (CFLAGS='$SQLITE3_CFLAGS' LIBS='$SQLITE3_LIBS')
  996. SSL Support: $have_ssl
  997. AppleTLS: $have_appletls (LDFLAGS='$APPLETLS_LDFLAGS')
  998. WinTLS: $have_wintls (LIBS='$WINTLS_LIBS')
  999. GnuTLS: $have_libgnutls (CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS')
  1000. OpenSSL: $have_openssl (CFLAGS='$OPENSSL_CFLAGS' LIBS='$OPENSSL_LIBS')
  1001. CA Bundle: $ca_bundle
  1002. LibNettle: $have_libnettle (CFLAGS='$LIBNETTLE_CFLAGS' LIBS='$LIBNETTLE_LIBS')
  1003. LibGmp: $have_libgmp (CFLAGS='$LIBGMP_CFLAGS' LIBS='$LIBGMP_LIBS')
  1004. LibGcrypt: $have_libgcrypt (CFLAGS='$LIBGCRYPT_CFLAGS' LIBS='$LIBGCRYPT_LIBS')
  1005. LibXML2: $have_libxml2 (CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS')
  1006. LibExpat: $have_libexpat (CFLAGS='$EXPAT_CFLAGS' LIBS='$EXPAT_LIBS')
  1007. LibCares: $have_libcares (CFLAGS='$LIBCARES_CFLAGS' LIBS='$LIBCARES_LIBS')
  1008. Zlib: $have_zlib (CFLAGS='$ZLIB_CFLAGS' LIBS='$ZLIB_LIBS')
  1009. Libssh2: $have_libssh2 (CFLAGS='$LIBSSH2_CFLAGS' LIBS='$LIBSSH2_LIBS')
  1010. Tcmalloc: $have_tcmalloc (CFLAGS='$TCMALLOC_CFLAGS' LIBS='$TCMALLOC_LIBS')
  1011. Jemalloc: $have_jemalloc (CFLAGS='$JEMALLOC_CFLAGS' LIBS='$JEMALLOC_LIBS')
  1012. Epoll: $have_epoll
  1013. Bittorrent: $enable_bittorrent
  1014. Metalink: $enable_metalink
  1015. XML-RPC: $enable_xml_rpc
  1016. Message Digest: $use_md
  1017. WebSocket: $enable_websocket (CFLAGS='$WSLAY_CFLAGS' LIBS='$WSLAY_LIBS')
  1018. Libaria2: $enable_libaria2 (shared=${enable_shared} static=${enable_static})
  1019. bash_completion dir: $bashcompletiondir
  1020. Static build: $ARIA2_STATIC
  1021. ])