xref: /php-src/ext/pcre/config0.m4 (revision 2f6a2107)
1dnl By default we'll compile and link against the bundled PCRE library. If
2dnl --with-external-pcre is supplied, we'll use that for linking.
3PHP_ARG_WITH([external-pcre],,
4  [AS_HELP_STRING([--with-external-pcre],
5    [Use external library for PCRE support])],
6  [no],
7  [no])
8
9PHP_ARG_WITH([pcre-jit],,
10  [AS_HELP_STRING([--without-pcre-jit],
11    [Disable PCRE JIT functionality])],
12  [yes],
13  [no])
14
15if test "$PHP_EXTERNAL_PCRE" != "no"; then
16
17  PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.30])
18
19  PHP_EVAL_INCLINE($PCRE2_CFLAGS)
20  PHP_EVAL_LIBLINE($PCRE2_LIBS)
21  AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
22
23  if test "$PHP_PCRE_JIT" != "no"; then
24    AC_CACHE_CHECK([for JIT support in PCRE2], ac_cv_have_pcre2_jit, [
25      AC_RUN_IFELSE([
26          AC_LANG_SOURCE([[
27              #include <pcre2.h>
28              #include <stdlib.h>
29              int main(void) {
30                uint32_t have_jit;
31                pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
32                return !have_jit;
33              }
34          ]])], [
35          ac_cv_have_pcre2_jit=yes
36        ],
37        [
38          ac_cv_have_pcre2_jit=no
39        ],
40        [
41          AC_CANONICAL_HOST
42          case $host_cpu in
43          arm*|i[[34567]]86|x86_64|mips*|powerpc*|sparc)
44            ac_cv_have_pcre2_jit=yes
45            ;;
46          *)
47            ac_cv_have_pcre2_jit=no
48            ;;
49          esac
50        ])
51      ])
52      if test $ac_cv_have_pcre2_jit = yes; then
53        AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
54      fi
55  fi
56
57  PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
58  PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
59else
60  AC_MSG_CHECKING([for PCRE library to use])
61  AC_MSG_RESULT([bundled])
62  pcrelib_sources="pcre2lib/pcre2_auto_possess.c pcre2lib/pcre2_chartables.c pcre2lib/pcre2_compile.c \
63      pcre2lib/pcre2_config.c pcre2lib/pcre2_context.c pcre2lib/pcre2_chkdint.c pcre2lib/pcre2_dfa_match.c pcre2lib/pcre2_error.c \
64  pcre2lib/pcre2_jit_compile.c pcre2lib/pcre2_maketables.c pcre2lib/pcre2_match.c pcre2lib/pcre2_match_data.c \
65  pcre2lib/pcre2_newline.c pcre2lib/pcre2_ord2utf.c pcre2lib/pcre2_pattern_info.c pcre2lib/pcre2_serialize.c \
66  pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c  pcre2lib/pcre2_substring.c \
67  pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
68  pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c pcre2lib/pcre2_script_run.c"
69  PHP_PCRE_CFLAGS="-Wno-implicit-fallthrough -DHAVE_CONFIG_H -DHAVE_MEMMOVE -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
70  AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
71  AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
72
73  AC_MSG_CHECKING([whether to enable PCRE JIT functionality])
74  if test "$PHP_PCRE_JIT" != "no"; then
75    AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
76    AC_MSG_RESULT([yes])
77
78    AC_CACHE_CHECK([whether Intel CET is enabled], ac_cv_have_pcre2_intel_cet, [
79      AC_COMPILE_IFELSE([
80        AC_LANG_PROGRAM([[
81          #ifndef __CET__
82          # error CET is not enabled
83          #endif
84        ]])], [
85          ac_cv_have_pcre2_intel_cet=yes
86        ], [
87          ac_cv_have_pcre2_intel_cet=no
88        ])
89    ])
90    if test "$ac_cv_have_pcre2_intel_cet" = yes; then
91      PHP_PCRE_CFLAGS="-mshstk $PHP_PCRE_CFLAGS"
92    fi
93
94  else
95    AC_MSG_RESULT([no])
96  fi
97
98  PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
99  PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
100  PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
101
102  if test "$PHP_VALGRIND" != "no" && test "$have_valgrind" = "yes"; then
103      dnl Enable pcre valgrind support only in DEBUG build (it affects performance)
104      if test "$ZEND_DEBUG" = "yes"; then
105        AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ])
106      fi
107  fi
108fi
109