Skip to content

Commit e622992

Browse files
authored
The configure script warns if libmemcached needs sasl.h if sasl.h cannot be found (#380)
1 parent 7ed5b38 commit e622992

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

Diff for: config.m4

+34-31
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ if test "$PHP_MEMCACHED" != "no"; then
184184
else
185185
AC_MSG_RESULT([$msgpack_inc_path])
186186
fi
187-
fi
187+
fi
188188

189189
AC_MSG_CHECKING([for memcached session support])
190190
if test "$PHP_MEMCACHED_SESSION" != "no"; then
@@ -255,50 +255,53 @@ if test "$PHP_MEMCACHED" != "no"; then
255255
PHP_EVAL_LIBLINE($PHP_LIBMEMCACHED_LIBS, MEMCACHED_SHARED_LIBADD)
256256
PHP_EVAL_INCLINE($PHP_LIBMEMCACHED_INCLUDES)
257257

258-
#
259-
# Added -lpthread here because AC_TRY_LINK tests on CentOS 6 seem to fail with undefined reference to pthread_once
260-
#
258+
dnl # Added -lpthread here because AC_TRY_LINK tests on CentOS 6 seem to fail with undefined reference to pthread_once
261259
ORIG_CFLAGS="$CFLAGS"
262260
CFLAGS="$CFLAGS $INCLUDES"
263261

262+
dnl # Always check if libmemcached was built with SASL support,
263+
dnl # because it will require sasl.h even if not used here.
264+
AC_CACHE_CHECK([for libmemcached sasl.h requirement], ac_cv_memc_sasl_support, [
265+
AC_TRY_COMPILE(
266+
[ #include <libmemcached/memcached.h> ],
267+
[
268+
#if LIBMEMCACHED_WITH_SASL_SUPPORT
269+
/* yes */
270+
#else
271+
# error "no sasl support"
272+
#endif
273+
],
274+
[ ac_cv_memc_sasl_support="yes" ],
275+
[ ac_cv_memc_sasl_support="no" ]
276+
)
277+
])
278+
279+
if test "$ac_cv_memc_sasl_support" = "yes"; then
280+
AC_CHECK_HEADERS([sasl/sasl.h], [ac_cv_have_memc_sasl_h="yes"], [ac_cv_have_memc_sasl_h="no"])
281+
fi
282+
283+
dnl # If libmemcached requires sasl.h but we can't find sasl.h, that's a hard error
284+
dnl # regardless of the option --enable-memcached-sasl or --disable-memcached-sasl
264285
AC_MSG_CHECKING([whether to enable sasl support])
286+
if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "no"; then
287+
AC_MSG_ERROR([no, libmemcached built with sasl required, but sasl.h not found.])
288+
fi
289+
265290
if test "$PHP_MEMCACHED_SASL" != "no"; then
266291
AC_MSG_RESULT(yes)
267-
AC_CHECK_HEADERS([sasl/sasl.h], [ac_cv_have_memc_sasl_h="yes"], [ac_cv_have_memc_sasl_h="no"])
268-
269-
if test "$ac_cv_have_memc_sasl_h" = "yes"; then
270-
271-
AC_CACHE_CHECK([whether libmemcached supports sasl], ac_cv_memc_sasl_support, [
272-
AC_TRY_COMPILE(
273-
[ #include <libmemcached/memcached.h> ],
274-
[
275-
#if LIBMEMCACHED_WITH_SASL_SUPPORT
276-
/* yes */
277-
#else
278-
# error "no sasl support"
279-
#endif
280-
],
281-
[ ac_cv_memc_sasl_support="yes" ],
282-
[ ac_cv_memc_sasl_support="no" ]
283-
)
284-
])
285-
286-
if test "$ac_cv_memc_sasl_support" = "yes"; then
287-
PHP_CHECK_LIBRARY(sasl2, sasl_client_init, [PHP_ADD_LIBRARY(sasl2, 1, MEMCACHED_SHARED_LIBADD)])
288-
AC_DEFINE(HAVE_MEMCACHED_SASL, 1, [Have SASL support])
289-
else
290-
AC_MSG_ERROR([no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check])
291-
fi
292+
if test "$ac_cv_memc_sasl_support" = "yes" && test "$ac_cv_have_memc_sasl_h" = "yes"; then
293+
PHP_CHECK_LIBRARY(sasl2, sasl_client_init, [PHP_ADD_LIBRARY(sasl2, 1, MEMCACHED_SHARED_LIBADD)])
294+
AC_DEFINE(HAVE_MEMCACHED_SASL, 1, [Have SASL support])
292295
else
293-
AC_MSG_ERROR([no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check])
296+
AC_MSG_ERROR([no, libmemcached built with sasl disabled. Run configure with --disable-memcached-sasl or update libmemcached with sasl support])
294297
fi
295298
else
296299
AC_MSG_RESULT([no])
297300
fi
298301

299302
ORIG_CFLAGS="$CFLAGS"
300303
ORIG_LIBS="$LIBS"
301-
304+
302305
CFLAGS="$CFLAGS $PHP_LIBMEMCACHED_INCLUDES"
303306
LIBS="$LIBS $PHP_LIBMEMCACHED_LIBS"
304307

0 commit comments

Comments
 (0)