xref: /PHP-5.3/ext/mysql/config.m4 (revision c50d732f)
1dnl
2dnl $Id$
3dnl
4
5AC_DEFUN([MYSQL_LIB_CHK], [
6  str="$MYSQL_DIR/$1/lib$MYSQL_LIBNAME.*"
7  for j in `echo $str`; do
8    if test -r $j; then
9      MYSQL_LIB_DIR=$MYSQL_DIR/$1
10      break 2
11    fi
12  done
13])
14
15AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [
16  for i in  \
17    /var/run/mysqld/mysqld.sock \
18    /var/tmp/mysql.sock \
19    /var/run/mysql/mysql.sock \
20    /var/lib/mysql/mysql.sock \
21    /var/mysql/mysql.sock \
22    /usr/local/mysql/var/mysql.sock \
23    /Private/tmp/mysql.sock \
24    /private/tmp/mysql.sock \
25    /tmp/mysql.sock \
26  ; do
27    if test -r $i; then
28      MYSQL_SOCK=$i
29      break 2
30    fi
31  done
32
33  if test -n "$MYSQL_SOCK"; then
34    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
35    AC_MSG_RESULT([$MYSQL_SOCK])
36  else
37    AC_MSG_RESULT([no])
38  fi
39])
40
41
42PHP_ARG_WITH(mysql, for MySQL support,
43[  --with-mysql[=DIR]      Include MySQL support.  DIR is the MySQL base
44                          directory.  If mysqlnd is passed as DIR,
45                          the MySQL native driver will be used [/usr/local]])
46
47PHP_ARG_WITH(mysql-sock, for specified location of the MySQL UNIX socket,
48[  --with-mysql-sock[=DIR]   MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
49                            If unspecified, the default locations are searched], no, no)
50
51if test -z "$PHP_ZLIB_DIR"; then
52  PHP_ARG_WITH(zlib-dir, for the location of libz,
53  [  --with-zlib-dir[=DIR]     MySQL: Set the path to libz install prefix], no, no)
54fi
55
56if test "$PHP_MYSQL" = "mysqlnd"; then
57  dnl enables build of mysqnd library
58  PHP_MYSQLND_ENABLED=yes
59
60elif test "$PHP_MYSQL" != "no"; then
61  MYSQL_DIR=
62  MYSQL_INC_DIR=
63
64  for i in $PHP_MYSQL /usr/local /usr; do
65    if test -r $i/include/mysql/mysql.h; then
66      MYSQL_DIR=$i
67      MYSQL_INC_DIR=$i/include/mysql
68      break
69    elif test -r $i/include/mysql.h; then
70      MYSQL_DIR=$i
71      MYSQL_INC_DIR=$i/include
72      break
73    fi
74  done
75
76  if test -z "$MYSQL_DIR"; then
77    AC_MSG_ERROR([Cannot find MySQL header files under $PHP_MYSQL.
78Note that the MySQL client library is not bundled anymore!])
79  fi
80
81  if test "$enable_maintainer_zts" = "yes"; then
82    MYSQL_LIBNAME=mysqlclient_r
83  else
84    MYSQL_LIBNAME=mysqlclient
85  fi
86  case $host_alias in
87    *netware*[)]
88      MYSQL_LIBNAME=mysql
89      ;;
90  esac
91
92  dnl for compat with PHP 4 build system
93  if test -z "$PHP_LIBDIR"; then
94    PHP_LIBDIR=lib
95  fi
96
97  for i in $PHP_LIBDIR $PHP_LIBDIR/mysql; do
98    MYSQL_LIB_CHK($i)
99  done
100
101  if test -z "$MYSQL_LIB_DIR"; then
102    MYSQL_LIB_CHK(lib/x86_64-linux-gnu)
103  fi
104  if test -z "$MYSQL_LIB_DIR"; then
105    MYSQL_LIB_CHK(lib/i386-linux-gnu)
106  fi
107
108  if test -z "$MYSQL_LIB_DIR"; then
109    AC_MSG_ERROR([Cannot find lib$MYSQL_LIBNAME under $MYSQL_DIR.
110Note that the MySQL client library is not bundled anymore!])
111  fi
112
113  PHP_CHECK_LIBRARY($MYSQL_LIBNAME, mysql_close, [ ],
114  [
115    if test "$PHP_ZLIB_DIR" != "no"; then
116      PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR, MYSQL_SHARED_LIBADD)
117      PHP_CHECK_LIBRARY($MYSQL_LIBNAME, mysql_error, [], [
118        AC_MSG_ERROR([mysql configure failed. Please check config.log for more information.])
119      ], [
120        -L$PHP_ZLIB_DIR/$PHP_LIBDIR -L$MYSQL_LIB_DIR
121      ])
122      MYSQL_LIBS="-L$PHP_ZLIB_DIR/$PHP_LIBDIR -lz"
123    else
124      PHP_ADD_LIBRARY(z,, MYSQL_SHARED_LIBADD)
125      PHP_CHECK_LIBRARY($MYSQL_LIBNAME, mysql_errno, [], [
126        AC_MSG_ERROR([Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.])
127      ], [
128        -L$MYSQL_LIB_DIR
129      ])
130      MYSQL_LIBS="-lz"
131    fi
132  ], [
133    -L$MYSQL_LIB_DIR
134  ])
135
136  PHP_ADD_LIBRARY_WITH_PATH($MYSQL_LIBNAME, $MYSQL_LIB_DIR, MYSQL_SHARED_LIBADD)
137  PHP_ADD_INCLUDE($MYSQL_INC_DIR)
138
139  MYSQL_MODULE_TYPE=external
140  MYSQL_LIBS="-L$MYSQL_LIB_DIR -l$MYSQL_LIBNAME $MYSQL_LIBS"
141  MYSQL_INCLUDE=-I$MYSQL_INC_DIR
142
143  PHP_SUBST_OLD(MYSQL_MODULE_TYPE)
144  PHP_SUBST_OLD(MYSQL_LIBS)
145  PHP_SUBST_OLD(MYSQL_INCLUDE)
146fi
147
148dnl Enable extension
149if test "$PHP_MYSQL" != "no"; then
150  AC_MSG_CHECKING([for MySQL UNIX socket location])
151  if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then
152    MYSQL_SOCK=$PHP_MYSQL_SOCK
153    AC_DEFINE_UNQUOTED(PHP_MYSQL_UNIX_SOCK_ADDR, "$MYSQL_SOCK", [ ])
154    AC_MSG_RESULT([$MYSQL_SOCK])
155  elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then
156    PHP_MYSQL_SOCKET_SEARCH
157  else
158    AC_MSG_RESULT([no])
159  fi
160
161  AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
162  PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared)
163  PHP_SUBST(MYSQL_SHARED_LIBADD)
164
165  if test "$PHP_MYSQL" = "mysqlnd"; then
166    PHP_ADD_EXTENSION_DEP(mysql, mysqlnd)
167    AC_DEFINE([MYSQL_USE_MYSQLND], 1, [Whether mysqlnd is enabled])
168  fi
169fi
170