Skip to content

Commit e5f6387

Browse files
authored
Autotools: Refactor pdo_mysql checks (#15334)
- Main checks wrapped in AS_CASE - s/UNIX/Unix - Redundant MYSQL_SOCK variable removed
1 parent edc88ee commit e5f6387

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

ext/pdo_mysql/config.m4

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ PHP_ARG_WITH([pdo-mysql],
77
if test "$PHP_PDO_MYSQL" != "no"; then
88
dnl This depends on ext/mysqli/config.m4 providing the PHP_MYSQL_SOCKET_SEARCH
99
dnl macro and --with-mysql-sock configure option.
10-
AC_MSG_CHECKING([for MySQL UNIX socket location])
11-
if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
12-
MYSQL_SOCK=$PHP_MYSQL_SOCK
13-
AC_DEFINE_UNQUOTED([PHP_MYSQL_UNIX_SOCK_ADDR], ["$MYSQL_SOCK"],
14-
[The MySQL Unix socket location.])
15-
AC_MSG_RESULT([$MYSQL_SOCK])
16-
elif test "$PHP_MYSQL_SOCK" = "yes"; then
17-
PHP_MYSQL_SOCKET_SEARCH
18-
else
19-
AC_MSG_RESULT([no])
20-
fi
10+
AC_MSG_CHECKING([for MySQL Unix socket location])
11+
AS_CASE([$PHP_MYSQL_SOCK],
12+
[yes], [PHP_MYSQL_SOCKET_SEARCH],
13+
[no], [AC_MSG_RESULT([no])],
14+
[
15+
AC_DEFINE_UNQUOTED([PHP_MYSQL_UNIX_SOCK_ADDR], ["$PHP_MYSQL_SOCK"],
16+
[The MySQL Unix socket location.])
17+
AC_MSG_RESULT([$PHP_MYSQL_SOCK])
18+
])
2119

2220
if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
2321
AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
@@ -37,12 +35,12 @@ if test "$PHP_PDO_MYSQL" != "no"; then
3735
fi
3836
fi
3937

40-
if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
41-
dnl enables build of mysqnd library
38+
dnl Whether to build with the mysqlnd extension or with the MySQL library.
39+
AS_CASE([$PHP_PDO_MYSQL], [yes|mysqlnd], [
4240
PHP_MYSQLND_ENABLED=yes
4341
AC_DEFINE([PDO_USE_MYSQLND], [1],
4442
[Define to 1 if the pdo_mysql extension uses mysqlnd.])
45-
else
43+
], [
4644
AC_MSG_CHECKING([for mysql_config])
4745
if test -n "$PDO_MYSQL_CONFIG"; then
4846
AC_MSG_RESULT([$PDO_MYSQL_CONFIG])
@@ -78,7 +76,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then
7876
7977
PHP_EVAL_INCLINE([$PDO_MYSQL_INCLUDE])
8078
PHP_EVAL_LIBLINE([$PDO_MYSQL_LIBS], [PDO_MYSQL_SHARED_LIBADD])
81-
fi
79+
])
8280

8381
PHP_CHECK_PDO_INCLUDES
8482

@@ -97,9 +95,9 @@ if test "$PHP_PDO_MYSQL" != "no"; then
9795
PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)
9896
PHP_ADD_MAKEFILE_FRAGMENT
9997

100-
if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
98+
AS_CASE([$PHP_PDO_MYSQL], [yes|mysqlnd], [
10199
PHP_ADD_EXTENSION_DEP(pdo_mysql, mysqlnd)
102-
fi
100+
])
103101

104102
PHP_SUBST([PDO_MYSQL_SHARED_LIBADD])
105103
fi

0 commit comments

Comments
 (0)