Skip to content

Commit c1a22f3

Browse files
eli-schwartznikic
authored andcommitted
Require pkg-config for external PCRE
Use standard PKG_CHECK_MODULES macro and remove the fallback case. The option is renamed to --with-external-pcre and no longer accepts an explicit path -- it should be specified through pkg-config instead.
1 parent 285a077 commit c1a22f3

File tree

1 file changed

+63
-98
lines changed

1 file changed

+63
-98
lines changed

ext/pcre/config0.m4

Lines changed: 63 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,81 @@ dnl config.m4 for extension pcre
33
dnl By default we'll compile and link against the bundled PCRE library
44
dnl if DIR is supplied, we'll use that for linking
55

6-
PHP_ARG_WITH(pcre-regex,,
7-
[ --with-pcre-regex=DIR Include Perl Compatible Regular Expressions support.
8-
DIR is the PCRE install prefix [BUNDLED]], yes, no)
6+
PHP_ARG_WITH(external-pcre,,
7+
[ --with-external-pcre Use external library for PCRE support], no, no)
98

10-
PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality (BUNDLED only)], yes, no)
9+
PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality], yes, no)
1110

12-
if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
13-
14-
if test "$PHP_PCRE_REGEX" = "/usr"; then
15-
if test -z "$PKG_CONFIG"; then
16-
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
17-
fi
18-
if test -x "$PKG_CONFIG"; then
19-
AC_MSG_CHECKING(for PCRE2 10.30 or greater)
20-
if $PKG_CONFIG --atleast-version 10.30 libpcre2-8; then
21-
PCRE2_VER=`$PKG_CONFIG --modversion libpcre2-8`
22-
AC_MSG_RESULT($PCRE2_VER)
23-
else
24-
AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
25-
fi
26-
PCRE2_LIB=`$PKG_CONFIG --libs libpcre2-8`
27-
PCRE2_INC=`$PKG_CONFIG --cflags libpcre2-8`
28-
fi
29-
fi
11+
if test "$PHP_EXTERNAL_PCRE" != "no"; then
3012

31-
dnl PCRE2 in a non standard prefix should still have its config tool.
32-
dnl CFLAGS can be empty, but libs shouldn't
33-
if test -z "$PCRE2_LIB"; then
34-
PCRE2_CONF=$PHP_PCRE_REGEX/bin/pcre2-config
35-
if test -x "$PCRE2_CONF"; then
36-
AC_MSG_CHECKING(for PCRE2 10.30 or greater)
37-
PCRE2_VER=`$PCRE2_CONF --version`
38-
if test "`echo $PCRE2_VER | sed 's,\.,,g'`" -lt 1030; then
39-
AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
40-
else
41-
AC_MSG_RESULT($PCRE2_VER)
42-
fi
43-
PCRE2_LIB=`$PCRE2_CONF --libs8`
44-
PCRE2_INC=`$PCRE2_CONF --cflags`
45-
else
46-
AC_MSG_ERROR(Couldn't find pcre2-config)
47-
fi
48-
fi
13+
PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.30])
4914

50-
PHP_EVAL_INCLINE($PCRE2_INC)
51-
PHP_EVAL_LIBLINE($PCRE2_LIB)
52-
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
53-
AC_DEFINE(HAVE_PCRE, 1, [ ])
15+
PHP_EVAL_INCLINE($PCRE2_CFLAGS)
16+
PHP_EVAL_LIBLINE($PCRE2_LIB)
17+
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
18+
AC_DEFINE(HAVE_PCRE, 1, [ ])
5419

55-
if test "$PHP_PCRE_JIT" != "no"; then
56-
AC_MSG_CHECKING([for JIT support in PCRE2])
57-
AC_RUN_IFELSE([
58-
AC_LANG_SOURCE([[
59-
#include <pcre2.h>
60-
#include <stdlib.h>
61-
int main(void) {
62-
uint32_t have_jit;
63-
pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
64-
return !have_jit;
65-
}
66-
]])], [
20+
if test "$PHP_PCRE_JIT" != "no"; then
21+
AC_MSG_CHECKING([for JIT support in PCRE2])
22+
AC_RUN_IFELSE([
23+
AC_LANG_SOURCE([[
24+
#include <pcre2.h>
25+
#include <stdlib.h>
26+
int main(void) {
27+
uint32_t have_jit;
28+
pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
29+
return !have_jit;
30+
}
31+
]])], [
32+
AC_MSG_RESULT([yes])
33+
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
34+
],
35+
[
36+
AC_MSG_RESULT([no])
37+
],
38+
[
39+
AC_CANONICAL_HOST
40+
case $host_cpu in
41+
arm*|i[34567]86|x86_64|mips*|powerpc*|sparc)
6742
AC_MSG_RESULT([yes])
6843
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
69-
],
70-
[
44+
;;
45+
*)
7146
AC_MSG_RESULT([no])
72-
],
73-
[
74-
AC_CANONICAL_HOST
75-
case $host_cpu in
76-
arm*|i[34567]86|x86_64|mips*|powerpc*|sparc)
77-
AC_MSG_RESULT([yes])
78-
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
79-
;;
80-
*)
81-
AC_MSG_RESULT([no])
82-
;;
83-
esac
84-
])
85-
fi
47+
;;
48+
esac
49+
])
50+
fi
8651

87-
PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
88-
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
89-
else
90-
AC_MSG_CHECKING([for PCRE library to use])
91-
AC_MSG_RESULT([bundled])
92-
pcrelib_sources="pcre2lib/pcre2_auto_possess.c pcre2lib/pcre2_chartables.c pcre2lib/pcre2_compile.c \
93-
pcre2lib/pcre2_config.c pcre2lib/pcre2_context.c pcre2lib/pcre2_dfa_match.c pcre2lib/pcre2_error.c \
94-
pcre2lib/pcre2_jit_compile.c pcre2lib/pcre2_maketables.c pcre2lib/pcre2_match.c pcre2lib/pcre2_match_data.c \
95-
pcre2lib/pcre2_newline.c pcre2lib/pcre2_ord2utf.c pcre2lib/pcre2_pattern_info.c pcre2lib/pcre2_serialize.c \
96-
pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c pcre2lib/pcre2_substring.c \
97-
pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
98-
pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c"
99-
PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
100-
PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
101-
PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
102-
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
103-
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
104-
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
52+
PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
53+
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
54+
else
55+
AC_MSG_CHECKING([for PCRE library to use])
56+
AC_MSG_RESULT([bundled])
57+
pcrelib_sources="pcre2lib/pcre2_auto_possess.c pcre2lib/pcre2_chartables.c pcre2lib/pcre2_compile.c \
58+
pcre2lib/pcre2_config.c pcre2lib/pcre2_context.c pcre2lib/pcre2_dfa_match.c pcre2lib/pcre2_error.c \
59+
pcre2lib/pcre2_jit_compile.c pcre2lib/pcre2_maketables.c pcre2lib/pcre2_match.c pcre2lib/pcre2_match_data.c \
60+
pcre2lib/pcre2_newline.c pcre2lib/pcre2_ord2utf.c pcre2lib/pcre2_pattern_info.c pcre2lib/pcre2_serialize.c \
61+
pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c pcre2lib/pcre2_substring.c \
62+
pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
63+
pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c"
64+
PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
65+
PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
66+
PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
67+
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
68+
AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
69+
AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
10570

106-
if test "$PHP_PCRE_REGEX" != "no"; then
107-
AC_MSG_CHECKING([whether to enable PCRE JIT functionality])
108-
if test "$PHP_PCRE_JIT" != "no"; then
109-
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
110-
AC_MSG_RESULT([yes])
111-
else
112-
AC_MSG_RESULT([no])
113-
fi
71+
if test "$PHP_PCRE_REGEX" != "no"; then
72+
AC_MSG_CHECKING([whether to enable PCRE JIT functionality])
73+
if test "$PHP_PCRE_JIT" != "no"; then
74+
AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
75+
AC_MSG_RESULT([yes])
76+
else
77+
AC_MSG_RESULT([no])
11478
fi
11579
fi
80+
fi
11681

11782
PHP_ARG_WITH(pcre-valgrind,,[ --with-pcre-valgrind=DIR
11883
Enable PCRE valgrind support. Developers only!], no, no)

0 commit comments

Comments
 (0)