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 [whether to enable PCRE JIT functionality], 11 [AS_HELP_STRING([--without-pcre-jit], 12 [Disable PCRE JIT functionality])], 13 [yes], 14 [no]) 15 16AH_TEMPLATE([PCRE2_CODE_UNIT_WIDTH], 17 [Number of bits in non-UTF mode for PCRE library.]) 18AH_TEMPLATE([HAVE_PCRE_JIT_SUPPORT], 19 [Define to 1 if PCRE JIT is enabled and supported.]) 20 21if test "$PHP_EXTERNAL_PCRE" != "no"; then 22 PKG_CHECK_MODULES([PCRE2], [libpcre2-8 >= 10.30]) 23 24 PHP_EVAL_INCLINE([$PCRE2_CFLAGS]) 25 PHP_EVAL_LIBLINE([$PCRE2_LIBS]) 26 AC_DEFINE([PCRE2_CODE_UNIT_WIDTH], [8]) 27 28 AS_VAR_IF([PHP_PCRE_JIT], [no],, 29 [AC_CACHE_CHECK([whether external PCRE2 library has JIT supported], 30 [php_cv_have_pcre2_jit], 31 [ 32 CFLAGS_SAVE=$CFLAGS 33 LIBS_SAVE=$LIBS 34 CFLAGS="$CFLAGS $PCRE2_CFLAGS" 35 LIBS="$LIBS $PCRE2_LIBS" 36 AC_RUN_IFELSE([AC_LANG_SOURCE([ 37 #include <pcre2.h> 38 #include <stdlib.h> 39 int main(void) { 40 uint32_t have_jit; 41 pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit); 42 return !have_jit; 43 } 44 ])], 45 [php_cv_have_pcre2_jit=yes], 46 [php_cv_have_pcre2_jit=no], 47 [AS_CASE([$host_cpu], 48 [arm*|i[[34567]]86|x86_64|mips*|powerpc*|sparc], 49 [php_cv_have_pcre2_jit=yes], 50 [php_cv_have_pcre2_jit=no])]) 51 CFLAGS=$CFLAGS_SAVE 52 LIBS=$LIBS_SAVE 53 ]) 54 AS_VAR_IF([php_cv_have_pcre2_jit], [yes], 55 [AC_DEFINE([HAVE_PCRE_JIT_SUPPORT], [1])]) 56 ]) 57 58 PHP_NEW_EXTENSION([pcre], 59 [php_pcre.c], 60 [no],, 61 [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) 62 PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h]) 63else 64 AC_MSG_CHECKING([for PCRE library to use]) 65 AC_MSG_RESULT([bundled]) 66 pcrelib_sources=m4_normalize([" 67 pcre2lib/pcre2_auto_possess.c 68 pcre2lib/pcre2_chartables.c 69 pcre2lib/pcre2_chkdint.c 70 pcre2lib/pcre2_compile.c 71 pcre2lib/pcre2_config.c 72 pcre2lib/pcre2_context.c 73 pcre2lib/pcre2_convert.c 74 pcre2lib/pcre2_dfa_match.c 75 pcre2lib/pcre2_error.c 76 pcre2lib/pcre2_extuni.c 77 pcre2lib/pcre2_find_bracket.c 78 pcre2lib/pcre2_jit_compile.c 79 pcre2lib/pcre2_maketables.c 80 pcre2lib/pcre2_match_data.c 81 pcre2lib/pcre2_match.c 82 pcre2lib/pcre2_newline.c 83 pcre2lib/pcre2_ord2utf.c 84 pcre2lib/pcre2_pattern_info.c 85 pcre2lib/pcre2_script_run.c 86 pcre2lib/pcre2_serialize.c 87 pcre2lib/pcre2_string_utils.c 88 pcre2lib/pcre2_study.c 89 pcre2lib/pcre2_substitute.c 90 pcre2lib/pcre2_substring.c 91 pcre2lib/pcre2_tables.c 92 pcre2lib/pcre2_ucd.c 93 pcre2lib/pcre2_valid_utf.c 94 pcre2lib/pcre2_xclass.c 95 "]) 96 97 AX_CHECK_COMPILE_FLAG([-Wno-implicit-fallthrough], 98 [PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -Wno-implicit-fallthrough"],, 99 [-Werror]) 100 101 PHP_PCRE_CFLAGS="$PHP_PCRE_CFLAGS -DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" 102 AC_DEFINE([HAVE_BUNDLED_PCRE], [1], 103 [Define to 1 if PHP uses the bundled PCRE library.]) 104 AC_DEFINE([PCRE2_CODE_UNIT_WIDTH], [8]) 105 106 AS_VAR_IF([PHP_PCRE_JIT], [no],, 107 [AC_DEFINE([HAVE_PCRE_JIT_SUPPORT], [1]) 108 AC_CACHE_CHECK([whether Intel CET is enabled], 109 [php_cv_have_pcre2_intel_cet], 110 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 111 #ifndef __CET__ 112 # error CET is not enabled 113 #endif 114 ])], 115 [php_cv_have_pcre2_intel_cet=yes], 116 [php_cv_have_pcre2_intel_cet=no]) 117 ]) 118 AS_VAR_IF([php_cv_have_pcre2_intel_cet], [yes], 119 [PHP_PCRE_CFLAGS="-mshstk $PHP_PCRE_CFLAGS"]) 120 ]) 121 122 dnl Enable pcre Valgrind support only in DEBUG build (it affects performance). 123 AS_VAR_IF([PHP_VALGRIND], [no],, 124 [AS_VAR_IF([ZEND_DEBUG], [yes], 125 [AC_DEFINE([HAVE_PCRE_VALGRIND_SUPPORT], [1], 126 [Define to 1 if pcre has Valgrind support enabled.])])]) 127 128 PHP_NEW_EXTENSION([pcre], 129 [$pcrelib_sources php_pcre.c], 130 [no],, 131 [$PHP_PCRE_CFLAGS]) 132 PHP_ADD_BUILD_DIR([$ext_builddir/pcre2lib]) 133 PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/]) 134fi 135