configure.ac 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. AM_CONDITIONAL([WANT_OPENSSL],[test "x$with_openssl" != x])
  33. AC_ARG_WITH(openssl,
  34. AS_HELP_STRING([--without-openssl],
  35. [Do not use Openssl. Default: auto-detect]), [
  36. case "$with_openssl" in
  37. yes|no)
  38. : # Nothing special to do here
  39. ;;
  40. *)
  41. if test ! -d "$withval" ; then
  42. AC_MSG_ERROR([--with-openssl path does not point to a directory])
  43. fi
  44. OPENSSL_DIR="$withval"
  45. AC_SUBST(OPENSSL_DIR)
  46. esac
  47. ])
  48. AH_TEMPLATE(USE_OPENSSL,[Openssl support is available])
  49. if test "$CALLER" = "ANT" ; then
  50. CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"${base_dir}/zookeeper-client/zookeeper-client-c/tests/zkServer.sh\\\"\""
  51. else
  52. CPPUNIT_CFLAGS="$CPPUNIT_CFLAGS -DZKSERVER_CMD=\"\\\"./tests/zkServer.sh\\\"\""
  53. AC_CHECK_FILES([$srcdir/generated/zookeeper.jute.c $srcdir/generated/zookeeper.jute.h],[],
  54. [AC_MSG_ERROR([jute files are missing! Please run "ant compile_jute" while in the zookeeper top level directory.])
  55. ])
  56. fi
  57. AC_SUBST(CPPUNIT_CFLAGS)
  58. AC_PROG_CC
  59. AM_PROG_CC_C_O
  60. AC_PROG_CXX
  61. AC_PROG_INSTALL
  62. AC_PROG_LN_S
  63. # AC_DISABLE_SHARED
  64. AC_PROG_LIBTOOL
  65. #enable -D_GNU_SOURCE since the return code value of getaddrinfo
  66. #ifdefed with __USE_GNU
  67. #features.h header undef's __USE_GNU and defines it only if _GNU_SOURCE is defined
  68. #hence this define for gcc
  69. AC_ARG_ENABLE([debug],
  70. [AS_HELP_STRING([--enable-debug],[enable debug build [default=no]])],
  71. [],[enable_debug=no])
  72. if test "x$enable_debug" = xyes; then
  73. if test "x$init_cflags" = x; then
  74. CFLAGS=""
  75. fi
  76. CFLAGS="$CFLAGS -g -O0 -D_GNU_SOURCE"
  77. else
  78. if test "x$init_cflags" = x; then
  79. CFLAGS="-g -O2 -D_GNU_SOURCE"
  80. fi
  81. fi
  82. if test "x$enable_debug" = xyes; then
  83. if test "x$init_cxxflags" = x; then
  84. CXXFLAGS=""
  85. fi
  86. CXXFLAGS="$CXXFLAGS -g -O0"
  87. else
  88. if test "x$init_cxxflags" = x; then
  89. CXXFLAGS="-g -O2"
  90. fi
  91. fi
  92. # Check whether to enable gcov (coverage test)
  93. AC_ARG_ENABLE(gcov, [AS_HELP_STRING([--enable-gcov],[enable coverage test])])
  94. AC_MSG_CHECKING([whether to enable gcov])
  95. AS_IF([test "x${enable_gcov}" = "xyes"],AC_MSG_RESULT([yes]),AC_MSG_RESULT([no]))
  96. AM_CONDITIONAL([ENABLEGCOV],[test "x${enable_gcov}" = "xyes"])
  97. CXXFLAGS="$CXXFLAGS -std=c++11"
  98. AC_ARG_WITH([syncapi],
  99. [AS_HELP_STRING([--with-syncapi],[build with support for SyncAPI [default=yes]])],
  100. [],[with_syncapi=yes])
  101. # Checks for libraries.
  102. AC_CHECK_LIB([pthread], [pthread_mutex_lock],[have_pthread=yes],[have_pthread=no])
  103. if test "x$with_syncapi" != xno && test "x$have_pthread" = xno; then
  104. AC_MSG_WARN([cannot build SyncAPI -- pthread not found])
  105. with_syncapi=no
  106. fi
  107. if test "x$with_syncapi" != xno; then
  108. AC_MSG_NOTICE([building with SyncAPI support])
  109. else
  110. AC_MSG_NOTICE([building without SyncAPI support])
  111. fi
  112. AM_CONDITIONAL([WANT_SYNCAPI],[test "x$with_syncapi" != xno])
  113. # Checks for header files.
  114. AC_HEADER_STDC
  115. 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])
  116. # Checks for typedefs, structures, and compiler characteristics.
  117. AC_C_CONST
  118. AC_C_INLINE
  119. AC_HEADER_TIME
  120. AC_CHECK_TYPE([nfds_t],
  121. [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[poll() second argument type])],
  122. [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[poll() second argument type])],
  123. [#include <poll.h>])
  124. AC_MSG_CHECKING([whether to enable ipv6])
  125. AC_TRY_RUN([ /* is AF_INET6 available? */
  126. #include <sys/types.h>
  127. #include <sys/socket.h>
  128. main()
  129. {
  130. if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
  131. exit(1);
  132. else
  133. exit(0);
  134. }
  135. ], AC_MSG_RESULT(yes)
  136. ipv6=yes,
  137. AC_MSG_RESULT(no)
  138. ipv6=no,
  139. AC_MSG_RESULT(no)
  140. ipv6=no)
  141. if test x"$ipv6" = xyes; then
  142. USEIPV6="-DZOO_IPV6_ENABLED"
  143. AC_SUBST(USEIPV6)
  144. fi
  145. # use SOCK_CLOEXEC if available and wanted
  146. AC_ARG_WITH([sock_cloexec],
  147. [AS_HELP_STRING([--with-sock-cloexec],[build with SOCK_CLOEXEC flag set on the connections])],
  148. [],[with_sock_cloexec=no])
  149. AC_MSG_CHECKING([whether SOCK_CLOEXEC is available])
  150. AC_TRY_RUN([ /* is SOCK_CLOEXEC available ? */
  151. #include <sys/types.h>
  152. #include <sys/socket.h>
  153. #include <stdlib.h>
  154. main()
  155. {
  156. #ifdef SOCK_CLOEXEC
  157. exit(0);
  158. #else
  159. exit(1);
  160. #endif
  161. }
  162. ], AC_MSG_RESULT(yes)
  163. has_sock_cloexec=yes,
  164. AC_MSG_RESULT(no)
  165. has_sock_cloexec=no,
  166. AC_MSG_RESULT(no)
  167. has_sock_cloexec=no)
  168. if test "x$with_sock_cloexec" != xno && test "x$has_sock_cloexec" = xno; then
  169. AC_MSG_WARN([cannot use SOCK_CLOEXEC -- SOCK_CLOEXEC undefined on this platform])
  170. with_sock_cloexec=no
  171. fi
  172. if test "x$with_sock_cloexec" != xno; then
  173. AC_MSG_NOTICE([building with SOCK_CLOEXEC])
  174. else
  175. AC_MSG_NOTICE([building without SOCK_CLOEXEC])
  176. fi
  177. AS_IF([test x"$with_sock_cloexec" != xno], [AC_DEFINE([SOCK_CLOEXEC_ENABLED], [1], [Define to 1, if SOCK_CLOEXEC is defined and wanted])])
  178. AM_CONDITIONAL([SOCK_CLOEXEC_ENABLED],[test "x$with_sock_cloexec" != xno])
  179. # Determine which libraries we need to use clock_gettime
  180. saved_LIBS="$LIBS"
  181. LIBS=""
  182. AC_CHECK_LIB(rt, clock_gettime)
  183. CLOCK_GETTIME_LIBS=$LIBS
  184. AC_SUBST(CLOCK_GETTIME_LIBS)
  185. LIBS="$saved_LIBS"
  186. # Checks for library functions.
  187. AC_CHECK_FUNCS([getcwd gethostbyname gethostname getlogin getpwuid_r gettimeofday getuid memmove memset poll socket strchr strdup strerror strtol])
  188. AC_CONFIG_FILES([Makefile])
  189. AC_CANONICAL_HOST
  190. AM_CONDITIONAL([SOLARIS],[
  191. case "$host_os" in
  192. *solaris*)
  193. true
  194. ;;
  195. *)
  196. false
  197. ;;
  198. esac ])
  199. AC_OUTPUT