summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugh McMaster <hugh.mcmaster@outlook.com>2019-06-07 22:29:55 +1000
committerJoe Watkins <krakjoe@php.net>2019-06-11 08:53:49 +0200
commit1e265174ed8b361c2d8b9c050f9e3b1f7034acc9 (patch)
tree3f59fe71d4d124d8538764f24111eed53419fc6b
parent27e592d3ce0115927aa39daa8418a48337ea9539 (diff)
downloadphp-git-1e265174ed8b361c2d8b9c050f9e3b1f7034acc9.tar.gz
ext/pgsql: Use PKG_CHECK_MODULES to detect the pq library
-rw-r--r--ext/pgsql/config.m471
1 files changed, 9 insertions, 62 deletions
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
index a5afd02923..f54bf5a822 100644
--- a/ext/pgsql/config.m4
+++ b/ext/pgsql/config.m4
@@ -1,70 +1,20 @@
PHP_ARG_WITH([pgsql],
- [for PostgreSQL support],
- [AS_HELP_STRING([[--with-pgsql[=DIR]]],
- [Include PostgreSQL support. DIR is the PostgreSQL base install directory or
- the path to pg_config])])
+ [whether to build with PostgreSQL support],
+ [AS_HELP_STRING([--with-pgsql],
+ [Build with PostgreSQL support.])])
if test "$PHP_PGSQL" != "no"; then
- PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
+ PKG_CHECK_MODULES([PGSQL], [libpq])
- AC_MSG_CHECKING(for pg_config)
- for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
- if test -x $i/pg_config; then
- PG_CONFIG="$i/pg_config"
- break;
- fi
- done
+ PHP_EVAL_INCLINE($PGSQL_CFLAGS)
+ PHP_EVAL_LIBLINE($PGSQL_LIBS, PGSQL_SHARED_LIBADD)
- if test -n "$PG_CONFIG"; then
- AC_MSG_RESULT([$PG_CONFIG])
- PGSQL_INCLUDE=`$PG_CONFIG --includedir`
- PGSQL_LIBDIR=`$PG_CONFIG --libdir`
- if test -r "$PGSQL_INCLUDE/pg_config.h"; then
- AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
- fi
- else
- AC_MSG_RESULT(not found)
- if test "$PHP_PGSQL" = "yes"; then
- PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
- else
- PGSQL_SEARCH_PATHS=$PHP_PGSQL
- fi
+ AC_DEFINE(HAVE_PG_CONFIG_H, 1, [Have pg_config.h])
+ AC_DEFINE(HAVE_PGSQL, 1, [Build with PostgreSQL support])
- for i in $PGSQL_SEARCH_PATHS; do
- for j in include include/pgsql include/postgres include/postgresql ""; do
- if test -r "$i/$j/libpq-fe.h"; then
- PGSQL_INC_BASE=$i
- PGSQL_INCLUDE=$i/$j
- if test -r "$i/$j/pg_config.h"; then
- AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
- fi
- fi
- done
-
- for j in lib $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
- if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
- PGSQL_LIBDIR=$i/$j
- fi
- done
- done
- fi
-
- if test -z "$PGSQL_INCLUDE"; then
- AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
- fi
-
- if test -z "$PGSQL_LIBDIR"; then
- AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
- fi
-
- if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
- AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
- fi
-
- AC_DEFINE(HAVE_PGSQL,1,[Whether to build PostgreSQL support or not])
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
- LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
+ LDFLAGS="$PGSQL_LIBS $LDFLAGS"
AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0 or later]))
AC_CHECK_LIB(pq, PQunescapeBytea,AC_DEFINE(HAVE_PQUNESCAPEBYTEA,1,[PostgreSQL 7.3.0 or later]))
AC_CHECK_LIB(pq, PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later]))
@@ -98,10 +48,7 @@ if test "$PHP_PGSQL" != "no"; then
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
- PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PGSQL_SHARED_LIBADD)
PHP_SUBST(PGSQL_SHARED_LIBADD)
- PHP_ADD_INCLUDE($PGSQL_INCLUDE)
-
PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi