1 PHP_ARG_WITH(pq, [whether to enable libpq (PostgreSQL) support],
2 [ --with-pq[=DIR] Include libpq support])
4 if test "$PHP_PQ" != "no"; then
5 SEARCH_PATH="/usr/local /usr /opt"
6 if test "$PHP_PQ" != "yes"; then
7 SEARCH_PATH="$PHP_PQ $SEARCH_PATH"
9 for i in $SEARCH_PATH; do
10 AC_MSG_CHECKING(for $i/include/libpq-events.h)
11 if test -f "$i/include/libpq-events.h"; then
19 if test -z "$PQ_DIR"; then
20 AC_MSG_ERROR(could not find include/libpq-events.h)
22 PHP_ADD_INCLUDE($PQ_DIR/include)
24 ifdef([AC_PROG_EGREP], [
27 AC_CHECK_PROG(EGREP, egrep, egrep)
31 dnl PQ_CHECK_CONST(name)
33 AC_DEFUN([PQ_CHECK_CONST], [
34 AC_MSG_CHECKING(for $1)
35 if $EGREP -q $1 $PQ_DIR/include/libpq-fe.h; then
36 AC_DEFINE(HAVE_$1, 1, [Have $1])
43 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
44 PQ_CHECK_CONST(PGRES_COPY_BOTH)
48 dnl PQ_CHECK_FUNC(sym, fail-hard)
50 AC_DEFUN([PQ_CHECK_FUNC], [
53 PHP_CHECK_LIBRARY(pq, $1, [
54 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
56 if test -n "$FAIL_HARD"; then
58 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
66 PQ_CHECK_FUNC(PQregisterEventProc, true)
67 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_DIR/$PHP_LIBDIR, PQ_SHARED_LIBADD)
68 PHP_SUBST(PQ_SHARED_LIBADD)
70 PQ_CHECK_FUNC(PQlibVersion)
71 PQ_CHECK_FUNC(PQconninfo)
72 PQ_CHECK_FUNC(PQsetSingleRowMode)
75 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
77 AC_DEFUN([PQ_HAVE_PHP_EXT], [
79 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
80 AC_MSG_CHECKING([for ext/$extname support])
81 if test "$haveext" != "no" && test "x$haveext" != "x"; then
82 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
85 elif test -x "$PHP_EXECUTABLE"; then
86 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
87 if test "$grepext" = "$extname"; then
88 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
92 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
97 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
106 src/php_pq_callback.c\
111 src/php_pqconn_event.c\
121 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
122 PHP_ADD_BUILD_DIR($ext_builddir/src)
123 PHP_ADD_INCLUDE($ext_srcdir/src)
125 PQ_HAVE_PHP_EXT([raphf], [
126 AC_MSG_CHECKING([for php_raphf.h])
128 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
130 if test -f $i/php_raphf.h; then
131 PQ_EXT_RAPHF_INCDIR=$i
133 elif test -f $i/ext/raphf/php_raphf.h; then
134 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
139 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
140 AC_MSG_ERROR([not found])
142 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
143 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
144 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
147 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
149 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
150 PQ_HAVE_PHP_EXT([json], [
151 AC_MSG_CHECKING([for php_json.h])
153 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
155 if test -f $i/php_json.h; then
156 PQ_EXT_JSON_INCDIR=$i
158 elif test -f $i/ext/json/php_json.h; then
159 PQ_EXT_JSON_INCDIR=$i/ext/json
164 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
165 AC_MSG_ERROR([not found])
167 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
168 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
169 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])