configure.ac 12 KB

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