configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. #
  4. AC_PREREQ(2.61)
  5. AC_INIT(aria2, 1.5.1, 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. ARIA2_ARG_WITH([gnutls])
  24. ARIA2_ARG_WITH([openssl])
  25. ARIA2_ARG_WITH([sqlite3])
  26. ARIA2_ARG_WITH([libxml2])
  27. ARIA2_ARG_WITH([libexpat])
  28. ARIA2_ARG_WITH([libcares])
  29. ARIA2_ARG_WITH([libz])
  30. ARIA2_ARG_ENABLE([bittorrent])
  31. ARIA2_ARG_ENABLE([metalink])
  32. ARIA2_ARG_ENABLE([epoll])
  33. AC_ARG_WITH([ca-bundle],
  34. AC_HELP_STRING([--with-ca-bundle=FILE], [Use FILE as default CA bundle.]),
  35. [ca_bundle=$withval], [ca_bundle=""])
  36. # Checks for programs.
  37. AC_PROG_CXX
  38. AC_PROG_CC
  39. AC_PROG_INSTALL
  40. AC_PROG_MKDIR_P
  41. AC_PROG_RANLIB
  42. AC_PROG_YACC
  43. # Setting language choice
  44. AC_LANG([C++])
  45. # Enable system extensions
  46. AC_USE_SYSTEM_EXTENSIONS
  47. # Checks for libraries.
  48. if test "x$with_libxml2" = "xyes"; then
  49. AM_PATH_XML2([2.6.24], [have_libxml2=yes])
  50. if test "x$have_libxml2" = "xyes"; then
  51. AC_DEFINE([HAVE_LIBXML2], [1], [Define to 1 if you have libxml2.])
  52. fi
  53. fi
  54. if test "x$with_libexpat" = "xyes" && test "x$have_libxml2" != "xyes"; then
  55. AM_PATH_LIBEXPAT
  56. fi
  57. if test "x$with_sqlite3" = "xyes"; then
  58. AM_PATH_SQLITE3
  59. fi
  60. if test "x$with_gnutls" = "xyes"; then
  61. # gnutls >= 2.8 doesn't have libgnutls-config anymore.
  62. # First check the presence of libgnutls using pkg-config.
  63. PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 1.2.9],
  64. [have_libgnutls=yes], [have_libgnutls=no])
  65. # If no libgnutls found by pkg-config, fall back to old macro
  66. if test "x$have_libgnutls" = "xno"; then
  67. AC_MSG_WARN([$LIBGNUTLS_PKG_ERRORS])
  68. AM_PATH_LIBGNUTLS([1.2.9], [have_libgnutls=yes])
  69. fi
  70. if test "x$have_libgnutls" = "xyes"; then
  71. AC_DEFINE([HAVE_LIBGNUTLS], [1], [Define to 1 if you have libgnutls.])
  72. fi
  73. AC_SUBST(LIBGNUTLS_LIBS)
  74. AC_SUBST(LIBGNUTLS_CFLAGS)
  75. fi
  76. if test "x$have_libgnutls" = "xyes"; then
  77. AM_PATH_LIBGCRYPT([1.2.2], [have_libgcrypt=yes])
  78. if test "x$have_libgcrypt" = "xyes"; then
  79. AC_DEFINE([HAVE_LIBGCRYPT], [1], [Define to 1 if you have libgcrypt.])
  80. fi
  81. fi
  82. if test "x$with_openssl" = "xyes" && test "x$have_libgnutls" != "xyes"; then
  83. AM_PATH_OPENSSL
  84. fi
  85. if test "x$with_libcares" = "xyes"; then
  86. AM_PATH_LIBCARES
  87. fi
  88. # Check availability of libz
  89. if test "x$with_libz" = "xyes"; then
  90. AM_PATH_LIBZ
  91. fi
  92. # Define variables based on the result of the checks for libraries.
  93. if test "x$have_libgnutls" = "xyes" || test "x$have_openssl" = "xyes"; then
  94. AC_DEFINE([ENABLE_SSL], [1], [Define to 1 if ssl support is enabled.])
  95. AM_CONDITIONAL([ENABLE_SSL], true)
  96. AC_SUBST([ca_bundle])
  97. else
  98. AM_CONDITIONAL([ENABLE_SSL], false)
  99. fi
  100. AM_CONDITIONAL([HAVE_LIBGNUTLS], [ test "x$have_libgnutls" = "xyes" ])
  101. AM_CONDITIONAL([HAVE_LIBSSL], [ test "x$have_openssl" = "xyes" ])
  102. if test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then
  103. AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
  104. [Define to 1 if message digest support is enabled.])
  105. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
  106. enable_message_digest=yes
  107. else
  108. AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
  109. fi
  110. if test "x$enable_bittorrent" = "xyes" &&
  111. test "x$enable_message_digest" = "xyes"; then
  112. AC_DEFINE([ENABLE_BITTORRENT], [1],
  113. [Define to 1 if BitTorrent support is enabled.])
  114. AM_CONDITIONAL([ENABLE_BITTORRENT], true)
  115. else
  116. enable_bittorrent=no
  117. AM_CONDITIONAL([ENABLE_BITTORRENT], false)
  118. fi
  119. if (test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes") &&
  120. test "x$enable_metalink" = "xyes"; then
  121. AC_DEFINE([ENABLE_METALINK], [1],
  122. [Define to 1 if Metalink support is enabled.])
  123. AM_CONDITIONAL([ENABLE_METALINK], true)
  124. else
  125. enable_metalink=no
  126. AM_CONDITIONAL([ENABLE_METALINK], false)
  127. fi
  128. AM_CONDITIONAL([ENABLE_METALINK_LIBXML2],
  129. [test "x$enable_metalink" = "xyes" && test "x$have_libxml2" = "xyes"])
  130. AM_CONDITIONAL([ENABLE_METALINK_LIBEXPAT],
  131. [test "x$enable_metalink" = "xyes" && test "x$have_libexpat" = "xyes"])
  132. if test "x$have_libxml2" = "xyes" || test "x$have_libexpat" = "xyes"; then
  133. enable_xml_rpc=yes
  134. fi
  135. if test "x$enable_xml_rpc" = "xyes"; then
  136. AC_DEFINE([ENABLE_XML_RPC], [1],
  137. [Define to 1 if XML-RPC support is enabled.])
  138. fi
  139. AM_CONDITIONAL([ENABLE_XML_RPC], [test "x$enable_xml_rpc" = "xyes"])
  140. AM_CONDITIONAL([HAVE_LIBXML2], [test "x$have_libxml2" = "xyes"])
  141. AM_CONDITIONAL([HAVE_LIBEXPAT], [test "x$have_libexpat" = "xyes"])
  142. if test "x$have_libcares" = "xyes"; then
  143. AC_DEFINE([ENABLE_ASYNC_DNS], [1],
  144. [Define to 1 if asynchronous DNS support is enabled.])
  145. AM_CONDITIONAL([ENABLE_ASYNC_DNS], true)
  146. else
  147. AM_CONDITIONAL([ENABLE_ASYNC_DNS], false)
  148. fi
  149. # Set conditional for libz
  150. AM_CONDITIONAL([HAVE_LIBZ], [test "x$have_libz" = "xyes"])
  151. # Set conditional for sqlite3
  152. AM_CONDITIONAL([HAVE_SQLITE3], [test "x$have_sqlite3" = "xyes"])
  153. # Checks for header files.
  154. AC_FUNC_ALLOCA
  155. AC_HEADER_STDC
  156. case "$target" in
  157. *mingw*)
  158. AC_CHECK_HEADERS([winsock2.h \
  159. ws2tcpip.h])
  160. ;;
  161. esac
  162. AC_CHECK_HEADERS([argz.h \
  163. arpa/inet.h \
  164. fcntl.h \
  165. float.h \
  166. inttypes.h \
  167. io.h \
  168. langinfo.h \
  169. libintl.h \
  170. limits.h \
  171. locale.h \
  172. malloc.h \
  173. netdb.h \
  174. netinet/in.h \
  175. stddef.h \
  176. stdint.h \
  177. stdio_ext.h \
  178. stdlib.h \
  179. string.h \
  180. strings.h \
  181. sys/ioctl.h \
  182. sys/param.h \
  183. sys/socket.h \
  184. sys/time.h \
  185. termios.h \
  186. unistd.h \
  187. wchar.h])
  188. # Checks for typedefs, structures, and compiler characteristics.
  189. AC_HEADER_STDBOOL
  190. AC_C_CONST
  191. AC_C_INLINE
  192. AC_TYPE_INT16_T
  193. AC_TYPE_INT32_T
  194. AC_TYPE_INT64_T
  195. AC_TYPE_INT8_T
  196. AC_TYPE_MODE_T
  197. AC_TYPE_OFF_T
  198. AC_TYPE_SIZE_T
  199. AC_TYPE_SSIZE_T
  200. AC_HEADER_TIME
  201. AC_STRUCT_TM
  202. AC_TYPE_UINT16_T
  203. AC_TYPE_UINT32_T
  204. AC_TYPE_UINT64_T
  205. AC_TYPE_UINT8_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_TYPE_SIGNAL
  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. daemon \
  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. case "$target" in
  299. *mingw*)
  300. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  301. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  302. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  303. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  304. ;;
  305. esac
  306. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  307. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  308. [Define to 1 if struct sockaddr_in has sin_len member.])],
  309. [],
  310. [[#include <netinet/in.h>]])
  311. # Check struct option.name is assignable from const char*. struct
  312. # option.name in opensolaris is of type char*. In Linux, it is const
  313. # char*
  314. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  315. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  316. #include <unistd.h>
  317. #include <getopt.h>
  318. ]],
  319. [[
  320. const char* s = "const char";
  321. option op;
  322. op.name = s;
  323. ]])],
  324. [have_option_const_name=yes], [have_option_const_name=no])
  325. AC_MSG_RESULT([$have_option_const_name])
  326. if test "x$have_option_const_name" = "xyes"; then
  327. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  328. fi
  329. AC_CONFIG_FILES([Makefile
  330. src/Makefile
  331. test/Makefile
  332. po/Makefile.in
  333. m4/Makefile
  334. intl/Makefile
  335. lib/Makefile
  336. doc/Makefile])
  337. AC_OUTPUT
  338. echo " "
  339. echo "Build: $build"
  340. echo "Target: $target"
  341. echo "Install prefix: $prefix"
  342. echo "CFLAGS: $CFLAGS"
  343. echo "CPPFLAGS: $CPPFLAGS"
  344. echo "LDFLAGS: $LDFLAGS"
  345. echo "LIBS: $LIBS"
  346. echo "SQLite3: $have_sqlite3"
  347. echo "GnuTLS: $have_libgnutls"
  348. echo "OpenSSL: $have_openssl"
  349. echo "CA Bundle: $ca_bundle"
  350. echo "LibXML2: $have_libxml2"
  351. echo "LibExpat: $have_libexpat"
  352. echo "LibCares: $have_libcares"
  353. echo "Libz: $have_libz"
  354. echo "Epoll: $have_epoll"
  355. echo "Bittorrent: $enable_bittorrent"
  356. echo "Metalink: $enable_metalink"
  357. echo "XML-RPC: $enable_xml_rpc"