configure.ac 14 KB

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