configure.ac 24 KB

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