configure.ac 20 KB

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