configure.ac 23 KB

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