config.m4 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. PHP_ARG_WITH([pgsql],
  2. [for PostgreSQL support],
  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])])
  6. if test "$PHP_PGSQL" != "no"; then
  7. PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
  8. dnl pg_config is still the default way to retrieve build options
  9. dnl pkgconfig support was only introduced in 9.3
  10. AC_MSG_CHECKING(for pg_config)
  11. for i in $PHP_PGSQL $PHP_PGSQL/bin /usr/local/pgsql/bin /usr/local/bin /usr/bin ""; do
  12. if test -x $i/pg_config; then
  13. PG_CONFIG="$i/pg_config"
  14. break;
  15. fi
  16. done
  17. if test -n "$PG_CONFIG"; then
  18. AC_MSG_RESULT([$PG_CONFIG])
  19. PGSQL_INCLUDE=`$PG_CONFIG --includedir`
  20. PGSQL_LIBDIR=`$PG_CONFIG --libdir`
  21. else
  22. AC_MSG_RESULT(not found)
  23. if test "$PHP_PGSQL" = "yes"; then
  24. PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
  25. else
  26. PGSQL_SEARCH_PATHS=$PHP_PGSQL
  27. fi
  28. for i in $PGSQL_SEARCH_PATHS; do
  29. for j in include include/pgsql include/postgres include/postgresql ""; do
  30. if test -r "$i/$j/libpq-fe.h"; then
  31. PGSQL_INC_BASE=$i
  32. PGSQL_INCLUDE=$i/$j
  33. fi
  34. done
  35. for j in lib $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
  36. if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
  37. PGSQL_LIBDIR=$i/$j
  38. fi
  39. done
  40. done
  41. fi
  42. if test -z "$PGSQL_INCLUDE"; then
  43. AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
  44. fi
  45. if test -z "$PGSQL_LIBDIR"; then
  46. AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
  47. fi
  48. if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
  49. AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
  50. fi
  51. AC_DEFINE(HAVE_PGSQL,1,[Whether to build PostgreSQL support or not])
  52. old_LIBS=$LIBS
  53. old_LDFLAGS=$LDFLAGS
  54. LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
  55. AC_CHECK_LIB(pq, PQlibVersion,, AC_MSG_ERROR([Unable to build the PostgreSQL extension: at least libpq 9.1 is required]))
  56. AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
  57. AC_CHECK_LIB(pq, lo_truncate64, AC_DEFINE(HAVE_PG_LO64,1,[PostgreSQL 9.3 or later]))
  58. LIBS=$old_LIBS
  59. LDFLAGS=$old_LDFLAGS
  60. PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PGSQL_SHARED_LIBADD)
  61. PHP_SUBST(PGSQL_SHARED_LIBADD)
  62. PHP_ADD_INCLUDE($PGSQL_INCLUDE)
  63. PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
  64. fi