83177bcab6877a08b8460b3f2d4fb71684789ef3
[m6w6/libmemcached] / configure.ac
1 #!/usr/bin/env bash
2 # LibmemcacheD
3 # Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
4 # Copyright (C) 2006-2010 Brian Aker, Monty Taylor, Trond Norbye
5 # All rights reserved.
6 #
7 # Use and distribution licensed under the BSD license. See
8 # the COPYING file in this directory for full text.
9
10 AC_INIT([libmemcached],[1.0.10],[http://libmemcached.org/])
11
12 AC_CONFIG_AUX_DIR(config)
13
14 AC_CANONICAL_TARGET
15
16 AM_INIT_AUTOMAKE
17
18 AC_CANONICAL_HOST
19 AC_CANONICAL_BUILD
20
21 AC_PREREQ([2.61])
22
23 AC_CONFIG_MACRO_DIR(m4)
24
25 AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
26
27 AC_CONFIG_SRCDIR([libmemcached/memcached.cc])
28
29 PANDORA_CANONICAL_TARGET(no-vc-changelog)
30 AC_CHECK_PROGS([YACC], ['bison'], [:])
31 AC_CHECK_PROGS([LEX], ['flex'], [:])
32
33 #shared library versioning
34 MEMCACHED_UTIL_LIBRARY_VERSION=2:0:0
35 MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0
36 MEMCACHED_LIBRARY_VERSION=11:0:0
37 # | | |
38 # +------+ | +---+
39 # | | |
40 # current:revision:age
41 # | | |
42 # | | +- increment if interfaces have been added
43 # | | set to zero if interfaces have been removed or changed
44 # | +- increment if source code has changed
45 # | set to zero if current is incremented
46 # +- increment if interfaces have been added, removed or changed
47 AC_SUBST(MEMCACHED_UTIL_LIBRARY_VERSION)
48 AC_SUBST(MEMCACHED_PROTOCAL_LIBRARY_VERSION)
49 AC_SUBST(MEMCACHED_LIBRARY_VERSION)
50
51
52 HASHKIT_LIBRARY_VERSION=2:0:0
53 AC_SUBST(HASHKIT_LIBRARY_VERSION)
54
55 LT_PREREQ([2.2])
56 LT_INIT()
57 LT_LANG([C++])
58 LT_LANG([C])
59 gl_VISIBILITY
60
61 AX_CXX_HEADER_STDCXX_98
62 if test "$ax_cv_cxx_stdcxx_98" = no; then
63 AC_MSG_ERROR([Your system lacks a new enough C++ compiler])
64 fi
65
66 # Adding support for libtest
67 m4_include([libtest/yatl.m4])
68
69 m4_include([m4/memcached_sasl.m4])
70 m4_include([m4/gearmand.m4])
71 m4_include([m4/libgearman.m4])
72
73 AM_CONDITIONAL(BUILDING_LIBMEMCACHED, true)
74 AM_CONDITIONAL(HAVE_LIBMEMCACHED, false)
75 AM_CONDITIONAL(HAVE_LIBDRIZZLE, false)
76 AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enables libmemcached Support])
77
78 AM_CONDITIONAL(BUILDING_GEARMAN, false)
79
80 AC_SEARCH_LIBS(getopt_long, gnugetopt)
81 AC_SEARCH_LIBS(gethostbyname, nsl)
82
83 dnl Specialty checks
84 AX_CXX_CINTTYPES
85 CONFIG_EXTRA
86 DETECT_BYTEORDER
87 SETSOCKOPT_SANITY
88 ENABLE_HSIEH_HASH
89 ENABLE_MURMUR_HASH
90 ENABLE_FNV64_HASH
91 ENABLE_MEMASLAP
92 PROTOCOL_BINARY_TEST
93 ENABLE_DEPRECATED
94
95 AC_CHECK_FUNCS([alarm])
96 AC_CHECK_FUNCS([clock_gettime])
97 AC_CHECK_FUNCS([dup2])
98 AC_CHECK_FUNCS([getline])
99 AC_CHECK_FUNCS([gettimeofday])
100 AC_CHECK_FUNCS([memchr])
101 AC_CHECK_FUNCS([memmove])
102 AC_CHECK_FUNCS([memset])
103 AC_CHECK_FUNCS([pipe2])
104 AC_CHECK_FUNCS([select])
105 AC_CHECK_FUNCS([setenv])
106 AC_CHECK_FUNCS([socket])
107 AC_CHECK_FUNCS([sqrt])
108 AC_CHECK_FUNCS([strcasecmp])
109 AC_CHECK_FUNCS([strchr])
110 AC_CHECK_FUNCS([strdup])
111 AC_CHECK_FUNCS([strerror])
112 AC_CHECK_FUNCS([strtol])
113 AC_CHECK_FUNCS([strtoul])
114 AC_CHECK_FUNCS([strtoull])
115
116 AC_CHECK_HEADERS([arpa/inet.h])
117 AC_CHECK_HEADERS([errno.h])
118 AC_CHECK_HEADERS([execinfo.h])
119 AC_CHECK_HEADERS([fcntl.h])
120 AC_CHECK_HEADERS([inttypes.h])
121 AC_CHECK_HEADERS([libintl.h])
122 AC_CHECK_HEADERS([limits.h])
123 AC_CHECK_HEADERS([malloc.h])
124 AC_CHECK_HEADERS([math.h])
125 AC_CHECK_HEADERS([netdb.h])
126 AC_CHECK_HEADERS([netinet/in.h])
127 AC_CHECK_HEADERS([pthread.h])
128 AC_CHECK_HEADERS([stdarg.h])
129 AC_CHECK_HEADERS([stddef.h])
130 AC_CHECK_HEADERS([stdlib.h])
131 AC_CHECK_HEADERS([sys/time.h])
132 AC_CHECK_HEADERS([unistd.h])
133 AC_CHECK_HEADERS([cxxabi.h],
134 AC_DEFINE([HAVE_CXXABI_H], [1], [Have cxxabi.h]),
135 AC_DEFINE([HAVE_CXXABI_H], [0], [Have cxxabi.h]))
136
137 AC_CHECK_HEADERS([sys/sysctl.h])
138
139 AC_CHECK_HEADER(umem.h, [
140 AC_DEFINE([HAVE_UMEM_H], 1,
141 [Define this if you have umem.h])
142 build_cache=no
143 ], [build_cache=yes])
144
145 AM_CONDITIONAL([BUILD_CACHE], [test "x$build_cache" = "xyes"])
146
147 AX_COMPILER_VENDOR
148
149 AC_FUNC_ALLOCA
150 AC_FUNC_ERROR_AT_LINE
151 AC_FUNC_FORK
152 AC_FUNC_MALLOC
153 AC_FUNC_REALLOC
154 AC_FUNC_STRERROR_R
155 AC_HEADER_STDBOOL
156 AC_TYPE_INT16_T
157 AC_TYPE_INT32_T
158 AC_TYPE_INT64_T
159 AC_TYPE_INT8_T
160 AC_TYPE_OFF_T
161 AC_TYPE_PID_T
162 AC_TYPE_SSIZE_T
163 AC_TYPE_UINT16_T
164 AC_TYPE_UINT32_T
165 AC_TYPE_UINT64_T
166 AC_TYPE_UINT8_T
167
168 AC_C_BIGENDIAN
169 AC_C_CONST
170 AC_C_INLINE
171 AC_C_VOLATILE
172 AC_C_RESTRICT
173
174 AX_CXX_GCC_ABI_DEMANGLE
175
176 AX_SASL_CHECK
177
178 dnl
179 dnl The sasl functions should only be visible if we build with sasl support
180 dnl
181 AS_IF([test "x$ac_enable_sasl" = "xyes"], [
182 [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1" ]
183 ], [
184 [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 0" ]
185 ])
186 AC_SUBST(LIBMEMCACHED_WITH_SASL_SUPPORT)
187
188 AX_CHECK_LIBRARY([LIBUUID], [uuid/uuid.h], [uuid],
189 [
190 LIBUUID_LDFLAGS="-luuid"
191 AC_DEFINE([HAVE_LIBUUID], [ 1 ], [Have libuuid])
192 ],
193 [
194 AC_DEFINE([HAVE_LIBUUID], [ 0 ], [Have libuuid])
195 ])
196
197 AC_CHECK_LIB([rt], [clock_gettime],
198 [
199 RT_LIB="-lrt"
200 AC_SUBST(RT_LIB)
201 AC_DEFINE([HAVE_LIBRT], [ 1 ], [Have clock_gettime])
202 ],
203 [
204 AC_DEFINE([HAVE_LIBRT], [ 0 ], [Have clock_gettime])
205 ])
206
207 AC_CHECK_LIB([m], [floor])
208 AC_CHECK_FUNCS([sigignore])
209
210 AC_CHECK_HEADERS([atomic.h])
211 AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"],[
212 AC_CHECK_FUNCS(atomic_add_64)
213 AC_CHECK_FUNCS(atomic_add_32)
214 AS_IF([test "x$ac_cv_func_atomic_add_64" = "xyes" -a "x$ac_cv_func_atomic_add_32" = "xyes"],[
215 AC_DEFINE([USE_ATOMIC_H],
216 [1],
217 [Define to true if you want to use functions from atomic.h])])])
218
219 AC_DEFINE([HAVE_LIBDRIZZLE], [0], [Support for libdrizzle])
220 AC_DEFINE([HAVE_DRIZZLED_BINARY], [0], [Support for DrizzleD])
221 AC_DEFINE([DRIZZLED_BINARY], [0], [Support for DrizzleD])
222 AC_DEFINE([GEARMAND_BLOBSLAP_WORKER], [0], [Support for Gearman Blobslap worker])
223 AC_DEFINE([HAVE_LIBPQ], [0], [Support for Postgres])
224 AC_DEFINE([HAVE_LIBCURL], [0], [Support for libcurl])
225
226 AC_DEFINE([HAVE_MEMCACHED_LIGHT_BINARY], [1], [Support for memcached_light])
227 AC_DEFINE([MEMCACHED_LIGHT_BINARY], ["example/memcached_light"], [Support for memcached_light])
228
229 dnl Check for the requirements for running memcached with less privileges
230 dnl than the default privilege set. On Solaris we need setppriv and priv.h
231 dnl If you want to add support for other platforms you should check for
232 dnl your requirements, define HAVE_DROP_PRIVILEGES, and make sure you add
233 dnl the source file containing the implementation into memcached_SOURCE
234 dnl in Makefile.am
235 AC_CHECK_FUNCS(setppriv, [
236 AC_CHECK_HEADER(priv.h, [
237 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1,
238 [Define this if you have an implementation of drop_privileges()])
239 build_solaris_privs=yes
240 ], [])
241 ],[])
242
243 AC_CHECK_HEADERS_ONCE(winsock2.h poll.h sys/wait.h fnmatch.h)
244 AM_CONDITIONAL(BUILD_POLL, test "x$ac_cv_header_poll_h" = "xno")
245 AM_CONDITIONAL(BUILD_WIN32_WRAPPERS, test "x$ac_cv_header_winsock2_h" = "xyes")
246 AS_IF(test "x$ac_cv_header_winsock2_h" = "xyes",
247 [AM_LDFLAGS="$AM_LDFLAGS -lws2_32"
248 AM_CFLAGS="$AM_CFLAGS $NO_WERROR"
249 AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR"
250 ])
251 SOCKET_SEND_FLAGS
252
253 AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event],
254 [
255 LIBEVENT_LDFLAGS="-levent"
256 ],
257 [
258 AC_MSG_WARN([Unable to find libevent])
259 ])
260 AM_CONDITIONAL(HAVE_LIBEVENT, test "x${ax_cv_have_LIBEVENT}" = "xyes")
261
262 dnl Check if we're a little-endian or a big-endian system, needed by hash code
263 AC_DEFUN([AC_C_ENDIAN],
264 [AC_CACHE_CHECK(for endianness, ac_cv_c_endian,
265 [
266 AC_RUN_IFELSE(
267 [AC_LANG_PROGRAM([], [dnl
268 long val = 1;
269 char *c = (char *) &val;
270 exit(*c == 1);
271 ])
272 ],[
273 ac_cv_c_endian=big
274 ],[
275 ac_cv_c_endian=little
276 ])
277 ])
278 if test $ac_cv_c_endian = big; then
279 AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian])
280 fi
281 if test $ac_cv_c_endian = little; then
282 AC_DEFINE(ENDIAN_LITTLE, 1, [machine is littleendian])
283 fi
284 ])
285
286 AX_CHECK_SOCK_CLOEXEC([AC_DEFINE([HAVE_SOCK_CLOEXEC], [1], [Check for SOCK_CLOEXEC.])],
287 [AC_DEFINE([HAVE_SOCK_CLOEXEC], [0], [Check for SOCK_CLOEXEC.])])
288
289 AX_PTHREAD(, [AC_MSG_ERROR(could not find libpthread)])
290
291 AX_HARDEN_COMPILER_FLAGS
292
293 AX_DEBUG
294
295 AC_CONFIG_FILES([
296 Makefile
297 docs/conf.py
298 libhashkit-1.0/configure.h
299 libmemcached-1.0/configure.h
300 libmemcached-1.2/configure.h
301 libmemcached-2.0/configure.h
302 support/libmemcached.pc
303 support/libmemcached.spec
304 support/libmemcached-fc.spec
305 ])
306 AC_OUTPUT
307
308 echo "---"
309 echo "Configuration summary for $PACKAGE_NAME version $VERSION"
310 echo ""
311 echo " * Installation prefix: $prefix"
312 echo " * System type: $host_vendor-$host_os"
313 echo " * Host CPU: $host_cpu"
314 echo " * C Compiler: $CC_VERSION"
315 echo " * Assertions enabled: $ac_cv_assert"
316 echo " * Debug enabled: $with_debug"
317 echo " * Warnings as failure: $ac_cv_warnings_as_errors"
318 echo " * SASL support: $ac_enable_sasl"
319 echo ""
320 echo "---"
321
322 case "$host_os" in
323 *freebsd*)
324 echo "*****"
325 echo "*"
326 echo "* NOTE: You are on FreeBSD. BSD make will not work."
327 echo "*"
328 echo "* use 'gmake' To build libmemcached"
329 echo "*"
330 echo "*****"
331 ;;
332 esac
333