configure.ac 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ(2.61)
  5. AC_INIT(aria2, 1.3.3, t-tujikawa@users.sourceforge.net)
  6. AC_CANONICAL_HOST
  7. AC_CANONICAL_SYSTEM
  8. AM_INIT_AUTOMAKE()
  9. AM_PATH_CPPUNIT(1.10.2)
  10. AC_CONFIG_SRCDIR([src/Socket.h])
  11. AC_CONFIG_HEADERS([config.h])
  12. case "$target" in
  13. *mingw*|*cygwin*)
  14. WINSOCK_LIBS="-lws2_32 -lpthread"
  15. AC_SUBST(WINSOCK_LIBS)
  16. ;;
  17. esac
  18. AC_DEFINE_UNQUOTED([TARGET], ["$target"], [Define target-type])
  19. # Set localedir
  20. localedir=${datadir}/locale
  21. AC_SUBST(localedir)
  22. # Checks for arguments.
  23. ARIA2_ARG_WITH([gnutls])
  24. ARIA2_ARG_WITH([openssl])
  25. ARIA2_ARG_WITH([sqlite3])
  26. ARIA2_ARG_WITH([libxml2])
  27. ARIA2_ARG_WITH([libexpat])
  28. ARIA2_ARG_WITH([libcares])
  29. ARIA2_ARG_WITH([libz])
  30. ARIA2_ARG_ENABLE([bittorrent])
  31. ARIA2_ARG_ENABLE([metalink])
  32. ARIA2_ARG_ENABLE([epoll])
  33. AC_ARG_WITH([ca-bundle],
  34. AC_HELP_STRING([--with-ca-bundle=FILE], [Use FILE as default CA bundle.]),
  35. [ca_bundle=$withval], [ca_bundle=""])
  36. # Checks for programs.
  37. AC_PROG_CXX
  38. AC_PROG_CC
  39. AC_PROG_INSTALL
  40. AC_PROG_MKDIR_P
  41. AC_PROG_RANLIB
  42. AC_PROG_YACC
  43. # Setting language choice
  44. AC_LANG([C++])
  45. # Enable system extensions
  46. AC_USE_SYSTEM_EXTENSIONS
  47. # Checks for libraries.
  48. if test "x$with_libxml2" = "xyes"; then
  49. AM_PATH_XML2([2.6.24], [have_libxml2=yes])
  50. if test "x$have_libxml2" = "xyes"; then
  51. AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
  52. fi
  53. fi
  54. if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
  55. AM_PATH_LIBEXPAT
  56. fi
  57. if test "x$with_sqlite3" = "xyes"; then
  58. AM_PATH_SQLITE3
  59. fi
  60. if test "x$with_gnutls" = "xyes"; then
  61. AM_PATH_LIBGNUTLS([1.2.9], [have_libgnutls=yes])
  62. if test "x$have_libgnutls" = "xyes"; then
  63. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  64. fi
  65. fi
  66. if test "x$have_libgnutls" = "xyes"; then
  67. AM_PATH_LIBGCRYPT([1.2.2], [have_libgcrypt=yes])
  68. if test "x$have_libgcrypt" = "xyes"; then
  69. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  70. fi
  71. fi
  72. if test "x$with_openssl" = "xyes" && test "x$have_libgnutls" != "xyes"; then
  73. AM_PATH_OPENSSL
  74. fi
  75. if test "x$with_libcares" = "xyes"; then
  76. AM_PATH_LIBCARES
  77. fi
  78. # Check availability of libz
  79. if test "x$with_libz" = "xyes"; then
  80. AM_PATH_LIBZ
  81. fi
  82. # Define variables based on the result of the checks for libraries.
  83. if test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  84. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  85. AM_CONDITIONAL([ENABLE_SSL], true)
  86. AC_SUBST([ca_bundle])
  87. else
  88. AM_CONDITIONAL([ENABLE_SSL], false)
  89. fi
  90. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  91. AM_CONDITIONAL([HAVE_LIBSSL], [ test "x$have_openssl" = "xyes" ])
  92. if test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  93. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
  94. [Define to 1 if message digest support is enabled.])
  95. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  96. enable_message_digest=yes
  97. else
  98. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  99. fi
  100. if test "x$enable_bittorrent" = "xyes" &&
  101. test "x$enable_message_digest" = "xyes"; then
  102. AC_DEFINE([ENABLE_BITTORRENT], [1],
  103. [Define to 1 if BitTorrent support is enabled.])
  104. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  105. else
  106. enable_bittorrent=no
  107. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  108. fi
  109. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  110. test "x$enable_metalink" = "xyes"; then
  111. AC_DEFINE([ENABLE_METALINK], [1],
  112. [Define to 1 if Metalink support is enabled.])
  113. AM_CONDITIONAL([ENABLE_METALINK], true)
  114. else
  115. enable_metalink=no
  116. AM_CONDITIONAL([ENABLE_METALINK], false)
  117. fi
  118. AM_CONDITIONAL([ENABLE_METALINK_LIBXML2],
  119. [test "x$enable_metalink" = "xyes" && test "x$have_libxml2" = "xyes"])
  120. AM_CONDITIONAL([ENABLE_METALINK_LIBEXPAT],
  121. [test "x$enable_metalink" = "xyes" && test "x$have_libexpat" = "xyes"])
  122. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  123. enable_xml_rpc=yes
  124. fi
  125. if test "x$enable_xml_rpc" = "xyes"; then
  126. AC_DEFINE([ENABLE_XML_RPC], [1],
  127. [Define to 1 if XML-RPC support is enabled.])
  128. fi
  129. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  130. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  131. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  132. if test "x$have_libcares" = "xyes"; then
  133. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  134. [Define to 1 if asynchronous DNS support is enabled.])
  135. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  136. else
  137. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  138. fi
  139. # Set conditional for libz
  140. AM_CONDITIONAL([HAVE_LIBZ], [test "x$have_libz" = "xyes"])
  141. # Set conditional for sqlite3
  142. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  143. # Checks for header files.
  144. AC_FUNC_ALLOCA
  145. AC_HEADER_STDC
  146. case "$target" in
  147. *mingw*)
  148. AC_CHECK_HEADERS([winsock2.h \
  149. ws2tcpip.h])
  150. ;;
  151. esac
  152. AC_CHECK_HEADERS([argz.h \
  153. arpa/inet.h \
  154. fcntl.h \
  155. float.h \
  156. inttypes.h \
  157. io.h \
  158. langinfo.h \
  159. libintl.h \
  160. limits.h \
  161. locale.h \
  162. malloc.h \
  163. netdb.h \
  164. netinet/in.h \
  165. stddef.h \
  166. stdint.h \
  167. stdio_ext.h \
  168. stdlib.h \
  169. string.h \
  170. strings.h \
  171. sys/ioctl.h \
  172. sys/param.h \
  173. sys/socket.h \
  174. sys/time.h \
  175. termios.h \
  176. unistd.h \
  177. wchar.h])
  178. # Checks for typedefs, structures, and compiler characteristics.
  179. AC_HEADER_STDBOOL
  180. AC_C_CONST
  181. AC_C_INLINE
  182. AC_TYPE_INT16_T
  183. AC_TYPE_INT32_T
  184. AC_TYPE_INT64_T
  185. AC_TYPE_INT8_T
  186. AC_TYPE_MODE_T
  187. AC_TYPE_OFF_T
  188. AC_TYPE_SIZE_T
  189. AC_TYPE_SSIZE_T
  190. AC_HEADER_TIME
  191. AC_STRUCT_TM
  192. AC_TYPE_UINT16_T
  193. AC_TYPE_UINT32_T
  194. AC_TYPE_UINT64_T
  195. AC_TYPE_UINT8_T
  196. AC_C_VOLATILE
  197. AC_CHECK_TYPES([ptrdiff_t])
  198. AC_C_BIGENDIAN
  199. AC_SYS_LARGEFILE
  200. # Checks for library functions.
  201. AM_GNU_GETTEXT
  202. AM_GNU_GETTEXT_VERSION([0.17])
  203. AC_FUNC_ERROR_AT_LINE
  204. AC_PROG_GCC_TRADITIONAL
  205. AC_FUNC_MEMCMP
  206. AC_FUNC_MKTIME
  207. AC_FUNC_MMAP
  208. AC_FUNC_SELECT_ARGTYPES
  209. AC_TYPE_SIGNAL
  210. AC_FUNC_STAT
  211. AC_FUNC_STRFTIME
  212. AC_FUNC_VPRINTF
  213. AC_CHECK_FUNCS([__argz_count \
  214. __argz_next \
  215. __argz_stringify \
  216. atexit \
  217. daemon \
  218. ftruncate \
  219. getcwd \
  220. gethostbyaddr \
  221. gethostbyname \
  222. getpagesize \
  223. inet_ntoa \
  224. memchr \
  225. memmove \
  226. mempcpy \
  227. memset \
  228. mkdir \
  229. munmap \
  230. nl_langinfo \
  231. posix_memalign \
  232. putenv \
  233. rmdir \
  234. select \
  235. setlocale \
  236. sleep \
  237. socket \
  238. stpcpy \
  239. strcasecmp \
  240. strchr \
  241. strcspn \
  242. strdup \
  243. strerror \
  244. strncasecmp \
  245. strstr \
  246. strtol \
  247. strtoul \
  248. strtoull \
  249. tzset \
  250. unsetenv \
  251. usleep])
  252. if test "x$enable_epoll" = "xyes"; then
  253. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  254. if test "x$have_epoll" = "xyes"; then
  255. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  256. fi
  257. fi
  258. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  259. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  260. AM_CONDITIONAL([HAVE_POSIX_FALLOCATE], [test "x$have_posix_fallocate" = "xyes"])
  261. AC_CHECK_FUNCS([asctime_r],
  262. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  263. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  264. AC_CHECK_FUNCS([basename],
  265. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  266. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  267. AC_CHECK_FUNCS([gai_strerror],
  268. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  269. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  270. AC_CHECK_FUNCS([getaddrinfo],
  271. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  272. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  273. AC_CHECK_FUNCS([gettimeofday],
  274. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  275. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  276. AC_CHECK_FUNCS([inet_aton],
  277. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  278. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  279. AC_CHECK_FUNCS([localtime_r],
  280. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  281. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  282. AC_CHECK_FUNCS([strptime],
  283. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  284. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  285. AC_CHECK_FUNCS([timegm],
  286. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  287. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  288. case "$target" in
  289. *mingw*)
  290. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  291. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  292. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  293. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  294. ;;
  295. esac
  296. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  297. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  298. [Define to 1 if struct sockaddr_in has sin_len member.])],
  299. [],
  300. [[#include <netinet/in.h>]])
  301. AC_CONFIG_FILES([Makefile
  302. src/Makefile
  303. test/Makefile
  304. po/Makefile.in
  305. m4/Makefile
  306. intl/Makefile
  307. lib/Makefile
  308. doc/Makefile])
  309. AC_OUTPUT
  310. echo " "
  311. echo "Build: $build"
  312. echo "Target: $target"
  313. echo "Install prefix: $prefix"
  314. echo "CFLAGS: $CFLAGS"
  315. echo "CPPFLAGS: $CPPFLAGS"
  316. echo "LDFLAGS: $LDFLAGS"
  317. echo "LIBS: $LIBS"
  318. echo "SQLite3: $have_sqlite3"
  319. echo "GnuTLS: $have_libgnutls"
  320. echo "OpenSSL: $have_openssl"
  321. echo "CA Bundle: $ca_bundle"
  322. echo "LibXML2: $have_libxml2"
  323. echo "LibExpat: $have_libexpat"
  324. echo "LibCares: $have_libcares"
  325. echo "Libz: $have_libz"
  326. echo "Epoll: $have_epoll"
  327. echo "Bittorrent: $enable_bittorrent"
  328. echo "Metalink: $enable_metalink"
  329. echo "XML-RPC: $enable_xml_rpc"