@@ -106,72 +106,29 @@ if test "$PHP_MEMCACHED" != "no"; then
106106 AC_MSG_RESULT ( [ $session_inc_path] )
107107 fi
108108 fi
109-
109+
110110 if test "$PHP_MEMCACHED_JSON" != "no"; then
111111 AC_MSG_CHECKING ( [ for json includes] )
112112 json_inc_path=""
113-
114- tmp_version=$PHP_VERSION
115- if test -z "$tmp_version"; then
116- if test -z "$PHP_CONFIG"; then
117- AC_MSG_ERROR ( [ php-config not found] )
118- fi
119- PHP_MEMCACHED_VERSION_ORIG=`$PHP_CONFIG --version`;
120- else
121- PHP_MEMCACHED_VERSION_ORIG=$tmp_version
122- fi
123113
124- if test -z $PHP_MEMCACHED_VERSION_ORIG; then
125- AC_MSG_ERROR ( [ failed to detect PHP version, please report] )
114+ if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then
115+ json_inc_path="$abs_srcdir/include/php"
116+ elif test -f "$abs_srcdir/ext/json/php_json.h"; then
117+ json_inc_path="$abs_srcdir"
118+ elif test -f "$phpincludedir/ext/json/php_json.h"; then
119+ json_inc_path="$phpincludedir"
120+ else
121+ for i in php php4 php5 php6; do
122+ if test -f "$prefix/include/$i/ext/json/php_json.h"; then
123+ json_inc_path="$prefix/include/$i"
124+ fi
125+ done
126126 fi
127-
128- PHP_MEMCACHED_VERSION_MASK=`echo ${PHP_MEMCACHED_VERSION_ORIG} | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
129-
130- if test $PHP_MEMCACHED_VERSION_MASK -ge 5003000; then
131- if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then
132- json_inc_path="$abs_srcdir/include/php"
133- elif test -f "$abs_srcdir/ext/json/php_json.h"; then
134- json_inc_path="$abs_srcdir"
135- elif test -f "$phpincludedir/ext/json/php_json.h"; then
136- json_inc_path="$phpincludedir"
137- else
138- for i in php php4 php5 php6; do
139- if test -f "$prefix/include/$i/ext/json/php_json.h"; then
140- json_inc_path="$prefix/include/$i"
141- fi
142- done
143- fi
144- if test "$json_inc_path" = ""; then
145- AC_MSG_ERROR ( [ Cannot find php_json.h] )
146- else
147- AC_DEFINE ( HAVE_JSON_API ,1 ,[ Whether JSON API is available] )
148- AC_DEFINE ( HAVE_JSON_API_5_3 ,1 ,[ Whether JSON API for PHP 5.3 is available] )
149- AC_MSG_RESULT ( [ $json_inc_path] )
150- fi
151- elif test $PHP_MEMCACHED_VERSION_MASK -ge 5002009; then
152- dnl Check JSON for PHP 5.2.9+
153- if test -f "$abs_srcdir/include/php/ext/json/php_json.h"; then
154- json_inc_path="$abs_srcdir/include/php"
155- elif test -f "$abs_srcdir/ext/json/php_json.h"; then
156- json_inc_path="$abs_srcdir"
157- elif test -f "$phpincludedir/ext/json/php_json.h"; then
158- json_inc_path="$phpincludedir"
159- else
160- for i in php php4 php5 php6; do
161- if test -f "$prefix/include/$i/ext/json/php_json.h"; then
162- json_inc_path="$prefix/include/$i"
163- fi
164- done
165- fi
166- if test "$json_inc_path" = ""; then
167- AC_MSG_ERROR ( [ Cannot find php_json.h] )
168- else
169- AC_DEFINE ( HAVE_JSON_API ,1 ,[ Whether JSON API is available] )
170- AC_DEFINE ( HAVE_JSON_API_5_2 ,1 ,[ Whether JSON API for PHP 5.2 is available] )
171- AC_MSG_RESULT ( [ $json_inc_path] )
172- fi
173- else
174- AC_MSG_RESULT ( [ the PHP version does not support JSON serialization API] )
127+ if test "$json_inc_path" = ""; then
128+ AC_MSG_ERROR ( [ Cannot find php_json.h] )
129+ else
130+ AC_DEFINE ( HAVE_JSON_API ,1 ,[ Whether JSON API is available] )
131+ AC_MSG_RESULT ( [ $json_inc_path] )
175132 fi
176133 fi
177134
@@ -339,6 +296,28 @@ if test "$PHP_MEMCACHED" != "no"; then
339296 AC_MSG_RESULT ( [ no] )
340297 fi
341298
299+ ORIG_CFLAGS="$CFLAGS"
300+ ORIG_LIBS="$LIBS"
301+
302+ CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES"
303+ LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS"
304+
305+ AC_CACHE_CHECK ( [ whether memcached_exist is defined] , ac_cv_have_memcached_exist , [
306+ AC_TRY_LINK (
307+ [ #include <libmemcached/memcached.h> ] ,
308+ [ memcached_exist (NULL, NULL, 0); ] ,
309+ [ ac_cv_have_memcached_exist="yes" ] ,
310+ [ ac_cv_have_memcached_exist="no" ]
311+ )
312+ ] )
313+
314+ CFLAGS="$ORIG_CFLAGS"
315+ LIBS="$ORIG_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+
342321 PHP_MEMCACHED_FILES="php_memcached.c php_libmemcached_compat.c g_fmt.c"
343322
344323 if test "$PHP_SYSTEM_FASTLZ" != "no"; then
0 commit comments