configure.ac 37 KB

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