Skip to content

Commit 6723345

Browse files
committed
Fix passing manual, non-standard installation paths
./configure \ --with-pgsql=/any/path/to/postgresql \ --with-pdo-postgresql=/any/path/to/postgresql
1 parent dc07df7 commit 6723345

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

build/php.m4

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,11 +1940,7 @@ dnl install directory or the path to pg_config.
19401940
dnl
19411941
AC_DEFUN([PHP_SETUP_PGSQL],
19421942
[found_pgsql=no
1943-
PKG_CHECK_MODULES([PGSQL], [libpq >= 9.3], [
1944-
PHP_EVAL_INCLINE([$PGSQL_CFLAGS])
1945-
PHP_EVAL_LIBLINE([$PGSQL_LIBS], [$1])
1946-
found_pgsql=yes
1947-
], [
1943+
PKG_CHECK_MODULES([PGSQL], [libpq >= 9.3], [found_pgsql=yes], [
19481944
dnl Undocumented BC feature: The PGSQL_INCLUDE variable can be also passed to
19491945
dnl configure script to override the PostgreSQL library include directory.
19501946
PHP_EXPAND_PATH([$PGSQL_INCLUDE], [PGSQL_INCLUDE])
@@ -1979,14 +1975,17 @@ dnl Set installation PostgreSQL directory if given from configure argument.
19791975
19801976
AS_IF([test -z "$PGSQL_INCLUDE" || test -z "PGSQL_LIBDIR"], [found_pgsql=no], [
19811977
found_pgsql=yes
1982-
PHP_ADD_LIBRARY_WITH_PATH([pq], [$PGSQL_LIBDIR], [$1])
1983-
PHP_ADD_INCLUDE([$PGSQL_INCLUDE])
1978+
PGSQL_CFLAGS="-I$PGSQL_INCLUDE"
1979+
PGSQL_LIBS="-lpq -L$PGSQL_LIBDIR"
19841980
])
19851981
])
19861982
1987-
AS_VAR_IF([found_pgsql], [yes],
1988-
[AC_CHECK_LIB([pq], [PQlibVersion], [:],
1989-
[AC_MSG_ERROR([PostgreSQL check failed: libpq 9.1 or later is required.])])
1983+
AS_VAR_IF([found_pgsql], [yes], [
1984+
PHP_EVAL_INCLINE([$PGSQL_CFLAGS])
1985+
PHP_EVAL_LIBLINE([$PGSQL_LIBS], [$1])
1986+
PHP_CHECK_LIBRARY([pq], [PQlibVersion],,
1987+
[AC_MSG_ERROR([PostgreSQL check failed: libpq 9.1 or later is required.])],
1988+
[$PGSQL_LIBS])
19901989
$2],
19911990
[m4_default([$3], [AC_MSG_ERROR(m4_normalize([
19921991
Cannot find libpq-fe.h or libpq.so anywhere under $PGSQL_SEARCH_PATHS. Please

ext/pdo_pgsql/config.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ if test "$PHP_PDO_PGSQL" != "no"; then
1616

1717
AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not])
1818

19-
AC_CHECK_LIB(pq, PQresultMemorySize, AC_DEFINE(HAVE_PG_RESULT_MEMORY_SIZE,1,[PostgreSQL 12 or later]))
19+
PHP_CHECK_LIBRARY([pq], [PQresultMemorySize],
20+
[AC_DEFINE([HAVE_PG_RESULT_MEMORY_SIZE], [1], [PostgreSQL 12 or later])],,
21+
[$PGSQL_LIBS])
2022

2123
PHP_CHECK_PDO_INCLUDES
2224

ext/pgsql/config.m4

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,28 @@ if test "$PHP_PGSQL" != "no"; then
1212

1313
AC_DEFINE(HAVE_PGSQL,1,[Whether to build PostgreSQL support or not])
1414

15-
old_CFLAGS=$CFLAGS
16-
CFLAGS="$CFLAGS -I$INCLUDES"
15+
PHP_CHECK_LIBRARY([pq], [pg_encoding_to_char],
16+
[AC_DEFINE([HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT], [1],
17+
[Whether libpq is compiled with --enable-multibyte])],,
18+
[$PGSQL_LIBS])
19+
PHP_CHECK_LIBRARY([pq], [lo_truncate64],
20+
[AC_DEFINE([HAVE_PG_LO64], [1], [PostgreSQL 9.3 or later])],,
21+
[$PGSQL_LIBS])
22+
PHP_CHECK_LIBRARY([pq], [PQsetErrorContextVisibility],
23+
[AC_DEFINE([HAVE_PG_CONTEXT_VISIBILITY], [1], [PostgreSQL 9.6 or later])],,
24+
[$PGSQL_LIBS])
25+
PHP_CHECK_LIBRARY([pq], [PQresultMemorySize],
26+
[AC_DEFINE([HAVE_PG_RESULT_MEMORY_SIZE], [1], [PostgreSQL 12 or later])],,
27+
[$PGSQL_LIBS])
28+
PHP_CHECK_LIBRARY([pq], [PQchangePassword],
29+
[AC_DEFINE([HAVE_PG_CHANGE_PASSWORD], [1], [PostgreSQL 17 or later])],,
30+
[$PGSQL_LIBS])
31+
PHP_CHECK_LIBRARY([pq], [PQsocketPoll],
32+
[AC_DEFINE([HAVE_PG_SOCKET_POLL], [1], [PostgreSQL 17 or later])],,
33+
[$PGSQL_LIBS])
1734

18-
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
19-
AC_CHECK_LIB(pq, lo_truncate64, AC_DEFINE(HAVE_PG_LO64,1,[PostgreSQL 9.3 or later]))
20-
AC_CHECK_LIB(pq, PQsetErrorContextVisibility, AC_DEFINE(HAVE_PG_CONTEXT_VISIBILITY,1,[PostgreSQL 9.6 or later]))
21-
AC_CHECK_LIB(pq, PQresultMemorySize, AC_DEFINE(HAVE_PG_RESULT_MEMORY_SIZE,1,[PostgreSQL 12 or later]))
22-
AC_CHECK_LIB(pq, PQchangePassword, AC_DEFINE(HAVE_PG_CHANGE_PASSWORD,1,[PostgreSQL 17 or later]))
23-
AC_CHECK_LIB(pq, PQsocketPoll, AC_DEFINE(HAVE_PG_SOCKET_POLL,1,[PostgreSQL 17 or later]))
35+
old_CFLAGS=$CFLAGS
36+
CFLAGS="$CFLAGS $PGSQL_CFLAGS"
2437

2538
dnl Available since PostgreSQL 12.
2639
AC_CACHE_CHECK([if PGVerbosity enum has PQERRORS_SQLSTATE],

0 commit comments

Comments
 (0)