configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. # Checks for header files.
  182. AC_FUNC_ALLOCA
  183. AC_HEADER_STDC
  184. case "$target" in
  185. *mingw*)
  186. AC_CHECK_HEADERS([winsock2.h \
  187. ws2tcpip.h])
  188. ;;
  189. esac
  190. AC_CHECK_HEADERS([argz.h \
  191. arpa/inet.h \
  192. fcntl.h \
  193. float.h \
  194. inttypes.h \
  195. io.h \
  196. langinfo.h \
  197. libintl.h \
  198. limits.h \
  199. locale.h \
  200. malloc.h \
  201. netdb.h \
  202. netinet/in.h \
  203. stddef.h \
  204. stdint.h \
  205. stdio_ext.h \
  206. stdlib.h \
  207. string.h \
  208. strings.h \
  209. sys/ioctl.h \
  210. sys/param.h \
  211. sys/socket.h \
  212. sys/time.h \
  213. termios.h \
  214. unistd.h \
  215. utime.h \
  216. wchar.h \
  217. ifaddrs.h])
  218. # Checks for typedefs, structures, and compiler characteristics.
  219. AC_HEADER_STDBOOL
  220. AC_C_CONST
  221. AC_C_INLINE
  222. AC_TYPE_INT16_T
  223. AC_TYPE_INT32_T
  224. AC_TYPE_INT64_T
  225. AC_TYPE_INT8_T
  226. AC_TYPE_MODE_T
  227. AC_TYPE_OFF_T
  228. AC_TYPE_SIZE_T
  229. AC_TYPE_SSIZE_T
  230. AC_HEADER_TIME
  231. AC_STRUCT_TM
  232. AC_TYPE_UINT16_T
  233. AC_TYPE_UINT32_T
  234. AC_TYPE_UINT64_T
  235. AC_TYPE_UINT8_T
  236. AC_TYPE_PID_T
  237. AC_C_VOLATILE
  238. AC_CHECK_TYPES([ptrdiff_t])
  239. AC_C_BIGENDIAN
  240. AC_SYS_LARGEFILE
  241. # Checks for library functions.
  242. AM_GNU_GETTEXT
  243. AM_GNU_GETTEXT_VERSION([0.17])
  244. AC_FUNC_ERROR_AT_LINE
  245. AC_PROG_GCC_TRADITIONAL
  246. AC_FUNC_MEMCMP
  247. AC_FUNC_MKTIME
  248. AC_FUNC_MMAP
  249. AC_FUNC_SELECT_ARGTYPES
  250. AC_FUNC_STAT
  251. AC_FUNC_STRFTIME
  252. AC_FUNC_VPRINTF
  253. AC_FUNC_FORK
  254. AC_FUNC_STRTOD
  255. AC_CHECK_FUNCS([__argz_count \
  256. __argz_next \
  257. __argz_stringify \
  258. atexit \
  259. ftruncate \
  260. getcwd \
  261. gethostbyaddr \
  262. gethostbyname \
  263. getifaddrs \
  264. getpagesize \
  265. inet_ntoa \
  266. memchr \
  267. memmove \
  268. mempcpy \
  269. memset \
  270. mkdir \
  271. munmap \
  272. nl_langinfo \
  273. posix_memalign \
  274. pow \
  275. putenv \
  276. rmdir \
  277. select \
  278. setlocale \
  279. sleep \
  280. socket \
  281. stpcpy \
  282. strcasecmp \
  283. strchr \
  284. strcspn \
  285. strdup \
  286. strerror \
  287. strncasecmp \
  288. strstr \
  289. strtol \
  290. strtoul \
  291. strtoull \
  292. tzset \
  293. unsetenv \
  294. usleep \
  295. utime])
  296. if test "x$enable_epoll" = "xyes"; then
  297. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  298. if test "x$have_epoll" = "xyes"; then
  299. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  300. fi
  301. fi
  302. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  303. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  304. AM_CONDITIONAL([HAVE_POSIX_FALLOCATE], [test "x$have_posix_fallocate" = "xyes"])
  305. AC_CHECK_FUNCS([asctime_r],
  306. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  307. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  308. AC_CHECK_FUNCS([basename],
  309. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  310. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  311. AC_CHECK_FUNCS([gai_strerror],
  312. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  313. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  314. AC_CHECK_FUNCS([getaddrinfo],
  315. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  316. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  317. AC_CHECK_FUNCS([gettimeofday],
  318. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  319. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  320. AC_CHECK_FUNCS([inet_aton],
  321. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  322. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  323. AC_CHECK_FUNCS([localtime_r],
  324. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  325. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  326. AC_CHECK_FUNCS([strptime],
  327. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  328. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  329. AC_CHECK_FUNCS([timegm],
  330. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  331. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  332. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  333. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  334. case "$target" in
  335. *mingw*)
  336. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  337. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  338. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  339. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  340. ;;
  341. esac
  342. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  343. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  344. [Define to 1 if struct sockaddr_in has sin_len member.])],
  345. [],
  346. [[#include <netinet/in.h>]])
  347. # Check struct option.name is assignable from const char*. struct
  348. # option.name in opensolaris is of type char*. In Linux, it is const
  349. # char*
  350. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  351. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  352. #include <unistd.h>
  353. #include <getopt.h>
  354. ]],
  355. [[
  356. const char* s = "const char";
  357. option op;
  358. op.name = s;
  359. ]])],
  360. [have_option_const_name=yes], [have_option_const_name=no])
  361. AC_MSG_RESULT([$have_option_const_name])
  362. if test "x$have_option_const_name" = "xyes"; then
  363. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  364. fi
  365. AC_CONFIG_FILES([Makefile
  366. src/Makefile
  367. test/Makefile
  368. po/Makefile.in
  369. intl/Makefile
  370. lib/Makefile
  371. doc/Makefile])
  372. AC_OUTPUT
  373. echo " "
  374. echo "Build: $build"
  375. echo "Target: $target"
  376. echo "Install prefix: $prefix"
  377. echo "CXXFLAGS: $CXXFLAGS"
  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"