1dnl vim:se ts=2 sw=2 et: 2 3PHP_ARG_ENABLE(memcached, whether to enable memcached support, 4[ --enable-memcached Enable memcached support]) 5 6PHP_ARG_WITH(libmemcached-dir, for libmemcached, 7[ --with-libmemcached-dir=DIR Set the path to libmemcached install prefix.], yes) 8 9PHP_ARG_ENABLE(memcached-session, whether to enable memcached session handler support, 10[ --enable-memcached-session Enable memcached session handler support], yes, no) 11 12PHP_ARG_ENABLE(memcached-igbinary, whether to enable memcached igbinary serializer support, 13[ --enable-memcached-igbinary Enable memcached igbinary serializer support], no, no) 14 15PHP_ARG_ENABLE(memcached-json, whether to enable memcached json serializer support, 16[ --enable-memcached-json Enable memcached json serializer support], no, no) 17 18PHP_ARG_ENABLE(memcached-msgpack, whether to enable memcached msgpack serializer support, 19[ --enable-memcached-msgpack Enable memcached msgpack serializer support], no, no) 20 21PHP_ARG_ENABLE(memcached-sasl, whether to enable memcached sasl support, 22[ --enable-memcached-sasl Enable memcached sasl support], yes, no) 23 24PHP_ARG_ENABLE(memcached-protocol, whether to enable memcached protocol support, 25[ --enable-memcached-protocol Enable memcached protocol support], no, no) 26 27PHP_ARG_WITH(system-fastlz, whether to use system FastLZ library, 28[ --with-system-fastlz Use system FastLZ library], no, no) 29 30if test -z "$PHP_ZLIB_DIR"; then 31PHP_ARG_WITH(zlib-dir, for ZLIB, 32[ --with-zlib-dir=DIR Set the path to ZLIB install prefix.], no) 33fi 34 35if test -z "$PHP_DEBUG"; then 36 AC_ARG_ENABLE(debug, 37 [ --enable-debug Compile with debugging symbols],[ 38 PHP_DEBUG=$enableval 39 ],[ PHP_DEBUG=no 40 ]) 41fi 42 43if test "$PHP_MEMCACHED" != "no"; then 44 45 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 46 if test "x$PKG_CONFIG" = "xno"; then 47 AC_MSG_RESULT([pkg-config not found]) 48 AC_MSG_ERROR([Please reinstall the pkg-config distribution]) 49 fi 50 51 dnl # zlib 52 if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then 53 if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then 54 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 55 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib" 56 elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then 57 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 58 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include" 59 else 60 AC_MSG_ERROR([Can't find ZLIB headers under "$PHP_ZLIB_DIR"]) 61 fi 62 else 63 for i in /usr/local /usr/local/opt/zlib /usr; do 64 if test -f "$i/include/zlib/zlib.h"; then 65 PHP_ZLIB_DIR="$i" 66 PHP_ZLIB_INCDIR="$i/include/zlib" 67 elif test -f "$i/include/zlib.h"; then 68 PHP_ZLIB_DIR="$i" 69 PHP_ZLIB_INCDIR="$i/include" 70 fi 71 done 72 fi 73 74 AC_MSG_CHECKING([for zlib location]) 75 if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then 76 AC_MSG_RESULT([$PHP_ZLIB_DIR]) 77 PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD) 78 PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR) 79 else 80 AC_MSG_ERROR([memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located]) 81 fi 82 83 if test "$PHP_MEMCACHED_SESSION" != "no"; then 84 AC_MSG_CHECKING([for session includes]) 85 session_inc_path="" 86 87 if test -f "$abs_srcdir/include/php/ext/session/php_session.h"; then 88 session_inc_path="$abs_srcdir/include/php" 89 elif test -f "$abs_srcdir/ext/session/php_session.h"; then 90 session_inc_path="$abs_srcdir" 91 elif test -f "$phpincludedir/ext/session/php_session.h"; then 92 session_inc_path="$phpincludedir" 93 else 94 for i in php php4 php5 php6; do 95 if test -f "$prefix/include/$i/ext/session/php_session.h"; then 96 session_inc_path="$prefix/include/$i" 97 fi 98 done 99 fi 100 101 if test "$session_inc_path" = ""; then 102 AC_MSG_ERROR([Cannot find php_session.h]) 103 else 104 AC_MSG_RESULT([$session_inc_path]) 105 fi 106 fi 107 108 if test "$PHP_MEMCACHED_JSON" != "no"; then 109 AC_MSG_CHECKING([for json includes]) 110 json_inc_path="" 111 112 if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then 113 json_inc_path="$abs_srcdir/include/php" 114 elif test -f "$abs_srcdir/ext/json/php_json.h"; then 115 json_inc_path="$abs_srcdir" 116 elif test -f "$phpincludedir/ext/json/php_json.h"; then 117 json_inc_path="$phpincludedir" 118 else 119 for i in php php4 php5 php6; do 120 if test -f "$prefix/include/$i/ext/json/php_json.h"; then 121 json_inc_path="$prefix/include/$i" 122 fi 123 done 124 fi 125 if test "$json_inc_path" = ""; then 126 AC_MSG_ERROR([Cannot find php_json.h]) 127 else 128 AC_DEFINE(HAVE_JSON_API,1,[Whether JSON API is available]) 129 AC_MSG_RESULT([$json_inc_path]) 130 fi 131 fi 132 133 if test "$PHP_MEMCACHED_IGBINARY" != "no"; then 134 AC_MSG_CHECKING([for igbinary includes]) 135 igbinary_inc_path="" 136 137 if test -f "$abs_srcdir/include/php/ext/igbinary/igbinary.h"; then 138 igbinary_inc_path="$abs_srcdir/include/php" 139 elif test -f "$abs_srcdir/ext/igbinary/igbinary.h"; then 140 igbinary_inc_path="$abs_srcdir" 141 elif test -f "$phpincludedir/ext/session/igbinary.h"; then 142 igbinary_inc_path="$phpincludedir" 143 elif test -f "$phpincludedir/ext/igbinary/igbinary.h"; then 144 igbinary_inc_path="$phpincludedir" 145 else 146 for i in php php4 php5 php6; do 147 if test -f "$prefix/include/$i/ext/igbinary/igbinary.h"; then 148 igbinary_inc_path="$prefix/include/$i" 149 fi 150 done 151 fi 152 153 if test "$igbinary_inc_path" = ""; then 154 AC_MSG_ERROR([Cannot find igbinary.h]) 155 else 156 AC_MSG_RESULT([$igbinary_inc_path]) 157 fi 158 fi 159 160 if test "$PHP_MEMCACHED_MSGPACK" != "no"; then 161 AC_MSG_CHECKING([for msgpack includes]) 162 msgpack_inc_path="" 163 164 if test -f "$abs_srcdir/include/php/ext/msgpack/php_msgpack.h"; then 165 msgpack_inc_path="$abs_srcdir/include/php" 166 elif test -f "$abs_srcdir/ext/msgpack/php_msgpack.h"; then 167 msgpack_inc_path="$abs_srcdir" 168 elif test -f "$phpincludedir/ext/session/php_msgpack.h"; then 169 msgpack_inc_path="$phpincludedir" 170 elif test -f "$phpincludedir/ext/msgpack/php_msgpack.h"; then 171 msgpack_inc_path="$phpincludedir" 172 else 173 for i in php php4 php5 php6; do 174 if test -f "$prefix/include/$i/ext/msgpack/php_msgpack.h"; then 175 msgpack_inc_path="$prefix/include/$i" 176 fi 177 done 178 fi 179 180 if test "$msgpack_inc_path" = ""; then 181 AC_MSG_ERROR([Cannot find php_msgpack.h]) 182 else 183 AC_MSG_RESULT([$msgpack_inc_path]) 184 fi 185 fi 186 187 AC_MSG_CHECKING([for memcached session support]) 188 if test "$PHP_MEMCACHED_SESSION" != "no"; then 189 AC_MSG_RESULT([enabled]) 190 AC_DEFINE(HAVE_MEMCACHED_SESSION,1,[Whether memcache session handler is enabled]) 191 SESSION_INCLUDES="-I$session_inc_path" 192 ifdef([PHP_ADD_EXTENSION_DEP], 193 [ 194 PHP_ADD_EXTENSION_DEP(memcached, session) 195 ]) 196 else 197 SESSION_INCLUDES="" 198 AC_MSG_RESULT([disabled]) 199 fi 200 201 AC_MSG_CHECKING([for memcached igbinary support]) 202 if test "$PHP_MEMCACHED_IGBINARY" != "no"; then 203 AC_MSG_RESULT([enabled]) 204 AC_DEFINE(HAVE_MEMCACHED_IGBINARY,1,[Whether memcache igbinary serializer is enabled]) 205 IGBINARY_INCLUDES="-I$igbinary_inc_path" 206 ifdef([PHP_ADD_EXTENSION_DEP], 207 [ 208 PHP_ADD_EXTENSION_DEP(memcached, igbinary) 209 ]) 210 else 211 IGBINARY_INCLUDES="" 212 AC_MSG_RESULT([disabled]) 213 fi 214 215 AC_MSG_CHECKING([for memcached msgpack support]) 216 if test "$PHP_MEMCACHED_MSGPACK" != "no"; then 217 AC_MSG_RESULT([enabled]) 218 AC_DEFINE(HAVE_MEMCACHED_MSGPACK,1,[Whether memcache msgpack serializer is enabled]) 219 MSGPACK_INCLUDES="-I$msgpack_inc_path" 220 ifdef([PHP_ADD_EXTENSION_DEP], 221 [ 222 PHP_ADD_EXTENSION_DEP(memcached, msgpack) 223 ]) 224 else 225 MSGPACK_INCLUDES="" 226 AC_MSG_RESULT([disabled]) 227 fi 228 229 AC_MSG_CHECKING([for libmemcached location]) 230 export ORIG_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" 231 232 if test "$PHP_LIBMEMCACHED_DIR" != "no" && test "$PHP_LIBMEMCACHED_DIR" != "yes"; then 233 export PKG_CONFIG_PATH="$PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR/pkgconfig" 234 235 if test ! -f "$PHP_LIBMEMCACHED_DIR/include/libmemcached/memcached.h"; then 236 AC_MSG_ERROR(Unable to find memcached.h under $PHP_LIBMEMCACHED_DIR) 237 fi 238 else 239 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/$PHP_LIBDIR/pkgconfig:/usr/$PHP_LIBDIR/pkgconfig:/opt/$PHP_LIBDIR/pkgconfig" 240 fi 241 242 if ! $PKG_CONFIG --exists libmemcached; then 243 AC_MSG_ERROR([memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located]) 244 else 245 PHP_LIBMEMCACHED_VERSION=`$PKG_CONFIG libmemcached --modversion` 246 PHP_LIBMEMCACHED_DIR=`$PKG_CONFIG libmemcached --variable=prefix` 247 248 AC_MSG_RESULT([found version $PHP_LIBMEMCACHED_VERSION, under $PHP_LIBMEMCACHED_DIR]) 249 250 PHP_LIBMEMCACHED_LIBS=`$PKG_CONFIG libmemcached --libs` 251 PHP_LIBMEMCACHED_INCLUDES=`$PKG_CONFIG libmemcached --cflags` 252 253 PHP_EVAL_LIBLINE($PHP_LIBMEMCACHED_LIBS, MEMCACHED_SHARED_LIBADD) 254 PHP_EVAL_INCLINE($PHP_LIBMEMCACHED_INCLUDES) 255 256 ORIG_CFLAGS="$CFLAGS" 257 CFLAGS="$CFLAGS $INCLUDES" 258 259 dnl # Always check if libmemcached was built with SASL support, 260 dnl # because it will require sasl.h even if not used here. 261 AC_CACHE_CHECK([for libmemcached sasl.h requirement], ac_cv_memc_sasl_support, [ 262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]], [[ 263 #if LIBMEMCACHED_WITH_SASL_SUPPORT 264 /* yes */ 265 #else 266 # error "no sasl support" 267 #endif 268 ]])], 269 [ac_cv_memc_sasl_support="yes"], 270 [ac_cv_memc_sasl_support="no"] 271 ) 272 ]) 273 274 if test "$ac_cv_memc_sasl_support" = "yes"; then 275 AC_CHECK_HEADERS([sasl/sasl.h], [ac_cv_have_memc_sasl_h="yes"], [ac_cv_have_memc_sasl_h="no"]) 276 fi 277 278 dnl # If libmemcached requires sasl.h but we can't find sasl.h, that's a hard error 279 dnl # regardless of the option --enable-memcached-sasl or --disable-memcached-sasl 280 AC_MSG_CHECKING([whether to enable sasl support]) 281 if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "no"; then 282 AC_MSG_ERROR([no, libmemcached built with sasl required, but sasl.h not found.]) 283 fi 284 285 if test "$PHP_MEMCACHED_SASL" != "no"; then 286 AC_MSG_RESULT(yes) 287 if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "yes"; then 288 PHP_CHECK_LIBRARY(sasl2, sasl_client_init, [PHP_ADD_LIBRARY(sasl2, 1, MEMCACHED_SHARED_LIBADD)]) 289 AC_DEFINE(HAVE_MEMCACHED_SASL, 1, [Have SASL support]) 290 else 291 AC_MSG_ERROR([no, libmemcached built with sasl disabled. Run configure with --disable-memcached-sasl or update libmemcached with sasl support]) 292 fi 293 else 294 AC_MSG_RESULT([no]) 295 fi 296 297 ORIG_CFLAGS="$CFLAGS" 298 ORIG_LIBS="$LIBS" 299 300 CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES" 301 LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS" 302 303 AC_CACHE_CHECK([whether memcached_exist is defined], ac_cv_have_memcached_exist, [ 304 AC_LINK_IFELSE( 305 [AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]], 306 [[memcached_exist (NULL, NULL, 0);]])], 307 [ac_cv_have_memcached_exist="yes"], 308 [ac_cv_have_memcached_exist="no"]) 309 ]) 310 311 CFLAGS="$ORIG_CFLAGS" 312 LIBS="$ORIG_LIBS" 313 314 CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES" 315 LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS" 316 317 if test "$ac_cv_have_memcached_exist" = "yes"; then 318 AC_DEFINE(HAVE_MEMCACHED_EXIST, [1], [Whether memcached_exist is defined]) 319 fi 320 321 AC_CACHE_CHECK([whether memcached_set_encoding_key is defined], ac_cv_have_memcached_set_encoding_key, [ 322 AC_LINK_IFELSE( 323 [AC_LANG_PROGRAM([[#include <libmemcached/memcached.h>]], 324 [[memcached_set_encoding_key (NULL, NULL, 0);]])], 325 [ac_cv_have_memcached_set_encoding_key="yes"], 326 [ac_cv_have_memcached_set_encoding_key="no"]) 327 ]) 328 329 CFLAGS="$ORIG_CFLAGS" 330 LIBS="$ORIG_LIBS" 331 332 if test "$ac_cv_have_memcached_set_encoding_key" = "yes"; then 333 AC_DEFINE(HAVE_MEMCACHED_SET_ENCODING_KEY, [1], [Whether memcached_set_encoding_key is defined]) 334 fi 335 336 PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.c g_fmt.c" 337 338 if test "$PHP_SYSTEM_FASTLZ" != "no"; then 339 AC_CHECK_HEADERS([fastlz.h], [ac_cv_have_fastlz="yes"], [ac_cv_have_fastlz="no"]) 340 PHP_CHECK_LIBRARY(fastlz, fastlz_compress, 341 [PHP_ADD_LIBRARY(fastlz, 1, MEMCACHED_SHARED_LIBADD)], 342 [AC_MSG_ERROR(FastLZ library not found)]) 343 else 344 ac_cv_have_fastlz="no" 345 PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} fastlz/fastlz.c" 346 fi 347 348 if test "$PHP_MEMCACHED_SESSION" != "no"; then 349 PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} php_memcached_session.c" 350 fi 351 352 LIBEVENT_INCLUDES="" 353 AC_MSG_CHECKING([for memcached protocol support]) 354 if test "$PHP_MEMCACHED_PROTOCOL" != "no"; then 355 AC_MSG_RESULT([enabled]) 356 357 AC_CACHE_CHECK([whether libmemcachedprotocol is usable], ac_cv_have_libmemcachedprotocol, [ 358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libmemcachedprotocol-0.0/handler.h>]], 359 [[memcached_binary_protocol_callback_st s_test_impl; 360 s_test_impl.interface.v1.delete_object = 0; 361 ]])], 362 [ac_cv_have_libmemcachedprotocol="yes"], 363 [ac_cv_have_libmemcachedprotocol="no"] 364 ) 365 ]) 366 367 if test "$ac_cv_have_libmemcachedprotocol" != "yes"; then 368 AC_MSG_ERROR([Cannot enable libmemcached protocol]) 369 fi 370 371 PHP_ADD_LIBRARY_WITH_PATH(memcachedprotocol, $PHP_LIBMEMCACHED_DIR/$PHP_LIBDIR, MEMCACHED_SHARED_LIBADD) 372 373 AC_MSG_CHECKING([for libevent]) 374 if $PKG_CONFIG --exists libevent; then 375 PHP_MEMCACHED_LIBEVENT_VERSION=`$PKG_CONFIG libevent --modversion` 376 PHP_MEMCACHED_LIBEVENT_PREFIX=`$PKG_CONFIG libevent --variable=prefix` 377 378 AC_MSG_RESULT([found version $PHP_MEMCACHED_LIBEVENT_VERSION, under $PHP_MEMCACHED_LIBEVENT_PREFIX]) 379 LIBEVENT_LIBS=`$PKG_CONFIG libevent --libs` 380 LIBEVENT_INCLUDES=`$PKG_CONFIG libevent --cflags` 381 382 PHP_EVAL_LIBLINE($LIBEVENT_LIBS, MEMCACHED_SHARED_LIBADD) 383 PHP_EVAL_INCLINE($LIBEVENT_INCLUDES) 384 else 385 AC_MSG_ERROR(Unable to find libevent installation) 386 fi 387 PHP_MEMCACHED_FILES="${PHP_MEMCACHED_FILES} php_memcached_server.c" 388 AC_DEFINE(HAVE_MEMCACHED_PROTOCOL,1,[Whether memcached protocol is enabled]) 389 else 390 AC_MSG_RESULT([disabled]) 391 fi 392 393 CFLAGS="$ORIG_CFLAGS" 394 395 export PKG_CONFIG_PATH="$ORIG_PKG_CONFIG_PATH" 396 PHP_SUBST(MEMCACHED_SHARED_LIBADD) 397 398 PHP_NEW_EXTENSION(memcached, $PHP_MEMCACHED_FILES, $ext_shared,,$SESSION_INCLUDES $IGBINARY_INCLUDES $LIBEVENT_INCLUDES $MSGPACK_INCLUDES) 399 if test "ac_cv_have_fastlz" != "yes"; then 400 PHP_ADD_BUILD_DIR($ext_builddir/fastlz, 1) 401 fi 402 403 ifdef([PHP_ADD_EXTENSION_DEP], 404 [ 405 PHP_ADD_EXTENSION_DEP(memcached, spl, true) 406 ]) 407 fi 408fi 409 410