configure.ac 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ(2.59)
  4. AC_INIT([zookeeper C client],3.10.0,[user@zookeeper.apache.org],[zookeeper])
  5. AC_CONFIG_SRCDIR([src/zookeeper.c])
  6. # Save initial CFLAGS and CXXFLAGS values before AC_PROG_CC and AC_PROG_CXX
  7. init_cflags="$CFLAGS"
  8. init_cxxflags="$CXXFLAGS"
  9. # initialize Doxygen support
  10. DX_HTML_FEATURE(ON)
  11. DX_CHM_FEATURE(OFF)
  12. DX_CHI_FEATURE(OFF)
  13. DX_MAN_FEATURE(OFF)
  14. DX_RTF_FEATURE(OFF)
  15. DX_XML_FEATURE(OFF)
  16. DX_PDF_FEATURE(OFF)
  17. DX_PS_FEATURE(OFF)
  18. DX_INIT_DOXYGEN([zookeeper],[c-doc.Doxyfile],[docs])
  19. # initialize automake
  20. AM_INIT_AUTOMAKE([-Wall foreign])
  21. AC_CONFIG_HEADER([config.h])
  22. # Checks for programs.
  23. AC_ARG_WITH(cppunit,
  24. [ --without-cppunit do not use CPPUNIT])
  25. if test "$with_cppunit" = "no" ; then
  26. CPPUNIT_PATH="No_CPPUNIT"
  27. CPPUNIT_INCLUDE=
  28. CPPUNIT_LIBS=
  29. else
  30. CHECK_CPPUNIT(1.10.2)
  31. fi
  32. dnl OpenSSL
  33. AC_ARG_WITH(openssl,
  34. [AC_HELP_STRING([--with-openssl[=DIR]], [build with openssl (autodetect openssl library by default) )])],
  35. [], [with_openssl=yes])
  36. AC_MSG_NOTICE([configuring SSL using --with-openssl=$with_openssl])
  37. saved_CPPFLAGS="$CPPFLAGS"
  38. saved_LDFLAGS="$LDFLAGS"
  39. if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" ; then
  40. CPPFLAGS="$CPPFLAGS -I$with_openssl/include"
  41. LDFLAGS="$LDFLAGS -L$with_openssl/lib"
  42. fi
  43. have_openssl=no
  44. AC_CHECK_HEADER(openssl/ssl.h, [ AC_CHECK_LIB(ssl, SSL_CTX_new, [have_openssl=yes]) ])
  45. if test "x$with_openssl" != "xno" && test "x$with_openssl" != "xyes" && test "x$have_openssl" != "xyes"; then
  46. CPPFLAGS="$saved_CPPFLAGS"
  47. LDFLAGS="$saved_LDFLAGS"
  48. fi
  49. if test "x$with_openssl" != xno && test "x$have_openssl" = xno; then
  50. AC_MSG_WARN([cannot build SSL support -- openssl not found])
  51. with_openssl=no
  52. fi
  53. if test "x$with_openssl" != xno; then
  54. AC_MSG_NOTICE([building with SSL support])
  55. else
  56. AC_MSG_NOTICE([building without SSL support])
  57. fi
  58. AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != xno])
  59. if test "$CALLER" = "ANT" ; then
  60. CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\""
  61. else
  62. CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"./tests/zkServer.sh\\\"\""
  63. AC_CHECK_FILES([$srcdir/generated/zookeeper.jute.c $srcdir/generated/zookeeper.jute.h],[],
  64. [AC_MSG_ERROR([jute files are missing! Please run "ant compile_jute" while in the zookeeper top level directory.])
  65. ])
  66. fi
  67. AC_SUBST(CPPUNIT_CFLAGS)
  68. AC_PROG_CC
  69. AM_PROG_CC_C_O
  70. AC_PROG_CXX
  71. AC_PROG_INSTALL
  72. AC_PROG_LN_S
  73. # AC_DISABLE_SHARED
  74. AC_PROG_LIBTOOL
  75. #enable -D_GNU_SOURCE since the return code value of getaddrinfo
  76. #ifdefed with __USE_GNU
  77. #features.h header undef's __USE_GNU and defines it only if _GNU_SOURCE is defined
  78. #hence this define for gcc
  79. AC_ARG_ENABLE([debug],
  80. [AS_HELP_STRING([--enable-debug],[enable debug build [default=no]])],
  81. [],[enable_debug=no])
  82. if test "x$enable_debug" = xyes; then
  83. if test "x$init_cflags" = x; then
  84. CFLAGS=""
  85. fi
  86. CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE"
  87. else
  88. if test "x$init_cflags" = x; then
  89. CFLAGS="-g -O2 -D_GNU_SOURCE"
  90. fi
  91. fi
  92. if test "x$enable_debug" = xyes; then
  93. if test "x$init_cxxflags" = x; then
  94. CXXFLAGS=""
  95. fi
  96. CXXFLAGS="$CXXFLAGS -g -O0"
  97. else
  98. if test "x$init_cxxflags" = x; then
  99. CXXFLAGS="-g -O2"
  100. fi
  101. fi
  102. # Check whether to enable gcov (coverage test)
  103. AC_ARG_ENABLE(gcov, [AS_HELP_STRING([--enable-gcov],[enable coverage test])])
  104. AC_MSG_CHECKING([whether to enable gcov])
  105. AS_IF([test "x${enable_gcov}" = "xyes"],AC_MSG_RESULT([yes]),AC_MSG_RESULT([no]))
  106. AM_CONDITIONAL([ENABLEGCOV],[test "x${enable_gcov}" = "xyes"])
  107. CXXFLAGS="$CXXFLAGS -std=c++11"
  108. AC_ARG_WITH([syncapi],
  109. [AS_HELP_STRING([--with-syncapi],[build with support for SyncAPI [default=yes]])],
  110. [],[with_syncapi=yes])
  111. # Checks for libraries.
  112. AC_CHECK_LIB([pthread], [pthread_mutex_lock],[have_pthread=yes],[have_pthread=no])
  113. if test "x$with_syncapi" != xno && test "x$have_pthread" = xno; then
  114. AC_MSG_WARN([cannot build SyncAPI -- pthread not found])
  115. with_syncapi=no
  116. fi
  117. if test "x$with_syncapi" != xno; then
  118. AC_MSG_NOTICE([building with SyncAPI support])
  119. else
  120. AC_MSG_NOTICE([building without SyncAPI support])
  121. fi
  122. AM_CONDITIONAL([WANT_SYNCAPI],[test "x$with_syncapi" != xno])
  123. dnl Cyrus SASL 2.x
  124. AC_ARG_WITH(sasl,
  125. [AC_HELP_STRING([--with-sasl[=DIR]], [build with SASL support via Cyrus SASL 2.x (default=auto)])],
  126. [], [with_sasl=yes])
  127. if test "x$with_sasl" != "xno"; then
  128. saved_CPPFLAGS="$CPPFLAGS"
  129. saved_LDFLAGS="$LDFLAGS"
  130. if test "x$with_sasl" != "xyes" ; then
  131. CPPFLAGS="$CPPFLAGS -I$with_sasl/include"
  132. LDFLAGS="$LDFLAGS -L$with_sasl/lib"
  133. fi
  134. have_sasl=no
  135. AC_CHECK_HEADER(sasl/sasl.h, [
  136. AC_CHECK_LIB(sasl2, sasl_client_init, [have_sasl=yes])])
  137. if test "x$have_sasl" != "xyes"; then
  138. CPPFLAGS="$saved_CPPFLAGS"
  139. LDFLAGS="$saved_LDFLAGS"
  140. fi
  141. fi
  142. if test "x$with_sasl" != xno && test "x$have_sasl" = xno; then
  143. AC_MSG_WARN([cannot build SASL support -- sasl2 not found])
  144. with_sasl=no
  145. fi
  146. if test "x$with_sasl" != xno; then
  147. AC_MSG_NOTICE([building with SASL support])
  148. else
  149. AC_MSG_NOTICE([building without SASL support])
  150. fi
  151. AM_CONDITIONAL([WANT_SASL],[test "x$with_sasl" != xno])
  152. # Checks for header files.
  153. AC_HEADER_STDC
  154. AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sys/utsname.h])
  155. # Checks for typedefs, structures, and compiler characteristics.
  156. AC_C_CONST
  157. AC_C_INLINE
  158. AC_HEADER_TIME
  159. AC_CHECK_TYPE([nfds_t],
  160. [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[poll() second argument type])],
  161. [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])],
  162. [#include <poll.h>])
  163. AC_MSG_CHECKING([whether to enable ipv6])
  164. AC_TRY_RUN([ /* is AF_INET6 available? */
  165. #include <sys/types.h>
  166. #include <sys/socket.h>
  167. main()
  168. {
  169. if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
  170. exit(1);
  171. else
  172. exit(0);
  173. }
  174. ], AC_MSG_RESULT(yes)
  175. ipv6=yes,
  176. AC_MSG_RESULT(no)
  177. ipv6=no,
  178. AC_MSG_RESULT(no)
  179. ipv6=no)
  180. if test x"$ipv6" = xyes; then
  181. USEIPV6="-DZOO_IPV6_ENABLED"
  182. AC_SUBST(USEIPV6)
  183. fi
  184. # use SOCK_CLOEXEC if available and wanted
  185. AC_ARG_WITH([sock_cloexec],
  186. [AS_HELP_STRING([--with-sock-cloexec],[build with SOCK_CLOEXEC flag set on the connections])],
  187. [],[with_sock_cloexec=no])
  188. AC_MSG_CHECKING([whether SOCK_CLOEXEC is available])
  189. AC_TRY_RUN([ /* is SOCK_CLOEXEC available ? */
  190. #include <sys/types.h>
  191. #include <sys/socket.h>
  192. #include <stdlib.h>
  193. main()
  194. {
  195. #ifdef SOCK_CLOEXEC
  196. exit(0);
  197. #else
  198. exit(1);
  199. #endif
  200. }
  201. ], AC_MSG_RESULT(yes)
  202. has_sock_cloexec=yes,
  203. AC_MSG_RESULT(no)
  204. has_sock_cloexec=no,
  205. AC_MSG_RESULT(no)
  206. has_sock_cloexec=no)
  207. if test "x$with_sock_cloexec" != xno && test "x$has_sock_cloexec" = xno; then
  208. AC_MSG_WARN([cannot use SOCK_CLOEXEC -- SOCK_CLOEXEC undefined on this platform])
  209. with_sock_cloexec=no
  210. fi
  211. if test "x$with_sock_cloexec" != xno; then
  212. AC_MSG_NOTICE([building with SOCK_CLOEXEC])
  213. else
  214. AC_MSG_NOTICE([building without SOCK_CLOEXEC])
  215. fi
  216. AS_IF([test x"$with_sock_cloexec" != xno], [AC_DEFINE([SOCK_CLOEXEC_ENABLED], [1], [Define to 1, if SOCK_CLOEXEC is defined and wanted])])
  217. AM_CONDITIONAL([SOCK_CLOEXEC_ENABLED],[test "x$with_sock_cloexec" != xno])
  218. # Determine which libraries we need to use clock_gettime
  219. saved_LIBS="$LIBS"
  220. LIBS=""
  221. AC_CHECK_LIB(rt, clock_gettime)
  222. CLOCK_GETTIME_LIBS=$LIBS
  223. AC_SUBST(CLOCK_GETTIME_LIBS)
  224. LIBS="$saved_LIBS"
  225. # Checks for library functions.
  226. AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol])
  227. AC_CONFIG_FILES([Makefile])
  228. AC_CANONICAL_HOST
  229. AM_CONDITIONAL([SOLARIS],[
  230. case "$host_os" in
  231. *solaris*)
  232. true
  233. ;;
  234. *)
  235. false
  236. ;;
  237. esac ])
  238. AC_OUTPUT