configure.ac 12 KB

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