summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pgsql/config.m419
-rw-r--r--ext/pgsql/php_pgsql.h2
2 files changed, 21 insertions, 0 deletions
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
index bedf744837..fee81e8e0f 100644
--- a/ext/pgsql/config.m4
+++ b/ext/pgsql/config.m4
@@ -23,6 +23,25 @@ if test "$PHP_PGSQL" != "no"; then
PGSQL_INCLUDE="-I$PGSQL_INCDIR"
+ AC_CACHE_CHECK([whether PostgreSQL needs postgres.h], ac_cv_php_pgsql_postgres_h,[
+ old_CPPFLAGS=$CPPFLAGS
+ CPPFLAGS="$CPPFLAGS $PGSQL_INCLUDE"
+ AC_TRY_COMPILE([
+#include <libpq-fe.h>
+],[
+ Oid x = InvalidOid;
+],[
+ ac_cv_php_pgsql_postgres_h=no
+],[
+ ac_cv_php_pgsql_postgres_h=yes
+])
+ CPPFLAGS=$old_CPPFLAGS
+])
+
+ if test "$ac_cv_php_pgsql_postgres_h" = "yes"; then
+ AC_DEFINE(PHP_PGSQL_NEEDS_POSTGRES_H, 1, [whether pgsql needs postgres.h])
+ fi
+
PGSQL_LIBDIR=$PGSQL_DIR/lib
test -d $PGSQL_DIR/lib/pgsql && PGSQL_LIBDIR=$PGSQL_DIR/lib/pgsql
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index e53670a1af..22ccfe2c75 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -29,7 +29,9 @@ extern zend_module_entry pgsql_module_entry;
#ifdef PHP_PGSQL_PRIVATE
#undef SOCKET_SIZE_TYPE
+#ifdef PHP_PGSQL_NEEDS_POSTGRES_H
#include <postgres.h>
+#endif
#include <libpq-fe.h>
#ifdef PHP_WIN32