[libsoup] tests: Configure PHP to load the XMLRPC extension if present



commit 6d28d98be104d9a83f678989b9d3952dab09fe59
Author: Jan Alexander Steffens (heftig) <jan steffens gmail com>
Date:   Tue May 9 22:54:16 2017 +0200

    tests: Configure PHP to load the XMLRPC extension if present
    
    This is needed when the system PHP configuration does not already load
    the extension.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782410

 configure.ac        |    7 ++++++-
 meson.build         |    5 ++++-
 tests/Makefile.am   |    8 +++++++-
 tests/httpd.conf.in |    2 ++
 tests/meson.build   |    6 ++++++
 tests/php.ini.in    |    1 +
 6 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f1e5f70..041696e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,13 +276,16 @@ if test "$have_apache" = 1; then
 
     if test "$have_php" = yes; then
        AC_MSG_CHECKING([for php-xmlrpc])
-       if $PHP -r 'exit(function_exists("xmlrpc_server_create")?0:1);'; then
+       if $PHP -d extension=xmlrpc -r 'exit(function_exists("xmlrpc_server_create")?0:1);'; then
            have_php_xmlrpc=yes
+           IF_HAVE_PHP_XMLRPC=""
            AC_DEFINE(HAVE_PHP_XMLRPC, 1, [Have php-xmlrpc])
        else
            have_php_xmlrpc=no
+           IF_HAVE_PHP_XMLRPC=";"
        fi
        AC_MSG_RESULT($have_php_xmlrpc)
+       AC_SUBST(IF_HAVE_PHP_XMLRPC)
     fi
 
     if test -f "$APACHE_MODULE_DIR/mod_unixd.so"; then
@@ -292,6 +295,7 @@ if test "$have_apache" = 1; then
     fi
     AC_SUBST(IF_HAVE_MOD_UNIXD)
 fi
+AM_CONDITIONAL(HAVE_PHP, test "$have_php" = yes)
 
 AC_PATH_PROG(CURL, curl, no)
 if test "$CURL" != no; then
@@ -419,6 +423,7 @@ AC_CONFIG_FILES([
        po/Makefile
        tests/Makefile
        tests/httpd.conf
+       tests/php.ini
        examples/Makefile
        docs/Makefile
        docs/reference/Makefile
diff --git a/meson.build b/meson.build
index 53b50db..849c3ec 100644
--- a/meson.build
+++ b/meson.build
@@ -137,20 +137,23 @@ if have_apache
 endif
 
 have_php = false
+have_php_xmlrpc = false
 if have_apache
   php = find_program('php', required : false)
   apache_php_module = run_command('test', '-d', cdata.get('APACHE_PHP_MODULE_DIR'))
   if apache_php_module.returncode() == 0
     have_php = true
-    php_xmlrpc = run_command(php, '-r', 'exit(function_exists("xmlrpc_server_create")?0:1);')
+    php_xmlrpc = run_command(php, '-d', 'extension=xmlrpc', '-r', 
'exit(function_exists("xmlrpc_server_create")?0:1);')
     if php_xmlrpc.returncode() == 0
       message('php-xmlrpc found')
+      have_php_xmlrpc = true
       cdata.set('HAVE_PHP_XMLRPC', '1')
     else
       message('php-xmlrpc not found')
     endif
   endif
   cdata.set('IF_HAVE_PHP', have_php ? '' : '#')
+  cdata.set('IF_HAVE_PHP_XMLRPC', have_php_xmlrpc ? '' : ';')
 endif
 
 cdata.set('HAVE_CURL', find_program('curl', required : false).found())
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 99442e0..c5638e1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,6 +73,11 @@ test_data +=                 \
        httpd.conf
 endif
 
+if HAVE_PHP
+test_data +=                   \
+       php.ini
+endif
+
 RESOURCES = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/soup-tests.gresource.xml)
 
 soup-tests.gresource: soup-tests.gresource.xml $(RESOURCES)
@@ -84,6 +89,7 @@ EXTRA_DIST +=                  \
        httpd.conf.in            \
        index.txt                \
        libsoup.supp             \
+       php.ini.in               \
        soup-tests.gresource.xml \
        test-cert.pem            \
        test-key.pem             \
@@ -91,7 +97,7 @@ EXTRA_DIST +=                  \
        meson.build              \
        $(RESOURCES)
 
-DISTCLEANFILES += soup-tests.gresource httpd.conf
+DISTCLEANFILES += soup-tests.gresource httpd.conf php.ini
 
 TESTS_ENVIRONMENT += SOUP_TESTS_IN_MAKE_CHECK=1
 
diff --git a/tests/httpd.conf.in b/tests/httpd.conf.in
index b818c12..31c3667 100644
--- a/tests/httpd.conf.in
+++ b/tests/httpd.conf.in
@@ -31,6 +31,8 @@ LoadModule proxy_connect_module @APACHE_MODULE_DIR@/mod_proxy_connect.so
 LoadModule ssl_module           @APACHE_SSL_MODULE_DIR@/mod_ssl.so
 @IF_HAVE_MOD_UNIXD@LoadModule unixd_module         @APACHE_SSL_MODULE_DIR@/mod_unixd.so
 
+@IF_HAVE_PHP@PHPIniDir .
+
 DirectoryIndex index.txt
 TypesConfig /dev/null
 AddType application/x-httpd-php .php
diff --git a/tests/meson.build b/tests/meson.build
index 7c3776c..10fda5d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -77,6 +77,12 @@ configure_file(output : 'httpd.conf',
   input : 'httpd.conf.in',
   configuration : cdata)
 
+if have_php
+  configure_file(output : 'php.ini',
+    input : 'php.ini.in',
+    configuration : cdata)
+endif
+
 # There is not copy_file() in Meson and this is official workaround as per
 # https://github.com/mesonbuild/meson/issues/860
 configure_file(input : 'htdigest',
diff --git a/tests/php.ini.in b/tests/php.ini.in
new file mode 100644
index 0000000..0f49c94
--- /dev/null
+++ b/tests/php.ini.in
@@ -0,0 +1 @@
+@IF_HAVE_PHP_XMLRPC@extension=xmlrpc


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]