ax_libmemcached.m4 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_LIB)
  15. # AC_SUBST(LIBMEMCACHED_UTIL_LIB)
  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. #serial 2
  52. AC_DEFUN([AX_LIBMEMCACHED], [
  53. AC_CHECK_HEADER([libmemcached-1.0/memcached.h], [
  54. AC_CACHE_CHECK([check for -lmemcached], [ax_cv_libmemcached], [
  55. AC_LANG_PUSH([C])
  56. AX_SAVE_FLAGS
  57. LIBS="-lmemcached $LIBS"
  58. AC_RUN_IFELSE([
  59. AC_LANG_PROGRAM([#include <libmemcached-1.0/memcached.h>], [
  60. memcached_st *memc;
  61. memc= memcached(NULL, 0);
  62. memcached_free(memc);
  63. ])],
  64. [ax_cv_libmemcached=yes],
  65. [ax_cv_libmemcached=no],
  66. [AC_MSG_WARN([test program execution failed])])
  67. AC_LANG_POP
  68. AX_RESTORE_FLAGS
  69. ])
  70. ])
  71. AS_IF([test "x$ax_cv_libmemcached" = "xyes"], [
  72. AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [1], [Have libmemcached-1.0/memcached.h])
  73. ],[
  74. AC_DEFINE([HAVE_LIBMEMCACHED_MEMCACHED_H], [0], [Have libmemcached-1.0/memcached.h])
  75. ])
  76. ])
  77. AC_DEFUN([AX_LIBMEMCACHED_UTIL], [
  78. AC_REQUIRE([AX_LIBMEMCACHED])
  79. AS_IF([test "$ax_cv_libmemcached" = yes], [
  80. AC_CHECK_HEADER([libmemcachedutil-1.0/util.h], [
  81. AC_CACHE_CHECK([check for -lmemcachedutil], [ax_cv_libmemcached_util], [
  82. AX_SAVE_FLAGS
  83. AC_LANG_PUSH([C])
  84. LIBS="-lmemcachedutil -lmemcached $LIBS"
  85. AC_RUN_IFELSE([
  86. AC_LANG_PROGRAM([#include <libmemcachedutil-1.0/util.h>], [
  87. memcached_pool_st *memc_pool= memcached_pool_create(NULL, 0, 3);
  88. memcached_pool_destroy(memc_pool);
  89. ])],
  90. [ax_cv_libmemcached_util=yes],
  91. [ax_cv_libmemcached_util=no],
  92. [AC_MSG_WARN([test program execution failed])])
  93. AC_LANG_POP
  94. AX_RESTORE_FLAGS
  95. ])
  96. ])
  97. ])
  98. AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
  99. AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [1], [Have libmemcachedutil-1.0/util.h])
  100. ],[
  101. AC_DEFINE([HAVE_LIBMEMCACHED_UTIL_H], [0], [Have libmemcachedutil-1.0/util.h])
  102. ])
  103. ])
  104. AC_DEFUN([_ENABLE_LIBMEMCACHED], [
  105. AC_REQUIRE([AX_LIBMEMCACHED_UTIL])
  106. AC_ARG_ENABLE([libmemcached],
  107. [AS_HELP_STRING([--disable-libmemcached],
  108. [Build with libmemcached support @<:@default=on@:>@])],
  109. [ax_enable_libmemcached="$enableval"],
  110. [ax_enable_libmemcached="yes"])
  111. AS_IF([test "x$ax_cv_libmemcached" != "xyes"], [
  112. ax_enable_libmemcached="not found"
  113. ])
  114. AS_IF([test "x$ax_enable_libmemcached" = "xyes"], [
  115. AC_DEFINE([HAVE_LIBMEMCACHED], [1], [Enable libmemcached support])
  116. LIBMEMCACHED_CFLAGS=
  117. AC_SUBST([LIBMEMCACHED_CFLAGS])
  118. LIBMEMCACHED_LIB="-lmemcached"
  119. AC_SUBST([LIBMEMCACHED_LIB])
  120. AS_IF([test "x$ax_cv_libmemcached_util" = "xyes"], [
  121. LIBMEMCACHED_UTIL_LIB="-lmemcachedutil -lmemcached"
  122. AC_SUBST([LIBMEMCACHED_UTIL_LIB])
  123. ])
  124. ],[
  125. AC_DEFINE([HAVE_LIBMEMCACHED], [0], [Enable libmemcached support])
  126. ])
  127. AM_CONDITIONAL(HAVE_LIBMEMCACHED, test "x${ax_enable_libmemcached}" = "xyes")
  128. ])
  129. AC_DEFUN([AX_ENABLE_LIBMEMCACHED], [ AC_REQUIRE([_ENABLE_LIBMEMCACHED]) ])