Test props with Connection::prepare() as well as Statement ctor
[m6w6/ext-pq] / config9.m4
1 PHP_ARG_WITH(pq, [whether to enable libpq (PostgreSQL) support],
2 [ --with-pq[=DIR] Include libpq support])
3
4 if test "$PHP_PQ" != "no"; then
5 SEARCH_PATH="/usr/local /usr /usr/include/postgresql /opt"
6 if test "$PHP_PQ" != "yes"; then
7 SEARCH_PATH="$PHP_PQ $SEARCH_PATH"
8 fi
9 for i in $SEARCH_PATH; do
10 AC_MSG_CHECKING(for $i/libpq-events.h)
11 if test -f "$i/libpq-events.h"; then
12 PQ_DIR=$i
13 AC_MSG_RESULT(yep)
14 break
15 fi
16 AC_MSG_RESULT(nope)
17
18 AC_MSG_CHECKING(for $i/include/libpq-events.h)
19 if test -f "$i/include/libpq-events.h"; then
20 PQ_DIR=$i/include
21 AC_MSG_RESULT(yep)
22 break
23 fi
24 AC_MSG_RESULT(nope)
25 done
26
27 if test -z "$PQ_DIR"; then
28 AC_MSG_ERROR(could not find include/libpq-events.h)
29 fi
30 PHP_ADD_INCLUDE($PQ_DIR)
31
32 ifdef([AC_PROG_EGREP], [
33 AC_PROG_EGREP
34 ], [
35 AC_CHECK_PROG(EGREP, egrep, egrep)
36 ])
37
38 dnl
39 dnl PQ_CHECK_CONST(name)
40 dnl
41 AC_DEFUN([PQ_CHECK_CONST], [
42 AC_MSG_CHECKING(for $1)
43 if $EGREP -q $1 $PQ_DIR/libpq-fe.h; then
44 AC_DEFINE(HAVE_$1, 1, [Have $1])
45 AC_MSG_RESULT(yep)
46 else
47 AC_MSG_RESULT(nope)
48 fi
49 ])
50
51 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
52 PQ_CHECK_CONST(PGRES_COPY_BOTH)
53
54
55 dnl
56 dnl PQ_CHECK_FUNC(sym, fail-hard)
57 dnl
58 AC_DEFUN([PQ_CHECK_FUNC], [
59 FAIL_HARD=$2
60
61 PHP_CHECK_LIBRARY(pq, $1, [
62 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
63 ], [
64 if test -n "$FAIL_HARD"; then
65 if "$FAIL_HARD"; then
66 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
67 fi
68 fi
69 ], [
70 -L$PQ_DIR/$PHP_LIBDIR
71 ])
72 ])
73
74 PQ_CHECK_FUNC(PQregisterEventProc, true)
75 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_DIR/$PHP_LIBDIR, PQ_SHARED_LIBADD)
76 PHP_SUBST(PQ_SHARED_LIBADD)
77
78 PQ_CHECK_FUNC(PQlibVersion)
79 PQ_CHECK_FUNC(PQconninfo)
80 PQ_CHECK_FUNC(PQsetSingleRowMode)
81
82 dnl
83 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
84 dnl
85 AC_DEFUN([PQ_HAVE_PHP_EXT], [
86 extname=$1
87 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
88 AC_MSG_CHECKING([for ext/$extname support])
89 if test "$haveext" != "no" && test "x$haveext" != "x"; then
90 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
91 AC_MSG_RESULT([yes])
92 $2
93 elif test -x "$PHP_EXECUTABLE"; then
94 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
95 if test "$grepext" = "$extname"; then
96 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
97 AC_MSG_RESULT([yes])
98 $2
99 else
100 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
101 AC_MSG_RESULT([no])
102 $3
103 fi
104 else
105 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
106 AC_MSG_RESULT([no])
107 $3
108 fi
109 ])
110
111 PQ_SRC="\
112 src/php_pq_module.c\
113 src/php_pq_misc.c\
114 src/php_pq_callback.c\
115 src/php_pq_object.c\
116 src/php_pq_params.c\
117 src/php_pqcancel.c\
118 src/php_pqconn.c\
119 src/php_pqconn_event.c\
120 src/php_pqcopy.c\
121 src/php_pqexc.c\
122 src/php_pqlob.c\
123 src/php_pqres.c\
124 src/php_pqstm.c\
125 src/php_pqtxn.c\
126 src/php_pqtypes.c\
127 src/php_pqcur.c\
128 "
129 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
130 PHP_ADD_BUILD_DIR($ext_builddir/src)
131 PHP_ADD_INCLUDE($ext_srcdir/src)
132
133 PQ_HAVE_PHP_EXT([raphf], [
134 AC_MSG_CHECKING([for php_raphf.h])
135 PQ_EXT_RAPHF_INCDIR=
136 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
137 if test -d $i; then
138 if test -f $i/php_raphf.h; then
139 PQ_EXT_RAPHF_INCDIR=$i
140 break
141 elif test -f $i/ext/raphf/php_raphf.h; then
142 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
143 break
144 fi
145 fi
146 done
147 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
148 AC_MSG_ERROR([not found])
149 else
150 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
151 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
152 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
153 fi
154 ], [
155 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
156 ])
157 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
158 PQ_HAVE_PHP_EXT([json], [
159 AC_MSG_CHECKING([for php_json.h])
160 PQ_EXT_JSON_INCDIR=
161 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
162 if test -d $i; then
163 if test -f $i/php_json.h; then
164 PQ_EXT_JSON_INCDIR=$i
165 break
166 elif test -f $i/ext/json/php_json.h; then
167 PQ_EXT_JSON_INCDIR=$i/ext/json
168 break
169 fi
170 fi
171 done
172 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
173 AC_MSG_ERROR([not found])
174 else
175 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
176 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
177 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])
178 fi
179 ])
180 fi