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