configure.ac 8.9 KB

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