configure.ac 5.6 KB

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