]> granicus.if.org Git - php/commitdiff
Use a common setup macro to detect the Expat library
authorHugh McMaster <hugh.mcmaster@outlook.com>
Wed, 29 May 2019 13:09:43 +0000 (23:09 +1000)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 4 Jun 2019 08:10:50 +0000 (10:10 +0200)
Closes GH-4221.

build/php.m4
ext/xml/config.m4
ext/xmlrpc/config.m4

index da0db4bd1c795e4fe046a9c7cd90e92d95b1c615..63670108ff3c1cdc69f7f7547eb164f15ea52895 100644 (file)
@@ -2064,6 +2064,20 @@ AC_DEFUN([PHP_SETUP_LIBXML], [
   $2
 ])
 
+dnl
+dnl PHP_SETUP_EXPAT([shared-add])
+dnl
+dnl Common setup macro for expat.
+dnl
+AC_DEFUN([PHP_SETUP_EXPAT], [
+  PKG_CHECK_MODULES([EXPAT], [expat])
+
+  PHP_EVAL_INCLINE($EXPAT_CFLAGS)
+  PHP_EVAL_LIBLINE($EXPAT_LIBS, $1)
+
+  AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
+])
+
 dnl ----------------------------------------------------------------------------
 dnl Misc. macros
 dnl ----------------------------------------------------------------------------
index 838972204c555ca9716262d5e8d37537ab429733..208f9e4c160c8eb6c1160d3f8d32a11fd207a7dc 100644 (file)
@@ -27,12 +27,7 @@ if test "$PHP_XML" != "no"; then
       PHP_ADD_EXTENSION_DEP(xml, libxml)
     ])
   else
-    PKG_CHECK_MODULES([EXPAT], [expat])
-
-    PHP_EVAL_INCLINE($EXPAT_CFLAGS)
-    PHP_EVAL_LIBLINE($EXPAT_LIBS, XML_SHARED_LIBADD)
-
-    AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
+    PHP_SETUP_EXPAT([XML_SHARED_LIBADD])
   fi
 
   PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
index 3ea2d6bd0684ff8bf4f02b1b874b7d34a8f5b349..c3411312978775dd9ef8623101e17370efb784de 100644 (file)
@@ -1,12 +1,12 @@
 PHP_ARG_WITH([xmlrpc],
-  [for XMLRPC-EPI support],
+  [whether to build with XMLRPC-EPI support],
   [AS_HELP_STRING([[--with-xmlrpc[=DIR]]],
     [Include XMLRPC-EPI support])])
 
-PHP_ARG_WITH([libexpat-dir],
-  [libexpat dir for XMLRPC-EPI],
-  [AS_HELP_STRING([--with-libexpat-dir=DIR],
-    [XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)])],
+PHP_ARG_WITH([expat],
+  [whether to build with expat support],
+  [AS_HELP_STRING([--with-expat],
+    [XMLRPC-EPI: use expat instead of libxml2])],
   [no],
   [no])
 
@@ -24,9 +24,9 @@ if test "$PHP_XMLRPC" != "no"; then
   AC_DEFINE(HAVE_XMLRPC,1,[ ])
 
   dnl
-  dnl Default to libxml2 if --with-libexpat-dir is not used
+  dnl Default to libxml2 if --with-expat is not specified.
   dnl
-  if test "$PHP_LIBEXPAT_DIR" = "no"; then
+  if test "$PHP_EXPAT" = "no"; then
 
     if test "$PHP_LIBXML" = "no"; then
       AC_MSG_ERROR([XML-RPC extension requires LIBXML extension, add --with-libxml])
@@ -39,20 +39,7 @@ if test "$PHP_XMLRPC" != "no"; then
       fi
     ])
   else
-    testval=no
-    for i in $PHP_LIBEXPAT_DIR $XMLRPC_DIR /usr/local /usr; do
-      if test -f $i/$PHP_LIBDIR/libexpat.a || test -f $i/$PHP_LIBDIR/libexpat.$SHLIB_SUFFIX_NAME; then
-        AC_DEFINE(HAVE_LIBEXPAT,1,[ ])
-        PHP_ADD_LIBRARY_WITH_PATH(expat, $i/$PHP_LIBDIR, XMLRPC_SHARED_LIBADD)
-        PHP_ADD_INCLUDE($i/include)
-        testval=yes
-        break
-      fi
-    done
-
-    if test "$testval" = "no"; then
-      AC_MSG_ERROR([XML-RPC support requires libexpat. Use --with-libexpat-dir=<DIR> (deprecated!)])
-    fi
+    PHP_SETUP_EXPAT([XMLRPC_SHARED_LIBADD])
   fi
 
   dnl if iconv is shared or missing then we should build iconv ourselves