xref: /PHP-8.0/ext/mysqli/config.m4 (revision 34dd032e)
1dnl ext/pdo_mysql/config.m4 also depends on this macro.
2AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [
3  for i in  \
4    /var/run/mysqld/mysqld.sock \
5    /var/tmp/mysql.sock \
6    /var/run/mysql/mysql.sock \
7    /var/lib/mysql/mysql.sock \
8    /var/mysql/mysql.sock \
9    /usr/local/mysql/var/mysql.sock \
10    /Private/tmp/mysql.sock \
11    /private/tmp/mysql.sock \
12    /tmp/mysql.sock \
13  ; do
14    if test -r $i; then
15      MYSQL_SOCK=$i
16      break 2
17    fi
18  done
19
20  if test -n "$MYSQL_SOCK"; then
21    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
22    AC_MSG_RESULT([$MYSQL_SOCK])
23  else
24    AC_MSG_RESULT([no])
25  fi
26])
27
28PHP_ARG_WITH([mysqli],
29  [for MySQLi support],
30  [AS_HELP_STRING([[--with-mysqli[=FILE]]],
31    [Include MySQLi support. FILE is the path to mysql_config. If no value or
32    mysqlnd is passed as FILE, the MySQL native driver will be used])])
33
34dnl ext/pdo_mysql/config.m4 also depends on this configure option.
35PHP_ARG_WITH([mysql-sock],
36  [for specified location of the MySQL UNIX socket],
37  [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])],
40  [no],
41  [no])
42
43if 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
47elif test "$PHP_MYSQLI" != "no"; then
48
49  MYSQL_CONFIG=$PHP_MYSQLI
50
51  if test -x "$MYSQL_CONFIG" && $MYSQL_CONFIG --libs > /dev/null 2>&1; then
52    MYSQLI_INCLINE=`$MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
53    MYSQLI_LIBLINE=`$MYSQL_CONFIG --libs | $SED -e "s/'//g"`
54  else
55    AC_MSG_RESULT([mysql_config not found])
56    AC_MSG_ERROR([Please reinstall the mysql distribution])
57  fi
58
59  PHP_EVAL_INCLINE($MYSQLI_INCLINE)
60  PHP_EVAL_LIBLINE($MYSQLI_LIBLINE, MYSQLI_SHARED_LIBADD)
61  AC_DEFINE(HAVE_MYSQLILIB, 1, [ ])
62fi
63
64dnl Build extension
65if test "$PHP_MYSQLI" != "no"; then
66  AC_MSG_CHECKING([for MySQL UNIX socket location])
67  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
68    MYSQL_SOCK=$PHP_MYSQL_SOCK
69    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
70    AC_MSG_RESULT([$MYSQL_SOCK])
71  elif test "$PHP_MYSQL_SOCK" = "yes"; then
72    PHP_MYSQL_SOCKET_SEARCH
73  else
74    AC_MSG_RESULT([no])
75  fi
76
77  mysqli_sources="mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c \
78                  mysqli_report.c mysqli_driver.c mysqli_warning.c \
79                  mysqli_exception.c mysqli_result_iterator.c"
80  PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
81  PHP_SUBST(MYSQLI_SHARED_LIBADD)
82  PHP_INSTALL_HEADERS([ext/mysqli/php_mysqli_structs.h])
83
84  if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then
85    PHP_ADD_EXTENSION_DEP(mysqli, mysqlnd)
86    AC_DEFINE([MYSQLI_USE_MYSQLND], 1, [Whether mysqlnd is enabled])
87    PHP_INSTALL_HEADERS([ext/mysqli/mysqli_mysqlnd.h])
88  else
89    PHP_INSTALL_HEADERS([ext/mysqli/mysqli_libmysql.h])
90  fi
91fi
92