configure.ac 11 KB

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