configure.ac 11 KB

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