xref: /PHP-7.3/ext/mysqli/config.m4 (revision 1aab7db6)
1dnl config.m4 for extension mysqli
2
3dnl ext/pdo_mysql/config.m4 also depends on this macro.
4AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [
5  for i in  \
6    /var/run/mysqld/mysqld.sock \
7    /var/tmp/mysql.sock \
8    /var/run/mysql/mysql.sock \
9    /var/lib/mysql/mysql.sock \
10    /var/mysql/mysql.sock \
11    /usr/local/mysql/var/mysql.sock \
12    /Private/tmp/mysql.sock \
13    /private/tmp/mysql.sock \
14    /tmp/mysql.sock \
15  ; do
16    if test -r $i; then
17      MYSQL_SOCK=$i
18      break 2
19    fi
20  done
21
22  if test -n "$MYSQL_SOCK"; then
23    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
24    AC_MSG_RESULT([$MYSQL_SOCK])
25  else
26    AC_MSG_RESULT([no])
27  fi
28])
29
30PHP_ARG_WITH(mysqli, for MySQLi support,
31[  --with-mysqli[=FILE]      Include MySQLi support.  FILE is the path
32                          to mysql_config.  If no value or mysqlnd is passed
33                          as FILE, the MySQL native driver will be used])
34
35PHP_ARG_ENABLE(embedded_mysqli, whether to enable embedded MySQLi support,
36[  --enable-embedded-mysqli
37                          MYSQLi: Enable embedded support
38                          Note: Does not work with MySQL native driver!], no, no)
39
40dnl ext/pdo_mysql/config.m4 also depends on this configure option.
41PHP_ARG_WITH(mysql-sock, for specified location of the MySQL UNIX socket,
42[  --with-mysql-sock[=SOCKPATH]
43                          MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
44                          If unspecified, the default locations are searched], no, no)
45
46if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then
47  dnl This needs to be set in any extension which wishes to use mysqlnd
48  PHP_MYSQLND_ENABLED=yes
49
50elif test "$PHP_MYSQLI" != "no"; then
51
52  MYSQL_CONFIG=$PHP_MYSQLI
53
54  MYSQL_LIB_NAME='mysqlclient'
55  if test "$PHP_EMBEDDED_MYSQLI" = "yes"; then
56    AC_DEFINE(HAVE_EMBEDDED_MYSQLI, 1, [embedded MySQL support enabled])
57    MYSQL_LIB_CFG='--libmysqld-libs'
58    dnl mysqlnd doesn't support embedded, so we have to add some extra stuff
59    mysqli_extra_sources="mysqli_embedded.c"
60  else
61    MYSQL_LIB_CFG='--libs'
62  fi
63
64  if test -x "$MYSQL_CONFIG" && $MYSQL_CONFIG $MYSQL_LIB_CFG > /dev/null 2>&1; then
65    MYSQLI_INCLINE=`$MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
66    MYSQLI_LIBLINE=`$MYSQL_CONFIG $MYSQL_LIB_CFG | $SED -e "s/'//g"`
67  else
68    AC_MSG_RESULT([mysql_config not found])
69    AC_MSG_ERROR([Please reinstall the mysql distribution])
70  fi
71
72  dnl
73  dnl Check the library
74  dnl
75  PHP_CHECK_LIBRARY($MYSQL_LIB_NAME, mysql_set_server_option,
76  [
77    PHP_EVAL_INCLINE($MYSQLI_INCLINE)
78    PHP_EVAL_LIBLINE($MYSQLI_LIBLINE, MYSQLI_SHARED_LIBADD)
79    AC_DEFINE(HAVE_MYSQLILIB, 1, [ ])
80    PHP_CHECK_LIBRARY($MYSQL_LIB_NAME, mysql_set_character_set,
81    [ ],[
82      AC_MSG_ERROR([MySQLI doesn't support versions < 4.1.13 (for MySQL 4.1.x) and < 5.0.7 for (MySQL 5.0.x) anymore. Please update your libraries.])
83    ],[$MYSQLI_LIBLINE])
84  ],[
85    AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.])
86  ],[
87    $MYSQLI_LIBLINE
88  ])
89  dnl
90  dnl Check the library for mysql_stmt_next_result
91  dnl
92  PHP_CHECK_LIBRARY($MYSQL_LIB_NAME, mysql_stmt_next_result,
93  [
94    AC_DEFINE(HAVE_STMT_NEXT_RESULT,             1, [ ])
95  ],[
96  ],[
97    $MYSQLI_LIBLINE
98  ])
99fi
100
101dnl Build extension
102if test "$PHP_MYSQLI" != "no"; then
103  AC_MSG_CHECKING([for MySQL UNIX socket location])
104  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
105    MYSQL_SOCK=$PHP_MYSQL_SOCK
106    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
107    AC_MSG_RESULT([$MYSQL_SOCK])
108  elif test "$PHP_MYSQL_SOCK" = "yes"; then
109    PHP_MYSQL_SOCKET_SEARCH
110  else
111    AC_MSG_RESULT([no])
112  fi
113
114  mysqli_sources="mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c \
115                  mysqli_fe.c mysqli_report.c mysqli_driver.c mysqli_warning.c \
116                  mysqli_exception.c mysqli_result_iterator.c $mysqli_extra_sources"
117  PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
118  PHP_SUBST(MYSQLI_SHARED_LIBADD)
119  PHP_INSTALL_HEADERS([ext/mysqli/php_mysqli_structs.h])
120
121  if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then
122    PHP_ADD_EXTENSION_DEP(mysqli, mysqlnd)
123    AC_DEFINE([MYSQLI_USE_MYSQLND], 1, [Whether mysqlnd is enabled])
124    PHP_INSTALL_HEADERS([ext/mysqli/mysqli_mysqlnd.h])
125  else
126    PHP_INSTALL_HEADERS([ext/mysqli/mysqli_libmysql.h])
127  fi
128fi
129