xref: /PHP-7.4/ext/pdo_mysql/config.m4 (revision 1aab7db6)
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_LIBNAME=mysqlclient
62      PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
63      PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
64    elif test -n "$PDO_MYSQL_DIR"; then
65      AC_MSG_RESULT([not found])
66      AC_MSG_CHECKING([for mysql install under $PDO_MYSQL_DIR])
67      if test -r $PDO_MYSQL_DIR/include/mysql; then
68        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include/mysql
69      else
70        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include
71      fi
72      if test -r $PDO_MYSQL_DIR/$PHP_LIBDIR/mysql; then
73        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR/mysql
74      else
75        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR
76      fi
77
78      if test -r "$PDO_MYSQL_LIB_DIR"; then
79        AC_MSG_RESULT([libs under $PDO_MYSQL_LIB_DIR; seems promising])
80      else
81        AC_MSG_RESULT([can not find it])
82        AC_MSG_ERROR([Unable to find your mysql installation])
83      fi
84
85      PHP_ADD_INCLUDE($PDO_MYSQL_INC_DIR)
86      PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
87    else
88      AC_MSG_RESULT([not found])
89      AC_MSG_ERROR([Unable to find your mysql installation])
90    fi
91
92    PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_commit,
93    [
94      PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
95      PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
96    ],[
97      if test "$PHP_ZLIB_DIR" != "no"; then
98        PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR, PDO_MYSQL_SHARED_LIBADD)
99        PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_commit, [], [
100          AC_MSG_ERROR([PDO_MYSQL configure failed, MySQL 4.1 needed. Please check config.log for more information.])
101        ], [
102          -L$PHP_ZLIB_DIR/$PHP_LIBDIR -L$PDO_MYSQL_LIB_DIR
103        ])
104        PDO_MYSQL_LIBS="$PDO_MYSQL_LIBS -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz"
105      else
106        PHP_ADD_LIBRARY(z,, PDO_MYSQL_SHARED_LIBADD)
107        PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_query, [], [
108          AC_MSG_ERROR([Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.])
109        ], [
110          -L$PDO_MYSQL_LIB_DIR
111        ])
112        PDO_MYSQL_LIBS="$PDO_MYSQL_LIBS -lz"
113      fi
114
115      PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
116      PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
117    ],[
118      $PDO_MYSQL_LIBS
119    ])
120  fi
121
122  PHP_CHECK_PDO_INCLUDES
123
124  if test -n "$PDO_MYSQL_CONFIG"; then
125    PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
126    AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
127  fi
128
129  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)
130
131  PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)
132
133  if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
134    PHP_ADD_EXTENSION_DEP(pdo_mysql, mysqlnd)
135  fi
136
137  PDO_MYSQL_MODULE_TYPE=external
138
139  PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)
140  PHP_SUBST_OLD(PDO_MYSQL_MODULE_TYPE)
141fi
142