xref: /aosp_15_r20/external/pcre/configure.ac (revision 22dc650d8ae982c6770746019a6f94af92b0f024)
1dnl Process this file with autoconf to produce a configure script.
2
3dnl NOTE FOR MAINTAINERS: Do not use minor version numbers 08 or 09 because
4dnl the leading zeros may cause them to be treated as invalid octal constants
5dnl if a PCRE2 user writes code that uses PCRE2_MINOR as a number. There is now
6dnl a check further down that throws an error if 08 or 09 are used.
7
8dnl The PCRE2_PRERELEASE feature is for identifying release candidates. It might
9dnl be defined as -RC2, for example. For real releases, it should be empty.
10
11m4_define(pcre2_major, [10])
12m4_define(pcre2_minor, [44])
13m4_define(pcre2_prerelease, [])
14m4_define(pcre2_date, [2024-06-07])
15
16# Libtool shared library interface versions (current:revision:age)
17m4_define(libpcre2_8_version,     [13:0:13])
18m4_define(libpcre2_16_version,    [13:0:13])
19m4_define(libpcre2_32_version,    [13:0:13])
20m4_define(libpcre2_posix_version, [3:5:0])
21
22# NOTE: The CMakeLists.txt file searches for the above variables in the first
23# 50 lines of this file. Please update that if the variables above are moved.
24
25AC_PREREQ([2.62])
26AC_INIT([PCRE2],pcre2_major.pcre2_minor[]pcre2_prerelease,[],[pcre2])
27AC_CONFIG_SRCDIR([src/pcre2.h.in])
28AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
29m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
30AC_CONFIG_HEADERS(src/config.h)
31
32# This was added at the suggestion of libtoolize (03-Jan-10)
33AC_CONFIG_MACRO_DIR([m4])
34
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.
42
43remember_set_CFLAGS="$CFLAGS"
44
45m4_version_prereq(2.70, [AC_PROG_CC], [AC_PROG_CC_C99])
46AM_PROG_CC_C_O
47AC_USE_SYSTEM_EXTENSIONS
48
49if test "x$remember_set_CFLAGS" = "x"
50then
51  if test "$CFLAGS" = "-g -O2"
52  then
53    CFLAGS="-O2"
54  elif test "$CFLAGS" = "-g"
55  then
56    CFLAGS=""
57  fi
58fi
59
60# This is a new thing required to stop a warning from automake 1.12
61m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
62
63# Check for a 64-bit integer type
64AC_TYPE_INT64_T
65
66AC_PROG_INSTALL
67LT_INIT([win32-dll])
68AC_PROG_LN_S
69
70AC_SYS_LARGEFILE
71
72# Check for GCC visibility feature
73
74PCRE2_VISIBILITY
75
76# Check for the mul_overflow() builtin
77
78AC_MSG_CHECKING([for __builtin_mul_overflow()])
79AC_LANG_PUSH([C])
80AC_LINK_IFELSE([AC_LANG_PROGRAM([[
81		#ifdef HAVE_SYS_TYPES_H
82		#include <sys/types.h>
83		#endif
84		#include <stddef.h>
85
86		int a, b;
87		size_t m;
88	]], [[__builtin_mul_overflow(a, b, &m)]])],
89	[pcre2_cc_cv_builtin_mul_overflow=yes],
90	[pcre2_cc_cv_builtin_mul_overflow=no])
91AC_MSG_RESULT([$pcre2_cc_cv_builtin_mul_overflow])
92if test "$pcre2_cc_cv_builtin_mul_overflow" = yes; then
93	AC_DEFINE([HAVE_BUILTIN_MUL_OVERFLOW], 1,
94		[Define this if your compiler provides __builtin_mul_overflow()])
95fi
96AC_LANG_POP([C])
97
98# Check for Clang __attribute__((uninitialized)) feature
99
100AC_MSG_CHECKING([for __attribute__((uninitialized))])
101AC_LANG_PUSH([C])
102tmp_CFLAGS=$CFLAGS
103CFLAGS="$CFLAGS -Werror"
104AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
105                   [[char buf[128] __attribute__((uninitialized));(void)buf]])],
106                   [pcre2_cc_cv_attribute_uninitialized=yes],
107                   [pcre2_cc_cv_attribute_uninitialized=no])
108AC_MSG_RESULT([$pcre2_cc_cv_attribute_uninitialized])
109if test "$pcre2_cc_cv_attribute_uninitialized" = yes; then
110  AC_DEFINE([HAVE_ATTRIBUTE_UNINITIALIZED], 1, [Define this if your compiler
111             supports __attribute__((uninitialized))])
112fi
113CFLAGS=$tmp_CFLAGS
114AC_LANG_POP([C])
115
116# Versioning
117
118PCRE2_MAJOR="pcre2_major"
119PCRE2_MINOR="pcre2_minor"
120PCRE2_PRERELEASE="pcre2_prerelease"
121PCRE2_DATE="pcre2_date"
122
123if test "$PCRE2_MINOR" = "08" -o "$PCRE2_MINOR" = "09"
124then
125  echo "***"
126  echo "*** Minor version number $PCRE2_MINOR must not be used. ***"
127  echo "*** Use only 00 to 07 or 10 onwards, to avoid octal issues. ***"
128  echo "***"
129  exit 1
130fi
131
132AC_SUBST(PCRE2_MAJOR)
133AC_SUBST(PCRE2_MINOR)
134AC_SUBST(PCRE2_PRERELEASE)
135AC_SUBST(PCRE2_DATE)
136
137# Set a more sensible default value for $(htmldir).
138if test "x$htmldir" = 'x${docdir}'
139then
140  htmldir='${docdir}/html'
141fi
142
143# Force an error for PCRE1 size options
144AC_ARG_ENABLE(pcre8,,,enable_pcre8=no)
145AC_ARG_ENABLE(pcre16,,,enable_pcre16=no)
146AC_ARG_ENABLE(pcre32,,,enable_pcre32=no)
147
148if test "$enable_pcre8$enable_pcre16$enable_pcre32" != "nonono"
149then
150  echo "** ERROR: Use --[[en|dis]]able-pcre2-[[8|16|32]], not --[[en|dis]]able-pcre[[8|16|32]]"
151  exit 1
152fi
153
154# Handle --disable-pcre2-8 (enabled by default)
155AC_ARG_ENABLE(pcre2-8,
156              AS_HELP_STRING([--disable-pcre2-8],
157                             [disable 8 bit character support]),
158              , enable_pcre2_8=unset)
159AC_SUBST(enable_pcre2_8)
160
161# Handle --enable-pcre2-16 (disabled by default)
162AC_ARG_ENABLE(pcre2-16,
163              AS_HELP_STRING([--enable-pcre2-16],
164                             [enable 16 bit character support]),
165              , enable_pcre2_16=unset)
166AC_SUBST(enable_pcre2_16)
167
168# Handle --enable-pcre2-32 (disabled by default)
169AC_ARG_ENABLE(pcre2-32,
170              AS_HELP_STRING([--enable-pcre2-32],
171                             [enable 32 bit character support]),
172              , enable_pcre2_32=unset)
173AC_SUBST(enable_pcre2_32)
174
175# Handle --enable-debug (disabled by default)
176AC_ARG_ENABLE(debug,
177              AS_HELP_STRING([--enable-debug],
178                             [enable debugging code]),
179              , enable_debug=no)
180
181# Handle --enable-jit (disabled by default)
182AC_ARG_ENABLE(jit,
183              AS_HELP_STRING([--enable-jit],
184                             [enable Just-In-Time compiling support]),
185              , enable_jit=no)
186
187# This code enables JIT if the hardware supports it.
188if test "$enable_jit" = "auto"; then
189  AC_LANG(C)
190  SAVE_CPPFLAGS=$CPPFLAGS
191  CPPFLAGS=-I$srcdir
192  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
193  #define SLJIT_CONFIG_AUTO 1
194  #include "src/sljit/sljitConfigCPU.h"
195  #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
196  #error unsupported
197  #endif]])], enable_jit=yes, enable_jit=no)
198  CPPFLAGS=$SAVE_CPPFLAGS
199  echo checking for JIT support on this hardware... $enable_jit
200fi
201
202# Handle --enable-jit-sealloc (disabled by default and only experimental)
203case $host_os in
204  linux* | netbsd*)
205    AC_ARG_ENABLE(jit-sealloc,
206      AS_HELP_STRING([--enable-jit-sealloc],
207        [enable SELinux compatible execmem allocator in JIT (experimental)]),
208        ,enable_jit_sealloc=no)
209    ;;
210  *)
211    enable_jit_sealloc=unsupported
212    ;;
213esac
214
215# Handle --disable-pcre2grep-jit (enabled by default)
216AC_ARG_ENABLE(pcre2grep-jit,
217              AS_HELP_STRING([--disable-pcre2grep-jit],
218                             [disable JIT support in pcre2grep]),
219              , enable_pcre2grep_jit=yes)
220
221# Handle --disable-pcre2grep-callout (enabled by default)
222AC_ARG_ENABLE(pcre2grep-callout,
223              AS_HELP_STRING([--disable-pcre2grep-callout],
224                             [disable callout script support in pcre2grep]),
225              , enable_pcre2grep_callout=yes)
226
227# Handle --disable-pcre2grep-callout-fork (enabled by default)
228AC_ARG_ENABLE(pcre2grep-callout-fork,
229              AS_HELP_STRING([--disable-pcre2grep-callout-fork],
230                             [disable callout script fork support in pcre2grep]),
231              , enable_pcre2grep_callout_fork=yes)
232
233# Handle --enable-rebuild-chartables
234AC_ARG_ENABLE(rebuild-chartables,
235              AS_HELP_STRING([--enable-rebuild-chartables],
236                             [rebuild character tables in current locale]),
237              , enable_rebuild_chartables=no)
238
239# Handle --disable-unicode (enabled by default)
240AC_ARG_ENABLE(unicode,
241              AS_HELP_STRING([--disable-unicode],
242                             [disable Unicode support]),
243              , enable_unicode=unset)
244
245# Handle newline options
246ac_pcre2_newline=lf
247AC_ARG_ENABLE(newline-is-cr,
248              AS_HELP_STRING([--enable-newline-is-cr],
249                             [use CR as newline character]),
250              ac_pcre2_newline=cr)
251AC_ARG_ENABLE(newline-is-lf,
252              AS_HELP_STRING([--enable-newline-is-lf],
253                             [use LF as newline character (default)]),
254              ac_pcre2_newline=lf)
255AC_ARG_ENABLE(newline-is-crlf,
256              AS_HELP_STRING([--enable-newline-is-crlf],
257                             [use CRLF as newline sequence]),
258              ac_pcre2_newline=crlf)
259AC_ARG_ENABLE(newline-is-anycrlf,
260              AS_HELP_STRING([--enable-newline-is-anycrlf],
261                             [use CR, LF, or CRLF as newline sequence]),
262              ac_pcre2_newline=anycrlf)
263AC_ARG_ENABLE(newline-is-any,
264              AS_HELP_STRING([--enable-newline-is-any],
265                             [use any valid Unicode newline sequence]),
266              ac_pcre2_newline=any)
267AC_ARG_ENABLE(newline-is-nul,
268              AS_HELP_STRING([--enable-newline-is-nul],
269                             [use NUL (binary zero) as newline character]),
270              ac_pcre2_newline=nul)
271enable_newline="$ac_pcre2_newline"
272
273# Handle --enable-bsr-anycrlf
274AC_ARG_ENABLE(bsr-anycrlf,
275              AS_HELP_STRING([--enable-bsr-anycrlf],
276                             [\R matches only CR, LF, CRLF by default]),
277              , enable_bsr_anycrlf=no)
278
279# Handle --enable-never-backslash-C
280AC_ARG_ENABLE(never-backslash-C,
281              AS_HELP_STRING([--enable-never-backslash-C],
282                             [use of \C causes an error]),
283              , enable_never_backslash_C=no)
284
285# Handle --enable-ebcdic
286AC_ARG_ENABLE(ebcdic,
287              AS_HELP_STRING([--enable-ebcdic],
288                             [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
289              , enable_ebcdic=no)
290
291# Handle --enable-ebcdic-nl25
292AC_ARG_ENABLE(ebcdic-nl25,
293              AS_HELP_STRING([--enable-ebcdic-nl25],
294                             [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
295              , enable_ebcdic_nl25=no)
296
297# Handle --enable-pcre2grep-libz
298AC_ARG_ENABLE(pcre2grep-libz,
299              AS_HELP_STRING([--enable-pcre2grep-libz],
300                             [link pcre2grep with libz to handle .gz files]),
301              , enable_pcre2grep_libz=no)
302
303# Handle --enable-pcre2grep-libbz2
304AC_ARG_ENABLE(pcre2grep-libbz2,
305              AS_HELP_STRING([--enable-pcre2grep-libbz2],
306                             [link pcre2grep with libbz2 to handle .bz2 files]),
307              , enable_pcre2grep_libbz2=no)
308
309# Handle --with-pcre2grep-bufsize=N
310AC_ARG_WITH(pcre2grep-bufsize,
311              AS_HELP_STRING([--with-pcre2grep-bufsize=N],
312                             [pcre2grep initial buffer size (default=20480, minimum=8192)]),
313              , with_pcre2grep_bufsize=20480)
314
315# Handle --with-pcre2grep-max-bufsize=N
316AC_ARG_WITH(pcre2grep-max-bufsize,
317              AS_HELP_STRING([--with-pcre2grep-max-bufsize=N],
318                             [pcre2grep maximum buffer size (default=1048576, minimum=8192)]),
319              , with_pcre2grep_max_bufsize=1048576)
320
321# Handle --enable-pcre2test-libedit
322AC_ARG_ENABLE(pcre2test-libedit,
323              AS_HELP_STRING([--enable-pcre2test-libedit],
324                             [link pcre2test with libedit]),
325              , enable_pcre2test_libedit=no)
326
327# Handle --enable-pcre2test-libreadline
328AC_ARG_ENABLE(pcre2test-libreadline,
329              AS_HELP_STRING([--enable-pcre2test-libreadline],
330                             [link pcre2test with libreadline]),
331              , enable_pcre2test_libreadline=no)
332
333# Handle --with-link-size=N
334AC_ARG_WITH(link-size,
335            AS_HELP_STRING([--with-link-size=N],
336                           [internal link size (2, 3, or 4 allowed; default=2)]),
337            , with_link_size=2)
338
339# Handle --with-max-varlookbehind=N
340AC_ARG_WITH(max-varlookbehind,
341            AS_HELP_STRING([--with-max-varlookbehind=N],
342                           [maximum length of variable lookbehind (default=255)]),
343            , with_max_varlookbehind=255)
344
345# Handle --with-parens-nest-limit=N
346AC_ARG_WITH(parens-nest-limit,
347            AS_HELP_STRING([--with-parens-nest-limit=N],
348                           [nested parentheses limit (default=250)]),
349            , with_parens_nest_limit=250)
350
351# Handle --with-heap-limit
352AC_ARG_WITH(heap-limit,
353            AS_HELP_STRING([--with-heap-limit=N],
354                           [default limit on heap memory (kibibytes, default=20000000)]),
355            , with_heap_limit=20000000)
356
357# Handle --with-match-limit=N
358AC_ARG_WITH(match-limit,
359            AS_HELP_STRING([--with-match-limit=N],
360                           [default limit on internal looping (default=10000000)]),
361            , with_match_limit=10000000)
362
363# Handle --with-match-limit-depth=N
364# Recognize old synonym --with-match-limit-recursion
365#
366# Note: In config.h, the default is to define MATCH_LIMIT_DEPTH symbolically as
367# MATCH_LIMIT, which in turn is defined to be some numeric value (e.g.
368# 10000000). MATCH_LIMIT_DEPTH can otherwise be set to some different numeric
369# value (or even the same numeric value as MATCH_LIMIT, though no longer
370# defined in terms of the latter).
371#
372AC_ARG_WITH(match-limit-depth,
373            AS_HELP_STRING([--with-match-limit-depth=N],
374                           [default limit on match tree depth (default=MATCH_LIMIT)]),
375            , with_match_limit_depth=MATCH_LIMIT)
376
377AC_ARG_WITH(match-limit-recursion,,
378            , with_match_limit_recursion=UNSET)
379
380# Handle --enable-valgrind
381AC_ARG_ENABLE(valgrind,
382              AS_HELP_STRING([--enable-valgrind],
383                             [enable valgrind support]),
384              , enable_valgrind=no)
385
386# Enable code coverage reports using gcov
387AC_ARG_ENABLE(coverage,
388              AS_HELP_STRING([--enable-coverage],
389                             [enable code coverage reports using gcov]),
390              , enable_coverage=no)
391
392# Handle --enable-fuzz-support
393AC_ARG_ENABLE(fuzz_support,
394              AS_HELP_STRING([--enable-fuzz-support],
395                             [enable fuzzer support]),
396              , enable_fuzz_support=no)
397
398# Handle --enable-diff-fuzz-support
399AC_ARG_ENABLE(diff_fuzz_support,
400              AS_HELP_STRING([--enable-diff-fuzz-support],
401                             [enable differential fuzzer support]),
402              , enable_diff_fuzz_support=no)
403
404# Handle --disable-stack-for-recursion
405# This option became obsolete at release 10.30.
406AC_ARG_ENABLE(stack-for-recursion,,
407              , enable_stack_for_recursion=yes)
408
409# Original code
410# AC_ARG_ENABLE(stack-for-recursion,
411#               AS_HELP_STRING([--disable-stack-for-recursion],
412#                              [don't use stack recursion when matching]),
413#               , enable_stack_for_recursion=yes)
414
415# Handle --disable-percent_zt (set as "auto" by default)
416AC_ARG_ENABLE(percent-zt,
417              AS_HELP_STRING([--disable-percent-zt],
418                             [disable the use of z and t formatting modifiers]),
419              , enable_percent_zt=auto)
420
421# Set the default value for pcre2-8
422if test "x$enable_pcre2_8" = "xunset"
423then
424  enable_pcre2_8=yes
425fi
426
427# Set the default value for pcre2-16
428if test "x$enable_pcre2_16" = "xunset"
429then
430  enable_pcre2_16=no
431fi
432
433# Set the default value for pcre2-32
434if test "x$enable_pcre2_32" = "xunset"
435then
436  enable_pcre2_32=no
437fi
438
439# Make sure at least one library is selected
440if test "x$enable_pcre2_8$enable_pcre2_16$enable_pcre2_32" = "xnonono"
441then
442  AC_MSG_ERROR([At least one of the 8, 16 or 32 bit libraries must be enabled])
443fi
444
445# Unicode is enabled by default.
446if test "x$enable_unicode" = "xunset"
447then
448  enable_unicode=yes
449fi
450
451# Convert the newline identifier into the appropriate integer value. These must
452# agree with the PCRE2_NEWLINE_xxx values in pcre2.h.
453
454case "$enable_newline" in
455  cr)      ac_pcre2_newline_value=1 ;;
456  lf)      ac_pcre2_newline_value=2 ;;
457  crlf)    ac_pcre2_newline_value=3 ;;
458  any)     ac_pcre2_newline_value=4 ;;
459  anycrlf) ac_pcre2_newline_value=5 ;;
460  nul)     ac_pcre2_newline_value=6 ;;
461  *)
462  AC_MSG_ERROR([invalid argument "$enable_newline" to --enable-newline option])
463  ;;
464esac
465
466# --enable-ebcdic-nl25 implies --enable-ebcdic
467if test "x$enable_ebcdic_nl25" = "xyes"; then
468  enable_ebcdic=yes
469fi
470
471# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
472# Also check that UTF support is not requested, because PCRE2 cannot handle
473# EBCDIC and UTF in the same build. To do so it would need to use different
474# character constants depending on the mode. Also, EBCDIC cannot be used with
475# 16-bit and 32-bit libraries.
476#
477if test "x$enable_ebcdic" = "xyes"; then
478  enable_rebuild_chartables=yes
479  if test "x$enable_unicode" = "xyes"; then
480    AC_MSG_ERROR([support for EBCDIC and Unicode cannot be enabled at the same time])
481  fi
482  if test "x$enable_pcre2_16" = "xyes" -o "x$enable_pcre2_32" = "xyes"; then
483    AC_MSG_ERROR([EBCDIC support is available only for the 8-bit library])
484  fi
485fi
486
487# Check argument to --with-link-size
488case "$with_link_size" in
489  2|3|4) ;;
490  *)
491  AC_MSG_ERROR([invalid argument "$with_link_size" to --with-link-size option])
492  ;;
493esac
494
495AH_TOP([
496/* PCRE2 is written in Standard C, but there are a few non-standard things it
497can cope with, allowing it to run on SunOS4 and other "close to standard"
498systems.
499
500In environments that support the GNU autotools, config.h.in is converted into
501config.h by the "configure" script. In environments that use CMake,
502config-cmake.in is converted into config.h. If you are going to build PCRE2 "by
503hand" without using "configure" or CMake, you should copy the distributed
504config.h.generic to config.h, and edit the macro definitions to be the way you
505need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
506so that config.h is included at the start of every source.
507
508Alternatively, you can avoid editing by using -D on the compiler command line
509to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
510but if you do, default values will be taken from config.h for non-boolean
511macros that are not defined on the command line.
512
513Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
514defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
515such macros are listed as a commented #undef in config.h.generic. Macros such
516as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
517surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
518
519PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
520HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
521sure both macros are undefined; an emulation function will then be used. */])
522
523# Checks for header files.
524AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h)
525AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
526AC_CHECK_HEADERS([sys/wait.h], [HAVE_SYS_WAIT_H=1])
527
528# Conditional compilation
529AM_CONDITIONAL(WITH_PCRE2_8, test "x$enable_pcre2_8" = "xyes")
530AM_CONDITIONAL(WITH_PCRE2_16, test "x$enable_pcre2_16" = "xyes")
531AM_CONDITIONAL(WITH_PCRE2_32, test "x$enable_pcre2_32" = "xyes")
532AM_CONDITIONAL(WITH_DEBUG, test "x$enable_debug" = "xyes")
533AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
534AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
535AM_CONDITIONAL(WITH_UNICODE, test "x$enable_unicode" = "xyes")
536AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
537AM_CONDITIONAL(WITH_FUZZ_SUPPORT, test "x$enable_fuzz_support" = "xyes")
538AM_CONDITIONAL(WITH_DIFF_FUZZ_SUPPORT, test "x$enable_diff_fuzz_support" = "xyes")
539
540if test "$enable_fuzz_support" = "yes" -a "$enable_pcre2_8" = "no"; then
541  echo "** ERROR: Fuzzer support requires the 8-bit library"
542  exit 1
543fi
544
545if test "$enable_diff_fuzz_support" = "yes"; then
546  if test "$enable_fuzz_support" = "no"; then
547    echo "** ERROR: Differential fuzzing support requires fuzzing support"
548    exit 1
549  fi
550  if test "$enable_jit" = "no"; then
551    echo "** ERROR: Differential fuzzing support requires Just-in-Time compilation support"
552    exit 1
553  fi
554  AC_DEFINE([SUPPORT_DIFF_FUZZ], [], [
555    Define to any value to enable differential fuzzing support.])
556fi
557
558# Checks for typedefs, structures, and compiler characteristics.
559
560AC_C_CONST
561AC_TYPE_SIZE_T
562
563# Checks for library functions.
564
565AC_CHECK_FUNCS(bcopy memfd_create memmove mkostemp secure_getenv strerror)
566AC_MSG_CHECKING([for realpath])
567AC_LINK_IFELSE([AC_LANG_PROGRAM([[
568#include <stdlib.h>
569#include <limits.h>
570]],[[
571char buffer[PATH_MAX];
572realpath(".", buffer);
573]])],
574[AC_MSG_RESULT([yes])
575 AC_DEFINE([HAVE_REALPATH], 1,
576  [Define to 1 if you have the `realpath' function.])
577],
578AC_MSG_RESULT([no]))
579
580# Check for the availability of libz (aka zlib)
581
582AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
583AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
584
585# Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
586# as for libz. However, this had the following problem, diagnosed and fixed by
587# a user:
588#
589#   - libbz2 uses the Pascal calling convention (WINAPI) for the functions
590#     under Win32.
591#   - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
592#     therefore missing the function definition.
593#   - The compiler thus generates a "C" signature for the test function.
594#   - The linker fails to find the "C" function.
595#   - PCRE2 fails to configure if asked to do so against libbz2.
596#
597# Solution:
598#
599#   - Replace the AC_CHECK_LIB test with a custom test.
600
601AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
602# Original test
603# AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
604#
605# Custom test follows
606
607AC_MSG_CHECKING([for libbz2])
608OLD_LIBS="$LIBS"
609LIBS="$LIBS -lbz2"
610AC_LINK_IFELSE([AC_LANG_PROGRAM([[
611#ifdef HAVE_BZLIB_H
612#include <bzlib.h>
613#endif]],
614[[return (int)BZ2_bzopen("conftest", "rb");]])],
615[AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
616AC_MSG_RESULT([no]))
617LIBS="$OLD_LIBS"
618
619# Check for the availabiity of libreadline
620
621if test "$enable_pcre2test_libreadline" = "yes"; then
622 AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
623 AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
624 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
625   [unset ac_cv_lib_readline_readline;
626    AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
627     [unset ac_cv_lib_readline_readline;
628      AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
629       [unset ac_cv_lib_readline_readline;
630        AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
631         [unset ac_cv_lib_readline_readline;
632	  AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
633           [unset ac_cv_lib_readline_readline;
634	    AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
635             [LIBREADLINE=""],
636             [-ltermcap])],
637           [-lncursesw])],
638         [-lncurses])],
639       [-lcurses])],
640     [-ltinfo])])
641 AC_SUBST(LIBREADLINE)
642 if test -n "$LIBREADLINE"; then
643   if test "$LIBREADLINE" != "-lreadline"; then
644     echo "-lreadline needs $LIBREADLINE"
645     LIBREADLINE="-lreadline $LIBREADLINE"
646   fi
647 fi
648fi
649
650# Check for the availability of libedit. Different distributions put its
651# headers in different places. Try to cover the most common ones.
652
653if test "$enable_pcre2test_libedit" = "yes"; then
654  AC_CHECK_HEADERS([editline/readline.h edit/readline/readline.h readline.h], [
655    HAVE_LIBEDIT_HEADER=1
656    break
657  ])
658  AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
659fi
660
661PCRE2_STATIC_CFLAG=""
662if test "x$enable_shared" = "xno" ; then
663  AC_DEFINE([PCRE2_STATIC], [1], [
664    Define to any value if linking statically (TODO: make nice with Libtool)])
665  PCRE2_STATIC_CFLAG="-DPCRE2_STATIC"
666fi
667AC_SUBST(PCRE2_STATIC_CFLAG)
668
669PCRE2POSIX_CFLAG=""
670if test "x$enable_shared" = "xyes" ; then
671  PCRE2POSIX_CFLAG="-DPCRE2POSIX_SHARED"
672fi
673AC_SUBST(PCRE2POSIX_CFLAG)
674
675# Here is where PCRE2-specific defines are handled
676
677if test "$enable_pcre2_8" = "yes"; then
678  AC_DEFINE([SUPPORT_PCRE2_8], [], [
679    Define to any value to enable the 8 bit PCRE2 library.])
680fi
681
682if test "$enable_pcre2_16" = "yes"; then
683  AC_DEFINE([SUPPORT_PCRE2_16], [], [
684    Define to any value to enable the 16 bit PCRE2 library.])
685fi
686
687if test "$enable_pcre2_32" = "yes"; then
688  AC_DEFINE([SUPPORT_PCRE2_32], [], [
689    Define to any value to enable the 32 bit PCRE2 library.])
690fi
691
692if test "$enable_debug" = "yes"; then
693  AC_DEFINE([PCRE2_DEBUG], [], [
694    Define to any value to include debugging code.])
695fi
696
697if test "$enable_percent_zt" = "no"; then
698  AC_DEFINE([DISABLE_PERCENT_ZT], [], [
699    Define to any value to disable the use of the z and t modifiers in
700    formatting settings such as %zu or %td (this is rarely needed).])
701else
702  enable_percent_zt=auto
703fi
704
705# Unless running under Windows, JIT support requires pthreads.
706
707if test "$enable_jit" = "yes"; then
708  if test "$HAVE_WINDOWS_H" != "1"; then
709    AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
710    CC="$PTHREAD_CC"
711    CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
712    LIBS="$PTHREAD_LIBS $LIBS"
713  fi
714  AC_DEFINE([SUPPORT_JIT], [], [
715    Define to any value to enable support for Just-In-Time compiling.])
716else
717  enable_pcre2grep_jit="no"
718fi
719
720if test "$enable_jit_sealloc" = "yes"; then
721  AC_DEFINE([SLJIT_PROT_EXECUTABLE_ALLOCATOR], [1], [
722    Define to any non-zero number to enable support for SELinux
723    compatible executable memory allocator in JIT. Note that this
724    will have no effect unless SUPPORT_JIT is also defined.])
725fi
726
727if test "$enable_pcre2grep_jit" = "yes"; then
728  AC_DEFINE([SUPPORT_PCRE2GREP_JIT], [], [
729    Define to any value to enable JIT support in pcre2grep. Note that this will
730    have no effect unless SUPPORT_JIT is also defined.])
731fi
732
733if test "$enable_pcre2grep_callout" = "yes"; then
734  if test "$enable_pcre2grep_callout_fork" = "yes"; then
735    if test "$HAVE_WINDOWS_H" != "1"; then
736      if test "$HAVE_SYS_WAIT_H" != "1"; then
737        AC_MSG_ERROR([Callout script support needs sys/wait.h.])
738      fi
739    fi
740    AC_DEFINE([SUPPORT_PCRE2GREP_CALLOUT_FORK], [], [
741      Define to any value to enable fork support in pcre2grep callout scripts.
742      This will have no effect unless SUPPORT_PCRE2GREP_CALLOUT is also
743      defined.])
744  fi
745  AC_DEFINE([SUPPORT_PCRE2GREP_CALLOUT], [], [
746    Define to any value to enable callout script support in pcre2grep.])
747else
748  enable_pcre2grep_callout_fork="no"
749fi
750
751if test "$enable_unicode" = "yes"; then
752  AC_DEFINE([SUPPORT_UNICODE], [], [
753    Define to any value to enable support for Unicode and UTF encoding.
754    This will work even in an EBCDIC environment, but it is incompatible
755    with the EBCDIC macro. That is, PCRE2 can support *either* EBCDIC
756    code *or* ASCII/Unicode, but not both at once.])
757fi
758
759if test "$enable_pcre2grep_libz" = "yes"; then
760  AC_DEFINE([SUPPORT_LIBZ], [], [
761    Define to any value to allow pcre2grep to be linked with libz, so that it is
762    able to handle .gz files.])
763fi
764
765if test "$enable_pcre2grep_libbz2" = "yes"; then
766  AC_DEFINE([SUPPORT_LIBBZ2], [], [
767    Define to any value to allow pcre2grep to be linked with libbz2, so that it
768    is able to handle .bz2 files.])
769fi
770
771if test $with_pcre2grep_bufsize -lt 8192 ; then
772  AC_MSG_WARN([$with_pcre2grep_bufsize is too small for --with-pcre2grep-bufsize; using 8192])
773  with_pcre2grep_bufsize="8192"
774else
775  if test $? -gt 1 ; then
776  AC_MSG_ERROR([Bad value for --with-pcre2grep-bufsize])
777  fi
778fi
779
780if test $with_pcre2grep_max_bufsize -lt $with_pcre2grep_bufsize ; then
781  with_pcre2grep_max_bufsize="$with_pcre2grep_bufsize"
782else
783  if test $? -gt 1 ; then
784  AC_MSG_ERROR([Bad value for --with-pcre2grep-max-bufsize])
785  fi
786fi
787
788AC_DEFINE_UNQUOTED([PCRE2GREP_BUFSIZE], [$with_pcre2grep_bufsize], [
789  The value of PCRE2GREP_BUFSIZE is the starting size of the buffer used by
790  pcre2grep to hold parts of the file it is searching. The buffer will be
791  expanded up to PCRE2GREP_MAX_BUFSIZE if necessary, for files containing very
792  long lines. The actual amount of memory used by pcre2grep is three times this
793  number, because it allows for the buffering of "before" and "after" lines.])
794
795AC_DEFINE_UNQUOTED([PCRE2GREP_MAX_BUFSIZE], [$with_pcre2grep_max_bufsize], [
796  The value of PCRE2GREP_MAX_BUFSIZE specifies the maximum size of the buffer
797  used by pcre2grep to hold parts of the file it is searching. The actual
798  amount of memory used by pcre2grep is three times this number, because it
799  allows for the buffering of "before" and "after" lines.])
800
801if test "$enable_pcre2test_libedit" = "yes"; then
802  AC_DEFINE([SUPPORT_LIBEDIT], [], [
803    Define to any value to allow pcre2test to be linked with libedit.])
804  LIBREADLINE="$LIBEDIT"
805elif test "$enable_pcre2test_libreadline" = "yes"; then
806  AC_DEFINE([SUPPORT_LIBREADLINE], [], [
807    Define to any value to allow pcre2test to be linked with libreadline.])
808fi
809
810AC_DEFINE_UNQUOTED([NEWLINE_DEFAULT], [$ac_pcre2_newline_value], [
811  The value of NEWLINE_DEFAULT determines the default newline character
812  sequence. PCRE2 client programs can override this by selecting other values
813  at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY),
814  5 (ANYCRLF), and 6 (NUL).])
815
816if test "$enable_bsr_anycrlf" = "yes"; then
817  AC_DEFINE([BSR_ANYCRLF], [], [
818    By default, the \R escape sequence matches any Unicode line ending
819    character or sequence of characters. If BSR_ANYCRLF is defined (to any
820    value), this is changed so that backslash-R matches only CR, LF, or CRLF.
821    The build-time default can be overridden by the user of PCRE2 at runtime.])
822fi
823
824if test "$enable_never_backslash_C" = "yes"; then
825  AC_DEFINE([NEVER_BACKSLASH_C], [], [
826    Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns.])
827fi
828
829AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
830  The value of LINK_SIZE determines the number of bytes used to store
831  links as offsets within the compiled regex. The default is 2, which
832  allows for compiled patterns up to 65535 code units long. This covers the
833  vast majority of cases. However, PCRE2 can also be compiled to use 3 or 4
834  bytes instead. This allows for longer patterns in extreme cases.])
835
836AC_DEFINE_UNQUOTED([MAX_VARLOOKBEHIND], [$with_max_varlookbehind], [
837  The value of MAX_VARLOOKBEHIND specifies the default maximum length, in
838  characters, for a variable-length lookbehind assertion.])
839
840AC_DEFINE_UNQUOTED([PARENS_NEST_LIMIT], [$with_parens_nest_limit], [
841  The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
842  parentheses (of any kind) in a pattern. This limits the amount of system
843  stack that is used while compiling a pattern.])
844
845AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
846  The value of MATCH_LIMIT determines the default number of times the
847  pcre2_match() function can record a backtrack position during a single
848  matching attempt. The value is also used to limit a loop counter in
849  pcre2_dfa_match(). There is a runtime interface for setting a different
850  limit. The limit exists in order to catch runaway regular expressions that
851  take forever to determine that they do not match. The default is set very
852  large so that it does not accidentally catch legitimate cases.])
853
854# --with-match-limit-recursion is an obsolete synonym for --with-match-limit-depth
855
856if test "$with_match_limit_recursion" != "UNSET"; then
857cat <<EOF
858
859WARNING: --with-match-limit-recursion is an obsolete option. Please use
860  --with-match-limit-depth in future. If both are set, --with-match-limit-depth
861  will be used. See also --with-heap-limit.
862
863EOF
864if test "$with_match_limit_depth" = "MATCH_LIMIT"; then
865  with_match_limit_depth=$with_match_limit_recursion
866fi
867fi
868
869AC_DEFINE_UNQUOTED([MATCH_LIMIT_DEPTH], [$with_match_limit_depth], [
870  The above limit applies to all backtracks, whether or not they are nested. In
871  some environments it is desirable to limit the nesting of backtracking (that
872  is, the depth of tree that is searched) more strictly, in order to restrict
873  the maximum amount of heap memory that is used. The value of
874  MATCH_LIMIT_DEPTH provides this facility. To have any useful effect, it must
875  be less than the value of MATCH_LIMIT. The default is to use the same value
876  as MATCH_LIMIT. There is a runtime method for setting a different limit. In
877  the case of pcre2_dfa_match(), this limit controls the depth of the internal
878  nested function calls that are used for pattern recursions, lookarounds, and
879  atomic groups.])
880
881AC_DEFINE_UNQUOTED([HEAP_LIMIT], [$with_heap_limit], [
882  This limits the amount of memory that may be used while matching
883  a pattern. It applies to both pcre2_match() and pcre2_dfa_match(). It does
884  not apply to JIT matching. The value is in kibibytes (units of 1024 bytes).])
885
886AC_DEFINE([MAX_NAME_SIZE], [128], [
887  This limit is parameterized just in case anybody ever wants to
888  change it. Care must be taken if it is increased, because it guards
889  against integer overflow caused by enormously large patterns.])
890
891AC_DEFINE([MAX_NAME_COUNT], [10000], [
892  This limit is parameterized just in case anybody ever wants to
893  change it. Care must be taken if it is increased, because it guards
894  against integer overflow caused by enormously large patterns.])
895
896AH_VERBATIM([PCRE2_EXP_DEFN], [
897/* If you are compiling for a system other than a Unix-like system or
898   Win32, and it needs some magic to be inserted before the definition
899   of a function that is exported by the library, define this macro to
900   contain the relevant magic. If you do not define this macro, a suitable
901   __declspec value is used for Windows systems; in other environments
902   a compiler relevant "extern" is used with any "visibility" related
903   attributes from PCRE2_EXPORT included.
904   This macro apears at the start of every exported function that is part
905   of the external API. It does not appear on functions that are "external"
906   in the C sense, but which are internal to the library. */
907#undef PCRE2_EXP_DEFN])
908
909if test "$enable_ebcdic" = "yes"; then
910  AC_DEFINE_UNQUOTED([EBCDIC], [], [
911    If you are compiling for a system that uses EBCDIC instead of ASCII
912    character codes, define this macro to any value. When EBCDIC is set, PCRE2
913    assumes that all input strings are in EBCDIC. If you do not define this
914    macro, PCRE2 will assume input strings are ASCII or UTF-8/16/32 Unicode. It
915    is not possible to build a version of PCRE2 that supports both EBCDIC and
916    UTF-8/16/32.])
917fi
918
919if test "$enable_ebcdic_nl25" = "yes"; then
920  AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
921    In an EBCDIC environment, define this macro to any value to arrange for
922    the NL character to be 0x25 instead of the default 0x15. NL plays the role
923    that LF does in an ASCII/Unicode environment.])
924fi
925
926if test "$enable_valgrind" = "yes"; then
927  AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
928     Define to any value for valgrind support to find invalid memory reads.])
929fi
930
931# Platform specific issues
932NO_UNDEFINED=
933EXPORT_ALL_SYMBOLS=
934case $host_os in
935  cygwin* | mingw* )
936    if test X"$enable_shared" = Xyes; then
937      NO_UNDEFINED="-no-undefined"
938      EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
939    fi
940    ;;
941esac
942
943# The extra LDFLAGS for each particular library. The libpcre2*_version values
944# are m4 variables, assigned above.
945
946EXTRA_LIBPCRE2_8_LDFLAGS="$EXTRA_LIBPCRE2_8_LDFLAGS \
947  $NO_UNDEFINED -version-info libpcre2_8_version"
948
949EXTRA_LIBPCRE2_16_LDFLAGS="$EXTRA_LIBPCRE2_16_LDFLAGS \
950  $NO_UNDEFINED -version-info libpcre2_16_version"
951
952EXTRA_LIBPCRE2_32_LDFLAGS="$EXTRA_LIBPCRE2_32_LDFLAGS \
953  $NO_UNDEFINED -version-info libpcre2_32_version"
954
955EXTRA_LIBPCRE2_POSIX_LDFLAGS="$EXTRA_LIBPCRE2_POSIX_LDFLAGS \
956  $NO_UNDEFINED -version-info libpcre2_posix_version"
957
958AC_SUBST(EXTRA_LIBPCRE2_8_LDFLAGS)
959AC_SUBST(EXTRA_LIBPCRE2_16_LDFLAGS)
960AC_SUBST(EXTRA_LIBPCRE2_32_LDFLAGS)
961AC_SUBST(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
962
963# When we run 'make distcheck', use these arguments. Turning off compiler
964# optimization makes it run faster.
965DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre2-16 --enable-pcre2-32 --enable-jit"
966AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
967
968# Check that, if --enable-pcre2grep-libz or --enable-pcre2grep-libbz2 is
969# specified, the relevant library is available.
970
971if test "$enable_pcre2grep_libz" = "yes"; then
972  if test "$HAVE_ZLIB_H" != "1"; then
973    echo "** Cannot --enable-pcre2grep-libz because zlib.h was not found"
974    exit 1
975  fi
976  if test "$HAVE_LIBZ" != "1"; then
977    echo "** Cannot --enable-pcre2grep-libz because libz was not found"
978    exit 1
979  fi
980  LIBZ="-lz"
981fi
982AC_SUBST(LIBZ)
983
984if test "$enable_pcre2grep_libbz2" = "yes"; then
985  if test "$HAVE_BZLIB_H" != "1"; then
986    echo "** Cannot --enable-pcre2grep-libbz2 because bzlib.h was not found"
987    exit 1
988  fi
989  if test "$HAVE_LIBBZ2" != "1"; then
990    echo "** Cannot --enable-pcre2grep-libbz2 because libbz2 was not found"
991    exit 1
992  fi
993  LIBBZ2="-lbz2"
994fi
995AC_SUBST(LIBBZ2)
996
997# Similarly for --enable-pcre2test-readline
998
999if test "$enable_pcre2test_libedit" = "yes"; then
1000  if test "$enable_pcre2test_libreadline" = "yes"; then
1001    echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline"
1002    exit 1
1003  fi
1004  if test -z "$HAVE_LIBEDIT_HEADER"; then
1005    echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h,"
1006    echo "** edit/readline/readline.h nor a compatible header was found."
1007    exit 1
1008  fi
1009  if test -z "$LIBEDIT"; then
1010    echo "** Cannot --enable-pcre2test-libedit because libedit library was not found."
1011    exit 1
1012  fi
1013fi
1014
1015if test "$enable_pcre2test_libreadline" = "yes"; then
1016  if test "$HAVE_READLINE_H" != "1"; then
1017    echo "** Cannot --enable-pcre2test-readline because readline/readline.h was not found."
1018    exit 1
1019  fi
1020  if test "$HAVE_HISTORY_H" != "1"; then
1021    echo "** Cannot --enable-pcre2test-readline because readline/history.h was not found."
1022    exit 1
1023  fi
1024  if test -z "$LIBREADLINE"; then
1025    echo "** Cannot --enable-pcre2test-readline because readline library was not found."
1026    exit 1
1027  fi
1028fi
1029
1030# Handle valgrind support
1031
1032if test "$enable_valgrind" = "yes"; then
1033  m4_ifdef([PKG_CHECK_MODULES],
1034           [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
1035           [AC_MSG_ERROR([pkg-config not supported])])
1036fi
1037
1038# Handle code coverage reporting support
1039if test "$enable_coverage" = "yes"; then
1040  if test "x$GCC" != "xyes"; then
1041    AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
1042  fi
1043
1044  # ccache is incompatible with gcov
1045  AC_PATH_PROG([SHTOOL],[shtool],[false])
1046  case `$SHTOOL path $CC` in
1047    *ccache*) cc_ccache=yes;;
1048    *) cc_ccache=no;;
1049  esac
1050
1051  if test "$cc_ccache" = "yes"; then
1052    if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
1053      AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
1054    fi
1055  fi
1056
1057  AC_ARG_VAR([LCOV],[the ltp lcov program])
1058  AC_PATH_PROG([LCOV],[lcov],[false])
1059  if test "x$LCOV" = "xfalse"; then
1060    AC_MSG_ERROR([lcov not found])
1061  fi
1062
1063  AC_ARG_VAR([GENHTML],[the ltp genhtml program])
1064  AC_PATH_PROG([GENHTML],[genhtml],[false])
1065  if test "x$GENHTML" = "xfalse"; then
1066    AC_MSG_ERROR([genhtml not found])
1067  fi
1068
1069  # Set flags needed for gcov
1070  GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1071  GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1072  GCOV_LIBS="-lgcov"
1073  AC_SUBST([GCOV_CFLAGS])
1074  AC_SUBST([GCOV_CXXFLAGS])
1075  AC_SUBST([GCOV_LIBS])
1076fi # enable_coverage
1077
1078AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
1079
1080AC_MSG_CHECKING([whether Intel CET is enabled])
1081AC_LANG_PUSH([C])
1082AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
1083                   [[#ifndef __CET__
1084# error CET is not enabled
1085#endif]])],
1086                   [pcre2_cc_cv_intel_cet_enabled=yes],
1087                   [pcre2_cc_cv_intel_cet_enabled=no])
1088AC_MSG_RESULT([$pcre2_cc_cv_intel_cet_enabled])
1089if test "$pcre2_cc_cv_intel_cet_enabled" = yes; then
1090  CET_CFLAGS="-mshstk"
1091  AC_SUBST([CET_CFLAGS])
1092fi
1093AC_LANG_POP([C])
1094
1095# LIB_POSTFIX is used by CMakeLists.txt for Windows debug builds.
1096# Pass empty LIB_POSTFIX to *.pc files and pcre2-config here.
1097AC_SUBST(LIB_POSTFIX)
1098
1099# Produce these files, in addition to config.h.
1100
1101AC_CONFIG_FILES(
1102	Makefile
1103	libpcre2-8.pc
1104	libpcre2-16.pc
1105	libpcre2-32.pc
1106	libpcre2-posix.pc
1107	pcre2-config
1108	src/pcre2.h
1109)
1110
1111# Make the generated script files executable.
1112AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
1113
1114# Make sure that pcre2_chartables.c is removed in case the method for
1115# creating it was changed by reconfiguration.
1116AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])
1117
1118AC_OUTPUT
1119
1120# --disable-stack-for-recursion is obsolete and has no effect.
1121
1122if test "$enable_stack_for_recursion" = "no"; then
1123cat <<EOF
1124
1125WARNING: --disable-stack-for-recursion is obsolete and has no effect.
1126EOF
1127fi
1128
1129# Print out a nice little message after configure is run displaying the
1130# chosen options.
1131
1132ebcdic_nl_code=n/a
1133if test "$enable_ebcdic_nl25" = "yes"; then
1134  ebcdic_nl_code=0x25
1135elif test "$enable_ebcdic" = "yes"; then
1136  ebcdic_nl_code=0x15
1137fi
1138
1139cat <<EOF
1140
1141$PACKAGE-$VERSION configuration summary:
1142
1143    Install prefix ..................... : ${prefix}
1144    C preprocessor ..................... : ${CPP}
1145    C compiler ......................... : ${CC}
1146    Linker ............................. : ${LD}
1147    C preprocessor flags ............... : ${CPPFLAGS}
1148    C compiler flags ................... : ${CFLAGS} ${VISIBILITY_CFLAGS}
1149    Linker flags ....................... : ${LDFLAGS}
1150    Extra libraries .................... : ${LIBS}
1151
1152    Build 8-bit pcre2 library .......... : ${enable_pcre2_8}
1153    Build 16-bit pcre2 library ......... : ${enable_pcre2_16}
1154    Build 32-bit pcre2 library ......... : ${enable_pcre2_32}
1155    Include debugging code ............. : ${enable_debug}
1156    Enable JIT compiling support ....... : ${enable_jit}
1157    Use SELinux allocator in JIT ....... : ${enable_jit_sealloc}
1158    Enable Unicode support ............. : ${enable_unicode}
1159    Newline char/sequence .............. : ${enable_newline}
1160    \R matches only ANYCRLF ............ : ${enable_bsr_anycrlf}
1161    \C is disabled ..................... : ${enable_never_backslash_C}
1162    EBCDIC coding ...................... : ${enable_ebcdic}
1163    EBCDIC code for NL ................. : ${ebcdic_nl_code}
1164    Rebuild char tables ................ : ${enable_rebuild_chartables}
1165    Internal link size ................. : ${with_link_size}
1166    Maximum variable lookbehind ........ : ${with_max_varlookbehind}
1167    Nested parentheses limit ........... : ${with_parens_nest_limit}
1168    Heap limit ......................... : ${with_heap_limit} kibibytes
1169    Match limit ........................ : ${with_match_limit}
1170    Match depth limit .................. : ${with_match_limit_depth}
1171    Build shared libs .................. : ${enable_shared}
1172    Build static libs .................. : ${enable_static}
1173    Use JIT in pcre2grep ............... : ${enable_pcre2grep_jit}
1174    Enable callouts in pcre2grep ....... : ${enable_pcre2grep_callout}
1175    Enable fork in pcre2grep callouts .. : ${enable_pcre2grep_callout_fork}
1176    Initial buffer size for pcre2grep .. : ${with_pcre2grep_bufsize}
1177    Maximum buffer size for pcre2grep .. : ${with_pcre2grep_max_bufsize}
1178    Link pcre2grep with libz ........... : ${enable_pcre2grep_libz}
1179    Link pcre2grep with libbz2 ......... : ${enable_pcre2grep_libbz2}
1180    Link pcre2test with libedit ........ : ${enable_pcre2test_libedit}
1181    Link pcre2test with libreadline .... : ${enable_pcre2test_libreadline}
1182    Valgrind support ................... : ${enable_valgrind}
1183    Code coverage ...................... : ${enable_coverage}
1184    Fuzzer support ..................... : ${enable_fuzz_support}
1185    Differential fuzzer support ........ : ${enable_diff_fuzz_support}
1186    Use %zu and %td .................... : ${enable_percent_zt}
1187
1188EOF
1189
1190dnl end configure.ac
1191