configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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.2],[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. utime.h \
  186. wchar.h])
  187. # Checks for typedefs, structures, and compiler characteristics.
  188. AC_HEADER_STDBOOL
  189. AC_C_CONST
  190. AC_C_INLINE
  191. AC_TYPE_INT16_T
  192. AC_TYPE_INT32_T
  193. AC_TYPE_INT64_T
  194. AC_TYPE_INT8_T
  195. AC_TYPE_MODE_T
  196. AC_TYPE_OFF_T
  197. AC_TYPE_SIZE_T
  198. AC_TYPE_SSIZE_T
  199. AC_HEADER_TIME
  200. AC_STRUCT_TM
  201. AC_TYPE_UINT16_T
  202. AC_TYPE_UINT32_T
  203. AC_TYPE_UINT64_T
  204. AC_TYPE_UINT8_T
  205. AC_TYPE_PID_T
  206. AC_C_VOLATILE
  207. AC_CHECK_TYPES([ptrdiff_t])
  208. AC_C_BIGENDIAN
  209. AC_SYS_LARGEFILE
  210. # Checks for library functions.
  211. AM_GNU_GETTEXT
  212. AM_GNU_GETTEXT_VERSION([0.17])
  213. AC_FUNC_ERROR_AT_LINE
  214. AC_PROG_GCC_TRADITIONAL
  215. AC_FUNC_MEMCMP
  216. AC_FUNC_MKTIME
  217. AC_FUNC_MMAP
  218. AC_FUNC_SELECT_ARGTYPES
  219. AC_FUNC_STAT
  220. AC_FUNC_STRFTIME
  221. AC_FUNC_VPRINTF
  222. AC_FUNC_FORK
  223. AC_FUNC_STRTOD
  224. AC_CHECK_FUNCS([__argz_count \
  225. __argz_next \
  226. __argz_stringify \
  227. atexit \
  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. pow \
  243. putenv \
  244. rmdir \
  245. select \
  246. setlocale \
  247. sleep \
  248. socket \
  249. stpcpy \
  250. strcasecmp \
  251. strchr \
  252. strcspn \
  253. strdup \
  254. strerror \
  255. strncasecmp \
  256. strstr \
  257. strtol \
  258. strtoul \
  259. strtoull \
  260. tzset \
  261. unsetenv \
  262. usleep \
  263. utime])
  264. if test "x$enable_epoll" = "xyes"; then
  265. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  266. if test "x$have_epoll" = "xyes"; then
  267. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  268. fi
  269. fi
  270. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  271. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  272. AM_CONDITIONAL([HAVE_POSIX_FALLOCATE], [test "x$have_posix_fallocate" = "xyes"])
  273. AC_CHECK_FUNCS([asctime_r],
  274. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  275. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  276. AC_CHECK_FUNCS([basename],
  277. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  278. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  279. AC_CHECK_FUNCS([gai_strerror],
  280. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  281. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  282. AC_CHECK_FUNCS([getaddrinfo],
  283. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  284. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  285. AC_CHECK_FUNCS([gettimeofday],
  286. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  287. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  288. AC_CHECK_FUNCS([inet_aton],
  289. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  290. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  291. AC_CHECK_FUNCS([localtime_r],
  292. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  293. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  294. AC_CHECK_FUNCS([strptime],
  295. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  296. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  297. AC_CHECK_FUNCS([timegm],
  298. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  299. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  300. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  301. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  302. case "$target" in
  303. *mingw*)
  304. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  305. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  306. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  307. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  308. ;;
  309. esac
  310. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  311. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  312. [Define to 1 if struct sockaddr_in has sin_len member.])],
  313. [],
  314. [[#include <netinet/in.h>]])
  315. # Check struct option.name is assignable from const char*. struct
  316. # option.name in opensolaris is of type char*. In Linux, it is const
  317. # char*
  318. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  319. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  320. #include <unistd.h>
  321. #include <getopt.h>
  322. ]],
  323. [[
  324. const char* s = "const char";
  325. option op;
  326. op.name = s;
  327. ]])],
  328. [have_option_const_name=yes], [have_option_const_name=no])
  329. AC_MSG_RESULT([$have_option_const_name])
  330. if test "x$have_option_const_name" = "xyes"; then
  331. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  332. fi
  333. AC_CONFIG_FILES([Makefile
  334. src/Makefile
  335. test/Makefile
  336. po/Makefile.in
  337. intl/Makefile
  338. lib/Makefile
  339. doc/Makefile])
  340. AC_OUTPUT
  341. echo " "
  342. echo "Build: $build"
  343. echo "Target: $target"
  344. echo "Install prefix: $prefix"
  345. echo "CFLAGS: $CFLAGS"
  346. echo "CPPFLAGS: $CPPFLAGS"
  347. echo "LDFLAGS: $LDFLAGS"
  348. echo "LIBS: $LIBS"
  349. echo "SQLite3: $have_sqlite3"
  350. echo "GnuTLS: $have_libgnutls"
  351. echo "OpenSSL: $have_openssl"
  352. echo "CA Bundle: $ca_bundle"
  353. echo "LibXML2: $have_libxml2"
  354. echo "LibExpat: $have_libexpat"
  355. echo "LibCares: $have_libcares"
  356. echo "Libz: $have_libz"
  357. echo "Epoll: $have_epoll"
  358. echo "Bittorrent: $enable_bittorrent"
  359. echo "Metalink: $enable_metalink"
  360. echo "XML-RPC: $enable_xml_rpc"