configure.ac 12 KB

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