php-src/ext/pdo_pgsql/config.m4

130 lines
4.2 KiB
Plaintext
Raw Normal View History

2004-05-20 10:27:49 +08:00
dnl $Id$
dnl config.m4 for extension pdo_pgsql
dnl vim:et:sw=2:ts=2:
2004-05-20 10:27:49 +08:00
PHP_ARG_WITH(pdo-pgsql,for PostgreSQL support for PDO,
2005-05-30 07:17:16 +08:00
[ --with-pdo-pgsql[=DIR] PDO: PostgreSQL support. DIR is the PostgreSQL base
install directory or the path to pg_config])
2004-05-20 10:27:49 +08:00
if test "$PHP_PDO_PGSQL" != "no"; then
if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
fi
2004-05-20 10:27:49 +08:00
PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
AC_MSG_CHECKING(for pg_config)
for i in $PHP_PDO_PGSQL $PHP_PDO_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
2007-07-09 20:38:02 +08:00
if test -x $i/pg_config; then
2004-05-20 10:27:49 +08:00
PG_CONFIG="$i/pg_config"
break;
fi
done
if test -n "$PG_CONFIG"; then
AC_MSG_RESULT([$PG_CONFIG])
PGSQL_INCLUDE=`$PG_CONFIG --includedir`
PGSQL_LIBDIR=`$PG_CONFIG --libdir`
AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
else
AC_MSG_RESULT(not found)
if test "$PHP_PDO_PGSQL" = "yes"; then
PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
else
PGSQL_SEARCH_PATHS=$PHP_PDO_PGSQL
fi
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 $PHP_LIBDIR $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
2004-05-20 10:27:49 +08:00
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
2007-07-12 05:51:55 +08:00
AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
2004-05-20 10:27:49 +08:00
fi
AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not])
AC_MSG_CHECKING([for openssl dependencies])
grep openssl $PGSQL_INCLUDE/libpq-fe.h >/dev/null 2>&1
if test $? -eq 0 ; then
2007-07-09 20:38:02 +08:00
AC_MSG_RESULT([yes])
dnl First try to find pkg-config
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
PDO_PGSQL_CFLAGS=`$PKG_CONFIG openssl --cflags`
fi
else
2007-07-09 20:38:02 +08:00
AC_MSG_RESULT([no])
fi
2004-05-20 10:27:49 +08:00
old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]), [
echo "Unable to build the PDO PostgreSQL driver: libpq 7.4+ is required"
exit 1
])
AC_CHECK_LIB(pq, PQprepare,AC_DEFINE(HAVE_PQPREPARE,1,[PostgreSQL 8.0 or later]))
AC_CHECK_LIB(pq, PQescapeStringConn, AC_DEFINE(HAVE_PQESCAPE_CONN,1,[PostgreSQL 8.1.4 or later]))
AC_CHECK_LIB(pq, PQescapeByteaConn, AC_DEFINE(HAVE_PQESCAPE_BYTEA_CONN,1,[PostgreSQL 8.1.4 or later]))
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
2004-05-20 10:27:49 +08:00
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PDO_PGSQL_SHARED_LIBADD)
PHP_SUBST(PDO_PGSQL_SHARED_LIBADD)
PHP_ADD_INCLUDE($PGSQL_INCLUDE)
2005-07-27 10:51:01 +08:00
ifdef([PHP_CHECK_PDO_INCLUDES],
[
2007-07-09 20:38:02 +08:00
PHP_CHECK_PDO_INCLUDES
2005-07-27 10:51:01 +08:00
],[
AC_MSG_CHECKING([for PDO includes])
if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
2011-05-15 13:03:29 +08:00
pdo_cv_inc_path=$abs_srcdir/ext
2005-07-27 10:51:01 +08:00
elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
2011-05-15 13:03:29 +08:00
pdo_cv_inc_path=$abs_srcdir/ext
2005-07-27 10:51:01 +08:00
elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
2011-05-15 13:03:29 +08:00
pdo_cv_inc_path=$prefix/include/php/ext
2005-07-27 10:51:01 +08:00
else
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
fi
2011-05-15 13:03:29 +08:00
AC_MSG_RESULT($pdo_cv_inc_path)
2005-07-27 10:51:01 +08:00
])
2004-05-20 10:27:49 +08:00
2011-05-15 13:03:29 +08:00
PHP_NEW_EXTENSION(pdo_pgsql, pdo_pgsql.c pgsql_driver.c pgsql_statement.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_PGSQL_CFLAGS)
2005-07-27 10:51:01 +08:00
ifdef([PHP_ADD_EXTENSION_DEP],
[
PHP_ADD_EXTENSION_DEP(pdo_pgsql, pdo)
])
2004-05-20 10:27:49 +08:00
fi