configure.ac 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  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.15.2],[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. [[#ifdef HAVE_WINDOWS_H
  301. # include <windows.h>
  302. #endif
  303. ]])
  304. ;;
  305. esac
  306. AC_CHECK_HEADERS([argz.h \
  307. arpa/inet.h \
  308. fcntl.h \
  309. float.h \
  310. inttypes.h \
  311. io.h \
  312. langinfo.h \
  313. libintl.h \
  314. limits.h \
  315. locale.h \
  316. malloc.h \
  317. netdb.h \
  318. netinet/in.h \
  319. netinet/tcp.h \
  320. poll.h \
  321. port.h \
  322. stddef.h \
  323. stdint.h \
  324. stdio_ext.h \
  325. stdlib.h \
  326. string.h \
  327. strings.h \
  328. sys/ioctl.h \
  329. sys/param.h \
  330. sys/socket.h \
  331. sys/time.h \
  332. sys/types.h \
  333. termios.h \
  334. unistd.h \
  335. utime.h \
  336. wchar.h \
  337. ifaddrs.h \
  338. pwd.h])
  339. # Checks for typedefs, structures, and compiler characteristics.
  340. AC_HEADER_STDBOOL
  341. AC_C_CONST
  342. AC_C_INLINE
  343. AC_TYPE_INT16_T
  344. AC_TYPE_INT32_T
  345. AC_TYPE_INT64_T
  346. AC_TYPE_INT8_T
  347. AC_TYPE_MODE_T
  348. AC_TYPE_OFF_T
  349. AC_TYPE_SIZE_T
  350. AC_TYPE_SSIZE_T
  351. AC_HEADER_TIME
  352. AC_STRUCT_TM
  353. AC_TYPE_UINT16_T
  354. AC_TYPE_UINT32_T
  355. AC_TYPE_UINT64_T
  356. AC_TYPE_UINT8_T
  357. AC_TYPE_PID_T
  358. AC_C_VOLATILE
  359. AC_CHECK_TYPES([ptrdiff_t, struct timespec])
  360. AC_C_BIGENDIAN
  361. AC_SYS_LARGEFILE
  362. # Checks for library functions.
  363. AM_GNU_GETTEXT
  364. AM_GNU_GETTEXT_VERSION([0.18])
  365. AC_FUNC_ERROR_AT_LINE
  366. AC_PROG_GCC_TRADITIONAL
  367. AC_FUNC_MEMCMP
  368. AC_FUNC_MKTIME
  369. AC_FUNC_MMAP
  370. AC_FUNC_SELECT_ARGTYPES
  371. AC_FUNC_STAT
  372. AC_FUNC_STRFTIME
  373. AC_FUNC_VPRINTF
  374. AC_FUNC_FORK
  375. AC_FUNC_STRTOD
  376. AC_CHECK_FUNCS([__argz_count \
  377. __argz_next \
  378. __argz_stringify \
  379. atexit \
  380. ftruncate \
  381. getcwd \
  382. gethostbyaddr \
  383. gethostbyname \
  384. getifaddrs \
  385. getpagesize \
  386. memchr \
  387. memmove \
  388. mempcpy \
  389. memset \
  390. mkdir \
  391. munmap \
  392. nl_langinfo \
  393. posix_memalign \
  394. pow \
  395. putenv \
  396. rmdir \
  397. select \
  398. setlocale \
  399. sleep \
  400. socket \
  401. stpcpy \
  402. strcasecmp \
  403. strchr \
  404. strcspn \
  405. strdup \
  406. strerror \
  407. strncasecmp \
  408. strstr \
  409. strtol \
  410. strtoul \
  411. strtoull \
  412. tzset \
  413. unsetenv \
  414. usleep \
  415. utime \
  416. utimes])
  417. if test "x$enable_epoll" = "xyes"; then
  418. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  419. if test "x$have_epoll" = "xyes"; then
  420. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  421. fi
  422. fi
  423. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  424. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  425. ARIA2_CHECK_FALLOCATE
  426. if test "x$have_posix_fallocate" = "xyes" ||
  427. test "x$have_fallocate" = "xyes" ||
  428. test "x$win_build" = "xyes"; then
  429. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  430. [Define to 1 if *_fallocate is available.])
  431. fi
  432. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  433. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes" \
  434. || test "x$win_build" = "xyes"])
  435. AC_CHECK_FUNCS([asctime_r],
  436. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  437. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  438. AC_CHECK_FUNCS([basename],
  439. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  440. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  441. AC_CHECK_FUNCS([gai_strerror],
  442. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  443. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  444. AC_CHECK_FUNCS([getaddrinfo],
  445. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  446. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  447. AC_CHECK_FUNCS([gettimeofday],
  448. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  449. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  450. AC_CHECK_FUNCS([localtime_r],
  451. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  452. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  453. AC_CHECK_FUNCS([strptime],
  454. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  455. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  456. AC_CHECK_FUNCS([timegm],
  457. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  458. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  459. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  460. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  461. AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes])
  462. if test "x$have_clock_gettime" != "xyes"; then
  463. AC_CHECK_FUNCS([mach_absolute_time], [have_mach_absolute_time=yes])
  464. fi
  465. AM_CONDITIONAL([HAVE_MACH_ABSOLUTE_TIME],
  466. [test "x$have_mach_absolute_time" = "xyes"])
  467. AC_CHECK_FUNCS([poll], [have_poll=yes])
  468. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  469. case "$host" in
  470. *mingw*)
  471. AM_CONDITIONAL([MINGW_BUILD], true)
  472. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  473. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  474. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  475. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  476. if test "x$have_clock_gettime" != "xyes"; then
  477. AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
  478. fi
  479. ;;
  480. *)
  481. AM_CONDITIONAL([MINGW_BUILD], false)
  482. AM_CONDITIONAL([HAVE_TIMEGETTIME], false)
  483. ;;
  484. esac
  485. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  486. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  487. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  488. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  489. if test "x$have_kqueue" = "xyes"; then
  490. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  491. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  492. #include <sys/types.h>
  493. #include <sys/event.h>
  494. #include <sys/time.h>
  495. ]],
  496. [[
  497. struct kevent event;
  498. event.udata = reinterpret_cast<intptr_t>(&event);
  499. ]])],
  500. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  501. AC_MSG_RESULT([$kevent_udata_intptr_t])
  502. if test "x$kevent_udata_intptr_t" = "xyes"; then
  503. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  504. fi
  505. fi
  506. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  507. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  508. [Define to 1 if struct sockaddr_in has sin_len member.])],
  509. [],
  510. [[
  511. #include <sys/types.h>
  512. #include <sys/socket.h>
  513. #include <netinet/in.h>
  514. ]])
  515. AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
  516. [AC_DEFINE([HAVE_SOCKADDR_IN6_SIN6_LEN],[1],
  517. [Define to 1 if struct sockaddr_in6 has sin6_len member.])],
  518. [],
  519. [[
  520. #include <sys/types.h>
  521. #include <sys/socket.h>
  522. #include <netinet/in.h>
  523. ]])
  524. # Check struct option.name is assignable from const char*. struct
  525. # option.name in opensolaris is of type char*. In Linux, it is const
  526. # char*
  527. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  528. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  529. #include <unistd.h>
  530. #include <getopt.h>
  531. ]],
  532. [[
  533. const char* s = "const char";
  534. option op;
  535. op.name = s;
  536. ]])],
  537. [have_option_const_name=yes], [have_option_const_name=no])
  538. AC_MSG_RESULT([$have_option_const_name])
  539. if test "x$have_option_const_name" = "xyes"; then
  540. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  541. fi
  542. AC_CONFIG_SUBDIRS([deps/wslay])
  543. if test "x$enable_message_digest" = "xyes"; then
  544. enable_websocket=yes
  545. AC_DEFINE([ENABLE_WEBSOCKET], [1],
  546. [Define 1 if WebSocket support is enabled.])
  547. LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la $LIBS"
  548. # $(top_srcdir) for `make distcheck`
  549. CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
  550. fi
  551. AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
  552. AC_SUBST([bashcompletiondir])
  553. case "$host" in
  554. *android*)
  555. LIBS="$LIBS -lstdc++ -lsupc++"
  556. ;;
  557. *)
  558. ;;
  559. esac
  560. if test "x$ARIA2_STATIC" = "xyes"; then
  561. LDFLAGS="$LDFLAGS -all-static -static-libgcc -static-libstdc++"
  562. dnl For non-MinGW build, we need additional libs for static build.
  563. if test "x$win_build" != "xyes"; then
  564. LIBS="$LIBS -lpthread -ldl -lrt"
  565. fi
  566. fi
  567. AC_CONFIG_FILES([Makefile
  568. src/Makefile
  569. test/Makefile
  570. po/Makefile.in
  571. intl/Makefile
  572. lib/Makefile
  573. doc/Makefile
  574. doc/manual-src/Makefile
  575. doc/manual-src/en/Makefile
  576. doc/manual-src/en/conf.py
  577. doc/manual-src/ru/Makefile
  578. doc/manual-src/ru/conf.py
  579. deps/Makefile])
  580. AC_OUTPUT
  581. echo " "
  582. echo "Build: $build"
  583. echo "Host: $host"
  584. echo "Target: $target"
  585. echo "Install prefix: $prefix"
  586. echo "CXXFLAGS: $CXXFLAGS"
  587. echo "CFLAGS: $CFLAGS"
  588. echo "CPPFLAGS: $CPPFLAGS"
  589. echo "LDFLAGS: $LDFLAGS"
  590. echo "LIBS: $LIBS"
  591. echo "DEFS: $DEFS"
  592. echo "SQLite3: $have_sqlite3"
  593. echo "GnuTLS: $have_libgnutls"
  594. echo "OpenSSL: $have_openssl"
  595. echo "CA Bundle: $ca_bundle"
  596. echo "LibXML2: $have_libxml2"
  597. echo "LibExpat: $have_libexpat"
  598. echo "LibCares: $have_libcares"
  599. echo "Zlib: $have_zlib"
  600. echo "Epoll: $have_epoll"
  601. echo "Bittorrent: $enable_bittorrent"
  602. echo "Metalink: $enable_metalink"
  603. echo "XML-RPC: $enable_xml_rpc"
  604. echo "Message Digest: $enable_message_digest"
  605. echo "WebSocket: $enable_websocket"
  606. echo "bash_completion dir: $bashcompletiondir"
  607. echo "Static build: $ARIA2_STATIC"