config.m4 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. PHP_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. if test "$PHP_PDO_PGSQL" != "no"; then
  7. if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
  8. AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
  9. fi
  10. PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
  11. AC_MSG_CHECKING(for pg_config)
  12. for i in $PHP_PDO_PGSQL $PHP_PDO_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
  13. if test -x $i/pg_config; then
  14. PG_CONFIG="$i/pg_config"
  15. break;
  16. fi
  17. done
  18. if test -n "$PG_CONFIG"; then
  19. AC_MSG_RESULT([$PG_CONFIG])
  20. PGSQL_INCLUDE=`$PG_CONFIG --includedir`
  21. PGSQL_LIBDIR=`$PG_CONFIG --libdir`
  22. else
  23. AC_MSG_RESULT(not found)
  24. if test "$PHP_PDO_PGSQL" = "yes"; then
  25. PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
  26. else
  27. PGSQL_SEARCH_PATHS=$PHP_PDO_PGSQL
  28. fi
  29. for i in $PGSQL_SEARCH_PATHS; do
  30. for j in include include/pgsql include/postgres include/postgresql ""; do
  31. if test -r "$i/$j/libpq-fe.h"; then
  32. PGSQL_INC_BASE=$i
  33. PGSQL_INCLUDE=$i/$j
  34. fi
  35. done
  36. for j in $PHP_LIBDIR $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
  37. if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
  38. PGSQL_LIBDIR=$i/$j
  39. fi
  40. done
  41. done
  42. fi
  43. if test -z "$PGSQL_INCLUDE"; then
  44. AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
  45. fi
  46. if test -z "$PGSQL_LIBDIR"; then
  47. AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
  48. fi
  49. if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
  50. AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
  51. fi
  52. AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not])
  53. old_LIBS=$LIBS
  54. old_LDFLAGS=$LDFLAGS
  55. LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
  56. AC_CHECK_LIB(pq, PQlibVersion,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: at least libpq 9.1 is required]))
  57. LIBS=$old_LIBS
  58. LDFLAGS=$old_LDFLAGS
  59. PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PDO_PGSQL_SHARED_LIBADD)
  60. PHP_SUBST(PDO_PGSQL_SHARED_LIBADD)
  61. PHP_ADD_INCLUDE($PGSQL_INCLUDE)
  62. PHP_CHECK_PDO_INCLUDES
  63. PHP_NEW_EXTENSION(pdo_pgsql, pdo_pgsql.c pgsql_driver.c pgsql_statement.c, $ext_shared,,-I$pdo_cv_inc_path)
  64. PHP_ADD_EXTENSION_DEP(pdo_pgsql, pdo)
  65. fi