Skip to content

Commit 97eb89a

Browse files
petkGirgias
andauthored
Autotools: Improve --with-mm configure option check (#15212)
The mm check code block needs to done only when session is enabled to prevent redundant mm library linkage in edge case mistakes like: ./configure --disable-session --with-mm CS is synced with AC_* macros. The 'm4_text_wrap' macro joins the given text with single space characters and limits it to 79 characters width. Co-authored-by: Gina Peter Banyard <[email protected]>
1 parent f0b3e3b commit 97eb89a

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

ext/session/config.m4

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,36 @@ if test "$PHP_SESSION" != "no"; then
1818
[mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c],
1919
[$ext_shared],,
2020
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
21+
2122
dnl https://bugs.php.net/53141
2223
PHP_ADD_EXTENSION_DEP(session, spl, true)
24+
2325
PHP_SUBST([SESSION_SHARED_LIBADD])
2426
PHP_INSTALL_HEADERS([ext/session], [php_session.h mod_files.h mod_user.h])
2527
AC_DEFINE([HAVE_PHP_SESSION], [1],
2628
[Define to 1 if the PHP extension 'session' is available.])
27-
fi
2829

29-
if test "$PHP_MM" != "no"; then
30-
for i in $PHP_MM /usr/local /usr; do
31-
test -f "$i/include/mm.h" && MM_DIR=$i && break
32-
done
33-
34-
if test -z "$MM_DIR" ; then
35-
AC_MSG_ERROR([cannot find mm library])
36-
fi
37-
38-
if test "$PHP_THREAD_SAFETY" = "yes"; then
39-
dnl The mm library is not thread-safe, and mod_mm.c refuses to compile.
40-
AC_MSG_ERROR([--with-mm cannot be combined with --enable-zts])
41-
fi
42-
43-
PHP_ADD_LIBRARY_WITH_PATH([mm],
44-
[$MM_DIR/$PHP_LIBDIR],
45-
[SESSION_SHARED_LIBADD])
46-
PHP_ADD_INCLUDE([$MM_DIR/include])
47-
PHP_INSTALL_HEADERS([ext/session], [mod_mm.h])
48-
AC_DEFINE([HAVE_LIBMM], [1], [Define to 1 if the system has the 'mm' library.])
30+
AS_VAR_IF([PHP_MM], [no],, [
31+
for i in $PHP_MM /usr/local /usr; do
32+
AS_IF([test -f "$i/include/mm.h"], [MM_DIR=$i; break;])
33+
done
34+
35+
AS_VAR_IF([MM_DIR],,
36+
[AC_MSG_ERROR([Cannot find the 'mm' library, <mm.h> header file not found.])])
37+
38+
AS_VAR_IF([PHP_THREAD_SAFETY], [yes], [AC_MSG_ERROR(m4_text_wrap([
39+
The configure option '--with-mm' cannot be combined with '--enable-zts'.
40+
The mm library is not thread-safe, and mod_mm.c refuses to compile. Either
41+
remove the '--with-mm' option, or build without thread safety (remove the
42+
'--enable-zts' option).
43+
]))])
44+
45+
PHP_ADD_LIBRARY_WITH_PATH([mm],
46+
[$MM_DIR/$PHP_LIBDIR],
47+
[SESSION_SHARED_LIBADD])
48+
PHP_ADD_INCLUDE([$MM_DIR/include])
49+
PHP_INSTALL_HEADERS([ext/session], [mod_mm.h])
50+
AC_DEFINE([HAVE_LIBMM], [1],
51+
[Define to 1 if the system has the 'mm' library.])
52+
])
4953
fi

0 commit comments

Comments
 (0)