Skip to content

Commit fcd4d39

Browse files
authored
Autotools: Refactor mysqli extension checks (#15323)
- AS_* macros used - s/UNIX/Unix - The --with-mysql result value moved into the check when extension is enabled - List of source files normalized with m4_normalize - Redundant variables omitted - CS synced
1 parent dbdc79d commit fcd4d39

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

ext/mysqli/config.m4

+32-31
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [
1717
fi
1818
done
1919
20-
if test -n "$MYSQL_SOCK"; then
20+
AS_VAR_IF([MYSQL_SOCK],, [AC_MSG_RESULT([no])], [
2121
AC_DEFINE_UNQUOTED([PHP_MYSQL_UNIX_SOCK_ADDR], ["$MYSQL_SOCK"],
2222
[The MySQL Unix socket location.])
2323
AC_MSG_RESULT([$MYSQL_SOCK])
24-
else
25-
AC_MSG_RESULT([no])
26-
fi
24+
])
2725
])
2826

2927
PHP_ARG_WITH([mysqli],
@@ -33,39 +31,42 @@ PHP_ARG_WITH([mysqli],
3331

3432
dnl ext/pdo_mysql/config.m4 also depends on this configure option.
3533
PHP_ARG_WITH([mysql-sock],
36-
[for specified location of the MySQL UNIX socket],
34+
[for specified location of the MySQL Unix socket],
3735
[AS_HELP_STRING([[--with-mysql-sock[=SOCKPATH]]],
38-
[MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer. If unspecified,
39-
the default locations are searched])],
36+
[MySQLi/PDO_MYSQL: Location of the MySQL Unix socket pointer. If
37+
unspecified, the default locations are searched])],
4038
[no],
4139
[no])
4240

43-
if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then
44-
dnl This needs to be set in any extension which wishes to use mysqlnd
45-
PHP_MYSQLND_ENABLED=yes
46-
47-
elif test "$PHP_MYSQLI" != "no"; then
48-
AC_MSG_ERROR([Linking mysqli against external library is no longer supported])
49-
fi
50-
51-
dnl Build extension
5241
if test "$PHP_MYSQLI" != "no"; then
53-
AC_MSG_CHECKING([for MySQL UNIX socket location])
54-
if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
55-
MYSQL_SOCK=$PHP_MYSQL_SOCK
56-
AC_DEFINE_UNQUOTED([PHP_MYSQL_UNIX_SOCK_ADDR], ["$MYSQL_SOCK"])
57-
AC_MSG_RESULT([$MYSQL_SOCK])
58-
elif test "$PHP_MYSQL_SOCK" = "yes"; then
59-
PHP_MYSQL_SOCKET_SEARCH
60-
else
61-
AC_MSG_RESULT([no])
62-
fi
42+
dnl The PHP_MYSQLND_ENABLED variable enables the mysqlnd extension.
43+
AS_CASE([$PHP_MYSQLI],
44+
[yes|mysqlnd], [PHP_MYSQLND_ENABLED=yes],
45+
[AC_MSG_ERROR(m4_text_wrap([
46+
Linking mysqli against external library is no longer supported. Replace
47+
'--with-mysqli=$PHP_MYSQLI' with '--with-mysqli'.
48+
]))])
49+
50+
AC_MSG_CHECKING([for MySQL Unix socket location])
51+
AS_CASE([$PHP_MYSQL_SOCK],
52+
[yes], [PHP_MYSQL_SOCKET_SEARCH],
53+
[no], [AC_MSG_RESULT([no])],
54+
[
55+
AC_DEFINE_UNQUOTED([PHP_MYSQL_UNIX_SOCK_ADDR], ["$PHP_MYSQL_SOCK"])
56+
AC_MSG_RESULT([$PHP_MYSQL_SOCK])
57+
])
6358

64-
mysqli_sources="mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c \
65-
mysqli_report.c mysqli_driver.c mysqli_warning.c \
66-
mysqli_exception.c mysqli_result_iterator.c"
67-
PHP_NEW_EXTENSION([mysqli],
68-
[$mysqli_sources],
59+
PHP_NEW_EXTENSION([mysqli], m4_normalize([
60+
mysqli_api.c
61+
mysqli_driver.c
62+
mysqli_exception.c
63+
mysqli_nonapi.c
64+
mysqli_prop.c
65+
mysqli_report.c
66+
mysqli_result_iterator.c
67+
mysqli_warning.c
68+
mysqli.c
69+
]),
6970
[$ext_shared],,
7071
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
7172
PHP_INSTALL_HEADERS([ext/mysqli], [php_mysqli_structs.h mysqli_mysqlnd.h])

0 commit comments

Comments
 (0)