config.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. dnl $Id$
  2. dnl config.m4 for extension pdo_pgsql
  3. dnl vim:et:sw=2:ts=2:
  4. PHP_ARG_WITH(pdo-pgsql,for PostgreSQL support for PDO,
  5. [ --with-pdo-pgsql[=DIR] PDO: PostgreSQL support. DIR is the PostgreSQL base
  6. install directory or the path to pg_config])
  7. if test "$PHP_PDO_PGSQL" != "no"; then
  8. if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
  9. AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
  10. fi
  11. PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE)
  12. AC_MSG_CHECKING(for pg_config)
  13. for i in $PHP_PDO_PGSQL $PHP_PDO_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. if test -n "$PG_CONFIG"; then
  20. AC_MSG_RESULT([$PG_CONFIG])
  21. PGSQL_INCLUDE=`$PG_CONFIG --includedir`
  22. PGSQL_LIBDIR=`$PG_CONFIG --libdir`
  23. AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
  24. else
  25. AC_MSG_RESULT(not found)
  26. if test "$PHP_PDO_PGSQL" = "yes"; then
  27. PGSQL_SEARCH_PATHS="/usr /usr/local /usr/local/pgsql"
  28. else
  29. PGSQL_SEARCH_PATHS=$PHP_PDO_PGSQL
  30. fi
  31. for i in $PGSQL_SEARCH_PATHS; do
  32. for j in include include/pgsql include/postgres include/postgresql ""; do
  33. if test -r "$i/$j/libpq-fe.h"; then
  34. PGSQL_INC_BASE=$i
  35. PGSQL_INCLUDE=$i/$j
  36. if test -r "$i/$j/pg_config.h"; then
  37. AC_DEFINE(HAVE_PG_CONFIG_H,1,[Whether to have pg_config.h])
  38. fi
  39. fi
  40. done
  41. for j in $PHP_LIBDIR $PHP_LIBDIR/pgsql $PHP_LIBDIR/postgres $PHP_LIBDIR/postgresql ""; do
  42. if test -f "$i/$j/libpq.so" || test -f "$i/$j/libpq.a"; then
  43. PGSQL_LIBDIR=$i/$j
  44. fi
  45. done
  46. done
  47. fi
  48. if test -z "$PGSQL_INCLUDE"; then
  49. AC_MSG_ERROR(Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path)
  50. fi
  51. if test -z "$PGSQL_LIBDIR"; then
  52. AC_MSG_ERROR(Cannot find libpq.so. Please specify correct PostgreSQL installation path)
  53. fi
  54. if test -z "$PGSQL_INCLUDE" -a -z "$PGSQL_LIBDIR" ; then
  55. AC_MSG_ERROR([Unable to find libpq anywhere under $PGSQL_SEARCH_PATHS])
  56. fi
  57. AC_DEFINE(HAVE_PDO_PGSQL,1,[Whether to build PostgreSQL for PDO support or not])
  58. AC_MSG_CHECKING([for openssl dependencies])
  59. grep openssl $PGSQL_INCLUDE/libpq-fe.h >/dev/null 2>&1
  60. if test $? -eq 0 ; then
  61. AC_MSG_RESULT([yes])
  62. dnl First try to find pkg-config
  63. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  64. if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
  65. PDO_PGSQL_CFLAGS=`$PKG_CONFIG openssl --cflags`
  66. fi
  67. else
  68. AC_MSG_RESULT([no])
  69. fi
  70. old_LIBS=$LIBS
  71. old_LDFLAGS=$LDFLAGS
  72. LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
  73. AC_CHECK_LIB(pq, PQprepare,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: a newer libpq is required]))
  74. AC_CHECK_LIB(pq, PQexecParams,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: a newer libpq is required]))
  75. AC_CHECK_LIB(pq, PQescapeStringConn,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: a newer libpq is required]))
  76. AC_CHECK_LIB(pq, PQescapeByteaConn,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: a newer libpq is required]))
  77. LIBS=$old_LIBS
  78. LDFLAGS=$old_LDFLAGS
  79. PHP_ADD_LIBRARY_WITH_PATH(pq, $PGSQL_LIBDIR, PDO_PGSQL_SHARED_LIBADD)
  80. PHP_SUBST(PDO_PGSQL_SHARED_LIBADD)
  81. PHP_ADD_INCLUDE($PGSQL_INCLUDE)
  82. ifdef([PHP_CHECK_PDO_INCLUDES],
  83. [
  84. PHP_CHECK_PDO_INCLUDES
  85. ],[
  86. AC_MSG_CHECKING([for PDO includes])
  87. if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
  88. pdo_cv_inc_path=$abs_srcdir/ext
  89. elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
  90. pdo_cv_inc_path=$abs_srcdir/ext
  91. elif test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
  92. pdo_cv_inc_path=$prefix/include/php/ext
  93. else
  94. AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
  95. fi
  96. AC_MSG_RESULT($pdo_cv_inc_path)
  97. ])
  98. PHP_NEW_EXTENSION(pdo_pgsql, pdo_pgsql.c pgsql_driver.c pgsql_statement.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_PGSQL_CFLAGS)
  99. ifdef([PHP_ADD_EXTENSION_DEP],
  100. [
  101. PHP_ADD_EXTENSION_DEP(pdo_pgsql, pdo)
  102. ])
  103. fi