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
6 SEARCH_PATH="/usr/local /usr /opt"
7 if test "$PHP_PQ" != "yes"; then
8 SEARCH_PATH="$PHP_PQ $SEARCH_PATH"
11 AC_MSG_CHECKING(for pg_config)
12 for i in $SEARCH_PATH; do
13 if test -x "$i/bin/pg_config"; then
14 PG_CONFIG="$i/bin/pg_config"
19 if test -z "$PG_CONFIG"; then
20 AC_PATH_PROG(PG_CONFIG, pg_config, no)
23 AC_MSG_RESULT($PG_CONFIG)
25 if test "$PG_CONFIG" = "no"; then
26 AC_MSG_ERROR(could not find a usable pg_config in $SEARCH_PATH)
28 if test "$PHP_PQ" != "yes" -a "$PHP_PQ/bin/pg_config" != "$PG_CONFIG"; then
29 AC_MSG_WARN(Found pg_config is not in $PHP_PQ)
32 AC_MSG_CHECKING(for PostgreSQL version)
33 PQ_VERSION=$($PG_CONFIG --version | $SED 's/PostgreSQL //')
35 if test -z "$PQ_VERSION"; then
36 AC_MSG_RESULT(not found)
37 AC_MSG_ERROR(\`$PG_CONFIG --version\` did not provide any meaningful output, please reinstall postgresql/libpq)
39 AC_MSG_RESULT($PQ_VERSION)
40 AC_DEFINE_UNQUOTED(PHP_PQ_LIBVERSION, "$PQ_VERSION", [ ])
43 PQ_INCDIR=$($PG_CONFIG --includedir)
44 PQ_LIBDIR=$($PG_CONFIG --libdir)
47 PHP_ADD_INCLUDE($PQ_INCDIR)
49 ifdef([AC_PROG_EGREP], [
52 AC_CHECK_PROG(EGREP, egrep, egrep)
56 dnl PQ_CHECK_CONST(name)
58 AC_DEFUN([PQ_CHECK_CONST], [
59 AC_MSG_CHECKING(for $1)
60 if $EGREP -q $1 $PQ_INCDIR/libpq-fe.h; then
61 AC_DEFINE(HAVE_$1, 1, [Have $1])
68 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
69 PQ_CHECK_CONST(PGRES_COPY_BOTH)
73 dnl PQ_CHECK_FUNC(sym, fail-hard)
75 AC_DEFUN([PQ_CHECK_FUNC], [
78 PHP_CHECK_LIBRARY(pq, $1, [
79 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
81 if test -n "$FAIL_HARD"; then
83 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
91 PQ_CHECK_FUNC(PQregisterEventProc, true)
92 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_LIBDIR, PQ_SHARED_LIBADD)
93 PHP_SUBST(PQ_SHARED_LIBADD)
95 PQ_CHECK_FUNC(PQlibVersion)
96 PQ_CHECK_FUNC(PQconninfo)
97 PQ_CHECK_FUNC(PQsetSingleRowMode)
100 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
102 AC_DEFUN([PQ_HAVE_PHP_EXT], [
104 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
105 AC_MSG_CHECKING([for ext/$extname support])
106 if test "$haveext" != "no" && test "x$haveext" != "x"; then
107 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
110 elif test -x "$PHP_EXECUTABLE"; then
111 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
112 if test "$grepext" = "$extname"; then
113 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
117 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
122 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
131 src/php_pq_callback.c\
136 src/php_pqconn_event.c\
146 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
147 PHP_ADD_BUILD_DIR($ext_builddir/src)
148 PHP_ADD_INCLUDE($ext_srcdir/src)
150 PQ_HAVE_PHP_EXT([raphf], [
151 AC_MSG_CHECKING([for php_raphf.h])
153 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
155 if test -f $i/php_raphf.h; then
156 PQ_EXT_RAPHF_INCDIR=$i
158 elif test -f $i/ext/raphf/php_raphf.h; then
159 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
164 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
165 AC_MSG_ERROR([not found])
167 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
168 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
169 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
172 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
174 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
175 PQ_HAVE_PHP_EXT([json], [
176 AC_MSG_CHECKING([for php_json.h])
178 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
180 if test -f $i/php_json.h; then
181 PQ_EXT_JSON_INCDIR=$i
183 elif test -f $i/ext/json/php_json.h; then
184 PQ_EXT_JSON_INCDIR=$i/ext/json
189 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
190 AC_MSG_ERROR([not found])
192 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
193 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
194 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])