configure.ac 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ(2.59)
  5. AC_INIT(aria2c, 0.12.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"
  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. AC_ARG_ENABLE([bittorrent], [ --enable-bittorrent enable BitTorrent support. Default: yes], [enable_bittorrent=$enableval], [enable_bittorrent=yes])
  30. AC_ARG_ENABLE([metalink], [ --enable-metalink enable Metalink support. Default: yes], [enable_metalink=$enableval], [enable_metalink=yes])
  31. # Checks for programs.
  32. AC_PROG_CXX
  33. AC_PROG_CC
  34. AC_PROG_INSTALL
  35. AC_PROG_RANLIB
  36. AC_PROG_YACC
  37. # Setting language choice
  38. AC_LANG([C++])
  39. # Check for GNU library
  40. AC_GNU_SOURCE
  41. # Enable system extensions
  42. AC_USE_SYSTEM_EXTENSIONS
  43. # Checks for libraries.
  44. if test "x$with_libxml2" = "xyes"; then
  45. AM_PATH_XML2([2.6.24], [have_libxml2=yes])
  46. if test "x$have_libxml2" = "xyes"; then
  47. AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
  48. fi
  49. fi
  50. if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
  51. AM_PATH_LIBEXPAT
  52. fi
  53. if test "x$with_gnutls" = "xyes"; then
  54. AM_PATH_LIBGNUTLS([1.2.9], [have_libgnutls=yes])
  55. if test "x$have_libgnutls" = "xyes"; then
  56. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  57. fi
  58. fi
  59. if test "x$have_libgnutls" = "xyes"; then
  60. AM_PATH_LIBGCRYPT([1.2.2], [have_libgcrypt=yes])
  61. if test "x$have_libgcrypt" = "xyes"; then
  62. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  63. fi
  64. fi
  65. if test "x$with_openssl" = "xyes" && test "x$have_libgnutls" != "xyes"; then
  66. AM_PATH_OPENSSL
  67. fi
  68. if test "x$with_libcares" = "xyes"; then
  69. AM_PATH_LIBCARES
  70. fi
  71. if test "x$have_libcares" = "x"; then
  72. if test "x$with_libares" = "xyes"; then
  73. AM_PATH_LIBARES
  74. fi
  75. fi
  76. # Define variables based on the result of the checks for libraries.
  77. if test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  78. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  79. fi
  80. if test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  81. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1], [Define to 1 if message digest support is enabled.])
  82. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  83. enable_message_digest=yes
  84. else
  85. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  86. fi
  87. if test "x$enable_bittorrent" = "xyes" && test "x$enable_message_digest" = "xyes"; then
  88. AC_DEFINE([ENABLE_BITTORRENT], [1], [Define to 1 if BitTorrent support is enabled.])
  89. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  90. else
  91. enable_bittorrent=no
  92. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  93. fi
  94. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") && test "x$enable_metalink" = "xyes"; then
  95. AC_DEFINE([ENABLE_METALINK], [1], [Define to 1 if Metalink support is enabled.])
  96. AM_CONDITIONAL([ENABLE_METALINK], true)
  97. else
  98. enable_metalink=no
  99. AM_CONDITIONAL([ENABLE_METALINK], false)
  100. fi
  101. AM_CONDITIONAL([ENABLE_LIBXML2], [test "x$enable_metalink" = "xyes" && test "x$have_libxml2" = "xyes"])
  102. AM_CONDITIONAL([ENABLE_LIBEXPAT], [test "x$enable_metalink" = "xyes" && test "x$have_libexpat" = "xyes"])
  103. if test "x$have_libcares" = "xyes" || test "x$have_libares" = "xyes"; then
  104. AC_DEFINE([ENABLE_ASYNC_DNS], [1], [Define to 1 if asynchronous DNS support is enabled.])
  105. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  106. else
  107. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  108. fi
  109. # Checks for header files.
  110. AC_FUNC_ALLOCA
  111. #AC_HEADER_STDC
  112. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h argz.h arpa/inet.h fcntl.h inttypes.h io.h langinfo.h libgen.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/param.h sys/socket.h sys/time.h unistd.h])
  113. # Checks for typedefs, structures, and compiler characteristics.
  114. AC_HEADER_STDBOOL
  115. AC_C_CONST
  116. AC_C_INLINE
  117. AC_TYPE_SIZE_T
  118. AC_HEADER_TIME
  119. AC_STRUCT_TM
  120. AC_C_VOLATILE
  121. # Checks for library functions.
  122. AM_GNU_GETTEXT
  123. AM_GNU_GETTEXT_VERSION([0.17])
  124. AC_FUNC_ERROR_AT_LINE
  125. case "$target" in
  126. *mingw*)
  127. ;;
  128. *)
  129. AC_FUNC_MALLOC
  130. AC_FUNC_REALLOC
  131. ;;
  132. esac
  133. AC_FUNC_MEMCMP
  134. AC_FUNC_MMAP
  135. AC_FUNC_SELECT_ARGTYPES
  136. AC_FUNC_STAT
  137. AC_FUNC_VPRINTF
  138. AC_CHECK_FUNCS([__argz_count __argz_next __argz_stringify daemon ftruncate getcwd getpagesize inet_ntoa memchr mempcpy memset mkdir munmap nl_langinfo posix_memalign random rmdir select setlocale sigaction sleep socket srandom stpcpy strcasecmp strchr strcspn strdup strerror strstr strtol strtoul unsetenv usleep])
  139. AC_CHECK_FUNCS([basename],
  140. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  141. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  142. AC_CHECK_FUNCS([gai_strerror],
  143. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  144. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  145. AC_CHECK_FUNCS([getaddrinfo],
  146. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  147. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  148. AC_CHECK_FUNCS([gettimeofday],
  149. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  150. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  151. AC_CHECK_FUNCS([inet_aton],
  152. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  153. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  154. AC_CHECK_FUNCS([localtime_r],
  155. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  156. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  157. AC_CHECK_FUNCS([strptime],
  158. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  159. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  160. AC_CHECK_FUNCS([timegm],
  161. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  162. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  163. case "$target" in
  164. *mingw*)
  165. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  166. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  167. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  168. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  169. ;;
  170. esac
  171. AC_CONFIG_FILES([Makefile
  172. src/Makefile
  173. test/Makefile
  174. po/Makefile.in
  175. m4/Makefile
  176. intl/Makefile
  177. doc/Makefile])
  178. AC_OUTPUT
  179. echo " "
  180. echo "Build: $build"
  181. echo "Target: $target"
  182. echo "Install prefix: $prefix"
  183. echo "CFLAGS: $CFLAGS"
  184. echo "CPPFLAGS: $CPPFLAGS"
  185. echo "LDFLAGS: $LDFLAGS"
  186. echo "LIBS: $LIBS"
  187. echo "GnuTLS: $have_libgnutls"
  188. echo "OpenSSL: $have_openssl"
  189. echo "LibXML2: $have_libxml2"
  190. echo "LibExpat: $have_libexpat"
  191. echo "LibAres: $have_libares"
  192. echo "LibCares: $have_libcares"
  193. echo "Bittorrent: $enable_bittorrent"
  194. echo "Metalink: $enable_metalink"