Skip to content

Commit a5f8cbd

Browse files
authored
Autotools: Refactor mysql_config checks in pdo_mysql (#15336)
- Scattered if blocks moved together as PDO_MYSQL_UNIX_ADDR is defined only when mysql_config is available - Obsolete backticks command substitutions `...` replaced with the recommended $(...)
1 parent e1c8329 commit a5f8cbd

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

ext/pdo_mysql/config.m4

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ if test "$PHP_PDO_MYSQL" != "no"; then
2121
AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
2222
fi
2323

24-
if test "$PHP_PDO_MYSQL" != "yes" && test "$PHP_PDO_MYSQL" != "mysqlnd"; then
24+
dnl Whether to build with the mysqlnd extension or with the MySQL library.
25+
AS_CASE([$PHP_PDO_MYSQL], [yes|mysqlnd], [
26+
PHP_MYSQLND_ENABLED=yes
27+
AC_DEFINE([PDO_USE_MYSQLND], [1],
28+
[Define to 1 if the pdo_mysql extension uses mysqlnd.])
29+
], [
30+
AC_MSG_CHECKING([for mysql_config])
2531
if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
2632
PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
2733
else
@@ -33,19 +39,15 @@ if test "$PHP_PDO_MYSQL" != "no"; then
3339
fi
3440
fi
3541
fi
36-
fi
3742
38-
dnl Whether to build with the mysqlnd extension or with the MySQL library.
39-
AS_CASE([$PHP_PDO_MYSQL], [yes|mysqlnd], [
40-
PHP_MYSQLND_ENABLED=yes
41-
AC_DEFINE([PDO_USE_MYSQLND], [1],
42-
[Define to 1 if the pdo_mysql extension uses mysqlnd.])
43-
], [
44-
AC_MSG_CHECKING([for mysql_config])
4543
if test -n "$PDO_MYSQL_CONFIG"; then
4644
AC_MSG_RESULT([$PDO_MYSQL_CONFIG])
47-
PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
48-
PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
45+
PDO_MYSQL_LIBS=$($PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g")
46+
PDO_MYSQL_INCLUDE=$($PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g")
47+
PDO_MYSQL_SOCKET=$($PDO_MYSQL_CONFIG --socket)
48+
AC_DEFINE_UNQUOTED([PDO_MYSQL_UNIX_ADDR], ["$PDO_MYSQL_SOCKET"],
49+
[The MySQL Unix socket location as defined by 'mysql_config' for use
50+
with the pdo_mysql extension.])
4951
elif test -n "$PDO_MYSQL_DIR"; then
5052
AC_MSG_RESULT([not found])
5153
AC_MSG_CHECKING([for mysql install under $PDO_MYSQL_DIR])
@@ -80,13 +82,6 @@ if test "$PHP_PDO_MYSQL" != "no"; then
8082

8183
PHP_CHECK_PDO_INCLUDES
8284

83-
if test -n "$PDO_MYSQL_CONFIG"; then
84-
PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
85-
AC_DEFINE_UNQUOTED([PDO_MYSQL_UNIX_ADDR], ["$PDO_MYSQL_SOCKET"],
86-
[The MySQL Unix socket location as defined by 'mysql_config' for use with
87-
the pdo_mysql extension.])
88-
fi
89-
9085
PHP_NEW_EXTENSION([pdo_mysql],
9186
[pdo_mysql.c mysql_driver.c mysql_statement.c mysql_sql_parser.c],
9287
[$ext_shared],,

0 commit comments

Comments
 (0)