configure.ac 22 KB

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