config0.m4 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. dnl config.m4 for extension pcre
  2. dnl By default we'll compile and link against the bundled PCRE library
  3. dnl if DIR is supplied, we'll use that for linking
  4. PHP_ARG_WITH(pcre-regex,,
  5. [ --with-pcre-regex=DIR Include Perl Compatible Regular Expressions support.
  6. DIR is the PCRE install prefix [BUNDLED]], yes, no)
  7. PHP_ARG_WITH(pcre-jit,,[ --with-pcre-jit Enable PCRE JIT functionality (BUNDLED only)], yes, no)
  8. if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
  9. if test "$PHP_PCRE_REGEX" = "/usr"; then
  10. if test -z "$PKG_CONFIG"; then
  11. AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  12. fi
  13. if test -x "$PKG_CONFIG"; then
  14. AC_MSG_CHECKING(for PCRE2 10.30 or greater)
  15. if $PKG_CONFIG --atleast-version 10.30 libpcre2-8; then
  16. PCRE2_VER=`$PKG_CONFIG --modversion libpcre2-8`
  17. AC_MSG_RESULT($PCRE2_VER)
  18. else
  19. AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
  20. fi
  21. PCRE2_LIB=`$PKG_CONFIG --libs libpcre2-8`
  22. PCRE2_INC=`$PKG_CONFIG --cflags libpcre2-8`
  23. fi
  24. fi
  25. dnl PCRE2 in a non standard prefix should still have its config tool.
  26. dnl CFLAGS can be empty, but libs shouldn't
  27. if test -z "$PCRE2_LIB"; then
  28. PCRE2_CONF=$PHP_PCRE_REGEX/bin/pcre2-config
  29. if test -x "$PCRE2_CONF"; then
  30. AC_MSG_CHECKING(for PCRE2 10.30 or greater)
  31. PCRE2_VER=`$PCRE2_CONF --version`
  32. if test "`echo $PCRE2_VER | $SED 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1\2/g'`" -lt "1030"; then
  33. AC_MSG_ERROR(PCRE2 version 10.30 or later is required to compile php with PCRE2 support)
  34. else
  35. AC_MSG_RESULT($PCRE2_VER)
  36. fi
  37. PCRE2_LIB=`$PCRE2_CONF --libs8`
  38. PCRE2_INC=`$PCRE2_CONF --cflags`
  39. else
  40. AC_MSG_ERROR(Couldn't find pcre2-config)
  41. fi
  42. fi
  43. PHP_EVAL_INCLINE($PCRE2_INC)
  44. PHP_EVAL_LIBLINE($PCRE2_LIB)
  45. AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
  46. AC_DEFINE(HAVE_PCRE, 1, [ ])
  47. if test "$PHP_PCRE_JIT" != "no"; then
  48. AC_MSG_CHECKING([for JIT support in PCRE2])
  49. AC_RUN_IFELSE([
  50. AC_LANG_SOURCE([[
  51. #include <pcre2.h>
  52. #include <stdlib.h>
  53. int main(void) {
  54. uint32_t have_jit;
  55. pcre2_config_8(PCRE2_CONFIG_JIT, &have_jit);
  56. return !have_jit;
  57. }
  58. ]])], [
  59. AC_MSG_RESULT([yes])
  60. AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
  61. ],
  62. [
  63. AC_MSG_RESULT([no])
  64. ],
  65. [
  66. AC_CANONICAL_HOST
  67. case $host_cpu in
  68. arm*|i[34567]86|x86_64|mips*|powerpc*|sparc)
  69. AC_MSG_RESULT([yes])
  70. AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [])
  71. ;;
  72. *)
  73. AC_MSG_RESULT([no])
  74. ;;
  75. esac
  76. ])
  77. fi
  78. PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
  79. PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h])
  80. else
  81. AC_MSG_CHECKING([for PCRE library to use])
  82. AC_MSG_RESULT([bundled])
  83. pcrelib_sources="pcre2lib/pcre2_auto_possess.c pcre2lib/pcre2_chartables.c pcre2lib/pcre2_compile.c \
  84. pcre2lib/pcre2_config.c pcre2lib/pcre2_context.c pcre2lib/pcre2_dfa_match.c pcre2lib/pcre2_error.c \
  85. pcre2lib/pcre2_jit_compile.c pcre2lib/pcre2_maketables.c pcre2lib/pcre2_match.c pcre2lib/pcre2_match_data.c \
  86. pcre2lib/pcre2_newline.c pcre2lib/pcre2_ord2utf.c pcre2lib/pcre2_pattern_info.c pcre2lib/pcre2_serialize.c \
  87. pcre2lib/pcre2_string_utils.c pcre2lib/pcre2_study.c pcre2lib/pcre2_substitute.c pcre2lib/pcre2_substring.c \
  88. pcre2lib/pcre2_tables.c pcre2lib/pcre2_ucd.c pcre2lib/pcre2_valid_utf.c pcre2lib/pcre2_xclass.c \
  89. pcre2lib/pcre2_find_bracket.c pcre2lib/pcre2_convert.c pcre2lib/pcre2_extuni.c"
  90. PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcre2lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
  91. PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
  92. PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
  93. PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
  94. AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ])
  95. AC_DEFINE(PCRE2_CODE_UNIT_WIDTH, 8, [ ])
  96. if test "$PHP_PCRE_REGEX" != "no"; then
  97. AC_MSG_CHECKING([whether to enable PCRE JIT functionality])
  98. if test "$PHP_PCRE_JIT" != "no"; then
  99. AC_DEFINE(HAVE_PCRE_JIT_SUPPORT, 1, [ ])
  100. AC_MSG_RESULT([yes])
  101. else
  102. AC_MSG_RESULT([no])
  103. fi
  104. fi
  105. fi
  106. PHP_ARG_WITH(pcre-valgrind,,[ --with-pcre-valgrind=DIR
  107. Enable PCRE valgrind support. Developers only!], no, no)
  108. if test "$PHP_PCRE_REGEX" != "yes" && test "$PHP_PCRE_REGEX" != "no"; then
  109. AC_MSG_WARN([PHP is going to be linked with an external PCRE, --with-pcre-valgrind has no effect])
  110. else
  111. if test "$PHP_PCRE_VALGRIND" != "no"; then
  112. PHP_PCRE_VALGRIND_INCDIR=
  113. AC_MSG_CHECKING([for Valgrind headers location])
  114. for i in $PHP_PCRE_VALGRIND $PHP_PCRE_VALGRIND/include $PHP_PCRE_VALGRIND/local/include /usr/include /usr/local/include; do
  115. if test -f $i/valgrind/memcheck.h
  116. then
  117. PHP_PCRE_VALGRIND_INCDIR=$i
  118. break
  119. fi
  120. done
  121. if test -z "$PHP_PCRE_VALGRIND_INCDIR"
  122. then
  123. AC_MSG_ERROR([Could not find valgrind/memcheck.h])
  124. else
  125. AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ])
  126. PHP_ADD_INCLUDE($PHP_PCRE_VALGRIND_INCDIR)
  127. AC_MSG_RESULT([$PHP_PCRE_VALGRIND_INCDIR])
  128. fi
  129. fi
  130. fi