configure.ac 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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.3],[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. inet_ntop \
  283. memchr \
  284. memmove \
  285. mempcpy \
  286. memset \
  287. mkdir \
  288. munmap \
  289. nl_langinfo \
  290. posix_memalign \
  291. pow \
  292. putenv \
  293. rmdir \
  294. select \
  295. setlocale \
  296. sleep \
  297. socket \
  298. stpcpy \
  299. strcasecmp \
  300. strchr \
  301. strcspn \
  302. strdup \
  303. strerror \
  304. strncasecmp \
  305. strstr \
  306. strtol \
  307. strtoul \
  308. strtoull \
  309. tzset \
  310. unsetenv \
  311. usleep \
  312. utime])
  313. if test "x$enable_epoll" = "xyes"; then
  314. AC_CHECK_FUNCS([epoll_create], [have_epoll=yes])
  315. if test "x$have_epoll" = "xyes"; then
  316. AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if epoll is available.])
  317. fi
  318. fi
  319. AM_CONDITIONAL([HAVE_EPOLL], [test "x$have_epoll" = "xyes"])
  320. AC_CHECK_FUNCS([posix_fallocate],[have_posix_fallocate=yes])
  321. ARIA2_CHECK_FALLOCATE
  322. if test "x$have_posix_fallocate" = "xyes" ||
  323. test "x$have_fallocate" = "xyes"; then
  324. AC_DEFINE([HAVE_SOME_FALLOCATE], [1],
  325. [Define to 1 if *_fallocate is available.])
  326. fi
  327. AM_CONDITIONAL([HAVE_SOME_FALLOCATE],
  328. [test "x$have_posix_fallocate" = "xyes" || test "x$have_fallocate" = "xyes"])
  329. AC_CHECK_FUNCS([asctime_r],
  330. [AM_CONDITIONAL([HAVE_ASCTIME_R], true)],
  331. [AM_CONDITIONAL([HAVE_ASCTIME_R], false)])
  332. AC_CHECK_FUNCS([basename],
  333. [AM_CONDITIONAL([HAVE_BASENAME], true)],
  334. [AM_CONDITIONAL([HAVE_BASENAME], false)])
  335. AC_CHECK_FUNCS([gai_strerror],
  336. [AM_CONDITIONAL([HAVE_GAI_STRERROR], true)],
  337. [AM_CONDITIONAL([HAVE_GAI_STRERROR], false)])
  338. AC_CHECK_FUNCS([getaddrinfo],
  339. [AM_CONDITIONAL([HAVE_GETADDRINFO], true)],
  340. [AM_CONDITIONAL([HAVE_GETADDRINFO], false)])
  341. AC_CHECK_FUNCS([gettimeofday],
  342. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], true)],
  343. [AM_CONDITIONAL([HAVE_GETTIMEOFDAY], false)])
  344. AC_CHECK_FUNCS([inet_aton],
  345. [AM_CONDITIONAL([HAVE_INET_ATON], true)],
  346. [AM_CONDITIONAL([HAVE_INET_ATON], false)])
  347. AC_CHECK_FUNCS([localtime_r],
  348. [AM_CONDITIONAL([HAVE_LOCALTIME_R], true)],
  349. [AM_CONDITIONAL([HAVE_LOCALTIME_R], false)])
  350. AC_CHECK_FUNCS([strptime],
  351. [AM_CONDITIONAL([HAVE_STRPTIME], true)],
  352. [AM_CONDITIONAL([HAVE_STRPTIME], false)])
  353. AC_CHECK_FUNCS([timegm],
  354. [AM_CONDITIONAL([HAVE_TIMEGM], true)],
  355. [AM_CONDITIONAL([HAVE_TIMEGM], false)])
  356. AC_CHECK_FUNCS([daemon], [have_daemon=yes])
  357. AM_CONDITIONAL([HAVE_DAEMON], [test "x$have_daemon" = "xyes"])
  358. AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes])
  359. if test "x$have_clock_gettime" != "xyes"; then
  360. AC_CHECK_FUNCS([mach_absolute_time], [have_mach_absolute_time=yes])
  361. fi
  362. AM_CONDITIONAL([HAVE_MACH_ABSOLUTE_TIME],
  363. [test "x$have_mach_absolute_time" = "xyes"])
  364. AC_CHECK_FUNCS([poll], [have_poll=yes])
  365. AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
  366. case "$target" in
  367. *mingw*)
  368. dnl defined in ws2tcpip.h, but only if _WIN32_WINNT >= 0x0501
  369. AM_CONDITIONAL([HAVE_GETADDRINFO], true)
  370. dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
  371. AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
  372. if test "x$have_clock_gettime" != "xyes"; then
  373. AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
  374. fi
  375. ;;
  376. *)
  377. AM_CONDITIONAL([HAVE_TIMEGETTIME], false)
  378. ;;
  379. esac
  380. AC_CHECK_FUNCS([port_associate], [have_port_associate=yes])
  381. AM_CONDITIONAL([HAVE_PORT_ASSOCIATE], [test "x$have_port_associate" = "xyes"])
  382. AC_CHECK_FUNCS([kqueue], [have_kqueue=yes])
  383. AM_CONDITIONAL([HAVE_KQUEUE], [test "x$have_kqueue" = "xyes"])
  384. if test "x$have_kqueue" = "xyes"; then
  385. AC_MSG_CHECKING([whether struct kevent.udata is intptr_t])
  386. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  387. #include <sys/types.h>
  388. #include <sys/event.h>
  389. #include <sys/time.h>
  390. ]],
  391. [[
  392. struct kevent event;
  393. event.udata = reinterpret_cast<intptr_t>(&event);
  394. ]])],
  395. [kevent_udata_intptr_t=yes], [kevent_udata_intptr_t=no])
  396. AC_MSG_RESULT([$kevent_udata_intptr_t])
  397. if test "x$kevent_udata_intptr_t" = "xyes"; then
  398. AC_DEFINE([KEVENT_UDATA_INTPTR_T], [1], [Define to 1 if struct kevent.udata is intptr_t])
  399. fi
  400. fi
  401. AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
  402. [AC_DEFINE([HAVE_SOCKADDR_IN_SIN_LEN],[1],
  403. [Define to 1 if struct sockaddr_in has sin_len member.])],
  404. [],
  405. [[#include <netinet/in.h>]])
  406. # Check struct option.name is assignable from const char*. struct
  407. # option.name in opensolaris is of type char*. In Linux, it is const
  408. # char*
  409. AC_MSG_CHECKING([whether struct option.name is assignable from const char*])
  410. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  411. #include <unistd.h>
  412. #include <getopt.h>
  413. ]],
  414. [[
  415. const char* s = "const char";
  416. option op;
  417. op.name = s;
  418. ]])],
  419. [have_option_const_name=yes], [have_option_const_name=no])
  420. AC_MSG_RESULT([$have_option_const_name])
  421. if test "x$have_option_const_name" = "xyes"; then
  422. AC_DEFINE([HAVE_OPTION_CONST_NAME], [1], [Define 1 if struct option.name is const char*])
  423. fi
  424. AC_CONFIG_FILES([Makefile
  425. src/Makefile
  426. test/Makefile
  427. po/Makefile.in
  428. intl/Makefile
  429. lib/Makefile
  430. doc/Makefile])
  431. AC_OUTPUT
  432. echo " "
  433. echo "Build: $build"
  434. echo "Target: $target"
  435. echo "Install prefix: $prefix"
  436. echo "CXXFLAGS: $CXXFLAGS"
  437. echo "CFLAGS: $CFLAGS"
  438. echo "CPPFLAGS: $CPPFLAGS"
  439. echo "LDFLAGS: $LDFLAGS"
  440. echo "LIBS: $LIBS"
  441. echo "SQLite3: $have_sqlite3"
  442. echo "GnuTLS: $have_libgnutls"
  443. echo "OpenSSL: $have_openssl"
  444. echo "CA Bundle: $ca_bundle"
  445. echo "LibXML2: $have_libxml2"
  446. echo "LibExpat: $have_libexpat"
  447. echo "LibCares: $have_libcares"
  448. echo "Libz: $have_libz"
  449. echo "Epoll: $have_epoll"
  450. echo "Bittorrent: $enable_bittorrent"
  451. echo "Metalink: $enable_metalink"
  452. echo "XML-RPC: $enable_xml_rpc"