xref: /PHP-5.5/ext/pgsql/config.m4 (revision c6d977dd)
1dnl
2dnl $Id$
3dnl
4
5PHP_ARG_WITH(pgsql,for PostgreSQL support,
6[  --with-pgsql[=DIR]        Include PostgreSQL support.  DIR is the PostgreSQL
7                          base install directory or the path to pg_config])
8
9if test "$PHP_PGSQL" != "no"; then
10  PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
11
12  AC_MSG_CHECKING(for pg_config)
13  for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
14	if test -x $i/pg_config; then
15      PG_CONFIG="$i/pg_config"
16      break;
17    fi
18  done
19
20  if test -n "$PG_CONFIG"; then
21    AC_MSG_RESULT([$PG_CONFIG])
22    PGSQL_INCLUDE=`$PG_CONFIG --includedir`
23    PGSQL_LIBDIR=`$PG_CONFIG --libdir`
24    if test -r "$PGSQL_INCLUDE/pg_config.h"; then
25      AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
26    fi
27  else
28    AC_MSG_RESULT(not found)
29    if test "$PHP_PGSQL" = "yes"; then
30      PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
31    else
32      PGSQL_SEARCH_PATHS=$PHP_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          if test -r "$i/$j/pg_config.h"; then
41            AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
42          fi
43        fi
44      done
45
46      for j in lib $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
47        if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
48          PGSQL_LIBDIR=$i/$j
49        fi
50      done
51    done
52  fi
53
54  if test -z "$PGSQL_INCLUDE"; then
55    AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
56  fi
57
58  if test -z "$PGSQL_LIBDIR"; then
59    AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
60  fi
61
62  if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
63    AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
64  fi
65
66  AC_DEFINE(HAVE_PGSQL,1,[Whether to build PostgreSQL support or not])
67  old_LIBS=$LIBS
68  old_LDFLAGS=$LDFLAGS
69  LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
70  AC_CHECK_LIB(pq, PQescapeString,AC_DEFINE(HAVE_PQESCAPE,1,[PostgreSQL 7.2.0 or later]))
71  AC_CHECK_LIB(pq, PQunescapeBytea,AC_DEFINE(HAVE_PQUNESCAPEBYTEA,1,[PostgreSQL 7.3.0 or later]))
72  AC_CHECK_LIB(pq, PQsetnonblocking,AC_DEFINE(HAVE_PQSETNONBLOCKING,1,[PostgreSQL 7.0.x or later]))
73  AC_CHECK_LIB(pq, PQcmdTuples,AC_DEFINE(HAVE_PQCMDTUPLES,1,[Broken libpq under windows]))
74  AC_CHECK_LIB(pq, PQoidValue,AC_DEFINE(HAVE_PQOIDVALUE,1,[Older PostgreSQL]))
75  AC_CHECK_LIB(pq, PQclientEncoding,AC_DEFINE(HAVE_PQCLIENTENCODING,1,[PostgreSQL 7.0.x or later]))
76  AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]))
77  AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
78  AC_CHECK_LIB(pq, PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or later]))
79  AC_CHECK_LIB(pq, PQexecParams,AC_DEFINE(HAVE_PQEXECPARAMS,1,[PostgreSQL 7.4 or later]))
80  AC_CHECK_LIB(pq, PQprepare,AC_DEFINE(HAVE_PQPREPARE,1,[PostgreSQL 7.4 or later]))
81  AC_CHECK_LIB(pq, PQexecPrepared,AC_DEFINE(HAVE_PQEXECPREPARED,1,[PostgreSQL 7.4 or later]))
82  AC_CHECK_LIB(pq, PQresultErrorField,AC_DEFINE(HAVE_PQRESULTERRORFIELD,1,[PostgreSQL 7.4 or later]))
83  AC_CHECK_LIB(pq, PQsendQueryParams,AC_DEFINE(HAVE_PQSENDQUERYPARAMS,1,[PostgreSQL 7.4 or later]))
84  AC_CHECK_LIB(pq, PQsendPrepare,AC_DEFINE(HAVE_PQSENDPREPARE,1,[PostgreSQL 7.4 or later]))
85  AC_CHECK_LIB(pq, PQsendQueryPrepared,AC_DEFINE(HAVE_PQSENDQUERYPREPARED,1,[PostgreSQL 7.4 or later]))
86  AC_CHECK_LIB(pq, PQputCopyData,AC_DEFINE(HAVE_PQPUTCOPYDATA,1,[PostgreSQL 7.4 or later]))
87  AC_CHECK_LIB(pq, PQputCopyEnd,AC_DEFINE(HAVE_PQPUTCOPYEND,1,[PostgreSQL 7.4 or later]))
88  AC_CHECK_LIB(pq, PQgetCopyData,AC_DEFINE(HAVE_PQGETCOPYDATA,1,[PostgreSQL 7.4 or later]))
89  AC_CHECK_LIB(pq, PQfreemem,AC_DEFINE(HAVE_PQFREEMEM,1,[PostgreSQL 7.4 or later]))
90  AC_CHECK_LIB(pq, PQsetErrorVerbosity,AC_DEFINE(HAVE_PQSETERRORVERBOSITY,1,[PostgreSQL 7.4 or later]))
91  AC_CHECK_LIB(pq, PQftable,AC_DEFINE(HAVE_PQFTABLE,1,[PostgreSQL 7.4 or later]))
92  AC_CHECK_LIB(pq, PQescapeStringConn, AC_DEFINE(HAVE_PQESCAPE_CONN,1,[PostgreSQL 8.1.4 or later]))
93  AC_CHECK_LIB(pq, PQescapeByteaConn, AC_DEFINE(HAVE_PQESCAPE_BYTEA_CONN,1,[PostgreSQL 8.1.4 or later]))
94  AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
95  AC_CHECK_LIB(pq, lo_create, AC_DEFINE(HAVE_PG_LO_CREATE,1,[PostgreSQL 8.1 or later]))
96  AC_CHECK_LIB(pq, lo_import_with_oid, AC_DEFINE(HAVE_PG_LO_IMPORT_WITH_OID,1,[PostgreSQL 8.4 or later]))
97  AC_CHECK_LIB(pq, PQescapeLiteral, AC_DEFINE(HAVE_PQESCAPELITERAL,1,[PostgreSQL 9.0 or later]))
98  LIBS=$old_LIBS
99  LDFLAGS=$old_LDFLAGS
100
101  PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PGSQL_SHARED_LIBADD)
102  PHP_SUBST(PGSQL_SHARED_LIBADD)
103
104  PHP_ADD_INCLUDE($PGSQL_INCLUDE)
105
106  PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared)
107fi
108
109
110