1
1
PHP_ARG_WITH([ pgsql] ,
2
2
[ for PostgreSQL support] ,
3
3
[ AS_HELP_STRING ( [ [ --with-pgsql[ =DIR] ] ] ,
4
- [ Include PostgreSQL support. DIR is the PostgreSQL base install directory or
5
- the path to pg_config] ) ] )
4
+ [ Include PostgreSQL support. Optional DIR is the PostgreSQL base install
5
+ directory or the path to pg_config. When using pkg-config, the PGSQL_CFLAGS
6
+ and PGSQL_LIBS environment variables can be used instead of the DIR argument
7
+ to customize the libpq paths.] ) ] )
6
8
7
9
if test "$PHP_PGSQL" != "no"; then
8
- PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
10
+ PHP_SETUP_PGSQL([ PGSQL_SHARED_LIBADD] ,,, [ $PHP_PGSQL] )
11
+ PHP_SUBST([ PGSQL_SHARED_LIBADD] )
9
12
10
- dnl pg_config is still the default way to retrieve build options
11
- dnl pkgconfig support was only introduced in 9.3
12
-
13
- AC_MSG_CHECKING ( for pg_config )
14
- for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
15
- if test -x $i/pg_config; then
16
- PG_CONFIG="$i/pg_config"
17
- break;
18
- fi
19
- done
20
-
21
- if test -n "$PG_CONFIG"; then
22
- AC_MSG_RESULT ( [ $PG_CONFIG] )
23
- PGSQL_INCLUDE=`$PG_CONFIG --includedir`
24
- PGSQL_LIBDIR=`$PG_CONFIG --libdir`
25
- else
26
- AC_MSG_RESULT ( not found )
27
- if test "$PHP_PGSQL" = "yes"; then
28
- PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
29
- else
30
- PGSQL_SEARCH_PATHS=$PHP_PGSQL
31
- fi
32
-
33
- for i in $PGSQL_SEARCH_PATHS; do
34
- for j in include include/pgsql include/postgres include/postgresql ""; do
35
- if test -r "$i/$j/libpq-fe.h"; then
36
- PGSQL_INC_BASE=$i
37
- PGSQL_INCLUDE=$i/$j
38
- fi
39
- done
40
-
41
- for j in lib $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
42
- if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
43
- PGSQL_LIBDIR=$i/$j
44
- fi
45
- done
46
- done
47
- fi
48
-
49
- if test -z "$PGSQL_INCLUDE"; then
50
- AC_MSG_ERROR ( Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path )
51
- fi
52
-
53
- if test -z "$PGSQL_LIBDIR"; then
54
- AC_MSG_ERROR ( Cannot find libpq.so. Please specify correct PostgreSQL installation path )
55
- fi
13
+ AC_DEFINE ( HAVE_PGSQL ,1 ,[ Whether to build PostgreSQL support or not] )
56
14
57
- if test -z "$PGSQL_INCLUDE" && test -z "$PGSQL_LIBDIR"; then
58
- AC_MSG_ERROR ( [ Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS] )
59
- fi
15
+ PHP_CHECK_LIBRARY([ pq] , [ lo_truncate64] ,
16
+ [ AC_DEFINE ( [ HAVE_PG_LO64] , [ 1] , [ PostgreSQL 9.3 or later] ) ] ,,
17
+ [ $PGSQL_LIBS] )
18
+ PHP_CHECK_LIBRARY([ pq] , [ PQsetErrorContextVisibility] ,
19
+ [ AC_DEFINE ( [ HAVE_PG_CONTEXT_VISIBILITY] , [ 1] , [ PostgreSQL 9.6 or later] ) ] ,,
20
+ [ $PGSQL_LIBS] )
21
+ PHP_CHECK_LIBRARY([ pq] , [ PQresultMemorySize] ,
22
+ [ AC_DEFINE ( [ HAVE_PG_RESULT_MEMORY_SIZE] , [ 1] , [ PostgreSQL 12 or later] ) ] ,,
23
+ [ $PGSQL_LIBS] )
24
+ PHP_CHECK_LIBRARY([ pq] , [ PQchangePassword] ,
25
+ [ AC_DEFINE ( [ HAVE_PG_CHANGE_PASSWORD] , [ 1] , [ PostgreSQL 17 or later] ) ] ,,
26
+ [ $PGSQL_LIBS] )
27
+ PHP_CHECK_LIBRARY([ pq] , [ PQsocketPoll] ,
28
+ [ AC_DEFINE ( [ HAVE_PG_SOCKET_POLL] , [ 1] , [ PostgreSQL 17 or later] ) ] ,,
29
+ [ $PGSQL_LIBS] )
60
30
61
- AC_DEFINE ( HAVE_PGSQL ,1 ,[ Whether to build PostgreSQL support or not] )
62
- old_LIBS=$LIBS
63
- old_LDFLAGS=$LDFLAGS
64
- LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
65
31
old_CFLAGS=$CFLAGS
66
- CFLAGS="$CFLAGS -I$PGSQL_INCLUDE"
67
- AC_CHECK_LIB ( pq , PQlibVersion ,, AC_MSG_ERROR ( [ Unable to build the PostgreSQL extension: at least libpq 9.1 is required] ) )
68
- AC_CHECK_LIB ( pq , lo_truncate64 , AC_DEFINE ( HAVE_PG_LO64 ,1 ,[ PostgreSQL 9.3 or later] ) )
69
- AC_CHECK_LIB ( pq , PQsetErrorContextVisibility , AC_DEFINE ( HAVE_PG_CONTEXT_VISIBILITY ,1 ,[ PostgreSQL 9.6 or later] ) )
70
- AC_CHECK_LIB ( pq , PQresultMemorySize , AC_DEFINE ( HAVE_PG_RESULT_MEMORY_SIZE ,1 ,[ PostgreSQL 12 or later] ) )
71
- AC_CHECK_LIB ( pq , PQchangePassword , AC_DEFINE ( HAVE_PG_CHANGE_PASSWORD ,1 ,[ PostgreSQL 17 or later] ) )
72
- AC_CHECK_LIB ( pq , PQsocketPoll , AC_DEFINE ( HAVE_PG_SOCKET_POLL ,1 ,[ PostgreSQL 17 or later] ) )
32
+ CFLAGS="$CFLAGS $PGSQL_CFLAGS"
73
33
74
34
dnl Available since PostgreSQL 12.
75
35
AC_CACHE_CHECK ( [ if PGVerbosity enum has PQERRORS_SQLSTATE] ,
@@ -82,15 +42,7 @@ if test "$PHP_PGSQL" != "no"; then
82
42
[ AC_DEFINE ( [ HAVE_PQERRORS_SQLSTATE] , [ 1] ,
83
43
[ Define to 1 if PGVerbosity enum has PQERRORS_SQLSTATE.] ) ] )
84
44
85
- LIBS=$old_LIBS
86
- LDFLAGS=$old_LDFLAGS
87
45
CFLAGS=$old_CFLAGS
88
46
89
- PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PGSQL_SHARED_LIBADD)
90
- PHP_SUBST(PGSQL_SHARED_LIBADD)
91
-
92
- PHP_ADD_INCLUDE($PGSQL_INCLUDE)
93
-
94
47
PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
95
- PHP_ADD_EXTENSION_DEP(pgsql, pcre)
96
48
fi
0 commit comments