Skip to content

Commit 59a21c3

Browse files
committed
allow to build with system liburiparser
1 parent be70f42 commit 59a21c3

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

ext/uri/config.m4

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
dnl Configure options
22
dnl
33

4+
PHP_ARG_WITH([external-uriparser],
5+
[for external/system liburiparser],
6+
[AS_HELP_STRING([--with-external-uriparser],
7+
[Use externalsystem liburiparser])],
8+
[no],
9+
[no])
10+
411
PHP_INSTALL_HEADERS([ext/uri], m4_normalize([
512
php_lexbor.h
613
php_uri.h
714
php_uri_common.h
815
]))
916

17+
1018
AC_DEFINE([URI_ENABLE_ANSI], [1], [Define to 1 for enabling ANSI support of uriparser.])
1119
AC_DEFINE([URI_NO_UNICODE], [1], [Define to 1 for disabling unicode support of uriparser.])
1220

13-
URIPARSER_DIR="uriparser"
14-
URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriEscape.c \
15-
$URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \
16-
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
17-
$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \
18-
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriShorten.c"
21+
if test "$PHP_EXTERNAL_URIPARSER" = "no"; then
22+
URIPARSER_DIR="uriparser"
23+
URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriEscape.c \
24+
$URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \
25+
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
26+
$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \
27+
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriShorten.c"
28+
URI_CFLAGS="-DURI_STATIC_BUILD"
29+
else
30+
PKG_CHECK_MODULES([LIBURIPARSER], [liburiparser >= 0.9.8])
31+
PHP_EVAL_LIBLINE([$LIBURIPARSER_LIBS], [URI_SHARED_LIBADD])
32+
PHP_EVAL_INCLINE([$LIBURIPARSER_CFLAGS])
33+
fi
1934

20-
PHP_NEW_EXTENSION(uri, [php_lexbor.c php_uri.c php_uri_common.c $URIPARSER_SOURCES], [no],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
35+
PHP_NEW_EXTENSION(uri, [php_lexbor.c php_uri.c php_uri_common.c $URIPARSER_SOURCES], [no],,[$URI_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
2136
PHP_ADD_EXTENSION_DEP(uri, lexbor)
22-
PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include)
37+
38+
if test "$PHP_EXTERNAL_URIPARSER" = "no"; then
39+
PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include)
40+
PHP_ADD_INCLUDE([$ext_srcdir/$URIPARSER_DIR/include])
41+
fi

ext/uri/php_uri.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "php_uri_common.h"
3030
#include "php_lexbor.h"
3131
#include "php_uri_arginfo.h"
32-
#include "uriparser/src/UriConfig.h"
32+
#include "uriparser/UriBase.h"
3333

3434
zend_class_entry *uri_whatwg_url_ce;
3535
zend_object_handlers uri_whatwg_uri_object_handlers;
@@ -40,8 +40,6 @@ zend_class_entry *uri_whatwg_invalid_url_exception_ce;
4040
zend_class_entry *uri_whatwg_url_validation_error_type_ce;
4141
zend_class_entry *uri_whatwg_url_validation_error_ce;
4242

43-
#define URIPARSER_VERSION PACKAGE_VERSION
44-
4543
static const zend_module_dep uri_deps[] = {
4644
ZEND_MOD_REQUIRED("lexbor")
4745
ZEND_MOD_END
@@ -650,9 +648,14 @@ static PHP_MINIT_FUNCTION(uri)
650648

651649
static PHP_MINFO_FUNCTION(uri)
652650
{
651+
653652
php_info_print_table_start();
654653
php_info_print_table_row(2, "uri support", "active");
655-
php_info_print_table_row(2, "uriparser library version", URIPARSER_VERSION);
654+
#ifdef URI_STATIC_BUILD
655+
php_info_print_table_row(2, "uriparser bundled library version", URI_VER_ANSI);
656+
#else
657+
php_info_print_table_row(2, "uriparser system library version", URI_VER_ANSI);
658+
#endif
656659
php_info_print_table_end();
657660
}
658661

0 commit comments

Comments
 (0)