configure.ac 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ([2.67])
  5. AC_INIT([aria2],[1.37.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], [], [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. if test "x$ARIA2_STATIC" = "xyes"; then
  440. LIBSSH2_CFLAGS="-DLIBSSH2_API= $LIBSSH2_CFLAGS"
  441. fi
  442. else
  443. AC_MSG_WARN([$LIBSSH2_PKG_ERRORS])
  444. if test "x$with_libssh2_requested" = "xyes"; then
  445. ARIA2_DEP_NOT_MET([libssh2])
  446. fi
  447. fi
  448. fi
  449. have_libcares=no
  450. if test "x$with_libcares" = "xyes"; then
  451. PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.0], [have_libcares=yes],
  452. [have_libcares=no])
  453. if test "x$have_libcares" = "xyes"; then
  454. AC_DEFINE([HAVE_LIBCARES], [1], [Define to 1 if you have libcares.])
  455. save_LIBS=$LIBS
  456. save_CPPFLAGS=$CPPFLAGS
  457. LIBS="$LIBCARES_LIBS $LIBS"
  458. CPPFLAGS="$LIBCARES_CFLAGS $CPPFLAGS"
  459. AC_CHECK_TYPES([ares_addr_node], [], [], [[#include <ares.h>]])
  460. AC_CHECK_FUNCS([ares_set_servers])
  461. LIBS=$save_LIBS
  462. CPPFLAGS=$save_CPPFLAGS
  463. # -DCARES_STATICLIB is appended by pkg-config file libcares.pc
  464. else
  465. AC_MSG_WARN([$LIBCARES_PKG_ERRORS])
  466. if test "x$with_libcares_requested" = "xyes"; then
  467. ARIA2_DEP_NOT_MET([libcares])
  468. fi
  469. fi
  470. fi
  471. use_md=""
  472. if test "x$have_appletls" = "xyes"; then
  473. use_md="apple"
  474. AC_DEFINE([USE_APPLE_MD], [1], [What message digest implementation to use])
  475. else
  476. if test "x$have_libnettle" = "xyes"; then
  477. AC_DEFINE([USE_LIBNETTLE_MD], [1], [What message digest implementation to use])
  478. use_md="libnettle"
  479. else
  480. if test "x$have_libgcrypt" = "xyes"; then
  481. AC_DEFINE([USE_LIBGCRYPT_MD], [1], [What message digest implementation to use])
  482. use_md="libgcrypt"
  483. else
  484. if test "x$have_openssl" = "xyes"; then
  485. AC_DEFINE([USE_OPENSSL_MD], [1], [What message digest implementation to use])
  486. use_md="openssl"
  487. else
  488. AC_DEFINE([USE_INTERNAL_MD], [1], [What message digest implementation to use])
  489. use_md="internal"
  490. fi
  491. fi
  492. fi
  493. fi
  494. # Define variables based on the result of the checks for libraries.
  495. if test "x$have_ssl" = "xyes"; then
  496. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  497. AM_CONDITIONAL([ENABLE_SSL], true)
  498. else
  499. have_ssl="no"
  500. AM_CONDITIONAL([ENABLE_SSL], false)
  501. fi
  502. AM_CONDITIONAL([HAVE_OSX], [ test "x$have_osx" = "xyes" ])
  503. AM_CONDITIONAL([HAVE_APPLETLS], [ test "x$have_appletls" = "xyes" ])
  504. AM_CONDITIONAL([HAVE_WINTLS], [ test "x$have_wintls" = "xyes" ])
  505. AM_CONDITIONAL([USE_APPLE_MD], [ test "x$use_md" = "xapple" ])
  506. AM_CONDITIONAL([USE_WINDOWS_MD], [ test "x$use_md" = "xwindows" ])
  507. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  508. AM_CONDITIONAL([HAVE_LIBNETTLE], [ test "x$have_libnettle" = "xyes" ])
  509. AM_CONDITIONAL([USE_LIBNETTLE_MD], [ test "x$use_md" = "xlibnettle"])
  510. AM_CONDITIONAL([HAVE_LIBGMP], [ test "x$have_libgmp" = "xyes" ])
  511. AM_CONDITIONAL([HAVE_LIBGCRYPT], [ test "x$have_libgcrypt" = "xyes" ])
  512. AM_CONDITIONAL([USE_LIBGCRYPT_MD], [ test "x$use_md" = "xlibgcrypt"])
  513. AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
  514. AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
  515. AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
  516. if test "x$have_libgmp" = "xyes" ||
  517. test "x$have_libgcrypt" = "xyes" ||
  518. test "x$have_openssl" = "xyes"; then
  519. AM_CONDITIONAL([USE_INTERNAL_BIGNUM], false)
  520. else
  521. AC_DEFINE([USE_INTERNAL_BIGNUM], [1], [Define to 1 if internal BIGNUM support is enabled.])
  522. AM_CONDITIONAL([USE_INTERNAL_BIGNUM], true)
  523. fi
  524. if test "x$have_libnettle" = "xyes" ||
  525. test "x$have_libgcrypt" = "xyes" ||
  526. test "x$have_openssl" = "xyes"; then
  527. AM_CONDITIONAL([USE_INTERNAL_ARC4], false)
  528. else
  529. AC_DEFINE([USE_INTERNAL_ARC4], [1], [Define to 1 if internal ARC4 support is enabled.])
  530. AM_CONDITIONAL([USE_INTERNAL_ARC4], true)
  531. fi
  532. if test "x$enable_bittorrent" = "xyes"; then
  533. AC_DEFINE([ENABLE_BITTORRENT], [1],
  534. [Define to 1 if BitTorrent support is enabled.])
  535. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  536. else
  537. if test "x$enable_bittorrent_requested" = "xyes"; then
  538. ARIA2_FET_NOT_SUPPORTED([bittorrent])
  539. fi
  540. enable_bittorrent=no
  541. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  542. fi
  543. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  544. test "x$enable_metalink" = "xyes"; then
  545. AC_DEFINE([ENABLE_METALINK], [1],
  546. [Define to 1 if Metalink support is enabled.])
  547. AM_CONDITIONAL([ENABLE_METALINK], true)
  548. else
  549. if test "x$enable_metalink_requested" = "xyes"; then
  550. ARIA2_FET_NOT_SUPPORTED([metalink])
  551. fi
  552. enable_metalink=no
  553. AM_CONDITIONAL([ENABLE_METALINK], false)
  554. fi
  555. AM_CONDITIONAL([HAVE_SOME_XMLLIB],
  556. [test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"])
  557. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  558. enable_xml_rpc=yes
  559. else
  560. enable_xml_rpc=no
  561. fi
  562. if test "x$enable_xml_rpc" = "xyes"; then
  563. AC_DEFINE([ENABLE_XML_RPC], [1],
  564. [Define to 1 if XML-RPC support is enabled.])
  565. fi
  566. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  567. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  568. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  569. if test "x$have_libcares" = "xyes"; then
  570. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  571. [Define to 1 if asynchronous DNS support is enabled.])
  572. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  573. else
  574. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  575. fi
  576. # Set conditional for libz
  577. AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])
  578. # Set conditional for sqlite3
  579. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  580. # Set conditional for libssh2
  581. AM_CONDITIONAL([HAVE_LIBSSH2], [test "x$have_libssh2" = "xyes"])
  582. case "$host" in
  583. *solaris*)
  584. save_LIBS=$LIBS
  585. LIBS=
  586. AC_SEARCH_LIBS([getaddrinfo], [nsl socket], [], [$save_LIBS])
  587. EXTRALIBS="$LIBS $EXTRALIBS"
  588. LIBS=$save_LIBS
  589. ;;
  590. esac
  591. # Checks for header files.
  592. AC_FUNC_ALLOCA
  593. AC_PROG_EGREP
  594. AC_CHECK_HEADERS([argz.h \
  595. arpa/inet.h \
  596. fcntl.h \
  597. float.h \
  598. inttypes.h \
  599. langinfo.h \
  600. libintl.h \
  601. limits.h \
  602. locale.h \
  603. malloc.h \
  604. netdb.h \
  605. netinet/in.h \
  606. netinet/tcp.h \
  607. poll.h \
  608. port.h \
  609. signal.h \
  610. stddef.h \
  611. stdint.h \
  612. stdio_ext.h \
  613. stdlib.h \
  614. string.h \
  615. strings.h \
  616. sys/ioctl.h \
  617. sys/param.h \
  618. sys/resource.h \
  619. sys/signal.h \
  620. sys/socket.h \
  621. sys/time.h \
  622. sys/types.h \
  623. sys/uio.h \
  624. sys/utsname.h \
  625. termios.h \
  626. unistd.h \
  627. utime.h \
  628. wchar.h \
  629. ifaddrs.h \
  630. pwd.h])
  631. # Checks for typedefs, structures, and compiler characteristics.
  632. AC_HEADER_STDBOOL
  633. AC_C_CONST
  634. AC_C_INLINE
  635. AC_TYPE_INT16_T
  636. AC_TYPE_INT32_T
  637. AC_TYPE_INT64_T
  638. AC_TYPE_INT8_T
  639. AC_TYPE_MODE_T
  640. AC_TYPE_OFF_T
  641. AC_TYPE_SIZE_T
  642. AC_TYPE_SSIZE_T
  643. AC_CHECK_HEADERS_ONCE([sys/time.h])
  644. AC_STRUCT_TM
  645. AC_TYPE_UINT16_T
  646. AC_TYPE_UINT32_T
  647. AC_TYPE_UINT64_T
  648. AC_TYPE_UINT8_T
  649. AC_TYPE_PID_T
  650. AC_C_VOLATILE
  651. AC_CHECK_TYPES([ptrdiff_t])
  652. AC_CHECK_TYPE([struct timespec], [have_timespec=yes], [have_timespec=no])
  653. AC_C_BIGENDIAN
  654. AC_SYS_LARGEFILE
  655. if test "x$have_timespec" = "xyes"; then
  656. AC_DEFINE([HAVE_A2_STRUCT_TIMESPEC], [1],
  657. [Define to 1 if the system has the type `struct timespec'.])
  658. fi
  659. # Checks for library functions.
  660. AM_GNU_GETTEXT([external])
  661. AM_GNU_GETTEXT_VERSION([0.18])
  662. AC_FUNC_ERROR_AT_LINE
  663. AC_PROG_GCC_TRADITIONAL
  664. AC_FUNC_MEMCMP
  665. AC_FUNC_MKTIME
  666. AC_FUNC_SELECT_ARGTYPES
  667. AC_FUNC_STAT
  668. AC_FUNC_STRFTIME
  669. AC_FUNC_VPRINTF
  670. AC_FUNC_FORK
  671. AC_FUNC_STRTOD
  672. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  673. # OpenWRT) which have mmap and it works in the way we use in aria2.
  674. # Instead use mmap in AC_CHECK_FUNCS list.
  675. AC_CHECK_FUNCS([__argz_count \
  676. __argz_next \
  677. __argz_stringify \
  678. atexit \
  679. ftruncate \
  680. getcwd \
  681. getentropy \
  682. gethostbyaddr \
  683. gethostbyname \
  684. getifaddrs \
  685. getpagesize \
  686. memchr \
  687. memmove \
  688. mempcpy \
  689. memset \
  690. mkdir \
  691. mmap \
  692. munmap \
  693. nl_langinfo \
  694. posix_fadvise \
  695. posix_memalign \
  696. pow \
  697. putenv \
  698. rmdir \
  699. select \
  700. setlocale \
  701. sigaction \
  702. sleep \
  703. socket \
  704. stpcpy \
  705. strcasecmp \
  706. strchr \
  707. strcspn \
  708. strdup \
  709. strerror \
  710. strncasecmp \
  711. strstr \
  712. strtol \
  713. strtoul \
  714. strtoull \
  715. tzset \
  716. unsetenv \
  717. usleep \
  718. utime \
  719. utimes])
  720. dnl Put tcmalloc/jemalloc checks after the posix_memalign check.
  721. dnl These libraries may implement posix_memalign, while the usual CRT may not
  722. dnl (e.g. mingw). Since we aren't including the corresponding library headers
  723. dnl this will lead to undefined posix_memalign() errors when compiling
  724. if test "x$with_tcmalloc_requested" = "xyes" &&
  725. test "x$with_jemalloc_requested" = "xyes"; then
  726. AC_MSG_FAILURE([Cannot use both, tcmalloc and jemalloc!])
  727. fi
  728. have_tcmalloc=no
  729. if test "x$with_tcmalloc" = "xyes"; then
  730. dnl Important: put malloc libs at the very end.
  731. dnl Only newish versions have a .pc, thus try CHECK_LIB as well.
  732. PKG_CHECK_MODULES([TCMALLOC], [libtcmalloc_minimal], [have_tcmalloc=yes], [have_tcmalloc=no])
  733. if test "x$have_tcmalloc" != "xyes"; then
  734. AC_CHECK_LIB([tcmalloc_minimal], [malloc], [have_tcmalloc=yes], [have_tcmalloc=no])
  735. if test "x$have_tcmalloc" = "xyes"; then
  736. TCMALLOC_CFLAGS=
  737. TCMALLOC_LIBS="-ltcmalloc_minimal"
  738. AC_SUBST([TCMALLOC_CFLAGS])
  739. AC_SUBST([TCMALLOC_LIBS])
  740. else
  741. if test "x$with_tcmalloc_requested" = "xyes"; then
  742. ARIA2_DEP_NOT_MET([tcmalloc_minimal])
  743. fi
  744. fi
  745. fi
  746. fi
  747. have_jemalloc=no
  748. if test "x$with_jemalloc" = "xyes"; then
  749. dnl Important: put malloc libs at the very end.
  750. dnl Usually jemalloc does not come with a .pc, as the official source does not
  751. dnl generate one.
  752. PKG_CHECK_MODULES([JEMALLOC], [jemalloc], [have_jemalloc=yes], [have_jemalloc=no])
  753. if test "x$have_jemalloc" != "xyes"; then
  754. AC_CHECK_LIB([jemalloc], [malloc], [have_jemalloc=yes], [have_jemalloc=no])
  755. if test "x$have_jemalloc" = "xyes"; then
  756. JEMALLOC_CFLAGS=
  757. JEMALLOC_LIBS="-ljemalloc"
  758. AC_SUBST([JEMALLOC_CFLAGS])
  759. AC_SUBST([JEMALLOC_LIBS])
  760. else
  761. if test "x$with_jemalloc_requested" = "xyes"; then
  762. ARIA2_DEP_NOT_MET([jemalloc (unprefixed)])
  763. fi
  764. fi
  765. fi
  766. fi
  767. have_epoll=no
  768. if test "x$enable_epoll" = "xyes"; then
  769. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  770. if test "x$have_epoll" = "xyes"; then
  771. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  772. fi
  773. fi
  774. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  775. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  776. ARIA2_CHECK_FALLOCATE
  777. if test "x$have_posix_fallocate" = "xyes" ||
  778. test "x$have_fallocate" = "xyes" ||
  779. test "x$have_osx" = "xyes" ||
  780. test "x$win_build" = "xyes"; then
  781. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  782. [Define to 1 if *_fallocate is available.])
  783. fi
  784. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  785. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  786. || test "x$have_osx" = "xyes" || test "x$win_build" = "xyes"])
  787. # mingw needs this
  788. save_CPPFLAGS=$CPPFLAGS
  789. CPPFLAGS="$CPPFLAGS $EXTRACPPFLAGS"
  790. AC_MSG_CHECKING([for asctime_r])
  791. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  792. #include <time.h>
  793. ]], [[
  794. struct tm r; char *c;
  795. asctime_r(&r, c);
  796. ]])],
  797. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)
  798. AC_MSG_RESULT([yes])
  799. AC_DEFINE([HAVE_ASCTIME_R], [1], [Define to 1 if you have the `asctime_r' function or macro.])],
  800. [AC_MSG_RESULT([no])
  801. AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  802. AC_MSG_CHECKING([for localtime_r])
  803. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  804. #include <time.h>
  805. ]], [[
  806. time_t t; struct tm r;
  807. localtime_r(&t, &r);
  808. ]])],
  809. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)
  810. AC_MSG_RESULT([yes])
  811. AC_DEFINE([HAVE_LOCALTIME_R], [1], [Define to 1 if you have the `localtime_r' function or macro.])],
  812. [AC_MSG_RESULT([no])
  813. AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  814. CPPFLAGS=$save_CPPFLAGS
  815. AC_CHECK_FUNCS([basename],
  816. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  817. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  818. AC_CHECK_FUNCS([gai_strerror],
  819. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  820. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  821. AC_CHECK_FUNCS([getaddrinfo],
  822. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  823. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  824. AC_CHECK_FUNCS([gettimeofday],
  825. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  826. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  827. AC_CHECK_FUNCS([strptime],
  828. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  829. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  830. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  831. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  832. AC_CHECK_FUNCS([poll], [have_poll=yes])
  833. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  834. case "$host" in
  835. *mingw*)
  836. AM_CONDITIONAL([MINGW_BUILD], true)
  837. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  838. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  839. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  840. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  841. ;;
  842. *)
  843. AM_CONDITIONAL([MINGW_BUILD], false)
  844. ;;
  845. esac
  846. AC_CHECK_FUNCS([timegm],
  847. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  848. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  849. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  850. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  851. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  852. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  853. if test "x$have_kqueue" = "xyes"; then
  854. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  855. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  856. #include <sys/types.h>
  857. #include <sys/event.h>
  858. #include <sys/time.h>
  859. ]],
  860. [[
  861. struct kevent event;
  862. event.udata = reinterpret_cast<intptr_t>(&event);
  863. ]])],
  864. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  865. AC_MSG_RESULT([$kevent_udata_intptr_t])
  866. if test "x$kevent_udata_intptr_t" = "xyes"; then
  867. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  868. fi
  869. fi
  870. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  871. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  872. [Define to 1 if struct sockaddr_in has sin_len member.])],
  873. [],
  874. [[
  875. #include <sys/types.h>
  876. #include <sys/socket.h>
  877. #include <netinet/in.h>
  878. ]])
  879. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  880. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  881. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  882. [],
  883. [[
  884. #include <sys/types.h>
  885. #include <sys/socket.h>
  886. #include <netinet/in.h>
  887. ]])
  888. # Check struct option.name is assignable from const char*. struct
  889. # option.name in opensolaris is of type char*. In Linux, it is const
  890. # char*
  891. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  892. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  893. #include <unistd.h>
  894. #include <getopt.h>
  895. ]],
  896. [[
  897. const char* s = "const char";
  898. option op;
  899. op.name = s;
  900. ]])],
  901. [have_option_const_name=yes], [have_option_const_name=no])
  902. AC_MSG_RESULT([$have_option_const_name])
  903. if test "x$have_option_const_name" = "xyes"; then
  904. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  905. fi
  906. if test "x$enable_websocket" = "xyes"; then
  907. AC_CONFIG_SUBDIRS([deps/wslay])
  908. enable_websocket=yes
  909. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  910. [Define 1 if WebSocket support is enabled.])
  911. # $(top_srcdir) for `make distcheck`
  912. WSLAY_CFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes"
  913. WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
  914. AC_SUBST([WSLAY_CFLAGS])
  915. AC_SUBST([WSLAY_LIBS])
  916. fi
  917. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  918. AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
  919. AC_SUBST([bashcompletiondir])
  920. if test "x$ARIA2_STATIC" = "xyes"; then
  921. # -static-libgcc and -static-libstdc++ are linker flags and not for
  922. # libtool.
  923. EXTRALDFLAGS="$EXTRALDFLAGS -all-static"
  924. dnl For non-MinGW build, we need additional libs for static build.
  925. case "$host" in
  926. *mingw*|*msvc*|*darwin*)
  927. ;;
  928. *)
  929. EXTRALIBS="$EXTRALIBS -lpthread -ldl -lrt"
  930. ;;
  931. esac
  932. fi
  933. if test "x$win_build" = "xyes" && test "x$enable_libaria2" = "xyes"; then
  934. # Creating dll needs this
  935. EXTRALDFLAGS="$EXTRALDFLAGS -no-undefined"
  936. fi
  937. AC_SUBST([EXTRACFLAGS])
  938. AC_SUBST([EXTRACXXFLAGS])
  939. AC_SUBST([EXTRACPPFLAGS])
  940. AC_SUBST([EXTRALDFLAGS])
  941. AC_SUBST([EXTRALIBS])
  942. save_CXXFLAGS=$CXXFLAGS
  943. CXXFLAGS=
  944. if test "x$enable_werror" = "xyes"; then
  945. AX_CHECK_COMPILE_FLAG([-Wall], [CXXFLAGS="$CXXFLAGS -Wall"])
  946. AX_CHECK_COMPILE_FLAG([-Werror], [CXXFLAGS="$CXXFLAGS -Werror"])
  947. AX_CHECK_COMPILE_FLAG([-Wformat-security], [CXXFLAGS="$CXXFLAGS -Wformat-security"])
  948. fi
  949. WARNCXXFLAGS=$CXXFLAGS
  950. CXXFLAGS=$save_CXXFLAGS
  951. AC_SUBST([WARNCXXFLAGS])
  952. AC_CONFIG_FILES([Makefile
  953. src/Makefile
  954. src/libaria2.pc
  955. src/includes/Makefile
  956. test/Makefile
  957. po/Makefile.in
  958. lib/Makefile
  959. doc/Makefile
  960. doc/manual-src/Makefile
  961. doc/manual-src/en/Makefile
  962. doc/manual-src/en/conf.py
  963. doc/manual-src/ru/Makefile
  964. doc/manual-src/ru/conf.py
  965. doc/manual-src/pt/Makefile
  966. doc/manual-src/pt/conf.py
  967. deps/Makefile])
  968. AC_OUTPUT
  969. AC_MSG_NOTICE([summary of build options:
  970. Build: $build
  971. Host: $host
  972. Target: $target
  973. Install prefix: $prefix
  974. CC: $CC
  975. CXX: $CXX
  976. CPP: $CPP
  977. CXXFLAGS: $CXXFLAGS
  978. CFLAGS: $CFLAGS
  979. CPPFLAGS: $CPPFLAGS
  980. LDFLAGS: $LDFLAGS
  981. LIBS: $LIBS
  982. DEFS: $DEFS
  983. CXX1XCXXFLAGS: $CXX1XCXXFLAGS
  984. EXTRACXXFLAGS: $EXTRACXXFLAGS
  985. EXTRACFLAGS: $EXTRACFLAGS
  986. EXTRACPPFLAGS: $EXTRACPPFLAGS
  987. EXTRALDFLAGS: $EXTRALDFLAGS
  988. EXTRALIBS: $EXTRALIBS
  989. WARNCXXFLAGS: $WARNCXXFLAGS
  990. LibUV: $have_libuv (CFLAGS='$LIBUV_CFLAGS' LIBS='$LIBUV_LIBS')
  991. SQLite3: $have_sqlite3 (CFLAGS='$SQLITE3_CFLAGS' LIBS='$SQLITE3_LIBS')
  992. SSL Support: $have_ssl
  993. AppleTLS: $have_appletls (LDFLAGS='$APPLETLS_LDFLAGS')
  994. WinTLS: $have_wintls (LIBS='$WINTLS_LIBS')
  995. GnuTLS: $have_libgnutls (CFLAGS='$LIBGNUTLS_CFLAGS' LIBS='$LIBGNUTLS_LIBS')
  996. OpenSSL: $have_openssl (CFLAGS='$OPENSSL_CFLAGS' LIBS='$OPENSSL_LIBS')
  997. CA Bundle: $ca_bundle
  998. LibNettle: $have_libnettle (CFLAGS='$LIBNETTLE_CFLAGS' LIBS='$LIBNETTLE_LIBS')
  999. LibGmp: $have_libgmp (CFLAGS='$LIBGMP_CFLAGS' LIBS='$LIBGMP_LIBS')
  1000. LibGcrypt: $have_libgcrypt (CFLAGS='$LIBGCRYPT_CFLAGS' LIBS='$LIBGCRYPT_LIBS')
  1001. LibXML2: $have_libxml2 (CFLAGS='$LIBXML2_CFLAGS' LIBS='$LIBXML2_LIBS')
  1002. LibExpat: $have_libexpat (CFLAGS='$EXPAT_CFLAGS' LIBS='$EXPAT_LIBS')
  1003. LibCares: $have_libcares (CFLAGS='$LIBCARES_CFLAGS' LIBS='$LIBCARES_LIBS')
  1004. Zlib: $have_zlib (CFLAGS='$ZLIB_CFLAGS' LIBS='$ZLIB_LIBS')
  1005. Libssh2: $have_libssh2 (CFLAGS='$LIBSSH2_CFLAGS' LIBS='$LIBSSH2_LIBS')
  1006. Tcmalloc: $have_tcmalloc (CFLAGS='$TCMALLOC_CFLAGS' LIBS='$TCMALLOC_LIBS')
  1007. Jemalloc: $have_jemalloc (CFLAGS='$JEMALLOC_CFLAGS' LIBS='$JEMALLOC_LIBS')
  1008. Epoll: $have_epoll
  1009. Bittorrent: $enable_bittorrent
  1010. Metalink: $enable_metalink
  1011. XML-RPC: $enable_xml_rpc
  1012. Message Digest: $use_md
  1013. WebSocket: $enable_websocket (CFLAGS='$WSLAY_CFLAGS' LIBS='$WSLAY_LIBS')
  1014. Libaria2: $enable_libaria2 (shared=${enable_shared} static=${enable_static})
  1015. bash_completion dir: $bashcompletiondir
  1016. Static build: $ARIA2_STATIC
  1017. ])