configure.ac 38 KB

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