configure.ac 22 KB

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