Skip to content

Commit 32114b5

Browse files
hughmcmasternikic
authored andcommitted
Use a common setup macro to detect the Expat library
Closes GH-4221.
1 parent 550f95e commit 32114b5

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

build/php.m4

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,20 @@ AC_DEFUN([PHP_SETUP_LIBXML], [
20642064
$2
20652065
])
20662066

2067+
dnl
2068+
dnl PHP_SETUP_EXPAT([shared-add])
2069+
dnl
2070+
dnl Common setup macro for expat.
2071+
dnl
2072+
AC_DEFUN([PHP_SETUP_EXPAT], [
2073+
PKG_CHECK_MODULES([EXPAT], [expat])
2074+
2075+
PHP_EVAL_INCLINE($EXPAT_CFLAGS)
2076+
PHP_EVAL_LIBLINE($EXPAT_LIBS, $1)
2077+
2078+
AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
2079+
])
2080+
20672081
dnl ----------------------------------------------------------------------------
20682082
dnl Misc. macros
20692083
dnl ----------------------------------------------------------------------------

ext/xml/config.m4

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ if test "$PHP_XML" != "no"; then
2727
PHP_ADD_EXTENSION_DEP(xml, libxml)
2828
])
2929
else
30-
PKG_CHECK_MODULES([EXPAT], [expat])
31-
32-
PHP_EVAL_INCLINE($EXPAT_CFLAGS)
33-
PHP_EVAL_LIBLINE($EXPAT_LIBS, XML_SHARED_LIBADD)
34-
35-
AC_DEFINE(HAVE_LIBEXPAT, 1, [ ])
30+
PHP_SETUP_EXPAT([XML_SHARED_LIBADD])
3631
fi
3732

3833
PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)

ext/xmlrpc/config.m4

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
PHP_ARG_WITH([xmlrpc],
2-
[for XMLRPC-EPI support],
2+
[whether to build with XMLRPC-EPI support],
33
[AS_HELP_STRING([[--with-xmlrpc[=DIR]]],
44
[Include XMLRPC-EPI support])])
55

6-
PHP_ARG_WITH([libexpat-dir],
7-
[libexpat dir for XMLRPC-EPI],
8-
[AS_HELP_STRING([--with-libexpat-dir=DIR],
9-
[XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)])],
6+
PHP_ARG_WITH([expat],
7+
[whether to build with expat support],
8+
[AS_HELP_STRING([--with-expat],
9+
[XMLRPC-EPI: use expat instead of libxml2])],
1010
[no],
1111
[no])
1212

@@ -24,9 +24,9 @@ if test "$PHP_XMLRPC" != "no"; then
2424
AC_DEFINE(HAVE_XMLRPC,1,[ ])
2525

2626
dnl
27-
dnl Default to libxml2 if --with-libexpat-dir is not used
27+
dnl Default to libxml2 if --with-expat is not specified.
2828
dnl
29-
if test "$PHP_LIBEXPAT_DIR" = "no"; then
29+
if test "$PHP_EXPAT" = "no"; then
3030

3131
if test "$PHP_LIBXML" = "no"; then
3232
AC_MSG_ERROR([XML-RPC extension requires LIBXML extension, add --with-libxml])
@@ -39,20 +39,7 @@ if test "$PHP_XMLRPC" != "no"; then
3939
fi
4040
])
4141
else
42-
testval=no
43-
for i in $PHP_LIBEXPAT_DIR $XMLRPC_DIR /usr/local /usr; do
44-
if test -f $i/$PHP_LIBDIR/libexpat.a || test -f $i/$PHP_LIBDIR/libexpat.$SHLIB_SUFFIX_NAME; then
45-
AC_DEFINE(HAVE_LIBEXPAT,1,[ ])
46-
PHP_ADD_LIBRARY_WITH_PATH(expat, $i/$PHP_LIBDIR, XMLRPC_SHARED_LIBADD)
47-
PHP_ADD_INCLUDE($i/include)
48-
testval=yes
49-
break
50-
fi
51-
done
52-
53-
if test "$testval" = "no"; then
54-
AC_MSG_ERROR([XML-RPC support requires libexpat. Use --with-libexpat-dir=<DIR> (deprecated!)])
55-
fi
42+
PHP_SETUP_EXPAT([XMLRPC_SHARED_LIBADD])
5643
fi
5744

5845
dnl if iconv is shared or missing then we should build iconv ourselves

0 commit comments

Comments
 (0)