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)
30 for PQ_DEF in PGRES_SINGLE_TUPLE PGRES_COPY_BOTH; do
31 AC_MSG_CHECKING(for $PQ_DEF)
32 if $EGREP -q $PQ_DEF $PQ_DIR/include/libpq-fe.h; then
33 AC_DEFINE([$PQ_DEF], [1], [Have $PQ_DEF])
42 dnl PQ_CHECK_FUNC(sym, fail-hard)
44 AC_DEFUN([PQ_CHECK_FUNC], [
47 PHP_CHECK_LIBRARY(pq, $1, [
48 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
50 if test -n "$FAIL_HARD"; then
52 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
60 PQ_CHECK_FUNC(PQregisterEventProc, true)
61 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_DIR/$PHP_LIBDIR, PQ_SHARED_LIBADD)
62 PHP_SUBST(PQ_SHARED_LIBADD)
64 PQ_CHECK_FUNC(PQlibVersion)
65 PQ_CHECK_FUNC(PQconninfo)
66 PQ_CHECK_FUNC(PQsetSingleRowMode)
69 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
71 AC_DEFUN([PQ_HAVE_PHP_EXT], [
73 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
74 AC_MSG_CHECKING([for ext/$extname support])
75 if test -x "$PHP_EXECUTABLE"; then
76 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
77 if test "$grepext" = "$extname"; then
78 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
82 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
86 elif test "$haveext" != "no" && test "x$haveext" != "x"; then
87 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
91 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
100 src/php_pq_callback.c\
105 src/php_pqconn_event.c\
115 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
116 PHP_ADD_BUILD_DIR($ext_builddir/src)
117 PHP_ADD_INCLUDE($ext_srcdir/src)
119 PQ_HAVE_PHP_EXT([raphf], [
120 AC_MSG_CHECKING([for php_raphf.h])
122 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
124 if test -f $i/php_raphf.h; then
125 PQ_EXT_RAPHF_INCDIR=$i
127 elif test -f $i/ext/raphf/php_raphf.h; then
128 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
133 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
134 AC_MSG_ERROR([not found])
136 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
137 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
138 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
141 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
143 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
144 PQ_HAVE_PHP_EXT([json], [
145 AC_MSG_CHECKING([for php_json.h])
147 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
149 if test -f $i/php_json.h; then
150 PQ_EXT_JSON_INCDIR=$i
152 elif test -f $i/ext/json/php_json.h; then
153 PQ_EXT_JSON_INCDIR=$i/ext/json
158 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
159 AC_MSG_ERROR([not found])
161 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
162 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
163 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])