1 dnl Process this file with autoconf to produce a configure script.
3 dnl NOTE FOR MAINTAINERS: Do not use minor version numbers 08 or 09 because
4 dnl the leading zeros may cause them to be treated as invalid octal constants
5 dnl if a PCRE2 user writes code that uses PCRE2_MINOR as a number. There is now
6 dnl a check further down that throws an error if 08 or 09 are used.
8 dnl The PCRE2_PRERELEASE feature is for identifying release candidates. It might
9 dnl be defined as -RC2, for example. For real releases, it should be empty.
11 m4_define(pcre2_major, [10])
12 m4_define(pcre2_minor, [32])
13 m4_define(pcre2_prerelease, [])
14 m4_define(pcre2_date, [2018-09-10])
16 # NOTE: The CMakeLists.txt file searches for the above variables in the first
17 # 50 lines of this file. Please update that if the variables above are moved.
19 # Libtool shared library interface versions (current:revision:age)
20 m4_define(libpcre2_8_version, [7:1:7])
21 m4_define(libpcre2_16_version, [7:1:7])
22 m4_define(libpcre2_32_version, [7:1:7])
23 m4_define(libpcre2_posix_version, [2:1:0])
26 AC_INIT(PCRE2, pcre2_major.pcre2_minor[]pcre2_prerelease, , pcre2)
27 AC_CONFIG_SRCDIR([src/pcre2.h.in])
28 AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
29 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
30 AC_CONFIG_HEADERS(src/config.h)
32 # This was added at the suggestion of libtoolize (03-Jan-10)
33 AC_CONFIG_MACRO_DIR([m4])
35 # The default CFLAGS in Autoconf are "-g -O2" for gcc and just "-g" for any
36 # other compiler. There doesn't seem to be a standard way of getting rid of the
37 # -g (which I don't think is needed for a production library). This fudge seems
38 # to achieve the necessary. First, we remember the externally set values of
39 # CFLAGS. Then call the AC_PROG_CC macro to find the compiler - if CFLAGS is
40 # not set, it will be set to Autoconf's defaults. Afterwards, if the original
41 # values were not set, remove the -g from the Autoconf defaults.
43 remember_set_CFLAGS="$CFLAGS"
47 AC_USE_SYSTEM_EXTENSIONS
49 if test "x$remember_set_CFLAGS" = "x"
51 if test "$CFLAGS" = "-g -O2"
54 elif test "$CFLAGS" = "-g"
60 # This is a new thing required to stop a warning from automake 1.12
61 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
63 # Check for a 64-bit integer type
71 # Check for GCC visibility feature
77 PCRE2_MAJOR="pcre2_major"
78 PCRE2_MINOR="pcre2_minor"
79 PCRE2_PRERELEASE="pcre2_prerelease"
80 PCRE2_DATE="pcre2_date"
82 if test "$PCRE2_MINOR" = "08" -o "$PCRE2_MINOR" = "09"
85 echo "*** Minor version number $PCRE2_MINOR must not be used. ***"
86 echo "*** Use only 00 to 07 or 10 onwards, to avoid octal issues. ***"
93 AC_SUBST(PCRE2_PRERELEASE)
96 # Set a more sensible default value for $(htmldir).
97 if test "x$htmldir" = 'x${docdir}'
99 htmldir='${docdir}/html'
102 # Force an error for PCRE1 size options
103 AC_ARG_ENABLE(pcre8,,,enable_pcre8=no)
104 AC_ARG_ENABLE(pcre16,,,enable_pcre16=no)
105 AC_ARG_ENABLE(pcre32,,,enable_pcre32=no)
107 if test "$enable_pcre8$enable_pcre16$enable_pcre32" != "nonono"
109 echo "** ERROR: Use --[[en|dis]]able-pcre2-[[8|16|32]], not --[[en|dis]]able-pcre[[8|16|32]]"
113 # Handle --disable-pcre2-8 (enabled by default)
114 AC_ARG_ENABLE(pcre2-8,
115 AS_HELP_STRING([--disable-pcre2-8],
116 [disable 8 bit character support]),
117 , enable_pcre2_8=unset)
118 AC_SUBST(enable_pcre2_8)
120 # Handle --enable-pcre2-16 (disabled by default)
121 AC_ARG_ENABLE(pcre2-16,
122 AS_HELP_STRING([--enable-pcre2-16],
123 [enable 16 bit character support]),
124 , enable_pcre2_16=unset)
125 AC_SUBST(enable_pcre2_16)
127 # Handle --enable-pcre2-32 (disabled by default)
128 AC_ARG_ENABLE(pcre2-32,
129 AS_HELP_STRING([--enable-pcre2-32],
130 [enable 32 bit character support]),
131 , enable_pcre2_32=unset)
132 AC_SUBST(enable_pcre2_32)
134 # Handle --dnable-debug (disabled by default)
136 AS_HELP_STRING([--enable-debug],
137 [enable debugging code]),
140 # Handle --enable-jit (disabled by default)
142 AS_HELP_STRING([--enable-jit],
143 [enable Just-In-Time compiling support]),
146 # This code enables JIT if the hardware supports it.
147 if test "$enable_jit" = "auto"; then
149 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
150 #define SLJIT_CONFIG_AUTO 1
151 #include "src/sljit/sljitConfigInternal.h"
152 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
154 #endif]])], enable_jit=yes, enable_jit=no)
155 echo checking for JIT support on this hardware... $enable_jit
158 # Handle --enable-jit-sealloc (disabled by default)
159 AC_ARG_ENABLE(jit-sealloc,
160 AS_HELP_STRING([--enable-jit-sealloc],
161 [enable SELinux compatible execmem allocator in JIT]),
162 , enable_jit_sealloc=no)
164 # Handle --disable-pcre2grep-jit (enabled by default)
165 AC_ARG_ENABLE(pcre2grep-jit,
166 AS_HELP_STRING([--disable-pcre2grep-jit],
167 [disable JIT support in pcre2grep]),
168 , enable_pcre2grep_jit=yes)
170 # Handle --disable-pcre2grep-callout (enabled by default)
171 AC_ARG_ENABLE(pcre2grep-callout,
172 AS_HELP_STRING([--disable-pcre2grep-callout],
173 [disable callout script support in pcre2grep]),
174 , enable_pcre2grep_callout=yes)
176 # Handle --enable-rebuild-chartables
177 AC_ARG_ENABLE(rebuild-chartables,
178 AS_HELP_STRING([--enable-rebuild-chartables],
179 [rebuild character tables in current locale]),
180 , enable_rebuild_chartables=no)
182 # Handle --disable-unicode (enabled by default)
183 AC_ARG_ENABLE(unicode,
184 AS_HELP_STRING([--disable-unicode],
185 [disable Unicode support]),
186 , enable_unicode=unset)
188 # Handle newline options
190 AC_ARG_ENABLE(newline-is-cr,
191 AS_HELP_STRING([--enable-newline-is-cr],
192 [use CR as newline character]),
194 AC_ARG_ENABLE(newline-is-lf,
195 AS_HELP_STRING([--enable-newline-is-lf],
196 [use LF as newline character (default)]),
198 AC_ARG_ENABLE(newline-is-crlf,
199 AS_HELP_STRING([--enable-newline-is-crlf],
200 [use CRLF as newline sequence]),
201 ac_pcre2_newline=crlf)
202 AC_ARG_ENABLE(newline-is-anycrlf,
203 AS_HELP_STRING([--enable-newline-is-anycrlf],
204 [use CR, LF, or CRLF as newline sequence]),
205 ac_pcre2_newline=anycrlf)
206 AC_ARG_ENABLE(newline-is-any,
207 AS_HELP_STRING([--enable-newline-is-any],
208 [use any valid Unicode newline sequence]),
209 ac_pcre2_newline=any)
210 AC_ARG_ENABLE(newline-is-nul,
211 AS_HELP_STRING([--enable-newline-is-nul],
212 [use NUL (binary zero) as newline character]),
213 ac_pcre2_newline=nul)
214 enable_newline="$ac_pcre2_newline"
216 # Handle --enable-bsr-anycrlf
217 AC_ARG_ENABLE(bsr-anycrlf,
218 AS_HELP_STRING([--enable-bsr-anycrlf],
219 [\R matches only CR, LF, CRLF by default]),
220 , enable_bsr_anycrlf=no)
222 # Handle --enable-never-backslash-C
223 AC_ARG_ENABLE(never-backslash-C,
224 AS_HELP_STRING([--enable-never-backslash-C],
225 [use of \C causes an error]),
226 , enable_never_backslash_C=no)
228 # Handle --enable-ebcdic
229 AC_ARG_ENABLE(ebcdic,
230 AS_HELP_STRING([--enable-ebcdic],
231 [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
234 # Handle --enable-ebcdic-nl25
235 AC_ARG_ENABLE(ebcdic-nl25,
236 AS_HELP_STRING([--enable-ebcdic-nl25],
237 [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
238 , enable_ebcdic_nl25=no)
240 # Handle --enable-pcre2grep-libz
241 AC_ARG_ENABLE(pcre2grep-libz,
242 AS_HELP_STRING([--enable-pcre2grep-libz],
243 [link pcre2grep with libz to handle .gz files]),
244 , enable_pcre2grep_libz=no)
246 # Handle --enable-pcre2grep-libbz2
247 AC_ARG_ENABLE(pcre2grep-libbz2,
248 AS_HELP_STRING([--enable-pcre2grep-libbz2],
249 [link pcre2grep with libbz2 to handle .bz2 files]),
250 , enable_pcre2grep_libbz2=no)
252 # Handle --with-pcre2grep-bufsize=N
253 AC_ARG_WITH(pcre2grep-bufsize,
254 AS_HELP_STRING([--with-pcre2grep-bufsize=N],
255 [pcre2grep initial buffer size (default=20480, minimum=8192)]),
256 , with_pcre2grep_bufsize=20480)
258 # Handle --with-pcre2grep-max-bufsize=N
259 AC_ARG_WITH(pcre2grep-max-bufsize,
260 AS_HELP_STRING([--with-pcre2grep-max-bufsize=N],
261 [pcre2grep maximum buffer size (default=1048576, minimum=8192)]),
262 , with_pcre2grep_max_bufsize=1048576)
264 # Handle --enable-pcre2test-libedit
265 AC_ARG_ENABLE(pcre2test-libedit,
266 AS_HELP_STRING([--enable-pcre2test-libedit],
267 [link pcre2test with libedit]),
268 , enable_pcre2test_libedit=no)
270 # Handle --enable-pcre2test-libreadline
271 AC_ARG_ENABLE(pcre2test-libreadline,
272 AS_HELP_STRING([--enable-pcre2test-libreadline],
273 [link pcre2test with libreadline]),
274 , enable_pcre2test_libreadline=no)
276 # Handle --with-link-size=N
277 AC_ARG_WITH(link-size,
278 AS_HELP_STRING([--with-link-size=N],
279 [internal link size (2, 3, or 4 allowed; default=2)]),
282 # Handle --with-parens-nest-limit=N
283 AC_ARG_WITH(parens-nest-limit,
284 AS_HELP_STRING([--with-parens-nest-limit=N],
285 [nested parentheses limit (default=250)]),
286 , with_parens_nest_limit=250)
288 # Handle --with-heap-limit
289 AC_ARG_WITH(heap-limit,
290 AS_HELP_STRING([--with-heap-limit=N],
291 [default limit on heap memory (kibibytes, default=20000000)]),
292 , with_heap_limit=20000000)
294 # Handle --with-match-limit=N
295 AC_ARG_WITH(match-limit,
296 AS_HELP_STRING([--with-match-limit=N],
297 [default limit on internal looping (default=10000000)]),
298 , with_match_limit=10000000)
300 # Handle --with-match-limit-depth=N
301 # Recognize old synonym --with-match-limit-recursion
303 # Note: In config.h, the default is to define MATCH_LIMIT_DEPTH symbolically as
304 # MATCH_LIMIT, which in turn is defined to be some numeric value (e.g.
305 # 10000000). MATCH_LIMIT_DEPTH can otherwise be set to some different numeric
306 # value (or even the same numeric value as MATCH_LIMIT, though no longer
307 # defined in terms of the latter).
309 AC_ARG_WITH(match-limit-depth,
310 AS_HELP_STRING([--with-match-limit-depth=N],
311 [default limit on match tree depth (default=MATCH_LIMIT)]),
312 , with_match_limit_depth=MATCH_LIMIT)
314 AC_ARG_WITH(match-limit-recursion,,
315 , with_match_limit_recursion=UNSET)
317 # Handle --enable-valgrind
318 AC_ARG_ENABLE(valgrind,
319 AS_HELP_STRING([--enable-valgrind],
320 [enable valgrind support]),
321 , enable_valgrind=no)
323 # Enable code coverage reports using gcov
324 AC_ARG_ENABLE(coverage,
325 AS_HELP_STRING([--enable-coverage],
326 [enable code coverage reports using gcov]),
327 , enable_coverage=no)
329 # Handle --enable-fuzz-support
330 AC_ARG_ENABLE(fuzz_support,
331 AS_HELP_STRING([--enable-fuzz-support],
332 [enable fuzzer support]),
333 , enable_fuzz_support=no)
335 # Handle --disable-stack-for-recursion
336 # This option became obsolete at release 10.30.
337 AC_ARG_ENABLE(stack-for-recursion,,
338 , enable_stack_for_recursion=yes)
341 # AC_ARG_ENABLE(stack-for-recursion,
342 # AS_HELP_STRING([--disable-stack-for-recursion],
343 # [don't use stack recursion when matching]),
344 # , enable_stack_for_recursion=yes)
346 # Set the default value for pcre2-8
347 if test "x$enable_pcre2_8" = "xunset"
352 # Set the default value for pcre2-16
353 if test "x$enable_pcre2_16" = "xunset"
358 # Set the default value for pcre2-32
359 if test "x$enable_pcre2_32" = "xunset"
364 # Make sure at least one library is selected
365 if test "x$enable_pcre2_8$enable_pcre2_16$enable_pcre2_32" = "xnonono"
367 AC_MSG_ERROR([At least one of the 8, 16 or 32 bit libraries must be enabled])
370 # Unicode is enabled by default.
371 if test "x$enable_unicode" = "xunset"
376 # Convert the newline identifier into the appropriate integer value. These must
377 # agree with the PCRE2_NEWLINE_xxx values in pcre2.h.
379 case "$enable_newline" in
380 cr) ac_pcre2_newline_value=1 ;;
381 lf) ac_pcre2_newline_value=2 ;;
382 crlf) ac_pcre2_newline_value=3 ;;
383 any) ac_pcre2_newline_value=4 ;;
384 anycrlf) ac_pcre2_newline_value=5 ;;
385 nul) ac_pcre2_newline_value=6 ;;
387 AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
391 # --enable-ebcdic-nl25 implies --enable-ebcdic
392 if test "x$enable_ebcdic_nl25" = "xyes"; then
396 # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
397 # Also check that UTF support is not requested, because PCRE2 cannot handle
398 # EBCDIC and UTF in the same build. To do so it would need to use different
399 # character constants depending on the mode. Also, EBCDIC cannot be used with
400 # 16-bit and 32-bit libraries.
402 if test "x$enable_ebcdic" = "xyes"; then
403 enable_rebuild_chartables=yes
404 if test "x$enable_unicode" = "xyes"; then
405 AC_MSG_ERROR([support for EBCDIC and Unicode cannot be enabled at the same time])
407 if test "x$enable_pcre2_16" = "xyes" -o "x$enable_pcre2_32" = "xyes"; then
408 AC_MSG_ERROR([EBCDIC support is available only for the 8-bit library])
412 # Check argument to --with-link-size
413 case "$with_link_size" in
416 AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
421 /* PCRE2 is written in Standard C, but there are a few non-standard things it
422 can cope with, allowing it to run on SunOS4 and other "close to standard"
425 In environments that support the GNU autotools, config.h.in is converted into
426 config.h by the "configure" script. In environments that use CMake,
427 config-cmake.in is converted into config.h. If you are going to build PCRE2 "by
428 hand" without using "configure" or CMake, you should copy the distributed
429 config.h.generic to config.h, and edit the macro definitions to be the way you
430 need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
431 so that config.h is included at the start of every source.
433 Alternatively, you can avoid editing by using -D on the compiler command line
434 to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
435 but if you do, default values will be taken from config.h for non-boolean
436 macros that are not defined on the command line.
438 Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
439 defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
440 such macros are listed as a commented #undef in config.h.generic. Macros such
441 as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
442 surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
444 PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
445 HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
446 sure both macros are undefined; an emulation function will then be used. */])
448 # Checks for header files.
450 AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h)
451 AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
452 AC_CHECK_HEADERS([sys/wait.h], [HAVE_SYS_WAIT_H=1])
454 AC_CHECK_HEADERS([stdint.h], [PCRE2_HAVE_STDINT_H=1], [PCRE2_HAVE_STDINT_H=0])
455 AC_CHECK_HEADERS([inttypes.h], [PCRE2_HAVE_INTTYPES_H=1], [PCRE2_HAVE_INTTYPES_H=0])
456 AC_SUBST([PCRE2_HAVE_STDINT_H])
457 AC_SUBST([PCRE2_HAVE_INTTYPES_H])
459 # Conditional compilation
460 AM_CONDITIONAL(WITH_PCRE2_8, test "x$enable_pcre2_8" = "xyes")
461 AM_CONDITIONAL(WITH_PCRE2_16, test "x$enable_pcre2_16" = "xyes")
462 AM_CONDITIONAL(WITH_PCRE2_32, test "x$enable_pcre2_32" = "xyes")
463 AM_CONDITIONAL(WITH_DEBUG, test "x$enable_debug" = "xyes")
464 AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
465 AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
466 AM_CONDITIONAL(WITH_UNICODE, test "x$enable_unicode" = "xyes")
467 AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
468 AM_CONDITIONAL(WITH_FUZZ_SUPPORT, test "x$enable_fuzz_support" = "xyes")
470 if test "$enable_fuzz_support" = "yes" -a "$enable_pcre2_8" = "no"; then
471 echo "** ERROR: Fuzzer support requires the 8-bit library"
475 # Checks for typedefs, structures, and compiler characteristics.
480 # Checks for library functions.
482 AC_CHECK_FUNCS(bcopy memmove strerror mkostemp secure_getenv)
484 # Check for the availability of libz (aka zlib)
486 AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
487 AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
489 # Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
490 # as for libz. However, this had the following problem, diagnosed and fixed by
493 # - libbz2 uses the Pascal calling convention (WINAPI) for the functions
495 # - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
496 # therefore missing the function definition.
497 # - The compiler thus generates a "C" signature for the test function.
498 # - The linker fails to find the "C" function.
499 # - PCRE2 fails to configure if asked to do so against libbz2.
503 # - Replace the AC_CHECK_LIB test with a custom test.
505 AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
507 # AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
509 # Custom test follows
511 AC_MSG_CHECKING([for libbz2])
514 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
518 [[return (int)BZ2_bzopen("conftest", "rb");]])],
519 [AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
523 # Check for the availabiity of libreadline
525 if test "$enable_pcre2test_libreadline" = "yes"; then
526 AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
527 AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
528 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
529 [unset ac_cv_lib_readline_readline;
530 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
531 [unset ac_cv_lib_readline_readline;
532 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
533 [unset ac_cv_lib_readline_readline;
534 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
535 [unset ac_cv_lib_readline_readline;
536 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
537 [unset ac_cv_lib_readline_readline;
538 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
545 AC_SUBST(LIBREADLINE)
546 if test -n "$LIBREADLINE"; then
547 if test "$LIBREADLINE" != "-lreadline"; then
548 echo "-lreadline needs $LIBREADLINE"
549 LIBREADLINE="-lreadline $LIBREADLINE"
555 # Check for the availability of libedit. Different distributions put its
556 # headers in different places. Try to cover the most common ones.
558 if test "$enable_pcre2test_libedit" = "yes"; then
559 AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
560 [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1],
561 [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])])
562 AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
565 PCRE2_STATIC_CFLAG=""
566 if test "x$enable_shared" = "xno" ; then
567 AC_DEFINE([PCRE2_STATIC], [1], [
568 Define to any value if linking statically (TODO: make nice with Libtool)])
569 PCRE2_STATIC_CFLAG="-DPCRE2_STATIC"
571 AC_SUBST(PCRE2_STATIC_CFLAG)
573 # Here is where PCRE2-specific defines are handled
575 if test "$enable_pcre2_8" = "yes"; then
576 AC_DEFINE([SUPPORT_PCRE2_8], [], [
577 Define to any value to enable the 8 bit PCRE2 library.])
580 if test "$enable_pcre2_16" = "yes"; then
581 AC_DEFINE([SUPPORT_PCRE2_16], [], [
582 Define to any value to enable the 16 bit PCRE2 library.])
585 if test "$enable_pcre2_32" = "yes"; then
586 AC_DEFINE([SUPPORT_PCRE2_32], [], [
587 Define to any value to enable the 32 bit PCRE2 library.])
590 if test "$enable_debug" = "yes"; then
591 AC_DEFINE([PCRE2_DEBUG], [], [
592 Define to any value to include debugging code.])
595 # Unless running under Windows, JIT support requires pthreads.
597 if test "$enable_jit" = "yes"; then
598 if test "$HAVE_WINDOWS_H" != "1"; then
599 AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
601 CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
602 LIBS="$PTHREAD_LIBS $LIBS"
604 AC_DEFINE([SUPPORT_JIT], [], [
605 Define to any value to enable support for Just-In-Time compiling.])
607 enable_pcre2grep_jit="no"
610 if test "$enable_jit_sealloc" = "yes"; then
611 AC_DEFINE([SLJIT_PROT_EXECUTABLE_ALLOCATOR], [1], [
612 Define to any non-zero number to enable support for SELinux
613 compatible executable memory allocator in JIT. Note that this
614 will have no effect unless SUPPORT_JIT is also defined.])
617 if test "$enable_pcre2grep_jit" = "yes"; then
618 AC_DEFINE([SUPPORT_PCRE2GREP_JIT], [], [
619 Define to any value to enable JIT support in pcre2grep. Note that this will
620 have no effect unless SUPPORT_JIT is also defined.])
623 if test "$enable_pcre2grep_callout" = "yes"; then
624 if test "$HAVE_WINDOWS_H" != "1"; then
625 if test "$HAVE_SYS_WAIT_H" != "1"; then
626 AC_MSG_ERROR([Callout script support needs sys/wait.h.])
629 AC_DEFINE([SUPPORT_PCRE2GREP_CALLOUT], [], [
630 Define to any value to enable callout script support in pcre2grep.])
633 if test "$enable_unicode" = "yes"; then
634 AC_DEFINE([SUPPORT_UNICODE], [], [
635 Define to any value to enable support for Unicode and UTF encoding.
636 This will work even in an EBCDIC environment, but it is incompatible
637 with the EBCDIC macro. That is, PCRE2 can support *either* EBCDIC
638 code *or* ASCII/Unicode, but not both at once.])
641 if test "$enable_pcre2grep_libz" = "yes"; then
642 AC_DEFINE([SUPPORT_LIBZ], [], [
643 Define to any value to allow pcre2grep to be linked with libz, so that it is
644 able to handle .gz files.])
647 if test "$enable_pcre2grep_libbz2" = "yes"; then
648 AC_DEFINE([SUPPORT_LIBBZ2], [], [
649 Define to any value to allow pcre2grep to be linked with libbz2, so that it
650 is able to handle .bz2 files.])
653 if test $with_pcre2grep_bufsize -lt 8192 ; then
654 AC_MSG_WARN([$with_pcre2grep_bufsize is too small for --with-pcre2grep-bufsize; using 8192])
655 with_pcre2grep_bufsize="8192"
657 if test $? -gt 1 ; then
658 AC_MSG_ERROR([Bad value for --with-pcre2grep-bufsize])
662 if test $with_pcre2grep_max_bufsize -lt $with_pcre2grep_bufsize ; then
663 with_pcre2grep_max_bufsize="$with_pcre2grep_bufsize"
665 if test $? -gt 1 ; then
666 AC_MSG_ERROR([Bad value for --with-pcre2grep-max-bufsize])
670 AC_DEFINE_UNQUOTED([PCRE2GREP_BUFSIZE], [$with_pcre2grep_bufsize], [
671 The value of PCRE2GREP_BUFSIZE is the starting size of the buffer used by
672 pcre2grep to hold parts of the file it is searching. The buffer will be
673 expanded up to PCRE2GREP_MAX_BUFSIZE if necessary, for files containing very
674 long lines. The actual amount of memory used by pcre2grep is three times this
675 number, because it allows for the buffering of "before" and "after" lines.])
677 AC_DEFINE_UNQUOTED([PCRE2GREP_MAX_BUFSIZE], [$with_pcre2grep_max_bufsize], [
678 The value of PCRE2GREP_MAX_BUFSIZE specifies the maximum size of the buffer
679 used by pcre2grep to hold parts of the file it is searching. The actual
680 amount of memory used by pcre2grep is three times this number, because it
681 allows for the buffering of "before" and "after" lines.])
683 if test "$enable_pcre2test_libedit" = "yes"; then
684 AC_DEFINE([SUPPORT_LIBEDIT], [], [
685 Define to any value to allow pcre2test to be linked with libedit.])
686 LIBREADLINE="$LIBEDIT"
687 elif test "$enable_pcre2test_libreadline" = "yes"; then
688 AC_DEFINE([SUPPORT_LIBREADLINE], [], [
689 Define to any value to allow pcre2test to be linked with libreadline.])
692 AC_DEFINE_UNQUOTED([NEWLINE_DEFAULT], [$ac_pcre2_newline_value], [
693 The value of NEWLINE_DEFAULT determines the default newline character
694 sequence. PCRE2 client programs can override this by selecting other values
695 at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY),
696 5 (ANYCRLF), and 6 (NUL).])
698 if test "$enable_bsr_anycrlf" = "yes"; then
699 AC_DEFINE([BSR_ANYCRLF], [], [
700 By default, the \R escape sequence matches any Unicode line ending
701 character or sequence of characters. If BSR_ANYCRLF is defined (to any
702 value), this is changed so that backslash-R matches only CR, LF, or CRLF.
703 The build-time default can be overridden by the user of PCRE2 at runtime.])
706 if test "$enable_never_backslash_C" = "yes"; then
707 AC_DEFINE([NEVER_BACKSLASH_C], [], [
708 Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns.])
711 AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
712 The value of LINK_SIZE determines the number of bytes used to store
713 links as offsets within the compiled regex. The default is 2, which
714 allows for compiled patterns up to 65535 code units long. This covers the
715 vast majority of cases. However, PCRE2 can also be compiled to use 3 or 4
716 bytes instead. This allows for longer patterns in extreme cases.])
718 AC_DEFINE_UNQUOTED([PARENS_NEST_LIMIT], [$with_parens_nest_limit], [
719 The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
720 parentheses (of any kind) in a pattern. This limits the amount of system
721 stack that is used while compiling a pattern.])
723 AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
724 The value of MATCH_LIMIT determines the default number of times the
725 pcre2_match() function can record a backtrack position during a single
726 matching attempt. The value is also used to limit a loop counter in
727 pcre2_dfa_match(). There is a runtime interface for setting a different
728 limit. The limit exists in order to catch runaway regular expressions that
729 take for ever to determine that they do not match. The default is set very
730 large so that it does not accidentally catch legitimate cases.])
732 # --with-match-limit-recursion is an obsolete synonym for --with-match-limit-depth
734 if test "$with_match_limit_recursion" != "UNSET"; then
737 WARNING: --with-match-limit-recursion is an obsolete option. Please use
738 --with-match-limit-depth in future. If both are set, --with-match-limit-depth
739 will be used. See also --with-heap-limit.
742 if test "$with_match_limit_depth" = "MATCH_LIMIT"; then
743 with_match_limit_depth=$with_match_limit_recursion
747 AC_DEFINE_UNQUOTED([MATCH_LIMIT_DEPTH], [$with_match_limit_depth], [
748 The above limit applies to all backtracks, whether or not they are nested. In
749 some environments it is desirable to limit the nesting of backtracking (that
750 is, the depth of tree that is searched) more strictly, in order to restrict
751 the maximum amount of heap memory that is used. The value of
752 MATCH_LIMIT_DEPTH provides this facility. To have any useful effect, it must
753 be less than the value of MATCH_LIMIT. The default is to use the same value
754 as MATCH_LIMIT. There is a runtime method for setting a different limit. In
755 the case of pcre2_dfa_match(), this limit controls the depth of the internal
756 nested function calls that are used for pattern recursions, lookarounds, and
759 AC_DEFINE_UNQUOTED([HEAP_LIMIT], [$with_heap_limit], [
760 This limits the amount of memory that may be used while matching
761 a pattern. It applies to both pcre2_match() and pcre2_dfa_match(). It does
762 not apply to JIT matching. The value is in kibibytes (units of 1024 bytes).])
764 AC_DEFINE([MAX_NAME_SIZE], [32], [
765 This limit is parameterized just in case anybody ever wants to
766 change it. Care must be taken if it is increased, because it guards
767 against integer overflow caused by enormously large patterns.])
769 AC_DEFINE([MAX_NAME_COUNT], [10000], [
770 This limit is parameterized just in case anybody ever wants to
771 change it. Care must be taken if it is increased, because it guards
772 against integer overflow caused by enormously large patterns.])
774 AH_VERBATIM([PCRE2_EXP_DEFN], [
775 /* If you are compiling for a system other than a Unix-like system or
776 Win32, and it needs some magic to be inserted before the definition
777 of a function that is exported by the library, define this macro to
778 contain the relevant magic. If you do not define this macro, a suitable
779 __declspec value is used for Windows systems; in other environments
780 "extern" is used for a C compiler and "extern C" for a C++ compiler.
781 This macro apears at the start of every exported function that is part
782 of the external API. It does not appear on functions that are "external"
783 in the C sense, but which are internal to the library. */
784 #undef PCRE2_EXP_DEFN])
786 if test "$enable_ebcdic" = "yes"; then
787 AC_DEFINE_UNQUOTED([EBCDIC], [], [
788 If you are compiling for a system that uses EBCDIC instead of ASCII
789 character codes, define this macro to any value. When EBCDIC is set, PCRE2
790 assumes that all input strings are in EBCDIC. If you do not define this
791 macro, PCRE2 will assume input strings are ASCII or UTF-8/16/32 Unicode. It
792 is not possible to build a version of PCRE2 that supports both EBCDIC and
796 if test "$enable_ebcdic_nl25" = "yes"; then
797 AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
798 In an EBCDIC environment, define this macro to any value to arrange for
799 the NL character to be 0x25 instead of the default 0x15. NL plays the role
800 that LF does in an ASCII/Unicode environment.])
803 if test "$enable_valgrind" = "yes"; then
804 AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
805 Define to any value for valgrind support to find invalid memory reads.])
808 # Platform specific issues
813 if test X"$enable_shared" = Xyes; then
814 NO_UNDEFINED="-no-undefined"
815 EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
820 # The extra LDFLAGS for each particular library. The libpcre2*_version values
821 # are m4 variables, assigned above.
823 EXTRA_LIBPCRE2_8_LDFLAGS="$EXTRA_LIBPCRE2_8_LDFLAGS \
824 $NO_UNDEFINED -version-info libpcre2_8_version"
826 EXTRA_LIBPCRE2_16_LDFLAGS="$EXTRA_LIBPCRE2_16_LDFLAGS \
827 $NO_UNDEFINED -version-info libpcre2_16_version"
829 EXTRA_LIBPCRE2_32_LDFLAGS="$EXTRA_LIBPCRE2_32_LDFLAGS \
830 $NO_UNDEFINED -version-info libpcre2_32_version"
832 EXTRA_LIBPCRE2_POSIX_LDFLAGS="$EXTRA_LIBPCRE2_POSIX_LDFLAGS \
833 $NO_UNDEFINED -version-info libpcre2_posix_version"
835 AC_SUBST(EXTRA_LIBPCRE2_8_LDFLAGS)
836 AC_SUBST(EXTRA_LIBPCRE2_16_LDFLAGS)
837 AC_SUBST(EXTRA_LIBPCRE2_32_LDFLAGS)
838 AC_SUBST(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
840 # When we run 'make distcheck', use these arguments. Turning off compiler
841 # optimization makes it run faster.
842 DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre2-16 --enable-pcre2-32 --enable-jit"
843 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
845 # Check that, if --enable-pcre2grep-libz or --enable-pcre2grep-libbz2 is
846 # specified, the relevant library is available.
848 if test "$enable_pcre2grep_libz" = "yes"; then
849 if test "$HAVE_ZLIB_H" != "1"; then
850 echo "** Cannot --enable-pcre2grep-libz because zlib.h was not found"
853 if test "$HAVE_LIBZ" != "1"; then
854 echo "** Cannot --enable-pcre2grep-libz because libz was not found"
861 if test "$enable_pcre2grep_libbz2" = "yes"; then
862 if test "$HAVE_BZLIB_H" != "1"; then
863 echo "** Cannot --enable-pcre2grep-libbz2 because bzlib.h was not found"
866 if test "$HAVE_LIBBZ2" != "1"; then
867 echo "** Cannot --enable-pcre2grep-libbz2 because libbz2 was not found"
874 # Similarly for --enable-pcre2test-readline
876 if test "$enable_pcre2test_libedit" = "yes"; then
877 if test "$enable_pcre2test_libreadline" = "yes"; then
878 echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline"
881 if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
882 "$HAVE_READLINE_READLINE_H" != "1"; then
883 echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h"
884 echo "** nor readline/readline.h was found."
887 if test -z "$LIBEDIT"; then
888 echo "** Cannot --enable-pcre2test-libedit because libedit library was not found."
893 if test "$enable_pcre2test_libreadline" = "yes"; then
894 if test "$HAVE_READLINE_H" != "1"; then
895 echo "** Cannot --enable-pcre2test-readline because readline/readline.h was not found."
898 if test "$HAVE_HISTORY_H" != "1"; then
899 echo "** Cannot --enable-pcre2test-readline because readline/history.h was not found."
902 if test -z "$LIBREADLINE"; then
903 echo "** Cannot --enable-pcre2test-readline because readline library was not found."
908 # Handle valgrind support
910 if test "$enable_valgrind" = "yes"; then
911 m4_ifdef([PKG_CHECK_MODULES],
912 [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
913 [AC_MSG_ERROR([pkg-config not supported])])
916 # Handle code coverage reporting support
917 if test "$enable_coverage" = "yes"; then
918 if test "x$GCC" != "xyes"; then
919 AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
922 # ccache is incompatible with gcov
923 AC_PATH_PROG([SHTOOL],[shtool],[false])
924 case `$SHTOOL path $CC` in
925 *ccache*) cc_ccache=yes;;
929 if test "$cc_ccache" = "yes"; then
930 if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
931 AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
935 AC_ARG_VAR([LCOV],[the ltp lcov program])
936 AC_PATH_PROG([LCOV],[lcov],[false])
937 if test "x$LCOV" = "xfalse"; then
938 AC_MSG_ERROR([lcov not found])
941 AC_ARG_VAR([GENHTML],[the ltp genhtml program])
942 AC_PATH_PROG([GENHTML],[genhtml],[false])
943 if test "x$GENHTML" = "xfalse"; then
944 AC_MSG_ERROR([genhtml not found])
947 # Set flags needed for gcov
948 GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
949 GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
951 AC_SUBST([GCOV_CFLAGS])
952 AC_SUBST([GCOV_CXXFLAGS])
953 AC_SUBST([GCOV_LIBS])
956 AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
958 # Produce these files, in addition to config.h.
969 # Make the generated script files executable.
970 AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
972 # Make sure that pcre2_chartables.c is removed in case the method for
973 # creating it was changed by reconfiguration.
974 AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])
978 # --disable-stack-for-recursion is obsolete and has no effect.
980 if test "$enable_stack_for_recursion" = "no"; then
983 WARNING: --disable-stack-for-recursion is obsolete and has no effect.
987 # Print out a nice little message after configure is run displaying the
991 if test "$enable_ebcdic_nl25" = "yes"; then
993 elif test "$enable_ebcdic" = "yes"; then
999 $PACKAGE-$VERSION configuration summary:
1001 Install prefix ..................... : ${prefix}
1002 C preprocessor ..................... : ${CPP}
1003 C compiler ......................... : ${CC}
1004 Linker ............................. : ${LD}
1005 C preprocessor flags ............... : ${CPPFLAGS}
1006 C compiler flags ................... : ${CFLAGS} ${VISIBILITY_CFLAGS}
1007 Linker flags ....................... : ${LDFLAGS}
1008 Extra libraries .................... : ${LIBS}
1010 Build 8-bit pcre2 library .......... : ${enable_pcre2_8}
1011 Build 16-bit pcre2 library ......... : ${enable_pcre2_16}
1012 Build 32-bit pcre2 library ......... : ${enable_pcre2_32}
1013 Include debugging code ............. : ${enable_debug}
1014 Enable JIT compiling support ....... : ${enable_jit}
1015 Use SELinux allocator in JIT ....... : ${enable_jit_sealloc}
1016 Enable Unicode support ............. : ${enable_unicode}
1017 Newline char/sequence .............. : ${enable_newline}
1018 \R matches only ANYCRLF ............ : ${enable_bsr_anycrlf}
1019 \C is disabled ..................... : ${enable_never_backslash_C}
1020 EBCDIC coding ...................... : ${enable_ebcdic}
1021 EBCDIC code for NL ................. : ${ebcdic_nl_code}
1022 Rebuild char tables ................ : ${enable_rebuild_chartables}
1023 Internal link size ................. : ${with_link_size}
1024 Nested parentheses limit ........... : ${with_parens_nest_limit}
1025 Heap limit ......................... : ${with_heap_limit} kibibytes
1026 Match limit ........................ : ${with_match_limit}
1027 Match depth limit .................. : ${with_match_limit_depth}
1028 Build shared libs .................. : ${enable_shared}
1029 Build static libs .................. : ${enable_static}
1030 Use JIT in pcre2grep ............... : ${enable_pcre2grep_jit}
1031 Enable callouts in pcre2grep ....... : ${enable_pcre2grep_callout}
1032 Initial buffer size for pcre2grep .. : ${with_pcre2grep_bufsize}
1033 Maximum buffer size for pcre2grep .. : ${with_pcre2grep_max_bufsize}
1034 Link pcre2grep with libz ........... : ${enable_pcre2grep_libz}
1035 Link pcre2grep with libbz2 ......... : ${enable_pcre2grep_libbz2}
1036 Link pcre2test with libedit ........ : ${enable_pcre2test_libedit}
1037 Link pcre2test with libreadline .... : ${enable_pcre2test_libreadline}
1038 Valgrind support ................... : ${enable_valgrind}
1039 Code coverage ...................... : ${enable_coverage}
1040 Fuzzer support ..................... : ${enable_fuzz_support}
1044 dnl end configure.ac