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