1dnl $Id$ 2dnl config.m4 for extension redis 3 4PHP_ARG_ENABLE(redis, whether to enable redis support, 5dnl Make sure that the comment is aligned: 6[ --enable-redis Enable redis support]) 7 8PHP_ARG_ENABLE(redis-session, whether to enable sessions, 9[ --disable-redis-session Disable session support], yes, no) 10 11PHP_ARG_ENABLE(redis-json, whether to enable json serializer support, 12[ --disable-redis-json Disable json serializer support], yes, no) 13 14PHP_ARG_ENABLE(redis-igbinary, whether to enable igbinary serializer support, 15[ --enable-redis-igbinary Enable igbinary serializer support], no, no) 16 17PHP_ARG_ENABLE(redis-msgpack, whether to enable msgpack serializer support, 18[ --enable-redis-msgpack Enable msgpack serializer support], no, no) 19 20PHP_ARG_ENABLE(redis-lzf, whether to enable lzf compression, 21[ --enable-redis-lzf Enable lzf compression support], no, no) 22 23PHP_ARG_WITH(liblzf, use system liblzf, 24[ --with-liblzf[=DIR] Use system liblzf], no, no) 25 26PHP_ARG_ENABLE(redis-zstd, whether to enable Zstd compression, 27[ --enable-redis-zstd Enable Zstd compression support], no, no) 28 29PHP_ARG_WITH(libzstd, use system libsztd, 30[ --with-libzstd[=DIR] Use system libzstd], yes, no) 31 32PHP_ARG_ENABLE(redis-lz4, whether to enable lz4 compression, 33[ --enable-redis-lz4 Enable lz4 compression support], no, no) 34 35PHP_ARG_WITH(liblz4, use system liblz4, 36[ --with-liblz4[=DIR] Use system liblz4], no, no) 37 38if test "$PHP_REDIS" != "no"; then 39 40 if test "$PHP_REDIS_SESSION" != "no"; then 41 AC_DEFINE(PHP_SESSION,1,[redis sessions]) 42 fi 43 44 AC_MSG_CHECKING([for hash includes]) 45 hash_inc_path="" 46 if test -f "$abs_srcdir/include/php/ext/hash/php_hash.h"; then 47 hash_inc_path="$abs_srcdir/include/php" 48 elif test -f "$abs_srcdir/ext/hash/php_hash.h"; then 49 hash_inc_path="$abs_srcdir" 50 elif test -f "$phpincludedir/ext/hash/php_hash.h"; then 51 hash_inc_path="$phpincludedir" 52 else 53 for i in php php7; do 54 if test -f "$prefix/include/$i/ext/hash/php_hash.h"; then 55 hash_inc_path="$prefix/include/$i" 56 fi 57 done 58 fi 59 60 if test "$hash_inc_path" = ""; then 61 AC_MSG_ERROR([Cannot find php_hash.h]) 62 else 63 AC_MSG_RESULT([$hash_inc_path]) 64 fi 65 66 if test "$PHP_REDIS_JSON" != "no"; then 67 AC_MSG_CHECKING([for json includes]) 68 json_inc_path="" 69 if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then 70 json_inc_path="$abs_srcdir/include/php" 71 elif test -f "$abs_srcdir/ext/json/php_json.h"; then 72 json_inc_path="$abs_srcdir" 73 elif test -f "$phpincludedir/ext/json/php_json.h"; then 74 json_inc_path="$phpincludedir" 75 else 76 for i in php php7; do 77 if test -f "$prefix/include/$i/ext/json/php_json.h"; then 78 json_inc_path="$prefix/include/$i" 79 fi 80 done 81 fi 82 83 if test "$json_inc_path" = ""; then 84 AC_MSG_ERROR([Cannot find php_json.h]) 85 else 86 AC_MSG_RESULT([$json_inc_path]) 87 fi 88 fi 89 90 AC_MSG_CHECKING([for redis json support]) 91 if test "$PHP_REDIS_JSON" != "no"; then 92 AC_MSG_RESULT([enabled]) 93 AC_DEFINE(HAVE_REDIS_JSON,1,[Whether redis json serializer is enabled]) 94 JSON_INCLUDES="-I$json_inc_path" 95 JSON_EXT_DIR="$json_inc_path/ext" 96 ifdef([PHP_ADD_EXTENSION_DEP], 97 [ 98 PHP_ADD_EXTENSION_DEP(redis, json) 99 ]) 100 PHP_ADD_INCLUDE($JSON_EXT_DIR) 101 else 102 JSON_INCLUDES="" 103 AC_MSG_RESULT([disabled]) 104 fi 105 106 if test "$PHP_REDIS_IGBINARY" != "no"; then 107 AC_MSG_CHECKING([for igbinary includes]) 108 igbinary_inc_path="" 109 110 if test -f "$abs_srcdir/include/php/ext/igbinary/igbinary.h"; then 111 igbinary_inc_path="$abs_srcdir/include/php" 112 elif test -f "$abs_srcdir/ext/igbinary/igbinary.h"; then 113 igbinary_inc_path="$abs_srcdir" 114 elif test -f "$phpincludedir/ext/igbinary/igbinary.h"; then 115 igbinary_inc_path="$phpincludedir" 116 else 117 for i in php php7; do 118 if test -f "$prefix/include/$i/ext/igbinary/igbinary.h"; then 119 igbinary_inc_path="$prefix/include/$i" 120 fi 121 done 122 fi 123 124 if test "$igbinary_inc_path" = ""; then 125 AC_MSG_ERROR([Cannot find igbinary.h]) 126 else 127 AC_MSG_RESULT([$igbinary_inc_path]) 128 fi 129 fi 130 131 AC_MSG_CHECKING([for redis igbinary support]) 132 if test "$PHP_REDIS_IGBINARY" != "no"; then 133 AC_MSG_RESULT([enabled]) 134 AC_DEFINE(HAVE_REDIS_IGBINARY,1,[Whether redis igbinary serializer is enabled]) 135 IGBINARY_INCLUDES="-I$igbinary_inc_path" 136 IGBINARY_EXT_DIR="$igbinary_inc_path/ext" 137 ifdef([PHP_ADD_EXTENSION_DEP], 138 [ 139 PHP_ADD_EXTENSION_DEP(redis, igbinary) 140 ]) 141 PHP_ADD_INCLUDE($IGBINARY_EXT_DIR) 142 else 143 IGBINARY_INCLUDES="" 144 AC_MSG_RESULT([disabled]) 145 fi 146 147 if test "$PHP_REDIS_MSGPACK" != "no"; then 148 AC_MSG_CHECKING([for msgpack includes]) 149 msgpack_inc_path="" 150 151 if test -f "$abs_srcdir/include/php/ext/msgpack/php_msgpack.h"; then 152 msgpack_inc_path="$abs_srcdir/include/php" 153 elif test -f "$abs_srcdir/ext/msgpack/php_msgpack.h"; then 154 msgpack_inc_path="$abs_srcdir" 155 elif test -f "$phpincludedir/ext/msgpack/php_msgpack.h"; then 156 msgpack_inc_path="$phpincludedir" 157 else 158 for i in php php7; do 159 if test -f "$prefix/include/$i/ext/msgpack/php_msgpack.h"; then 160 msgpack_inc_path="$prefix/include/$i" 161 fi 162 done 163 fi 164 165 if test "$msgpack_inc_path" = ""; then 166 AC_MSG_ERROR([Cannot find php_msgpack.h]) 167 else 168 AC_MSG_RESULT([$msgpack_inc_path]) 169 fi 170 fi 171 172 if test "$PHP_REDIS_MSGPACK" != "no"; then 173 AC_MSG_CHECKING([for php msgpack version >= 2.0.3]) 174 MSGPACK_VERSION=`$EGREP "define PHP_MSGPACK_VERSION" $msgpack_inc_path/ext/msgpack/php_msgpack.h | $SED -e 's/[[^0-9\.]]//g'` 175 if test `echo $MSGPACK_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000 + $2*100 + $3*10 + $4}'` -lt 2030; then 176 AC_MSG_ERROR([version >= 2.0.3 required]) 177 else 178 AC_MSG_RESULT([yes]) 179 fi 180 181 AC_DEFINE(HAVE_REDIS_MSGPACK,1,[Whether redis msgpack serializer is enabled]) 182 MSGPACK_INCLUDES="-I$msgpack_inc_path" 183 MSGPACK_EXT_DIR="$msgpack_inc_path/ext" 184 ifdef([PHP_ADD_EXTENSION_DEP], 185 [ 186 PHP_ADD_EXTENSION_DEP(redis, msgpack) 187 ]) 188 PHP_ADD_INCLUDE($MSGPACK_EXT_DIR) 189 else 190 MSGPACK_INCLUDES="" 191 fi 192 193 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 194 195 if test "$PHP_REDIS_LZF" != "no"; then 196 AC_DEFINE(HAVE_REDIS_LZF, 1, [ ]) 197 198 if test "$PHP_LIBLZF" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists liblzf; then 199 AC_MSG_CHECKING(for liblzf using pkg-config) 200 201 LIBLZF_INC=`$PKG_CONFIG liblzf --cflags` 202 LIBLZF_LIB=`$PKG_CONFIG liblzf --libs` 203 LIBLZF_VER=`$PKG_CONFIG liblzf --modversion` 204 AC_MSG_RESULT(found version $LIBLZF_VER) 205 PHP_EVAL_LIBLINE($LIBLZF_LIB, REDIS_SHARED_LIBADD) 206 PHP_EVAL_INCLINE($LIBLZF_INC) 207 208 elif test "$PHP_LIBLZF" != "no"; then 209 AC_MSG_CHECKING(for liblzf files in default path) 210 for i in $PHP_LIBLZF /usr/local /usr; do 211 if test -r $i/include/lzf.h; then 212 AC_MSG_RESULT(found in $i) 213 LIBLZF_DIR=$i 214 break 215 fi 216 done 217 if test -z "$LIBLZF_DIR"; then 218 AC_MSG_RESULT([not found]) 219 AC_MSG_ERROR([Please reinstall the liblzf distribution]) 220 fi 221 PHP_CHECK_LIBRARY(lzf, lzf_compress, 222 [ 223 PHP_ADD_LIBRARY_WITH_PATH(lzf, $LIBLZF_DIR/$PHP_LIBDIR, REDIS_SHARED_LIBADD) 224 ], [ 225 AC_MSG_ERROR([could not find usable liblzf]) 226 ], [ 227 -L$LIBLZF_DIR/$PHP_LIBDIR 228 ]) 229 else 230 PHP_ADD_INCLUDE(liblzf) 231 PHP_ADD_INCLUDE($srcdir/liblzf) 232 PHP_ADD_BUILD_DIR(liblzf) 233 lzf_sources="liblzf/lzf_c.c liblzf/lzf_d.c" 234 fi 235 fi 236 237 if test "$PHP_REDIS_LZ4" != "no"; then 238 AC_DEFINE(HAVE_REDIS_LZ4, 1, [ ]) 239 240 if test "$PHP_LIBLZ4" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists liblz4; then 241 AC_MSG_CHECKING(for liblz4 using pkg-config) 242 243 LIBLZ4_VER=`$PKG_CONFIG liblz4 --modversion` 244 LIBLZ4_INC=`$PKG_CONFIG liblz4 --cflags` 245 LIBLZ4_LIB=`$PKG_CONFIG liblz4 --libs` 246 AC_MSG_RESULT(found version $LIBLZ4_VER) 247 PHP_EVAL_LIBLINE($LIBLZ4_LIB, REDIS_SHARED_LIBADD) 248 PHP_EVAL_INCLINE($LIBLZ4_INC) 249 250 elif test "$PHP_LIBLZ4" != "no"; then 251 AC_MSG_CHECKING(for liblz4 files in default path) 252 for i in $PHP_LIBLZ4 /usr/local /usr; do 253 if test -r $i/include/lz4.h; then 254 AC_MSG_RESULT(found in $i) 255 LIBLZ4_DIR=$i 256 break 257 fi 258 done 259 if test -z "$LIBLZ4_DIR"; then 260 AC_MSG_RESULT([not found]) 261 AC_MSG_ERROR([Please reinstall the liblz4 distribution]) 262 fi 263 PHP_CHECK_LIBRARY(lz4, LZ4_compress, 264 [ 265 PHP_ADD_LIBRARY_WITH_PATH(lz4, $LIBLZ4_DIR/$PHP_LIBDIR, REDIS_SHARED_LIBADD) 266 ], [ 267 AC_MSG_ERROR([could not find usable liblz4]) 268 ], [ 269 -L$LIBLZ4_DIR/$PHP_LIBDIR 270 ]) 271 PHP_SUBST(REDIS_SHARED_LIBADD) 272 else 273 AC_MSG_ERROR([only system liblz4 is supported]) 274 fi 275 fi 276 277 if test "$PHP_REDIS_ZSTD" != "no"; then 278 AC_DEFINE(HAVE_REDIS_ZSTD, 1, [ ]) 279 280 if test "$PHP_LIBZSTD" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzstd; then 281 AC_MSG_CHECKING(for libzstd using pkg-config) 282 283 LIBZSTD_VER=`$PKG_CONFIG libzstd --modversion` 284 if $PKG_CONFIG libzstd --atleast-version 1.3.0; then 285 LIBZSTD_INC=`$PKG_CONFIG libzstd --cflags` 286 LIBZSTD_LIB=`$PKG_CONFIG libzstd --libs` 287 AC_MSG_RESULT(found version $LIBZSTD_VER) 288 PHP_EVAL_LIBLINE($LIBZSTD_LIB, REDIS_SHARED_LIBADD) 289 PHP_EVAL_INCLINE($LIBZSTD_INC) 290 else 291 AC_MSG_ERROR([found version $LIBZSTD_VER, version 1.3.0 required]) 292 fi 293 294 elif test "$PHP_LIBZSTD" != "no"; then 295 AC_MSG_CHECKING(for libzstd files in default path) 296 for i in $PHP_LIBZSTD /usr/local /usr; do 297 if test -r $i/include/zstd.h; then 298 AC_MSG_RESULT(found in $i) 299 LIBZSTD_DIR=$i 300 break 301 fi 302 done 303 if test -z "$LIBZSTD_DIR"; then 304 AC_MSG_RESULT([not found]) 305 AC_MSG_ERROR([Please reinstall the libzstd distribution]) 306 fi 307 PHP_CHECK_LIBRARY(zstd, ZSTD_getFrameContentSize, 308 [ 309 PHP_ADD_LIBRARY_WITH_PATH(zstd, $LIBZSTD_DIR/$PHP_LIBDIR, REDIS_SHARED_LIBADD) 310 ], [ 311 AC_MSG_ERROR([could not find usable libzstd, version 1.3.0 required]) 312 ], [ 313 -L$LIBZSTD_DIR/$PHP_LIBDIR 314 ]) 315 else 316 AC_MSG_ERROR([only system libzstd is supported]) 317 fi 318 fi 319 320 AC_CHECK_PROG([GIT], [git], [yes], [no]) 321 if test "$GIT" = "yes" && test -d "$srcdir/.git"; then 322 AC_DEFINE_UNQUOTED(GIT_REVISION, ["$(git log -1 --format=%H)"], [ ]) 323 fi 324 325 PHP_SUBST(REDIS_SHARED_LIBADD) 326 PHP_NEW_EXTENSION(redis, redis.c redis_commands.c library.c redis_session.c redis_array.c redis_array_impl.c redis_cluster.c cluster_library.c redis_sentinel.c sentinel_library.c backoff.c $lzf_sources, $ext_shared) 327fi 328