xref: /php-src/ext/pgsql/config.m4 (revision 1da352c3)
1PHP_ARG_WITH([pgsql],
2  [for PostgreSQL support],
3  [AS_HELP_STRING([[--with-pgsql[=DIR]]],
4    [Include PostgreSQL support. Optional DIR is the PostgreSQL base install
5    directory or the path to pg_config. Also, the PGSQL_CFLAGS and PGSQL_LIBS
6    environment variables can be used instead of the DIR argument to customize
7    the libpq paths.])])
8
9if test "$PHP_PGSQL" != "no"; then
10  PHP_SETUP_PGSQL([PGSQL_SHARED_LIBADD],,, [$PHP_PGSQL])
11  PHP_SUBST([PGSQL_SHARED_LIBADD])
12
13  AC_DEFINE([HAVE_PGSQL], [1],
14    [Define to 1 if the PHP extension 'pgsql' is available.])
15
16  PHP_CHECK_LIBRARY([pq], [PQresultMemorySize],
17    [AC_DEFINE([HAVE_PG_RESULT_MEMORY_SIZE], [1],
18      [Define to 1 if libpq has the 'PQresultMemorySize' function (PostgreSQL 12
19      or later).])],,
20    [$PGSQL_LIBS])
21  PHP_CHECK_LIBRARY([pq], [PQchangePassword],
22    [AC_DEFINE([HAVE_PG_CHANGE_PASSWORD], [1],
23      [Define to 1 if libpq has the 'PQchangePassword' function (PostgreSQL 17
24      or later).])],,
25    [$PGSQL_LIBS])
26  PHP_CHECK_LIBRARY([pq], [PQsocketPoll],
27    [AC_DEFINE([HAVE_PG_SOCKET_POLL], [1],
28      [Define to 1 if libpq has the 'PQsocketPoll' function (PostgreSQL 17 or
29      later).])],,
30    [$PGSQL_LIBS])
31  PHP_CHECK_LIBRARY([pq], [PQsetChunkedRowsMode],
32    [AC_DEFINE([HAVE_PG_SET_CHUNKED_ROWS_SIZE], [1],
33      [Define to 1 if libpq has the 'PQsetChunkedRowsMode' function (PostgreSQL
34      17 or later).])],,
35    [$PGSQL_LIBS])
36  PHP_CHECK_LIBRARY([pq], [PQclosePrepared],
37    [AC_DEFINE([HAVE_PG_CLOSE_STMT], [1], [PostgreSQL 17 or later])],,
38    [$PGSQL_LIBS])
39
40  old_CFLAGS=$CFLAGS
41  CFLAGS="$CFLAGS $PGSQL_CFLAGS"
42
43  dnl Available since PostgreSQL 12.
44  AC_CACHE_CHECK([if PGVerbosity enum has PQERRORS_SQLSTATE],
45    [php_cv_enum_pgverbosity_pqerrors_sqlstate],
46    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <libpq-fe.h>],
47      [PGVerbosity e = PQERRORS_SQLSTATE; (void)e;])],
48      [php_cv_enum_pgverbosity_pqerrors_sqlstate=yes],
49      [php_cv_enum_pgverbosity_pqerrors_sqlstate=no])])
50  AS_VAR_IF([php_cv_enum_pgverbosity_pqerrors_sqlstate], [yes],
51    [AC_DEFINE([HAVE_PQERRORS_SQLSTATE], [1],
52      [Define to 1 if PGVerbosity enum has PQERRORS_SQLSTATE.])])
53
54  CFLAGS=$old_CFLAGS
55
56  PHP_NEW_EXTENSION([pgsql],
57    [pgsql.c],
58    [$ext_shared],,
59    [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
60  PHP_ADD_EXTENSION_DEP(pgsql, pcre)
61fi
62