php.m4 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # -*- Mode: autoconf -*-
  2. # php.m4 for configure scripts to check for php development files
  3. # exports the following variables:
  4. # PHP_INCLUDES
  5. # PHP_LDFLAGS
  6. # PHP_EXTENSION_DIR
  7. # PHP_VERSION
  8. AC_DEFUN([PHP_WITH_PHP_CONFIG],[
  9. AC_ARG_WITH(php-config, AC_HELP_STRING([--with-php-config=PATH],[path to the php-config script]),
  10. [PHP_CONFIG=${withval}],[PHP_CONFIG=php-config])
  11. AC_MSG_CHECKING([for PHP])
  12. if ! test -x "`which $PHP_CONFIG 2>/dev/null`"; then
  13. AC_MSG_ERROR([Cannot execute $PHP_CONFIG])
  14. fi
  15. PHP_INCLUDES=`$PHP_CONFIG --includes`
  16. PHP_LDFLAGS=`$PHP_CONFIG --ldflags`
  17. PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
  18. PHP_VERSION=`$PHP_CONFIG --version`
  19. # watch escaping for brackets, only take the first word (2nd sed). will contain "Usage:" when php doesn't understand the --configure-options parameter.
  20. PHP_SYSCONF_DIR=`$PHP_CONFIG --configure-options | sed -e 's_.*with-config-file-scan-dir=\([[^ ]]\+\).*_\1_' | sed -e 's/\([[^ ]]\+\).*/\1/'`
  21. phpdn=`dirname $PHP_SYSCONF_DIR`
  22. if test -z "${PHP_SYSCONF_DIR}" -o "${phpdn}" = "."; then
  23. # find path in existing paths
  24. if test -d "/etc/php.d"; then
  25. PHP_SYSCONF_DIR="/etc/php.d"
  26. elif test -d "/etc/php7/conf.d"; then
  27. PHP_SYSCONF_DIR="/etc/php7/conf.d"
  28. elif test -d "/etc/php7/apache2/conf.d"; then
  29. PHP_SYSCONF_DIR="/etc/php7/apache2/conf.d"
  30. elif test -d "/etc/php5/conf.d"; then
  31. PHP_SYSCONF_DIR="/etc/php5/conf.d"
  32. elif test -d "/etc/php5/apache2/conf.d"; then
  33. PHP_SYSCONF_DIR="/etc/php5/apache2/conf.d"
  34. else
  35. # this happens on old distributions
  36. AC_MSG_RESULT([Cannot find php sysconf path, forcing /usr/share/doc/kopano])
  37. PHP_SYSCONF_DIR="/usr/share/doc/kopano"
  38. fi
  39. fi
  40. if test ! -d "${PHP_SYSCONF_DIR}"; then
  41. AC_MSG_WARN([$PHP_CONFIG returned sysconf scan dir "$PHP_SYSCONF_DIR", however this directory does not (yet) exist])
  42. fi
  43. AC_SUBST(PHP_SYSCONF_DIR)
  44. if test -z "$PHP_EXTENSION_DIR"; then
  45. AC_MSG_ERROR(Cannot find php-config. Please use --with-php-config=PATH)
  46. fi
  47. AC_SUBST(PHP_INCLUDES)
  48. AC_SUBST(PHP_LDFLAGS)
  49. AC_SUBST(PHP_EXTENSION_DIR)
  50. AC_SUBST(PHP_VERSION)
  51. AC_MSG_CHECKING([for PHP includes])
  52. AC_MSG_RESULT($PHP_INCLUDES)
  53. AC_MSG_CHECKING([for PHP extension directory])
  54. AC_MSG_RESULT($PHP_EXTENSION_DIR)
  55. AC_MSG_CHECKING([for PHP config scan directory])
  56. AC_MSG_RESULT($PHP_SYSCONF_DIR)
  57. ])
  58. dnl php-config can be in a different package that the header files (suse 9.1)
  59. dnl so we explicitly check if something would compile with the found include parameters
  60. AC_DEFUN([PHP_CHECK_INCLUDES],[
  61. CXXFLAGS="$CXXFLAGS $PHP_INCLUDES"
  62. AC_MSG_CHECKING([acquired PHP settings])
  63. AC_LINK_IFELSE([
  64. AC_LANG_SOURCE([
  65. #include <php.h>
  66. int main() {
  67. zval *ptr = NULL;
  68. }
  69. ]) ], [ AC_MSG_RESULT([ok]) ], [ AC_MSG_ERROR([broken])
  70. ])
  71. CXXFLAGS=$CXXFLAGS_system
  72. ])