configure.ac 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ(2.61)
  5. AC_INIT(aria2c, 0.15.0dev, 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. AC_ARG_WITH([gnutls], [ --with-gnutls use gnutls library if installed. Default: yes], [with_gnutls=$withval], [with_gnutls=yes])
  24. AC_ARG_WITH([openssl], [ --with-openssl use openssl library if installed. Default: yes], [with_openssl=$withval], [with_openssl=yes])
  25. AC_ARG_WITH([libxml2], [ --with-libxml2 use libxml2 library if installed. Default: yes], [with_libxml2=$withval], [with_libxml2=yes])
  26. AC_ARG_WITH([libexpat], [ --with-libexpat use libexpat library if installed. Default: yes], [with_libexpat=$withval], [with_libexpat=yes])
  27. AC_ARG_WITH([libares], [ --with-libares use ares library if installed. Default: yes], [with_libares=$withval], [with_libares=yes])
  28. AC_ARG_WITH([libcares], [ --with-libcares use c-ares library if installed. Default: yes], [with_libcares=$withval], [with_libcares=yes])
  29. ARIA2_ARG_WITH([libz])
  30. AC_ARG_ENABLE([bittorrent], [ --enable-bittorrent enable BitTorrent support. Default: yes], [enable_bittorrent=$enableval], [enable_bittorrent=yes])
  31. AC_ARG_ENABLE([metalink], [ --enable-metalink enable Metalink support. Default: yes], [enable_metalink=$enableval], [enable_metalink=yes])
  32. AC_ARG_ENABLE([epoll], [ --enable-epoll enable epoll support. Default: yes], [enable_epoll=$enableval], [enable_epoll=yes])
  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_gnutls" = "xyes"; then
  57. AM_PATH_LIBGNUTLS([1.2.9], [have_libgnutls=yes])
  58. if test "x$have_libgnutls" = "xyes"; then
  59. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  60. fi
  61. fi
  62. if test "x$have_libgnutls" = "xyes"; then
  63. AM_PATH_LIBGCRYPT([1.2.2], [have_libgcrypt=yes])
  64. if test "x$have_libgcrypt" = "xyes"; then
  65. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  66. fi
  67. fi
  68. if test "x$with_openssl" = "xyes" && test "x$have_libgnutls" != "xyes"; then
  69. AM_PATH_OPENSSL
  70. fi
  71. if test "x$with_libcares" = "xyes"; then
  72. AM_PATH_LIBCARES
  73. fi
  74. if test "x$have_libcares" = "x"; then
  75. if test "x$with_libares" = "xyes"; then
  76. AM_PATH_LIBARES
  77. fi
  78. fi
  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. fi
  86. if test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  87. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1], [Define to 1 if message digest support is enabled.])
  88. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  89. enable_message_digest=yes
  90. else
  91. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  92. fi
  93. if test "x$enable_bittorrent" = "xyes" && test "x$enable_message_digest" = "xyes"; then
  94. AC_DEFINE([ENABLE_BITTORRENT], [1], [Define to 1 if BitTorrent support is enabled.])
  95. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  96. else
  97. enable_bittorrent=no
  98. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  99. fi
  100. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") && test "x$enable_metalink" = "xyes"; then
  101. AC_DEFINE([ENABLE_METALINK], [1], [Define to 1 if Metalink support is enabled.])
  102. AM_CONDITIONAL([ENABLE_METALINK], true)
  103. else
  104. enable_metalink=no
  105. AM_CONDITIONAL([ENABLE_METALINK], false)
  106. fi
  107. AM_CONDITIONAL([ENABLE_LIBXML2], [test "x$enable_metalink" = "xyes" && test "x$have_libxml2" = "xyes"])
  108. AM_CONDITIONAL([ENABLE_LIBEXPAT], [test "x$enable_metalink" = "xyes" && test "x$have_libexpat" = "xyes"])
  109. if test "x$have_libcares" = "xyes" || test "x$have_libares" = "xyes"; then
  110. AC_DEFINE([ENABLE_ASYNC_DNS], [1], [Define to 1 if asynchronous DNS support is enabled.])
  111. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  112. else
  113. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  114. fi
  115. AM_CONDITIONAL([HAVE_LIBZ], [test "x$have_libz" = "xyes"])
  116. # Checks for header files.
  117. AC_FUNC_ALLOCA
  118. AC_HEADER_STDC
  119. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h argz.h arpa/inet.h fcntl.h float.h inttypes.h io.h langinfo.h libintl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h termios.h unistd.h wchar.h])
  120. # Checks for typedefs, structures, and compiler characteristics.
  121. AC_HEADER_STDBOOL
  122. AC_C_CONST
  123. AC_C_INLINE
  124. AC_TYPE_INT16_T
  125. AC_TYPE_INT32_T
  126. AC_TYPE_INT64_T
  127. AC_TYPE_INT8_T
  128. AC_TYPE_MODE_T
  129. AC_TYPE_OFF_T
  130. AC_TYPE_SIZE_T
  131. AC_TYPE_SSIZE_T
  132. AC_HEADER_TIME
  133. AC_STRUCT_TM
  134. AC_TYPE_UINT16_T
  135. AC_TYPE_UINT32_T
  136. AC_TYPE_UINT64_T
  137. AC_TYPE_UINT8_T
  138. AC_C_VOLATILE
  139. AC_CHECK_TYPES([ptrdiff_t])
  140. AC_SYS_LARGEFILE
  141. # Checks for library functions.
  142. AM_GNU_GETTEXT
  143. AM_GNU_GETTEXT_VERSION([0.17])
  144. AC_FUNC_ERROR_AT_LINE
  145. AC_PROG_GCC_TRADITIONAL
  146. case "$target" in
  147. *mingw*)
  148. ;;
  149. *)
  150. AC_FUNC_MALLOC
  151. AC_FUNC_REALLOC
  152. ;;
  153. esac
  154. AC_FUNC_MEMCMP
  155. AC_FUNC_MKTIME
  156. AC_FUNC_MMAP
  157. AC_FUNC_SELECT_ARGTYPES
  158. AC_TYPE_SIGNAL
  159. AC_FUNC_STAT
  160. AC_FUNC_STRFTIME
  161. AC_FUNC_VPRINTF
  162. AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify atexit daemon ftruncate getcwd gethostbyaddr gethostbyname getpagesize inet_ntoa memchr memmove mempcpy memset mkdir munmap nl_langinfo posix_memalign putenv rmdir select setlocale sleep socket stpcpy strcasecmp strchr strcspn strdup strerror strncasecmp strstr strtol strtoul strtoull tzset unsetenv usleep])
  163. if test "x$enable_epoll" = "xyes"; then
  164. AC_CHECK_FUNCS([epoll_create])
  165. fi
  166. AC_CHECK_FUNCS([asctime_r],
  167. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  168. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  169. AC_CHECK_FUNCS([basename],
  170. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  171. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  172. AC_CHECK_FUNCS([gai_strerror],
  173. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  174. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  175. AC_CHECK_FUNCS([getaddrinfo],
  176. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  177. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  178. AC_CHECK_FUNCS([gettimeofday],
  179. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  180. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  181. AC_CHECK_FUNCS([inet_aton],
  182. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  183. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  184. AC_CHECK_FUNCS([localtime_r],
  185. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  186. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  187. AC_CHECK_FUNCS([strptime],
  188. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  189. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  190. AC_CHECK_FUNCS([timegm],
  191. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  192. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  193. case "$target" in
  194. *mingw*)
  195. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  196. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  197. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  198. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  199. ;;
  200. esac
  201. AC_CONFIG_FILES([Makefile
  202. src/Makefile
  203. test/Makefile
  204. po/Makefile.in
  205. m4/Makefile
  206. intl/Makefile
  207. lib/Makefile
  208. doc/Makefile])
  209. AC_OUTPUT
  210. echo " "
  211. echo "Build: $build"
  212. echo "Target: $target"
  213. echo "Install prefix: $prefix"
  214. echo "CFLAGS: $CFLAGS"
  215. echo "CPPFLAGS: $CPPFLAGS"
  216. echo "LDFLAGS: $LDFLAGS"
  217. echo "LIBS: $LIBS"
  218. echo "GnuTLS: $have_libgnutls"
  219. echo "OpenSSL: $have_openssl"
  220. echo "LibXML2: $have_libxml2"
  221. echo "LibExpat: $have_libexpat"
  222. echo "LibAres: $have_libares"
  223. echo "LibCares: $have_libcares"
  224. echo "Libz: $have_libz"
  225. echo "Bittorrent: $enable_bittorrent"
  226. echo "Metalink: $enable_metalink"