configure.ac 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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.6.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. # Checks for header files.
  124. AC_HEADER_STDC
  125. 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])
  126. # Checks for typedefs, structures, and compiler characteristics.
  127. AC_C_CONST
  128. AC_C_INLINE
  129. AC_HEADER_TIME
  130. AC_CHECK_TYPE([nfds_t],
  131. [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[poll() second argument type])],
  132. [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])],
  133. [#include <poll.h>])
  134. AC_MSG_CHECKING([whether to enable ipv6])
  135. AC_TRY_RUN([ /* is AF_INET6 available? */
  136. #include <sys/types.h>
  137. #include <sys/socket.h>
  138. main()
  139. {
  140. if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
  141. exit(1);
  142. else
  143. exit(0);
  144. }
  145. ], AC_MSG_RESULT(yes)
  146. ipv6=yes,
  147. AC_MSG_RESULT(no)
  148. ipv6=no,
  149. AC_MSG_RESULT(no)
  150. ipv6=no)
  151. if test x"$ipv6" = xyes; then
  152. USEIPV6="-DZOO_IPV6_ENABLED"
  153. AC_SUBST(USEIPV6)
  154. fi
  155. # use SOCK_CLOEXEC if available and wanted
  156. AC_ARG_WITH([sock_cloexec],
  157. [AS_HELP_STRING([--with-sock-cloexec],[build with SOCK_CLOEXEC flag set on the connections])],
  158. [],[with_sock_cloexec=no])
  159. AC_MSG_CHECKING([whether SOCK_CLOEXEC is available])
  160. AC_TRY_RUN([ /* is SOCK_CLOEXEC available ? */
  161. #include <sys/types.h>
  162. #include <sys/socket.h>
  163. #include <stdlib.h>
  164. main()
  165. {
  166. #ifdef SOCK_CLOEXEC
  167. exit(0);
  168. #else
  169. exit(1);
  170. #endif
  171. }
  172. ], AC_MSG_RESULT(yes)
  173. has_sock_cloexec=yes,
  174. AC_MSG_RESULT(no)
  175. has_sock_cloexec=no,
  176. AC_MSG_RESULT(no)
  177. has_sock_cloexec=no)
  178. if test "x$with_sock_cloexec" != xno && test "x$has_sock_cloexec" = xno; then
  179. AC_MSG_WARN([cannot use SOCK_CLOEXEC -- SOCK_CLOEXEC undefined on this platform])
  180. with_sock_cloexec=no
  181. fi
  182. if test "x$with_sock_cloexec" != xno; then
  183. AC_MSG_NOTICE([building with SOCK_CLOEXEC])
  184. else
  185. AC_MSG_NOTICE([building without SOCK_CLOEXEC])
  186. fi
  187. AS_IF([test x"$with_sock_cloexec" != xno], [AC_DEFINE([SOCK_CLOEXEC_ENABLED], [1], [Define to 1, if SOCK_CLOEXEC is defined and wanted])])
  188. AM_CONDITIONAL([SOCK_CLOEXEC_ENABLED],[test "x$with_sock_cloexec" != xno])
  189. # Determine which libraries we need to use clock_gettime
  190. saved_LIBS="$LIBS"
  191. LIBS=""
  192. AC_CHECK_LIB(rt, clock_gettime)
  193. CLOCK_GETTIME_LIBS=$LIBS
  194. AC_SUBST(CLOCK_GETTIME_LIBS)
  195. LIBS="$saved_LIBS"
  196. # Checks for library functions.
  197. AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol])
  198. AC_CONFIG_FILES([Makefile])
  199. AC_CANONICAL_HOST
  200. AM_CONDITIONAL([SOLARIS],[
  201. case "$host_os" in
  202. *solaris*)
  203. true
  204. ;;
  205. *)
  206. false
  207. ;;
  208. esac ])
  209. AC_OUTPUT