configure.ac 9.6 KB

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