configure.ac 20 KB

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