xref: /PHP-8.3/ext/pdo_mysql/config.m4 (revision 34dd032e)
1PHP_ARG_WITH([pdo-mysql],
2  [for MySQL support for PDO],
3  [AS_HELP_STRING([[--with-pdo-mysql[=DIR]]],
4    [PDO: MySQL support. DIR is the MySQL base directory. If no value or mysqlnd
5    is passed as DIR, the MySQL native driver will be used])])
6
7if test -z "$PHP_ZLIB_DIR"; then
8  PHP_ARG_WITH([zlib-dir],
9    [for the location of libz],
10    [AS_HELP_STRING([[--with-zlib-dir[=DIR]]],
11      [PDO_MySQL: Set the path to libz install prefix])],
12    [no],
13    [no])
14fi
15
16if test "$PHP_PDO_MYSQL" != "no"; then
17  dnl This depends on ext/mysqli/config.m4 providing the PHP_MYSQL_SOCKET_SEARCH
18  dnl macro and --with-mysql-sock configure option.
19  AC_MSG_CHECKING([for MySQL UNIX socket location])
20  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
21    MYSQL_SOCK=$PHP_MYSQL_SOCK
22    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
23    AC_MSG_RESULT([$MYSQL_SOCK])
24  elif test "$PHP_MYSQL_SOCK" = "yes"; then
25    PHP_MYSQL_SOCKET_SEARCH
26  else
27    AC_MSG_RESULT([no])
28  fi
29
30  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
31    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
32  fi
33
34  if test "$PHP_PDO_MYSQL" != "yes" && test "$PHP_PDO_MYSQL" != "mysqlnd"; then
35    if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
36      PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
37    else
38      if test -d "$PHP_PDO_MYSQL" ; then
39        if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
40          PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
41        else
42          PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
43        fi
44      fi
45    fi
46  fi
47
48  if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
49    dnl enables build of mysqnd library
50    PHP_MYSQLND_ENABLED=yes
51    AC_DEFINE([PDO_USE_MYSQLND], 1, [Whether pdo_mysql uses mysqlnd])
52  else
53    AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
54
55    AC_MSG_CHECKING([for mysql_config])
56    if test -n "$PDO_MYSQL_CONFIG"; then
57      AC_MSG_RESULT($PDO_MYSQL_CONFIG)
58      if test "x$SED" = "x"; then
59        AC_PATH_PROG(SED, sed)
60      fi
61      PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
62      PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
63    elif test -n "$PDO_MYSQL_DIR"; then
64      AC_MSG_RESULT([not found])
65      AC_MSG_CHECKING([for mysql install under $PDO_MYSQL_DIR])
66      if test -r $PDO_MYSQL_DIR/include/mysql; then
67        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include/mysql
68      else
69        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include
70      fi
71      if test -r $PDO_MYSQL_DIR/$PHP_LIBDIR/mysql; then
72        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR/mysql
73      else
74        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR
75      fi
76
77      if test -r "$PDO_MYSQL_LIB_DIR"; then
78        AC_MSG_RESULT([libs under $PDO_MYSQL_LIB_DIR; seems promising])
79      else
80        AC_MSG_RESULT([can not find it])
81        AC_MSG_ERROR([Unable to find your mysql installation])
82      fi
83
84      PHP_ADD_INCLUDE($PDO_MYSQL_INC_DIR)
85      PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
86    else
87      AC_MSG_RESULT([not found])
88      AC_MSG_ERROR([Unable to find your mysql installation])
89    fi
90
91    PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
92    PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
93  fi
94
95  PHP_CHECK_PDO_INCLUDES
96
97  if test -n "$PDO_MYSQL_CONFIG"; then
98    PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
99    AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
100  fi
101
102  PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_cv_inc_path -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
103
104  PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)
105
106  if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
107    PHP_ADD_EXTENSION_DEP(pdo_mysql, mysqlnd)
108  fi
109
110  PDO_MYSQL_MODULE_TYPE=external
111
112  PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)
113  PHP_SUBST_OLD(PDO_MYSQL_MODULE_TYPE)
114fi
115