configure.ac 24 KB

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