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