configure.ac 14 KB

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