1 # ===========================================================================
2 # https//libmemcached.org/
3 # ===========================================================================
7 # AX_LIBMEMCACHED, AX_LIBMEMCACHED_UTIL, AX_ENABLE_LIBMEMCACHED
11 # Checked for installation of libmemcached
13 # AC_SUBST(LIBMEMCACHED_CFLAGS)
14 # AC_SUBST(LIBMEMCACHED_LDFLAGS)
15 # AC_SUBST(LIBMEMCACHED_UTIL_LDFLAGS)
17 # NOTE: Implementation uses AC_CHECK_HEADER.
21 # Copyright (C) 2012 Brian Aker
22 # All rights reserved.
24 # Redistribution and use in source and binary forms, with or without
25 # modification, are permitted provided that the following conditions are
28 # * Redistributions of source code must retain the above copyright
29 # notice, this list of conditions and the following disclaimer.
31 # * Redistributions in binary form must reproduce the above
32 # copyright notice, this list of conditions and the following disclaimer
33 # in the documentation and/or other materials provided with the
36 # * The names of its contributors may not be used to endorse or
37 # promote products derived from this software without specific prior
40 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 AC_DEFUN([AX_LIBMEMCACHED], [
55 AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [
56 AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [
59 LIBS="-lmemcached $LIBS"
61 AC_LANG_PROGRAM([#include <libmemcached-1.0/memcached.h>], [
63 memc= memcached(NULL, 0);
66 [ax_cv_libmemcached=yes],
67 [ax_cv_libmemcached=no],
68 [AC_MSG_WARN([test program execution failed])])
74 AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [
75 AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h])
77 AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h])
81 AC_DEFUN([AX_LIBMEMCACHED_UTIL], [
82 AC_REQUIRE([AX_LIBMEMCACHED])
83 AS_IF([test "$ax_cv_libmemcached" = yes], [
84 AC_CHECK_HEADER([libmemcachedutil-1.0/util.h], [
85 AC_CACHE_CHECK([check for -lmemcachedutil], [ax_cv_libmemcached_util], [
88 LIBS="-lmemcachedutil -lmemcached $LIBS"
90 AC_LANG_PROGRAM([#include <libmemcachedutil-1.0/util.h>], [
91 memcached_pool_st *memc_pool= memcached_pool_create(NULL, 0, 3);
92 memcached_pool_destroy(memc_pool);
94 [ax_cv_libmemcached_util=yes],
95 [ax_cv_libmemcached_util=no],
96 [AC_MSG_WARN([test program execution failed])])
103 AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
104 AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h])
106 AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h])
110 AC_DEFUN([_ENABLE_LIBMEMCACHED], [
111 AC_REQUIRE([AX_LIBMEMCACHED_UTIL])
112 AC_ARG_ENABLE([libmemcached],
113 [AS_HELP_STRING([--disable-libmemcached],
114 [Build with libmemcached support @<:@default=on@:>@])],
115 [ax_enable_libmemcached="$enableval"],
116 [ax_enable_libmemcached="yes"])
118 AS_IF([test "x$ax_cv_libmemcached" != "xyes"], [
119 ax_enable_libmemcached="not found"
122 AS_IF([test "x$ax_enable_libmemcached" = "xyes"], [
123 AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enable libmemcached support])
125 AC_SUBST([LIBMEMCACHED_CFLAGS])
126 LIBMEMCACHED_LDFLAGS="-lmemcached"
127 AC_SUBST([LIBMEMCACHED_LDFLAGS])
128 AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
129 LIBMEMCACHED_UTIL_LDFLAGS="-lmemcached -lmemcachedutil"
130 AC_SUBST([LIBMEMCACHED_UTIL_LDFLAGS])
133 AC_DEFINE([HAVE_LIBMEMCACHED], [0], [Enable libmemcached support])
135 AM_CONDITIONAL(HAVE_LIBMEMCACHED, test "x${ax_enable_libmemcached}" = "xyes")
138 AC_DEFUN([AX_ENABLE_LIBMEMCACHED], [ AC_REQUIRE([_ENABLE_LIBMEMCACHED]) ])