docs: cmake build
[m6w6/libmemcached] / m4 / ax_libmemcached.m4
1 # ===========================================================================
2 # https//libmemcached.org/
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_LIBMEMCACHED, AX_LIBMEMCACHED_UTIL, AX_ENABLE_LIBMEMCACHED
8 #
9 # DESCRIPTION
10 #
11 # Checked for installation of libmemcached
12 #
13 # AC_SUBST(LIBMEMCACHED_CFLAGS)
14 # AC_SUBST(LIBMEMCACHED_LDFLAGS)
15 # AC_SUBST(LIBMEMCACHED_UTIL_LDFLAGS)
16 #
17 # NOTE: Implementation uses AC_CHECK_HEADER.
18 #
19 # LICENSE
20 #
21 # Copyright (C) 2012 Brian Aker
22 # All rights reserved.
23 #
24 # Redistribution and use in source and binary forms, with or without
25 # modification, are permitted provided that the following conditions are
26 # met:
27 #
28 # * Redistributions of source code must retain the above copyright
29 # notice, this list of conditions and the following disclaimer.
30 #
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
34 # distribution.
35 #
36 # * The names of its contributors may not be used to endorse or
37 # promote products derived from this software without specific prior
38 # written permission.
39 #
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.
51
52 #serial 1
53
54 AC_DEFUN([AX_LIBMEMCACHED], [
55 AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [
56 AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [
57 AC_LANG_PUSH([C])
58 AX_SAVE_FLAGS
59 LIBS="-lmemcached $LIBS"
60 AC_RUN_IFELSE([
61 AC_LANG_PROGRAM([#include <libmemcached-1.0/memcached.h>], [
62 memcached_st *memc;
63 memc= memcached(NULL, 0);
64 memcached_free(memc);
65 ])],
66 [ax_cv_libmemcached=yes],
67 [ax_cv_libmemcached=no],
68 [AC_MSG_WARN([test program execution failed])])
69 AC_LANG_POP
70 AX_RESTORE_FLAGS
71 ])
72 ])
73
74 AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [
75 AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h])
76 ],[
77 AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h])
78 ])
79 ])
80
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], [
86 AX_SAVE_FLAGS
87 AC_LANG_PUSH([C])
88 LIBS="-lmemcachedutil -lmemcached $LIBS"
89 AC_RUN_IFELSE([
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);
93 ])],
94 [ax_cv_libmemcached_util=yes],
95 [ax_cv_libmemcached_util=no],
96 [AC_MSG_WARN([test program execution failed])])
97 AC_LANG_POP
98 AX_RESTORE_FLAGS
99 ])
100 ])
101 ])
102
103 AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
104 AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h])
105 ],[
106 AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h])
107 ])
108 ])
109
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"])
117
118 AS_IF([test "x$ax_cv_libmemcached" != "xyes"], [
119 ax_enable_libmemcached="not found"
120 ])
121
122 AS_IF([test "x$ax_enable_libmemcached" = "xyes"], [
123 AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enable libmemcached support])
124 LIBMEMCACHED_CFLAGS=
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])
131 ])
132 ],[
133 AC_DEFINE([HAVE_LIBMEMCACHED], [0], [Enable libmemcached support])
134 ])
135 AM_CONDITIONAL(HAVE_LIBMEMCACHED, test "x${ax_enable_libmemcached}" = "xyes")
136 ])
137
138 AC_DEFUN([AX_ENABLE_LIBMEMCACHED], [ AC_REQUIRE([_ENABLE_LIBMEMCACHED]) ])