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([--with-pcre-jit], 11 [Enable 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 AC_DEFINE(HAVE_PCRE, 1, [ ]) 23 24 if test "$PHP_PCRE_JIT" != "no"; then 25 AC_CACHE_CHECK([for JIT support in PCRE2], ac_cv_have_pcre2_jit, [ 26 AC_RUN_IFELSE([ 27 AC_LANG_SOURCE([[ 28 #include <pcre2.h> 29 #include <stdlib.h> 30 int main(void) { 31 uint32_t have_jit; 32 pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit); 33 return !have_jit; 34 } 35 ]])], [ 36 ac_cv_have_pcre2_jit=yes 37 ], 38 [ 39 ac_cv_have_pcre2_jit=no 40 ], 41 [ 42 AC_CANONICAL_HOST 43 case $host_cpu in 44 arm*|i[34567]86|x86_64|mips*|powerpc*|sparc) 45 ac_cv_have_pcre2_jit=yes 46 ;; 47 *) 48 ac_cv_have_pcre2_jit=no 49 ;; 50 esac 51 ]) 52 ]) 53 if test $ac_cv_have_pcre2_jit = yes; then 54 AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, []) 55 fi 56 fi 57 58 PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) 59 PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h]) 60else 61 AC_MSG_CHECKING([for PCRE library to use]) 62 AC_MSG_RESULT([bundled]) 63 pcrelib_sources="pcre2lib/pcre2_auto_possess.c pcre2lib/pcre2_chartables.c pcre2lib/pcre2_compile.c \ 64 pcre2lib/pcre2_config.c pcre2lib/pcre2_context.c pcre2lib/pcre2_dfa_match.c pcre2lib/pcre2_error.c \ 65 pcre2lib/pcre2_jit_compile.c pcre2lib/pcre2_maketables.c pcre2lib/pcre2_match.c pcre2lib/pcre2_match_data.c \ 66 pcre2lib/pcre2_newline.c pcre2lib/pcre2_ord2utf.c pcre2lib/pcre2_pattern_info.c pcre2lib/pcre2_serialize.c \ 67 pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c pcre2lib/pcre2_substring.c \ 68 pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \ 69 pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c pcre2lib/pcre2_script_run.c" 70 PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" 71 AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ]) 72 AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ]) 73 74 AC_MSG_CHECKING([whether to enable PCRE JIT functionality]) 75 if test "$PHP_PCRE_JIT" != "no"; then 76 AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ]) 77 AC_MSG_RESULT([yes]) 78 79 AC_CACHE_CHECK([whether Intel CET is enabled], ac_cv_have_pcre2_intel_cet, [ 80 AC_COMPILE_IFELSE([ 81 AC_LANG_SOURCE([[ 82 #ifndef __CET__ 83 # error CET is not enabled 84 #endif 85 ]])], [ 86 ac_cv_have_pcre2_intel_cet=yes 87 ], [ 88 ac_cv_have_pcre2_intel_cet=no 89 ]) 90 if test "$ac_cv_have_pcre2_intel_cet" = yes; then 91 PHP_PCRE_CFLAGS="-mshstk $PHP_PCRE_CFLAGS" 92 fi 93 ]) 94 95 else 96 AC_MSG_RESULT([no]) 97 fi 98 99 PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS) 100 PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib) 101 PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/]) 102 103 if test "$PHP_VALGRIND" != "no" && test "$have_valgrind" = "yes"; then 104 dnl Enable pcre valgrind support only in DEBUG build (it affects performance) 105 if test "$ZEND_DEBUG" = "yes"; then 106 AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ]) 107 fi 108 fi 109fi 110