configure.ac 34 KB

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