diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-09-06 07:28:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 07:28:35 +0200 |
commit | 776f8e272543754ed0184cfb3f0f139218cc62d2 (patch) | |
tree | 9c4b07e5d3d1d40e8d7707f4c5f7c92fa2289a43 | |
parent | 5bec71f891412cc0b6037cb66fb6e13aea27da50 (diff) | |
parent | 280822b00bfe6de4a28990cb722dad35359e7839 (diff) | |
download | weechat-776f8e272543754ed0184cfb3f0f139218cc62d2.zip |
Merge pull request #1064 from adsr/patch-fix-php-cmake
php: ensure CMake script finds PHP 7
-rw-r--r-- | cmake/FindPHP.cmake | 15 | ||||
-rw-r--r-- | configure.ac | 28 |
2 files changed, 26 insertions, 17 deletions
diff --git a/cmake/FindPHP.cmake b/cmake/FindPHP.cmake index 026ee9fb5..955862943 100644 --- a/cmake/FindPHP.cmake +++ b/cmake/FindPHP.cmake @@ -18,12 +18,12 @@ # if(PHP_FOUND) - set(PHP_FIND_QUIETLY TRUE) + set(PHP_FIND_QUIETLY TRUE) endif() find_package(PkgConfig) if(PKG_CONFIG_FOUND) - pkg_search_module(php7 php) + pkg_search_module(PHP php7) endif() if(NOT PHP_FOUND) @@ -36,9 +36,12 @@ if(NOT PHP_FOUND) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE PHP_LIB_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --includes OUTPUT_VARIABLE PHP_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE PHP_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "-I" "" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS}) - SEPARATE_ARGUMENTS(PHP_INCLUDE_DIRS) - set(PHP_LDFLAGS "-L${PHP_LIB_PREFIX}/lib/ ${PHP_LIBS} -lphp7") - set(PHP_FOUND 1) + execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE PHP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + if(${PHP_VERSION} MATCHES "^7") + string(REPLACE "-I" "" PHP_INCLUDE_DIRS ${PHP_INCLUDE_DIRS}) + SEPARATE_ARGUMENTS(PHP_INCLUDE_DIRS) + set(PHP_LDFLAGS "-L${PHP_LIB_PREFIX}/lib/ ${PHP_LIBS} -lphp7") + set(PHP_FOUND 1) + endif() endif() endif() diff --git a/configure.ac b/configure.ac index 7af248fc1..d6cad33bc 100644 --- a/configure.ac +++ b/configure.ac @@ -954,13 +954,16 @@ if test "x$enable_php" = "xyes" ; then if test "x$PHP_CFLAGS" = "x" -o "x$PHP_LFLAGS" = "x" ; then AC_MSG_CHECKING(for PHP headers and libraries with pkg-config) echo - for l in "$php_suffix" "" "7" "7.2" "72" "7.1" "71" "7.0" "70" ; do + for l in "$php_suffix" "7" "7.2" "72" "7.1" "71" "7.0" "70" "" ; do pkgconfig_php_found=`$PKGCONFIG --exists php$l 2>/dev/null` if test "x$?" = "x0" ; then - PHP_VERSION=`$PKGCONFIG --modversion php$l` - PHP_CFLAGS="$PHP_CFLAGS "`$PKGCONFIG --cflags php$l` - PHP_LFLAGS="$PHP_LFLAGS "`$PKGCONFIG --libs php$l` - break + pkgconfig_php_found=`$PKGCONFIG --atleast-version=7 php$l 2>/dev/null` + if test "x$?" = "x0" ; then + PHP_VERSION=`$PKGCONFIG --modversion php$l` + PHP_CFLAGS="$PHP_CFLAGS "`$PKGCONFIG --cflags php$l` + PHP_LFLAGS="$PHP_LFLAGS "`$PKGCONFIG --libs php$l` + break + fi fi done fi @@ -968,13 +971,16 @@ if test "x$enable_php" = "xyes" ; then if test "x$PHP_CFLAGS" = "x" -o "x$PHP_LFLAGS" = "x" ; then PHPCONFIG="" AC_MSG_CHECKING(for PHP headers and libraries with php-config) - for l in "$php_suffix" "" "7" "7.2" "72" "7.1" "71" "7.0" "70" ; do + for l in "$php_suffix" "7" "7.2" "72" "7.1" "71" "7.0" "70" "" ; do AC_CHECK_PROG(PHPCONFIG, "php-config$l", "php-config$l") if test "x$PHPCONFIG" != "x" ; then - PHP_CFLAGS=`$PHPCONFIG --includes` - PHP_LFLAGS="-L$($PHPCONFIG --prefix)/lib/ $($PHPCONFIG --libs) -lphp7" - PHP_VERSION=`$PHPCONFIG --version` - break + php_config_version=`$PHPCONFIG --version` + if test "x${php_config_version#7}" != "x${php_config_version}" ; then + PHP_VERSION=$php_config_version + PHP_CFLAGS=`$PHPCONFIG --includes` + PHP_LFLAGS="-L$($PHPCONFIG --prefix)/lib/ $($PHPCONFIG --libs) -lphp7" + break + fi fi done fi @@ -986,7 +992,7 @@ if test "x$enable_php" = "xyes" ; then if test "x$ac_found_php_header" = "xyes" ; then PHP_CFLAGS="$CFLAGS" fi - for l in "$php_suffix" "" "7" "7.2" "72" "7.1" "71" "7.0" "70" ; do + for l in "$php_suffix" "7" "7.2" "72" "7.1" "71" "7.0" "70" "" ; do AC_CHECK_LIB(php$l,php_execute_script,ac_found_php_lib="yes",ac_found_php_lib="no") if test "x$ac_found_php_lib" = "xyes" ; then PHP_VERSION=">=7.0.0" |