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
11 AC_MSG_CHECKING(for $i/include/postgresql/libpq-events.h)
12 if test -f "$i/include/postgresql/libpq-events.h"; then
19 AC_MSG_CHECKING(for $i/include/libpq-events.h)
20 if test -f "$i/include/libpq-events.h"; then
28 if test -z "$PQ_INCDIR"; then
29 AC_MSG_ERROR(could not find include/libpq-events.h)
32 for i in $SEARCH_PATH; do
33 AC_MSG_CHECKING(for $i/$PHP_LIBDIR/libpq.$SHLIB_SUFFIX_NAME)
34 if test -f "$i/$PHP_LIBDIR/libpq.$SHLIB_SUFFIX_NAME"; then
35 PQ_LIBDIR=$i/$PHP_LIBDIR
40 if test -f "$i/$PHP_LIBDIR/x86_64-linux-gnu/libpq.$SHLIB_SUFFIX_NAME"; then
41 PQ_LIBDIR=$i/$PHP_LIBDIR/x86_64-linux-gnu
48 if test -z "$PQ_LIBDIR"; then
49 AC_MSG_ERROR(could not find libpq.$SHLIB_SUFFIX_NAME)
52 PHP_ADD_INCLUDE($PQ_INCDIR)
54 ifdef([AC_PROG_EGREP], [
57 AC_CHECK_PROG(EGREP, egrep, egrep)
61 dnl PQ_CHECK_CONST(name)
63 AC_DEFUN([PQ_CHECK_CONST], [
64 AC_MSG_CHECKING(for $1)
65 if $EGREP -q $1 $PQ_INCDIR/libpq-fe.h; then
66 AC_DEFINE(HAVE_$1, 1, [Have $1])
73 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
74 PQ_CHECK_CONST(PGRES_COPY_BOTH)
78 dnl PQ_CHECK_FUNC(sym, fail-hard)
80 AC_DEFUN([PQ_CHECK_FUNC], [
83 PHP_CHECK_LIBRARY(pq, $1, [
84 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
86 if test -n "$FAIL_HARD"; then
88 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
96 PQ_CHECK_FUNC(PQregisterEventProc, true)
97 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_LIBDIR, PQ_SHARED_LIBADD)
98 PHP_SUBST(PQ_SHARED_LIBADD)
100 PQ_CHECK_FUNC(PQlibVersion)
101 PQ_CHECK_FUNC(PQconninfo)
102 PQ_CHECK_FUNC(PQsetSingleRowMode)
105 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
107 AC_DEFUN([PQ_HAVE_PHP_EXT], [
109 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
110 AC_MSG_CHECKING([for ext/$extname support])
111 if test "$haveext" != "no" && test "x$haveext" != "x"; then
112 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
115 elif test -x "$PHP_EXECUTABLE"; then
116 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
117 if test "$grepext" = "$extname"; then
118 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
122 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
127 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
136 src/php_pq_callback.c\
141 src/php_pqconn_event.c\
151 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
152 PHP_ADD_BUILD_DIR($ext_builddir/src)
153 PHP_ADD_INCLUDE($ext_srcdir/src)
155 PQ_HAVE_PHP_EXT([raphf], [
156 AC_MSG_CHECKING([for php_raphf.h])
158 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
160 if test -f $i/php_raphf.h; then
161 PQ_EXT_RAPHF_INCDIR=$i
163 elif test -f $i/ext/raphf/php_raphf.h; then
164 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
169 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
170 AC_MSG_ERROR([not found])
172 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
173 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
174 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
177 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
179 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
180 PQ_HAVE_PHP_EXT([json], [
181 AC_MSG_CHECKING([for php_json.h])
183 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
185 if test -f $i/php_json.h; then
186 PQ_EXT_JSON_INCDIR=$i
188 elif test -f $i/ext/json/php_json.h; then
189 PQ_EXT_JSON_INCDIR=$i/ext/json
194 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
195 AC_MSG_ERROR([not found])
197 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
198 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
199 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])