| 1 |
# Configure paths for php |
| 2 |
# Yoshihiro OKUMURA 05-03-12 |
| 3 |
# Adapted from: |
| 4 |
# Configure paths for GLIB |
| 5 |
# Owen Taylor 97-11-3 |
| 6 |
|
| 7 |
dnl AM_PATH_PHP([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
| 8 |
dnl Test for PHP, and define following variables: |
| 9 |
dnl PHP_CONFIG PHP_PREFIX PHP_INCLUDES PHP_LDFLAGS PHP_LIBS |
| 10 |
dnl PHP_EXTENSION_DIR PHP_VERSION |
| 11 |
dnl |
| 12 |
AC_DEFUN([AM_PATH_PHP],[ |
| 13 |
PHP_CONFIG="" |
| 14 |
PHP_PREFIX="" |
| 15 |
PHP_INCLUDES="" |
| 16 |
PHP_LDFLAGS="" |
| 17 |
PHP_LIBS="" |
| 18 |
PHP_EXTENSION_DIR="" |
| 19 |
PHP_VERSION="" |
| 20 |
AC_ARG_WITH([php-prefix], |
| 21 |
[ --with-php-prefix=PFX Prefix where php is installed (optional)], |
| 22 |
php_config_prefix="$withval", php_config_prefix="") |
| 23 |
AC_ARG_WITH([php-exec-prefix], |
| 24 |
[ --with-php-exec-prefix=PFX |
| 25 |
Exec prefix where php is installed (optional)], |
| 26 |
php_config_exec_prefix="$withval", php_config_exec_prefix="") |
| 27 |
if test x$php_config_exec_prefix != x ; then |
| 28 |
php_config_args="$php_config_args" |
| 29 |
if test x${PHP_CONFIG+set} != xset ; then |
| 30 |
PHP_CONFIG=$php_config_exec_prefix/bin/php-config |
| 31 |
fi |
| 32 |
fi |
| 33 |
if test x$php_config_prefix != x ; then |
| 34 |
php_config_args="$php_config_args --prefix=$php_config_prefix" |
| 35 |
if test x${PHP_CONFIG+set} != xset ; then |
| 36 |
PHP_CONFIG=$php_config_prefix/bin/php-config |
| 37 |
fi |
| 38 |
fi |
| 39 |
|
| 40 |
# checking config script |
| 41 |
AC_PATH_PROG(PHP_CONFIG, php-config, no) |
| 42 |
min_php_version=ifelse([$1],,4.3.2,[$1]) |
| 43 |
require_major_version=`echo $min_php_version | \ |
| 44 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 45 |
require_minor_version=`echo $min_php_version | \ |
| 46 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 47 |
require_micro_version=`echo $min_php_version | \ |
| 48 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 49 |
|
| 50 |
if test x$PHP_CONFIG = xno; then |
| 51 |
AC_MSG_ERROR([*** php not installed - please install first ***]) |
| 52 |
fi |
| 53 |
AC_MSG_CHECKING(for php - version >= $min_php_version) |
| 54 |
no_php="" |
| 55 |
if test "$PHP_CONFIG" = "no" ; then |
| 56 |
no_php=yes |
| 57 |
else |
| 58 |
PHP_PREFIX="`$PHP_CONFIG --prefix`" |
| 59 |
PHP_INCLUDES="`$PHP_CONFIG --includes`" |
| 60 |
PHP_LDFLAGS="`$PHP_CONFIG --ldflags`" |
| 61 |
PHP_LIBS="`$PHP_CONFIG --libs`" |
| 62 |
PHP_EXTENSION_DIR="`$PHP_CONFIG --extension-dir`" |
| 63 |
PHP_VERSION="`$PHP_CONFIG --version`" |
| 64 |
php_config_major_version=`$PHP_CONFIG $php_config_args --version | \ |
| 65 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 66 |
php_config_minor_version=`$PHP_CONFIG $php_config_args --version | \ |
| 67 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 68 |
php_config_micro_version=`$PHP_CONFIG $php_config_args --version | \ |
| 69 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 70 |
if test $php_config_major_version -gt $require_major_version || \ |
| 71 |
(test $php_config_major_version -eq $require_major_version && \ |
| 72 |
test $php_config_minor_version -gt $require_minor_version) || \ |
| 73 |
(test $php_config_major_version -eq $require_major_version && \ |
| 74 |
test $php_config_minor_version -eq $require_minor_version && \ |
| 75 |
test $php_config_micro_version -ge $require_micro_version); then |
| 76 |
version_check="yes" |
| 77 |
else |
| 78 |
version_check="no" |
| 79 |
fi |
| 80 |
fi |
| 81 |
if test "x$no_php" = x ; then |
| 82 |
if test "x$version_check" = "xyes" ; then |
| 83 |
AC_MSG_RESULT(yes (version $php_config_major_version.$php_config_minor_version.$php_config_micro_version)) |
| 84 |
ifelse([$2], , :, [$2]) |
| 85 |
else |
| 86 |
AC_MSG_RESULT(no (version $php_config_major_version.$php_config_minor_version.$php_config_micro_version)) |
| 87 |
echo "*** An old version of php $PHP_VERSION was found." |
| 88 |
echo "*** You need a version of php newer than $min_php_version." |
| 89 |
PHP_CONFIG="" |
| 90 |
PHP_PREFIX="" |
| 91 |
PHP_INCLUDES="" |
| 92 |
PHP_LDFLAGS="" |
| 93 |
PHP_LIBS="" |
| 94 |
PHP_EXTENSION_DIR="" |
| 95 |
PHP_VERSION="" |
| 96 |
ifelse([$3], , :, [$3]) |
| 97 |
fi |
| 98 |
else |
| 99 |
AC_MSG_RESULT(no) |
| 100 |
if test "$PHP_CONFIG" = "no" ; then |
| 101 |
echo "*** The php-config script installed by PHP could not be found " |
| 102 |
echo "*** If php was installed in PREFIX, make sure PREFIX/bin is in" |
| 103 |
echo "*** your path, or set the PHP_CONFIG environment variable to the" |
| 104 |
echo "*** full path to php-config." |
| 105 |
fi |
| 106 |
PHP_CONFIG="" |
| 107 |
PHP_PREFIX="" |
| 108 |
PHP_INCLUDES="" |
| 109 |
PHP_LDFLAGS="" |
| 110 |
PHP_LIBS="" |
| 111 |
PHP_EXTENSION_DIR="" |
| 112 |
PHP_VERSION="" |
| 113 |
ifelse([$3], , :, [$3]) |
| 114 |
fi |
| 115 |
# exporting variables |
| 116 |
AC_SUBST(PHP_CONFIG) |
| 117 |
AC_SUBST(PHP_PREFIX) |
| 118 |
AC_SUBST(PHP_INCLUDES) |
| 119 |
AC_SUBST(PHP_LDFLAGS) |
| 120 |
AC_SUBST(PHP_LIBS) |
| 121 |
AC_SUBST(PHP_EXTENSION_DIR) |
| 122 |
AC_SUBST(PHP_VERSION) |
| 123 |
]) |