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