xref: /PHP-8.1/ext/pdo_pgsql/config.m4 (revision ce668c0e)
1PHP_ARG_WITH([pdo-pgsql],
2  [for PostgreSQL support for PDO],
3  [AS_HELP_STRING([[--with-pdo-pgsql[=DIR]]],
4    [PDO: PostgreSQL support. DIR is the PostgreSQL base install directory or
5    the path to pg_config])])
6
7if test "$PHP_PDO_PGSQL" != "no"; then
8
9  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
10    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
11  fi
12
13  PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
14
15  AC_MSG_CHECKING(for pg_config)
16  for i in $PHP_PDO_PGSQL $PHP_PDO_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
17    if test -x $i/pg_config; then
18      PG_CONFIG="$i/pg_config"
19      break;
20    fi
21  done
22
23  if test -n "$PG_CONFIG"; then
24    AC_MSG_RESULT([$PG_CONFIG])
25    PGSQL_INCLUDE=`$PG_CONFIG --includedir`
26    PGSQL_LIBDIR=`$PG_CONFIG --libdir`
27  else
28    AC_MSG_RESULT(not found)
29    if test "$PHP_PDO_PGSQL" = "yes"; then
30      PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
31    else
32      PGSQL_SEARCH_PATHS=$PHP_PDO_PGSQL
33    fi
34
35    for i in $PGSQL_SEARCH_PATHS; do
36      for j in include include/pgsql include/postgres include/postgresql ""; do
37        if test -r "$i/$j/libpq-fe.h"; then
38          PGSQL_INC_BASE=$i
39          PGSQL_INCLUDE=$i/$j
40        fi
41      done
42
43      for j in $PHP_LIBDIR $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
44        if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
45          PGSQL_LIBDIR=$i/$j
46        fi
47      done
48    done
49  fi
50
51  if test -z "$PGSQL_INCLUDE"; then
52    AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
53  fi
54
55  if test -z "$PGSQL_LIBDIR"; then
56    AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
57  fi
58
59  if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
60    AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
61  fi
62
63  AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not])
64
65  old_LIBS=$LIBS
66  old_LDFLAGS=$LDFLAGS
67  LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
68
69  AC_CHECK_LIB(pq, PQlibVersion,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: at least libpq 9.1 is required]))
70
71  LIBS=$old_LIBS
72  LDFLAGS=$old_LDFLAGS
73
74  PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PDO_PGSQL_SHARED_LIBADD)
75  PHP_SUBST(PDO_PGSQL_SHARED_LIBADD)
76
77  PHP_ADD_INCLUDE($PGSQL_INCLUDE)
78
79  PHP_CHECK_PDO_INCLUDES
80
81  PHP_NEW_EXTENSION(pdo_pgsql, pdo_pgsql.c pgsql_driver.c pgsql_statement.c, $ext_shared,,-I$pdo_cv_inc_path)
82  PHP_ADD_EXTENSION_DEP(pdo_pgsql, pdo)
83fi
84