configure.ac 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ([2.67])
  5. LT_PREREQ([2.2.6])
  6. AC_INIT([aria2],[1.17.0],[t-tujikawa@users.sourceforge.net],[aria2],[http://aria2.sourceforge.net/])
  7. AC_USE_SYSTEM_EXTENSIONS
  8. LT_INIT()
  9. AC_CONFIG_MACRO_DIR([m4])
  10. AC_CANONICAL_HOST
  11. AC_CANONICAL_TARGET
  12. AM_INIT_AUTOMAKE()
  13. AM_PATH_CPPUNIT(1.10.2)
  14. AC_CONFIG_SRCDIR([src/a2io.h])
  15. AC_CONFIG_HEADERS([config.h])
  16. case "$host" in
  17. *mingw*)
  18. win_build=yes
  19. LIBS="$LIBS -lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi"
  20. ;;
  21. esac
  22. AC_DEFINE_UNQUOTED([TARGET], ["$target"], [Define target-type])
  23. # Checks for arguments.
  24. ARIA2_ARG_WITHOUT([libuv])
  25. ARIA2_ARG_WITHOUT([appletls])
  26. ARIA2_ARG_WITHOUT([gnutls])
  27. ARIA2_ARG_WITHOUT([libnettle])
  28. ARIA2_ARG_WITHOUT([libgmp])
  29. ARIA2_ARG_WITHOUT([libgcrypt])
  30. ARIA2_ARG_WITHOUT([openssl])
  31. ARIA2_ARG_WITHOUT([sqlite3])
  32. ARIA2_ARG_WITHOUT([libxml2])
  33. ARIA2_ARG_WITHOUT([libexpat])
  34. ARIA2_ARG_WITHOUT([libcares])
  35. ARIA2_ARG_WITHOUT([libz])
  36. ARIA2_ARG_DISABLE([bittorrent])
  37. ARIA2_ARG_DISABLE([metalink])
  38. ARIA2_ARG_DISABLE([epoll])
  39. AC_ARG_WITH([ca-bundle],
  40. AS_HELP_STRING([--with-ca-bundle=FILE],[Use FILE as default CA bundle.]),
  41. [ca_bundle=$withval], [ca_bundle=""])
  42. AC_ARG_WITH([bashcompletiondir],
  43. AS_HELP_STRING([--with-bashcompletiondir=DIR],
  44. [Directory to install bash_completion file]),
  45. [bashcompletiondir=$withval], [bashcompletiondir=$docdir/bash_completion])
  46. AC_ARG_VAR([ARIA2_STATIC], [Set 'yes' to build a statically linked aria2])
  47. # Checks for programs.
  48. AC_PROG_CXX
  49. AC_PROG_CC
  50. AC_PROG_INSTALL
  51. AC_PROG_MKDIR_P
  52. AC_PROG_YACC
  53. AC_CHECK_TOOL([AR], [ar], [:])
  54. if test "x$AR" = "x:"; then
  55. AC_MSG_FAILURE([ar is not found in the system.])
  56. fi
  57. AC_SUBST([AR])
  58. AC_PATH_PROG([A2X], [a2x])
  59. AC_SUBST([A2X])
  60. AM_CONDITIONAL([HAVE_A2X], [ test "x$A2X" != "x" ])
  61. AC_PATH_PROG([ASCIIDOC], [asciidoc])
  62. AC_SUBST([ASCIIDOC])
  63. AM_CONDITIONAL([HAVE_ASCIIDOC], [ test "x$ASCIIDOC" != "x" ])
  64. # Setting language choice
  65. AC_LANG([C++])
  66. # Check pkg-config is available
  67. PKG_PROG_PKG_CONFIG([0.20])
  68. # Check static build is requested
  69. if test "x$ARIA2_STATIC" = "xyes"; then
  70. case "$host" in
  71. i686*mingw*)
  72. dnl Define _USE_32BIT_TIME_T because 32bit library of MinGW-w64
  73. dnl does not implement many 64bit version functions.
  74. CPPFLAGS="-D_USE_32BIT_TIME_T $CPPFLAGS"
  75. ;;
  76. esac
  77. # Make pkg-config produce static linking variables
  78. PKG_CONFIG="$PKG_CONFIG --static"
  79. else
  80. dnl Make variable empty to avoid confusion
  81. ARIA2_STATIC=
  82. fi
  83. # Checks for libraries.
  84. # Check availability of libz
  85. if test "x$with_libz" = "xyes"; then
  86. PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3], [have_zlib=yes], [have_zlib=no])
  87. if test "x$have_zlib" = "xyes"; then
  88. AC_DEFINE([HAVE_ZLIB], [1], [Define to 1 if you have zlib.])
  89. LIBS="$ZLIB_LIBS $LIBS"
  90. CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS"
  91. AC_CHECK_FUNCS([gzbuffer gzsetparams])
  92. else
  93. AC_MSG_WARN([$ZLIB_PKG_ERRORS])
  94. if test "x$with_libz_requested" = "xyes"; then
  95. ARIA2_DEP_NOT_MET([libz])
  96. fi
  97. fi
  98. fi
  99. if test "x$with_libuv" = "xyes"; then
  100. case "$host" in
  101. *mingw*|*msvc*)
  102. old_CPPFLAGS=$CPPFLAGS
  103. CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
  104. AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [
  105. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  106. break;
  107. ], [have_libuv=no])
  108. if test "x$have_libuv" != "xyes"; then
  109. CPPFLAGS=$old_CPPFLAGS
  110. fi
  111. ;;
  112. *darwin*)
  113. old_LDFLAGS=$LDFLAGS
  114. LDFLAGS="$LDFLAGS -framework Foundation -framework CoreServices -framework ApplicationServices"
  115. old_LIBS=$LIBS
  116. LIBS="$LIBS -lm"
  117. AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [
  118. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  119. break;
  120. ], [have_libuv=no])
  121. if test "x$have_libuv" != "xyes"; then
  122. LDFLAGS=$old_LDFLAGS
  123. LIBS=$old_LIBS
  124. fi
  125. ;;
  126. *)
  127. dnl Yeah, sucks that luv does not bring a pkg-config or config-tool
  128. AC_MSG_CHECKING([for libuv])
  129. for combo in "" "-lrt" "-ldl -lrt" "-ldl -lrt -lpthread" "-lkvm"; do
  130. old_LIBS=$LIBS
  131. LIBS="-luv $combo $LIBS -lm"
  132. AC_LINK_IFELSE([AC_LANG_SOURCE([
  133. extern "C" int uv_poll_init_socket(void);
  134. int main() { return uv_poll_init_socket(); }
  135. ])], [
  136. AC_MSG_RESULT(-luv $combo -lm)
  137. AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no])
  138. break;
  139. ], [have_libuv=no])
  140. if test "x$have_libuv" = "xyes"; then
  141. break;
  142. else
  143. LIBS=$old_LIBS
  144. fi
  145. done
  146. if test "x$have_libuv" != "xyes"; then
  147. AC_MSG_RESULT("no")
  148. fi
  149. ;;
  150. esac
  151. if test "x$have_libuv" = "xyes"; then
  152. AC_DEFINE([HAVE_LIBUV], [1], [Define to 1 if you have libuv.])
  153. elif test "x$with_libuv_requested" = "xyes"; then
  154. ARIA2_DEP_NOT_MET([libuv])
  155. fi
  156. fi
  157. AM_CONDITIONAL([HAVE_LIBUV], [test "x$have_libuv" = "xyes"])
  158. if test "x$with_libxml2" = "xyes"; then
  159. AM_PATH_XML2([2.6.24], [have_libxml2=yes])
  160. if test "x$have_libxml2" = "xyes"; then
  161. AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
  162. LIBS="$XML_LIBS $LIBS"
  163. CPPFLAGS="$XML_CPPFLAGS $CPPFLAGS"
  164. elif test "x$with_libxml2_requested" = "xyes"; then
  165. ARIA2_DEP_NOT_MET([libxml2])
  166. fi
  167. fi
  168. if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
  169. AM_PATH_LIBEXPAT
  170. if test "x$have_libexpat" = "xyes"; then
  171. LIBS="$EXPAT_LIBS $LIBS"
  172. CPPFLAGS="$EXPAT_CFLAGS $CPPFLAGS"
  173. elif test "x$with_libexpat_requested" = "xyes"; then
  174. ARIA2_DEP_NOT_MET([libexpat])
  175. fi
  176. fi
  177. if test "x$with_sqlite3" = "xyes"; then
  178. PKG_CHECK_MODULES([SQLITE3],[sqlite3],[have_sqlite3=yes],[have_sqlite3=no])
  179. if test "x$have_sqlite3" = "xyes"; then
  180. AC_DEFINE([HAVE_SQLITE3], [1], [Define to 1 if you have sqlite3.])
  181. LIBS="$SQLITE3_LIBS $LIBS"
  182. CPPFLAGS="$SQLITE3_CFLAGS $CPPFLAGS"
  183. AC_CHECK_FUNCS([sqlite3_open_v2])
  184. else
  185. AC_MSG_WARN([$SQLITE3_PKG_ERRORS])
  186. if test "x$with_sqlite3_requested" = "xyes"; then
  187. ARIA2_DEP_NOT_MET([sqlite3])
  188. fi
  189. fi
  190. fi
  191. case "$host" in
  192. *darwin*)
  193. have_osx="yes"
  194. ;;
  195. esac
  196. if test "x$with_appletls" = "xyes"; then
  197. AC_MSG_CHECKING([whether to enable Mac OS X native SSL/TLS])
  198. if test "x$have_osx" = "xyes"; then
  199. AC_DEFINE([HAVE_APPLETLS], [1], [Define to 1 if you have Apple TLS])
  200. LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Security"
  201. have_appletls="yes"
  202. AC_MSG_RESULT(yes)
  203. else
  204. AC_MSG_RESULT(no)
  205. if test "x$with_appletls_requested" = "xyes"; then
  206. ARIA2_DEP_NOT_MET([appletls])
  207. fi
  208. fi
  209. fi
  210. if test "x$with_gnutls" = "xyes" && test "x$have_appletls" != "xyes"; then
  211. # gnutls >= 2.8 doesn't have libgnutls-config anymore. We require
  212. # 2.2.0 because we use gnutls_priority_set_direct()
  213. PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.2.0],
  214. [have_libgnutls=yes], [have_libgnutls=no])
  215. if test "x$have_libgnutls" = "xyes"; then
  216. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  217. LIBS="$LIBGNUTLS_LIBS $LIBS"
  218. CPPFLAGS="$LIBGNUTLS_CFLAGS $CPPFLAGS"
  219. AC_CHECK_FUNCS([gnutls_certificate_set_x509_system_trust])
  220. else
  221. AC_MSG_WARN([$LIBGNUTLS_PKG_ERRORS])
  222. if test "x$with_gnutls_requested" = "xyes"; then
  223. ARIA2_DEP_NOT_MET([gnutls])
  224. fi
  225. fi
  226. fi
  227. if test "x$with_openssl" = "xyes" && test "x$have_appletls" != "xyes" && test "x$have_libgnutls" != "xyes"; then
  228. PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],
  229. [have_openssl=yes], [have_openssl=no])
  230. if test "x$have_openssl" = "xyes"; then
  231. AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if you have openssl.])
  232. LIBS="$OPENSSL_LIBS $LIBS"
  233. CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS"
  234. AC_CHECK_FUNCS([EVP_DigestInit_ex], [have_digestinit_ex=yes])
  235. if test "x$have_digestinit_ex" = "x"; then
  236. AC_DEFINE([HAVE_OLD_OPENSSL], [1], [Define to 1 if you have old openssl.])
  237. fi
  238. AC_CHECK_FUNCS([EVP_sha224])
  239. AC_CHECK_FUNCS([EVP_sha256])
  240. AC_CHECK_FUNCS([EVP_sha384])
  241. AC_CHECK_FUNCS([EVP_sha512])
  242. else
  243. AC_MSG_WARN([$OPENSSL_PKG_ERRORS])
  244. if test "x$with_openssl_requested" = "xyes"; then
  245. ARIA2_DEP_NOT_MET([openssl])
  246. fi
  247. fi
  248. fi
  249. if test "x$have_openssl" != "xyes"; then
  250. if test "x$with_libnettle" = "xyes"; then
  251. AC_SEARCH_LIBS([nettle_sha1_init], [nettle],
  252. [have_libnettle=yes], [have_libnettle=no])
  253. if test "x$have_libnettle" = "xyes"; then
  254. AC_DEFINE([HAVE_LIBNETTLE], [1], [Define to 1 if you have libnettle.])
  255. fi
  256. fi
  257. if test "x$with_libgmp" = "xyes" &&
  258. test "x$have_libnettle" = "xyes" &&
  259. test "x$enable_bittorrent" = "xyes"; then
  260. AC_SEARCH_LIBS([__gmpz_init], [gmp], [have_libgmp=yes], [have_libgmp=no])
  261. if test "x$have_libgmp" = "xyes"; then
  262. AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have libgmp.])
  263. fi
  264. fi
  265. if test "x$with_libgcrypt" = "xyes" &&
  266. test "x$have_libnettle" != "xyes"; then
  267. AM_PATH_LIBGCRYPT([1.2.4], [have_libgcrypt=yes])
  268. if test "x$have_libgcrypt" = "xyes"; then
  269. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  270. LIBS="$LIBGCRYPT_LIBS $LIBS"
  271. CPPFLAGS="$LIBGCRYPT_CFLAGS $CPPFLAGS"
  272. fi
  273. fi
  274. fi
  275. if test "x$with_libcares" = "xyes"; then
  276. PKG_CHECK_MODULES([LIBCARES], [libcares >= 1.7.0], [have_libcares=yes],
  277. [have_libcares=no])
  278. if test "x$have_libcares" = "xyes"; then
  279. AC_DEFINE([HAVE_LIBCARES], [1], [Define to 1 if you have libcares.])
  280. LIBS="$LIBCARES_LIBS $LIBS"
  281. CPPFLAGS="$LIBCARES_CFLAGS $CPPFLAGS"
  282. AC_CHECK_TYPES([ares_addr_node], [], [], [[#include <ares.h>]])
  283. AC_CHECK_FUNCS([ares_set_servers])
  284. if test "x$ARIA2_STATIC" = "xyes"; then
  285. CPPFLAGS="-DCARES_STATICLIB $CPPFLAGS"
  286. fi
  287. else
  288. AC_MSG_WARN([$LIBCARES_PKG_ERRORS])
  289. if test "x$with_libcares_requested" = "xyes"; then
  290. ARIA2_DEP_NOT_MET([libcares])
  291. fi
  292. fi
  293. fi
  294. use_md=""
  295. if test "x$have_osx" == "xyes"; then
  296. use_md="apple"
  297. AC_DEFINE([USE_APPLE_MD], [1], [What message digest implementation to use])
  298. else
  299. if test "x$have_libnettle" = "xyes"; then
  300. AC_DEFINE([USE_LIBNETTLE_MD], [1], [What message digest implementation to use])
  301. use_md="libnettle"
  302. else
  303. if test "x$have_libgcrypt" = "xyes"; then
  304. AC_DEFINE([USE_LIBGCRYPT_MD], [1], [What message digest implementation to use])
  305. use_md="libgcrypt"
  306. else
  307. if test "x$have_openssl" = "xyes"; then
  308. AC_DEFINE([USE_OPENSSL_MD], [1], [What message digest implementation to use])
  309. use_md="openssl"
  310. fi
  311. fi
  312. fi
  313. fi
  314. # Define variables based on the result of the checks for libraries.
  315. if test "x$have_appletls" = "xyes" || test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  316. have_ssl="yes"
  317. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  318. AM_CONDITIONAL([ENABLE_SSL], true)
  319. AC_SUBST([ca_bundle])
  320. else
  321. AM_CONDITIONAL([ENABLE_SSL], false)
  322. fi
  323. AM_CONDITIONAL([HAVE_OSX], [ test "x$have_osx" = "xyes" ])
  324. AM_CONDITIONAL([HAVE_APPLETLS], [ test "x$have_appletls" = "xyes" ])
  325. AM_CONDITIONAL([USE_APPLE_MD], [ test "x$use_md" = "xapple" ])
  326. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  327. AM_CONDITIONAL([HAVE_LIBNETTLE], [ test "x$have_libnettle" = "xyes" ])
  328. AM_CONDITIONAL([USE_LIBNETTLE_MD], [ test "x$use_md" = "xlibnettle"])
  329. AM_CONDITIONAL([HAVE_LIBGMP], [ test "x$have_libgmp" = "xyes" ])
  330. AM_CONDITIONAL([HAVE_LIBGCRYPT], [ test "x$have_libgcrypt" = "xyes" ])
  331. AM_CONDITIONAL([USE_LIBGCRYPT_MD], [ test "x$use_md" = "xlibgcrypt"])
  332. AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
  333. AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
  334. if test "x$use_md" != "x"; then
  335. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
  336. [Define to 1 if message digest support is enabled.])
  337. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  338. enable_message_digest=yes
  339. else
  340. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  341. fi
  342. if test "x$have_libnettle" = "xyes" && test "x$have_libgmp" = "xyes" ||
  343. test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  344. enable_bignum=yes
  345. fi
  346. if test "x$enable_bittorrent" = "xyes" &&
  347. test "x$enable_message_digest" = "xyes" &&
  348. test "x$enable_bignum" = "xyes"; then
  349. AC_DEFINE([ENABLE_BITTORRENT], [1],
  350. [Define to 1 if BitTorrent support is enabled.])
  351. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  352. else
  353. if test "x$enable_bittorrent_requested" = "xyes"; then
  354. ARIA2_FET_NOT_SUPPORTED([bittorrent])
  355. fi
  356. enable_bittorrent=no
  357. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  358. fi
  359. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  360. test "x$enable_metalink" = "xyes"; then
  361. AC_DEFINE([ENABLE_METALINK], [1],
  362. [Define to 1 if Metalink support is enabled.])
  363. AM_CONDITIONAL([ENABLE_METALINK], true)
  364. else
  365. if test "x$enable_metalink_requested" = "xyes"; then
  366. ARIA2_FET_NOT_SUPPORTED([metalink])
  367. fi
  368. enable_metalink=no
  369. AM_CONDITIONAL([ENABLE_METALINK], false)
  370. fi
  371. AM_CONDITIONAL([HAVE_SOME_XMLLIB],
  372. [test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"])
  373. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  374. enable_xml_rpc=yes
  375. fi
  376. if test "x$enable_xml_rpc" = "xyes"; then
  377. AC_DEFINE([ENABLE_XML_RPC], [1],
  378. [Define to 1 if XML-RPC support is enabled.])
  379. fi
  380. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  381. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  382. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  383. if test "x$have_libcares" = "xyes"; then
  384. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  385. [Define to 1 if asynchronous DNS support is enabled.])
  386. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  387. else
  388. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  389. fi
  390. # Set conditional for libz
  391. AM_CONDITIONAL([HAVE_ZLIB], [test "x$have_zlib" = "xyes"])
  392. # Set conditional for sqlite3
  393. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  394. AC_SEARCH_LIBS([clock_gettime], [rt])
  395. case "$host" in
  396. *solaris*)
  397. AC_SEARCH_LIBS([getaddrinfo], [nsl socket])
  398. ;;
  399. esac
  400. # Checks for header files.
  401. AC_FUNC_ALLOCA
  402. AC_HEADER_STDC
  403. case "$host" in
  404. *mingw*)
  405. AC_CHECK_HEADERS([windows.h \
  406. winsock2.h \
  407. ws2tcpip.h \
  408. mmsystem.h \
  409. io.h \
  410. iphlpapi.h\
  411. winioctl.h \
  412. share.h], [], [],
  413. [[
  414. #ifdef HAVE_WS2TCPIP_H
  415. # include <ws2tcpip.h>
  416. #endif
  417. #ifdef HAVE_WINSOCK2_H
  418. # include <winsock2.h>
  419. #endif
  420. #ifdef HAVE_WINDOWS_H
  421. # include <windows.h>
  422. #endif
  423. ]])
  424. ;;
  425. esac
  426. AC_CHECK_HEADERS([argz.h \
  427. arpa/inet.h \
  428. fcntl.h \
  429. float.h \
  430. inttypes.h \
  431. langinfo.h \
  432. libintl.h \
  433. limits.h \
  434. locale.h \
  435. malloc.h \
  436. netdb.h \
  437. netinet/in.h \
  438. netinet/tcp.h \
  439. poll.h \
  440. port.h \
  441. signal.h \
  442. stddef.h \
  443. stdint.h \
  444. stdio_ext.h \
  445. stdlib.h \
  446. string.h \
  447. strings.h \
  448. sys/ioctl.h \
  449. sys/param.h \
  450. sys/signal.h \
  451. sys/socket.h \
  452. sys/time.h \
  453. sys/types.h \
  454. sys/uio.h \
  455. termios.h \
  456. unistd.h \
  457. utime.h \
  458. wchar.h \
  459. ifaddrs.h \
  460. pwd.h])
  461. # Checks for typedefs, structures, and compiler characteristics.
  462. AC_HEADER_STDBOOL
  463. AC_C_CONST
  464. AC_C_INLINE
  465. AC_TYPE_INT16_T
  466. AC_TYPE_INT32_T
  467. AC_TYPE_INT64_T
  468. AC_TYPE_INT8_T
  469. AC_TYPE_MODE_T
  470. AC_TYPE_OFF_T
  471. AC_TYPE_SIZE_T
  472. AC_TYPE_SSIZE_T
  473. AC_HEADER_TIME
  474. AC_STRUCT_TM
  475. AC_TYPE_UINT16_T
  476. AC_TYPE_UINT32_T
  477. AC_TYPE_UINT64_T
  478. AC_TYPE_UINT8_T
  479. AC_TYPE_PID_T
  480. AC_C_VOLATILE
  481. AC_CHECK_TYPES([ptrdiff_t, struct timespec])
  482. AC_C_BIGENDIAN
  483. AC_SYS_LARGEFILE
  484. # Checks for library functions.
  485. AM_GNU_GETTEXT
  486. AM_GNU_GETTEXT_VERSION([0.18])
  487. AC_FUNC_ERROR_AT_LINE
  488. AC_PROG_GCC_TRADITIONAL
  489. AC_FUNC_MEMCMP
  490. AC_FUNC_MKTIME
  491. AC_FUNC_SELECT_ARGTYPES
  492. AC_FUNC_STAT
  493. AC_FUNC_STRFTIME
  494. AC_FUNC_VPRINTF
  495. AC_FUNC_FORK
  496. AC_FUNC_STRTOD
  497. # Don't use AC_FUNC_MMAP becaue it fails on some platforms (e.g.,
  498. # OpenWRT) which have mmap and it works in the way we use in aria2.
  499. # Instead use mmap in AC_CHECK_FUNCS list.
  500. AC_CHECK_FUNCS([__argz_count \
  501. __argz_next \
  502. __argz_stringify \
  503. atexit \
  504. ftruncate \
  505. getcwd \
  506. gethostbyaddr \
  507. gethostbyname \
  508. getifaddrs \
  509. getpagesize \
  510. memchr \
  511. memmove \
  512. mempcpy \
  513. memset \
  514. mkdir \
  515. mmap \
  516. munmap \
  517. nl_langinfo \
  518. posix_memalign \
  519. pow \
  520. putenv \
  521. rmdir \
  522. select \
  523. setlocale \
  524. sigaction \
  525. sleep \
  526. socket \
  527. stpcpy \
  528. strcasecmp \
  529. strchr \
  530. strcspn \
  531. strdup \
  532. strerror \
  533. strncasecmp \
  534. strstr \
  535. strtol \
  536. strtoul \
  537. strtoull \
  538. tzset \
  539. unsetenv \
  540. usleep \
  541. utime \
  542. utimes])
  543. if test "x$enable_epoll" = "xyes"; then
  544. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  545. if test "x$have_epoll" = "xyes"; then
  546. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  547. fi
  548. fi
  549. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  550. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  551. ARIA2_CHECK_FALLOCATE
  552. if test "x$have_posix_fallocate" = "xyes" ||
  553. test "x$have_fallocate" = "xyes" ||
  554. test "x$win_build" = "xyes"; then
  555. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  556. [Define to 1 if *_fallocate is available.])
  557. fi
  558. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  559. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  560. || test "x$win_build" = "xyes"])
  561. AC_CHECK_FUNCS([asctime_r],
  562. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  563. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  564. AC_CHECK_FUNCS([basename],
  565. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  566. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  567. AC_CHECK_FUNCS([gai_strerror],
  568. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  569. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  570. AC_CHECK_FUNCS([getaddrinfo],
  571. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  572. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  573. AC_CHECK_FUNCS([gettimeofday],
  574. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  575. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  576. AC_CHECK_FUNCS([localtime_r],
  577. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  578. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  579. AC_CHECK_FUNCS([strptime],
  580. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  581. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  582. AC_CHECK_FUNCS([timegm],
  583. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  584. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  585. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  586. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  587. AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes])
  588. if test "x$have_clock_gettime" != "xyes"; then
  589. AC_CHECK_FUNCS([mach_absolute_time], [have_mach_absolute_time=yes])
  590. fi
  591. AM_CONDITIONAL([HAVE_MACH_ABSOLUTE_TIME],
  592. [test "x$have_mach_absolute_time" = "xyes"])
  593. AC_CHECK_FUNCS([poll], [have_poll=yes])
  594. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  595. case "$host" in
  596. *mingw*)
  597. AM_CONDITIONAL([MINGW_BUILD], true)
  598. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  599. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  600. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  601. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  602. if test "x$have_clock_gettime" != "xyes"; then
  603. AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
  604. fi
  605. ;;
  606. *)
  607. AM_CONDITIONAL([MINGW_BUILD], false)
  608. AM_CONDITIONAL([HAVE_TIMEGETTIME], false)
  609. ;;
  610. esac
  611. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  612. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  613. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  614. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  615. if test "x$have_kqueue" = "xyes"; then
  616. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  617. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  618. #include <sys/types.h>
  619. #include <sys/event.h>
  620. #include <sys/time.h>
  621. ]],
  622. [[
  623. struct kevent event;
  624. event.udata = reinterpret_cast<intptr_t>(&event);
  625. ]])],
  626. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  627. AC_MSG_RESULT([$kevent_udata_intptr_t])
  628. if test "x$kevent_udata_intptr_t" = "xyes"; then
  629. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  630. fi
  631. fi
  632. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  633. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  634. [Define to 1 if struct sockaddr_in has sin_len member.])],
  635. [],
  636. [[
  637. #include <sys/types.h>
  638. #include <sys/socket.h>
  639. #include <netinet/in.h>
  640. ]])
  641. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  642. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  643. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  644. [],
  645. [[
  646. #include <sys/types.h>
  647. #include <sys/socket.h>
  648. #include <netinet/in.h>
  649. ]])
  650. # Check struct option.name is assignable from const char*. struct
  651. # option.name in opensolaris is of type char*. In Linux, it is const
  652. # char*
  653. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  654. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  655. #include <unistd.h>
  656. #include <getopt.h>
  657. ]],
  658. [[
  659. const char* s = "const char";
  660. option op;
  661. op.name = s;
  662. ]])],
  663. [have_option_const_name=yes], [have_option_const_name=no])
  664. AC_MSG_RESULT([$have_option_const_name])
  665. if test "x$have_option_const_name" = "xyes"; then
  666. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  667. fi
  668. AC_CONFIG_SUBDIRS([deps/wslay])
  669. if test "x$enable_message_digest" = "xyes"; then
  670. enable_websocket=yes
  671. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  672. [Define 1 if WebSocket support is enabled.])
  673. LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la $LIBS"
  674. # $(top_srcdir) for `make distcheck`
  675. CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
  676. fi
  677. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  678. AC_SUBST([bashcompletiondir])
  679. case "$host" in
  680. *android*)
  681. LIBS="$LIBS -lstdc++ -lsupc++"
  682. ;;
  683. *)
  684. ;;
  685. esac
  686. if test "x$ARIA2_STATIC" = "xyes"; then
  687. LDFLAGS="$LDFLAGS -all-static -static-libgcc -static-libstdc++"
  688. dnl For non-MinGW build, we need additional libs for static build.
  689. if test "x$win_build" != "xyes"; then
  690. LIBS="$LIBS -lpthread -ldl -lrt"
  691. fi
  692. fi
  693. AC_CONFIG_FILES([Makefile
  694. src/Makefile
  695. test/Makefile
  696. po/Makefile.in
  697. intl/Makefile
  698. lib/Makefile
  699. doc/Makefile
  700. doc/manual-src/Makefile
  701. doc/manual-src/en/Makefile
  702. doc/manual-src/en/conf.py
  703. doc/manual-src/ru/Makefile
  704. doc/manual-src/ru/conf.py
  705. doc/manual-src/pt/Makefile
  706. doc/manual-src/pt/conf.py
  707. deps/Makefile])
  708. AC_OUTPUT
  709. echo " "
  710. echo "Build: $build"
  711. echo "Host: $host"
  712. echo "Target: $target"
  713. echo "Install prefix: $prefix"
  714. echo "CC: $CC"
  715. echo "CXX: $CXX"
  716. echo "CPP: $CPP"
  717. echo "CXXFLAGS: $CXXFLAGS"
  718. echo "CFLAGS: $CFLAGS"
  719. echo "CPPFLAGS: $CPPFLAGS"
  720. echo "LDFLAGS: $LDFLAGS"
  721. echo "LIBS: $LIBS"
  722. echo "DEFS: $DEFS"
  723. echo "LibUV: $have_libuv"
  724. echo "SQLite3: $have_sqlite3"
  725. echo "SSL Support: $have_ssl"
  726. echo "AppleTLS: $have_appletls"
  727. echo "GnuTLS: $have_libgnutls"
  728. echo "OpenSSL: $have_openssl"
  729. echo "CA Bundle: $ca_bundle"
  730. echo "LibXML2: $have_libxml2"
  731. echo "LibExpat: $have_libexpat"
  732. echo "LibCares: $have_libcares"
  733. echo "Zlib: $have_zlib"
  734. echo "Epoll: $have_epoll"
  735. echo "Bittorrent: $enable_bittorrent"
  736. echo "Metalink: $enable_metalink"
  737. echo "XML-RPC: $enable_xml_rpc"
  738. echo "Message Digest: $enable_message_digest"
  739. echo "WebSocket: $enable_websocket"
  740. echo "bash_completion dir: $bashcompletiondir"
  741. echo "Static build: $ARIA2_STATIC"