xref: /PHP-7.3/ext/pdo_mysql/config.m4 (revision 1aab7db6)
1dnl config.m4 for extension pdo_mysql
2dnl vim: se ts=2 sw=2 et:
3
4PHP_ARG_WITH(pdo-mysql, for MySQL support for PDO,
5[  --with-pdo-mysql[=DIR]    PDO: MySQL support. DIR is the MySQL base directory
6                          If no value or mysqlnd is passed as DIR, the
7                          MySQL native driver will be used])
8
9if test -z "$PHP_ZLIB_DIR"; then
10  PHP_ARG_WITH(zlib-dir, for the location of libz,
11  [  --with-zlib-dir[=DIR]     PDO_MySQL: Set the path to libz install prefix], no, no)
12fi
13
14if test "$PHP_PDO_MYSQL" != "no"; then
15  dnl This depends on ext/mysqli/config.m4 providing the
16  dnl PHP_MYSQL_SOCKET_SEARCH macro and --with-mysql-sock configure option.
17  AC_MSG_CHECKING([for MySQL UNIX socket location])
18  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
19    MYSQL_SOCK=$PHP_MYSQL_SOCK
20    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
21    AC_MSG_RESULT([$MYSQL_SOCK])
22  elif test "$PHP_MYSQL_SOCK" = "yes"; then
23    PHP_MYSQL_SOCKET_SEARCH
24  else
25    AC_MSG_RESULT([no])
26  fi
27
28  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
29    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
30  fi
31
32  AC_DEFUN([PDO_MYSQL_LIB_CHK], [
33    str="$PDO_MYSQL_DIR/$1/libmysqlclient*"
34    for j in `echo $str`; do
35      if test -r $j; then
36        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$1
37        break 2
38      fi
39    done
40  ])
41
42  if test "$PHP_PDO_MYSQL" != "yes" && test "$PHP_PDO_MYSQL" != "mysqlnd"; then
43    if test -f $PHP_PDO_MYSQL && test -x $PHP_PDO_MYSQL ; then
44      PDO_MYSQL_CONFIG=$PHP_PDO_MYSQL
45    else
46      if test -d "$PHP_PDO_MYSQL" ; then
47        if test -x "$PHP_PDO_MYSQL/bin/mysql_config" ; then
48          PDO_MYSQL_CONFIG="$PHP_PDO_MYSQL/bin/mysql_config"
49        else
50          PDO_MYSQL_DIR="$PHP_PDO_MYSQL"
51        fi
52      fi
53    fi
54  fi
55
56  if test "$PHP_PDO_MYSQL" = "yes" || test "$PHP_PDO_MYSQL" = "mysqlnd"; then
57    dnl enables build of mysqnd library
58    PHP_MYSQLND_ENABLED=yes
59    AC_DEFINE([PDO_USE_MYSQLND], 1, [Whether pdo_mysql uses mysqlnd])
60  else
61    AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
62
63    AC_MSG_CHECKING([for mysql_config])
64    if test -n "$PDO_MYSQL_CONFIG"; then
65      AC_MSG_RESULT($PDO_MYSQL_CONFIG)
66      if test "x$SED" = "x"; then
67        AC_PATH_PROG(SED, sed)
68      fi
69      PDO_MYSQL_LIBNAME=mysqlclient
70      PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs | $SED -e "s/'//g"`
71      PDO_MYSQL_INCLUDE=`$PDO_MYSQL_CONFIG --cflags | $SED -e "s/'//g"`
72    elif test -n "$PDO_MYSQL_DIR"; then
73      AC_MSG_RESULT([not found])
74      AC_MSG_CHECKING([for mysql install under $PDO_MYSQL_DIR])
75      if test -r $PDO_MYSQL_DIR/include/mysql; then
76        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include/mysql
77      else
78        PDO_MYSQL_INC_DIR=$PDO_MYSQL_DIR/include
79      fi
80      if test -r $PDO_MYSQL_DIR/$PHP_LIBDIR/mysql; then
81        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR/mysql
82      else
83        PDO_MYSQL_LIB_DIR=$PDO_MYSQL_DIR/$PHP_LIBDIR
84      fi
85
86      if test -r "$PDO_MYSQL_LIB_DIR"; then
87        AC_MSG_RESULT([libs under $PDO_MYSQL_LIB_DIR; seems promising])
88      else
89        AC_MSG_RESULT([can not find it])
90        AC_MSG_ERROR([Unable to find your mysql installation])
91      fi
92
93      PHP_ADD_INCLUDE($PDO_MYSQL_INC_DIR)
94      PDO_MYSQL_INCLUDE=-I$PDO_MYSQL_INC_DIR
95    else
96      AC_MSG_RESULT([not found])
97      AC_MSG_ERROR([Unable to find your mysql installation])
98    fi
99
100    PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_commit,
101    [
102      PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
103      PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
104    ],[
105      if test "$PHP_ZLIB_DIR" != "no"; then
106        PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR, PDO_MYSQL_SHARED_LIBADD)
107        PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_commit, [], [
108          AC_MSG_ERROR([PDO_MYSQL configure failed, MySQL 4.1 needed. Please check config.log for more information.])
109        ], [
110          -L$PHP_ZLIB_DIR/$PHP_LIBDIR -L$PDO_MYSQL_LIB_DIR
111        ])
112        PDO_MYSQL_LIBS="$PDO_MYSQL_LIBS -L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz"
113      else
114        PHP_ADD_LIBRARY(z,, PDO_MYSQL_SHARED_LIBADD)
115        PHP_CHECK_LIBRARY($PDO_MYSQL_LIBNAME, mysql_query, [], [
116          AC_MSG_ERROR([Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.])
117        ], [
118          -L$PDO_MYSQL_LIB_DIR
119        ])
120        PDO_MYSQL_LIBS="$PDO_MYSQL_LIBS -lz"
121      fi
122
123      PHP_EVAL_INCLINE($PDO_MYSQL_INCLUDE)
124      PHP_EVAL_LIBLINE($PDO_MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD)
125    ],[
126      $PDO_MYSQL_LIBS
127    ])
128  fi
129
130  ifdef([PHP_CHECK_PDO_INCLUDES],
131  [
132    PHP_CHECK_PDO_INCLUDES
133  ],[
134    AC_MSG_CHECKING([for PDO includes])
135    if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
136      pdo_cv_inc_path=$abs_srcdir/ext
137    elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
138      pdo_cv_inc_path=$abs_srcdir/ext
139    elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
140      pdo_cv_inc_path=$phpincludedir/ext
141    else
142      AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
143    fi
144    AC_MSG_RESULT($pdo_cv_inc_path)
145  ])
146
147  if test -n "$PDO_MYSQL_CONFIG"; then
148    PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket`
149    AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ])
150  fi
151
152  dnl fix after renaming to pdo_mysql
153  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)
154  ifdef([PHP_ADD_EXTENSION_DEP],
155  [
156    PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)
157    if test "$PHP_MYSQL" = "mysqlnd"; then
158      PHP_ADD_EXTENSION_DEP(pdo_mysql, mysqlnd)
159    fi
160  ])
161  PDO_MYSQL_MODULE_TYPE=external
162
163  PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)
164  PHP_SUBST_OLD(PDO_MYSQL_MODULE_TYPE)
165fi
166