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/postgresql/libpq-events.h)
11 if test -f "$i/include/postgresql/libpq-events.h"; then
18 AC_MSG_CHECKING(for $i/include/libpq-events.h)
19 if test -f "$i/include/libpq-events.h"; then
27 if test -z "$PQ_INCDIR"; then
28 AC_MSG_ERROR(could not find include/libpq-events.h)
31 for i in $SEARCH_PATH; do
32 AC_MSG_CHECKING(for $i/$PHP_LIBDIR/libpq.$SHLIB_SUFFIX_NAME)
33 if test -f "$i/$PHP_LIBDIR/libpq.$SHLIB_SUFFIX_NAME"; then
34 PQ_LIBDIR=$i/$PHP_LIBDIR
41 if test -z "$PQ_LIBDIR"; then
42 AC_MSG_ERROR(could not find libpq.$SHLIB_SUFFIX_NAME)
45 PHP_ADD_INCLUDE($PQ_INCDIR)
47 ifdef([AC_PROG_EGREP], [
50 AC_CHECK_PROG(EGREP, egrep, egrep)
54 dnl PQ_CHECK_CONST(name)
56 AC_DEFUN([PQ_CHECK_CONST], [
57 AC_MSG_CHECKING(for $1)
58 if $EGREP -q $1 $PQ_INCDIR/libpq-fe.h; then
59 AC_DEFINE(HAVE_$1, 1, [Have $1])
66 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
67 PQ_CHECK_CONST(PGRES_COPY_BOTH)
71 dnl PQ_CHECK_FUNC(sym, fail-hard)
73 AC_DEFUN([PQ_CHECK_FUNC], [
76 PHP_CHECK_LIBRARY(pq, $1, [
77 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
79 if test -n "$FAIL_HARD"; then
81 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
89 PQ_CHECK_FUNC(PQregisterEventProc, true)
90 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_LIBDIR, PQ_SHARED_LIBADD)
91 PHP_SUBST(PQ_SHARED_LIBADD)
93 PQ_CHECK_FUNC(PQlibVersion)
94 PQ_CHECK_FUNC(PQconninfo)
95 PQ_CHECK_FUNC(PQsetSingleRowMode)
98 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
100 AC_DEFUN([PQ_HAVE_PHP_EXT], [
102 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
103 AC_MSG_CHECKING([for ext/$extname support])
104 if test "$haveext" != "no" && test "x$haveext" != "x"; then
105 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
108 elif test -x "$PHP_EXECUTABLE"; then
109 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
110 if test "$grepext" = "$extname"; then
111 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
115 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
120 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
129 src/php_pq_callback.c\
134 src/php_pqconn_event.c\
144 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
145 PHP_ADD_BUILD_DIR($ext_builddir/src)
146 PHP_ADD_INCLUDE($ext_srcdir/src)
148 PQ_HAVE_PHP_EXT([raphf], [
149 AC_MSG_CHECKING([for php_raphf.h])
151 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
153 if test -f $i/php_raphf.h; then
154 PQ_EXT_RAPHF_INCDIR=$i
156 elif test -f $i/ext/raphf/php_raphf.h; then
157 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
162 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
163 AC_MSG_ERROR([not found])
165 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
166 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
167 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
170 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
172 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
173 PQ_HAVE_PHP_EXT([json], [
174 AC_MSG_CHECKING([for php_json.h])
176 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
178 if test -f $i/php_json.h; then
179 PQ_EXT_JSON_INCDIR=$i
181 elif test -f $i/ext/json/php_json.h; then
182 PQ_EXT_JSON_INCDIR=$i/ext/json
187 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
188 AC_MSG_ERROR([not found])
190 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
191 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
192 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])