prepare v2.2.3
[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
6 SEARCH_PATH="/usr/local /usr /opt"
7 if test "$PHP_PQ" != "yes"; then
8 SEARCH_PATH="$PHP_PQ $SEARCH_PATH"
9 fi
10
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"
15 break
16 fi
17 done
18
19 if test -z "$PG_CONFIG"; then
20 AC_PATH_PROG(PG_CONFIG, pg_config, no)
21 fi
22
23 AC_MSG_RESULT($PG_CONFIG)
24
25 if test "$PG_CONFIG" = "no"; then
26 AC_MSG_ERROR(could not find a usable pg_config in $SEARCH_PATH)
27 else
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)
30 fi
31
32 AC_MSG_CHECKING(for PostgreSQL version)
33 PQ_VERSION=$($PG_CONFIG --version | $SED 's/PostgreSQL //')
34
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)
38 else
39 AC_MSG_RESULT($PQ_VERSION)
40 AC_DEFINE_UNQUOTED(PHP_PQ_LIBVERSION, "$PQ_VERSION", [ ])
41 fi
42
43 PQ_INCDIR=$($PG_CONFIG --includedir)
44 PQ_LIBDIR=$($PG_CONFIG --libdir)
45 fi
46
47 PHP_ADD_INCLUDE($PQ_INCDIR)
48
49 ifdef([AC_PROG_EGREP], [
50 AC_PROG_EGREP
51 ], [
52 AC_CHECK_PROG(EGREP, egrep, egrep)
53 ])
54
55 dnl
56 dnl PQ_CHECK_CONST(name)
57 dnl
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])
62 AC_MSG_RESULT(yep)
63 else
64 AC_MSG_RESULT(nope)
65 fi
66 ])
67
68 PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
69 PQ_CHECK_CONST(PGRES_COPY_BOTH)
70
71 PQ_CHECK_CONST(CONNECTION_CHECK_WRITABLE)
72 PQ_CHECK_CONST(CONNECTION_CONSUME)
73 PQ_CHECK_CONST(CONNECTION_GSS_STARTUP)
74
75 dnl
76 dnl PQ_CHECK_FUNC(sym, fail-hard)
77 dnl
78 AC_DEFUN([PQ_CHECK_FUNC], [
79 FAIL_HARD=$2
80
81 PHP_CHECK_LIBRARY(pq, $1, [
82 AC_DEFINE([HAVE_]translit($1,a-z,A-Z), 1, Have $1)
83 ], [
84 if test -n "$FAIL_HARD"; then
85 if "$FAIL_HARD"; then
86 AC_MSG_ERROR(could not find $PQ_SYM in -lpq)
87 fi
88 fi
89 ], [
90 -L$PQ_LIBDIR
91 ])
92 ])
93
94 PQ_CHECK_FUNC(PQregisterEventProc, true)
95 PHP_ADD_LIBRARY_WITH_PATH(pq, $PQ_LIBDIR, PQ_SHARED_LIBADD)
96 PHP_SUBST(PQ_SHARED_LIBADD)
97
98 PQ_CHECK_FUNC(PQlibVersion)
99 PQ_CHECK_FUNC(PQconninfo)
100 PQ_CHECK_FUNC(PQsetSingleRowMode)
101
102 dnl
103 dnl PQ_HAVE_PHP_EXT(name[, code-if-yes[, code-if-not]])
104 dnl
105 AC_DEFUN([PQ_HAVE_PHP_EXT], [
106 extname=$1
107 haveext=$[PHP_]translit($1,a-z_-,A-Z__)
108 AC_MSG_CHECKING([for ext/$extname support])
109 if test "$haveext" != "no" && test "x$haveext" != "x"; then
110 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
111 AC_MSG_RESULT([yes])
112 $2
113 elif test -x "$PHP_EXECUTABLE"; then
114 grepext=`$PHP_EXECUTABLE -m | $EGREP ^$extname\$`
115 if test "$grepext" = "$extname"; then
116 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=1
117 AC_MSG_RESULT([yes])
118 $2
119 else
120 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
121 AC_MSG_RESULT([no])
122 $3
123 fi
124 else
125 [PHP_PQ_HAVE_EXT_]translit($1,a-z_-,A-Z__)=
126 AC_MSG_RESULT([no])
127 $3
128 fi
129 ])
130
131 PQ_SRC="\
132 src/php_pq_module.c\
133 src/php_pq_misc.c\
134 src/php_pq_callback.c\
135 src/php_pq_object.c\
136 src/php_pq_params.c\
137 src/php_pqcancel.c\
138 src/php_pqconn.c\
139 src/php_pqconn_event.c\
140 src/php_pqcopy.c\
141 src/php_pqexc.c\
142 src/php_pqlob.c\
143 src/php_pqres.c\
144 src/php_pqstm.c\
145 src/php_pqtxn.c\
146 src/php_pqtypes.c\
147 src/php_pqcur.c\
148 "
149 PHP_NEW_EXTENSION(pq, $PQ_SRC, $ext_shared)
150 PHP_ADD_BUILD_DIR($ext_builddir/src)
151 PHP_ADD_INCLUDE($ext_srcdir/src)
152
153 PQ_HAVE_PHP_EXT([raphf], [
154 AC_MSG_CHECKING([for php_raphf.h])
155 PQ_EXT_RAPHF_INCDIR=
156 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../raphf; do
157 if test -d $i; then
158 if test -f $i/php_raphf.h; then
159 PQ_EXT_RAPHF_INCDIR=$i
160 break
161 elif test -f $i/ext/raphf/php_raphf.h; then
162 PQ_EXT_RAPHF_INCDIR=$i/ext/raphf
163 break
164 fi
165 fi
166 done
167 if test "x$PQ_EXT_RAPHF_INCDIR" = "x"; then
168 AC_MSG_ERROR([not found])
169 else
170 AC_MSG_RESULT([$PQ_EXT_RAPHF_INCDIR])
171 AC_DEFINE([PHP_PQ_HAVE_PHP_RAPHF_H], [1], [Have ext/raphf support])
172 PHP_ADD_INCLUDE([$PQ_EXT_RAPHF_INCDIR])
173 fi
174 ], [
175 AC_MSG_ERROR([Please install pecl/raphf and activate extension=raphf.$SHLIB_DL_SUFFIX_NAME in your php.ini])
176 ])
177 PHP_ADD_EXTENSION_DEP(pq, raphf, true)
178 PQ_HAVE_PHP_EXT([json], [
179 AC_MSG_CHECKING([for php_json.h])
180 PQ_EXT_JSON_INCDIR=
181 for i in `echo $INCLUDES | $SED -e's/-I//g'` $abs_srcdir ../json ../jsonc ../jsond; do
182 if test -d $i; then
183 if test -f $i/php_json.h; then
184 PQ_EXT_JSON_INCDIR=$i
185 break
186 elif test -f $i/ext/json/php_json.h; then
187 PQ_EXT_JSON_INCDIR=$i/ext/json
188 break
189 fi
190 fi
191 done
192 if test "x$PQ_EXT_JSON_INCDIR" = "x"; then
193 AC_MSG_ERROR([not found])
194 else
195 AC_MSG_RESULT([$PQ_EXT_JSON_INCDIR])
196 AC_DEFINE([PHP_PQ_HAVE_PHP_JSON_H], [1], [Have ext/json support])
197 PHP_ADD_INCLUDE([$PQ_EXT_JSON_INCDIR])
198 fi
199 ])
200 fi