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_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 70 AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], 71 [PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -Wno-implicit-fallthrough"],, 72 [-Werror]) 73 74 PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" 75 AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ]) 76 AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ]) 77 78 AC_MSG_CHECKING([whether to enable PCRE JIT functionality]) 79 if test "$PHP_PCRE_JIT" != "no"; then 80 AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ]) 81 AC_MSG_RESULT([yes]) 82 83 AC_CACHE_CHECK([whether Intel CET is enabled], ac_cv_have_pcre2_intel_cet, [ 84 AC_COMPILE_IFELSE([ 85 AC_LANG_SOURCE([[ 86 #ifndef __CET__ 87 # error CET is not enabled 88 #endif 89 ]])], [ 90 ac_cv_have_pcre2_intel_cet=yes 91 ], [ 92 ac_cv_have_pcre2_intel_cet=no 93 ]) 94 if test "$ac_cv_have_pcre2_intel_cet" = yes; then 95 PHP_PCRE_CFLAGS="-mshstk $PHP_PCRE_CFLAGS" 96 fi 97 ]) 98 99 else 100 AC_MSG_RESULT([no]) 101 fi 102 103 PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS) 104 PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib) 105 PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/]) 106 107 if test "$PHP_VALGRIND" != "no" && test "$have_valgrind" = "yes"; then 108 dnl Enable pcre valgrind support only in DEBUG build (it affects performance) 109 if test "$ZEND_DEBUG" = "yes"; then 110 AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ]) 111 fi 112 fi 113fi 114