configure.ac 14 KB

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