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 PCRE user writes code that uses PCRE_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 PCRE_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(pcre_major, [8])
12 m4_define(pcre_minor, [44])
13 m4_define(pcre_prerelease, [])
14 m4_define(pcre_date, [2020-02-12])
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(libpcre_version, [3:12:2])
21 m4_define(libpcre16_version, [2:12:2])
22 m4_define(libpcre32_version, [0:12:0])
23 m4_define(libpcreposix_version, [1:0:0])
24 m4_define(libpcrecpp_version, [0:2:0])
27 AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre)
28 AC_CONFIG_SRCDIR([pcre.h.in])
29 AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
30 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
31 AC_CONFIG_HEADERS(config.h)
33 # This is a new thing required to stop a warning from automake 1.12
34 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
36 # This was added at the suggestion of libtoolize (03-Jan-10)
37 AC_CONFIG_MACRO_DIR([m4])
39 # The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just
40 # "-g" for any other compiler. There doesn't seem to be a standard way of
41 # getting rid of the -g (which I don't think is needed for a production
42 # library). This fudge seems to achieve the necessary. First, we remember the
43 # externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and
44 # AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not
45 # set, they will be set to Autoconf's defaults. Afterwards, if the original
46 # values were not set, remove the -g from the Autoconf defaults.
49 remember_set_CFLAGS="$CFLAGS"
50 remember_set_CXXFLAGS="$CXXFLAGS"
56 if test "x$remember_set_CFLAGS" = "x"
58 if test "$CFLAGS" = "-g -O2"
61 elif test "$CFLAGS" = "-g"
67 if test "x$remember_set_CXXFLAGS" = "x"
69 if test "$CXXFLAGS" = "-g -O2"
72 elif test "$CXXFLAGS" = "-g"
78 # AC_PROG_CXX will return "g++" even if no c++ compiler is installed.
79 # Check for that case, and just disable c++ code if g++ doesn't run.
81 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],, CXX=""; CXXCP=""; CXXFLAGS="")
84 # Check for a 64-bit integer type
92 # Check for GCC visibility feature
98 PCRE_MAJOR="pcre_major"
99 PCRE_MINOR="pcre_minor"
100 PCRE_PRERELEASE="pcre_prerelease"
101 PCRE_DATE="pcre_date"
103 if test "$PCRE_MINOR" = "08" -o "$PCRE_MINOR" = "09"
106 echo "*** Minor version number $PCRE_MINOR must not be used. ***"
107 echo "*** Use only 01 to 07 or 10 onwards, to avoid octal issues. ***"
114 AC_SUBST(PCRE_PRERELEASE)
117 # Set a more sensible default value for $(htmldir).
118 if test "x$htmldir" = 'x${docdir}'
120 htmldir='${docdir}/html'
123 # Handle --disable-pcre8 (enabled by default)
125 AS_HELP_STRING([--disable-pcre8],
126 [disable 8 bit character support]),
127 , enable_pcre8=unset)
128 AC_SUBST(enable_pcre8)
130 # Handle --enable-pcre16 (disabled by default)
131 AC_ARG_ENABLE(pcre16,
132 AS_HELP_STRING([--enable-pcre16],
133 [enable 16 bit character support]),
134 , enable_pcre16=unset)
135 AC_SUBST(enable_pcre16)
137 # Handle --enable-pcre32 (disabled by default)
138 AC_ARG_ENABLE(pcre32,
139 AS_HELP_STRING([--enable-pcre32],
140 [enable 32 bit character support]),
141 , enable_pcre32=unset)
142 AC_SUBST(enable_pcre32)
144 # Handle --disable-cpp. The substitution of enable_cpp is needed for use in
147 AS_HELP_STRING([--disable-cpp],
148 [disable C++ support]),
152 # Handle --enable-jit (disabled by default)
154 AS_HELP_STRING([--enable-jit],
155 [enable Just-In-Time compiling support]),
158 # This code enables JIT if the hardware supports it.
160 if test "$enable_jit" = "auto"; then
162 SAVE_CPPFLAGS=$CPPFLAGS
164 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
165 #define SLJIT_CONFIG_AUTO 1
166 #include "sljit/sljitConfigInternal.h"
167 #if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
169 #endif]])], enable_jit=yes, enable_jit=no)
170 CPPFLAGS=$SAVE_CPPFLAGS
173 # Handle --disable-pcregrep-jit (enabled by default)
174 AC_ARG_ENABLE(pcregrep-jit,
175 AS_HELP_STRING([--disable-pcregrep-jit],
176 [disable JIT support in pcregrep]),
177 , enable_pcregrep_jit=yes)
179 # Handle --enable-rebuild-chartables
180 AC_ARG_ENABLE(rebuild-chartables,
181 AS_HELP_STRING([--enable-rebuild-chartables],
182 [rebuild character tables in current locale]),
183 , enable_rebuild_chartables=no)
185 # Handle --enable-utf8 (disabled by default)
187 AS_HELP_STRING([--enable-utf8],
188 [another name for --enable-utf. Kept only for compatibility reasons]),
191 # Handle --enable-utf (disabled by default)
193 AS_HELP_STRING([--enable-utf],
194 [enable UTF-8/16/32 support (incompatible with --enable-ebcdic)]),
197 # Handle --enable-unicode-properties
198 AC_ARG_ENABLE(unicode-properties,
199 AS_HELP_STRING([--enable-unicode-properties],
200 [enable Unicode properties support (implies --enable-utf)]),
201 , enable_unicode_properties=no)
203 # Handle newline options
205 AC_ARG_ENABLE(newline-is-cr,
206 AS_HELP_STRING([--enable-newline-is-cr],
207 [use CR as newline character]),
209 AC_ARG_ENABLE(newline-is-lf,
210 AS_HELP_STRING([--enable-newline-is-lf],
211 [use LF as newline character (default)]),
213 AC_ARG_ENABLE(newline-is-crlf,
214 AS_HELP_STRING([--enable-newline-is-crlf],
215 [use CRLF as newline sequence]),
216 ac_pcre_newline=crlf)
217 AC_ARG_ENABLE(newline-is-anycrlf,
218 AS_HELP_STRING([--enable-newline-is-anycrlf],
219 [use CR, LF, or CRLF as newline sequence]),
220 ac_pcre_newline=anycrlf)
221 AC_ARG_ENABLE(newline-is-any,
222 AS_HELP_STRING([--enable-newline-is-any],
223 [use any valid Unicode newline sequence]),
225 enable_newline="$ac_pcre_newline"
227 # Handle --enable-bsr-anycrlf
228 AC_ARG_ENABLE(bsr-anycrlf,
229 AS_HELP_STRING([--enable-bsr-anycrlf],
230 [\R matches only CR, LF, CRLF by default]),
231 , enable_bsr_anycrlf=no)
233 # Handle --enable-ebcdic
234 AC_ARG_ENABLE(ebcdic,
235 AS_HELP_STRING([--enable-ebcdic],
236 [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
239 # Handle --enable-ebcdic-nl25
240 AC_ARG_ENABLE(ebcdic-nl25,
241 AS_HELP_STRING([--enable-ebcdic-nl25],
242 [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
243 , enable_ebcdic_nl25=no)
245 # Handle --disable-stack-for-recursion
246 AC_ARG_ENABLE(stack-for-recursion,
247 AS_HELP_STRING([--disable-stack-for-recursion],
248 [don't use stack recursion when matching]),
249 , enable_stack_for_recursion=yes)
251 # Handle --enable-pcregrep-libz
252 AC_ARG_ENABLE(pcregrep-libz,
253 AS_HELP_STRING([--enable-pcregrep-libz],
254 [link pcregrep with libz to handle .gz files]),
255 , enable_pcregrep_libz=no)
257 # Handle --enable-pcregrep-libbz2
258 AC_ARG_ENABLE(pcregrep-libbz2,
259 AS_HELP_STRING([--enable-pcregrep-libbz2],
260 [link pcregrep with libbz2 to handle .bz2 files]),
261 , enable_pcregrep_libbz2=no)
263 # Handle --with-pcregrep-bufsize=N
264 AC_ARG_WITH(pcregrep-bufsize,
265 AS_HELP_STRING([--with-pcregrep-bufsize=N],
266 [pcregrep buffer size (default=20480, minimum=8192)]),
267 , with_pcregrep_bufsize=20480)
269 # Handle --enable-pcretest-libedit
270 AC_ARG_ENABLE(pcretest-libedit,
271 AS_HELP_STRING([--enable-pcretest-libedit],
272 [link pcretest with libedit]),
273 , enable_pcretest_libedit=no)
275 # Handle --enable-pcretest-libreadline
276 AC_ARG_ENABLE(pcretest-libreadline,
277 AS_HELP_STRING([--enable-pcretest-libreadline],
278 [link pcretest with libreadline]),
279 , enable_pcretest_libreadline=no)
281 # Handle --with-posix-malloc-threshold=NBYTES
282 AC_ARG_WITH(posix-malloc-threshold,
283 AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES],
284 [threshold for POSIX malloc usage (default=10)]),
285 , with_posix_malloc_threshold=10)
287 # Handle --with-link-size=N
288 AC_ARG_WITH(link-size,
289 AS_HELP_STRING([--with-link-size=N],
290 [internal link size (2, 3, or 4 allowed; default=2)]),
293 # Handle --with-parens-nest-limit=N
294 AC_ARG_WITH(parens-nest-limit,
295 AS_HELP_STRING([--with-parens-nest-limit=N],
296 [nested parentheses limit (default=250)]),
297 , with_parens_nest_limit=250)
299 # Handle --with-match-limit=N
300 AC_ARG_WITH(match-limit,
301 AS_HELP_STRING([--with-match-limit=N],
302 [default limit on internal looping (default=10000000)]),
303 , with_match_limit=10000000)
305 # Handle --with-match-limit_recursion=N
307 # Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
308 # symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
309 # value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
310 # different numeric value (or even the same numeric value as MATCH_LIMIT,
311 # though no longer defined in terms of the latter).
313 AC_ARG_WITH(match-limit-recursion,
314 AS_HELP_STRING([--with-match-limit-recursion=N],
315 [default limit on internal recursion (default=MATCH_LIMIT)]),
316 , with_match_limit_recursion=MATCH_LIMIT)
318 # Handle --enable-valgrind
319 AC_ARG_ENABLE(valgrind,
320 AS_HELP_STRING([--enable-valgrind],
322 , enable_valgrind=no)
324 # Enable code coverage reports using gcov
325 AC_ARG_ENABLE(coverage,
326 AS_HELP_STRING([--enable-coverage],
327 [enable code coverage reports using gcov]),
328 , enable_coverage=no)
330 # Copy enable_utf8 value to enable_utf for compatibility reasons
331 if test "x$enable_utf8" != "xunset"
333 if test "x$enable_utf" != "xunset"
335 AC_MSG_ERROR([--enable/disable-utf8 is kept only for compatibility reasons and its value is copied to --enable/disable-utf. Newer code must use --enable/disable-utf alone.])
337 enable_utf=$enable_utf8
340 # Set the default value for pcre8
341 if test "x$enable_pcre8" = "xunset"
346 # Set the default value for pcre16
347 if test "x$enable_pcre16" = "xunset"
352 # Set the default value for pcre32
353 if test "x$enable_pcre32" = "xunset"
358 # Make sure enable_pcre8 or enable_pcre16 was set
359 if test "x$enable_pcre8$enable_pcre16$enable_pcre32" = "xnonono"
361 AC_MSG_ERROR([At least one of 8, 16 or 32 bit pcre library must be enabled])
364 # Make sure that if enable_unicode_properties was set, that UTF support is enabled.
365 if test "x$enable_unicode_properties" = "xyes"
367 if test "x$enable_utf" = "xno"
369 AC_MSG_ERROR([support for Unicode properties requires UTF-8/16/32 support])
374 # enable_utf is disabled by default.
375 if test "x$enable_utf" = "xunset"
380 # enable_cpp copies the value of enable_pcre8 by default
381 if test "x$enable_cpp" = "xunset"
383 enable_cpp=$enable_pcre8
386 # Make sure that if enable_cpp was set, that enable_pcre8 support is enabled
387 if test "x$enable_cpp" = "xyes"
389 if test "x$enable_pcre8" = "xno"
391 AC_MSG_ERROR([C++ library requires pcre library with 8 bit characters])
395 # Convert the newline identifier into the appropriate integer value. The first
396 # three are ASCII values 0x0a, 0x0d, and 0x0d0a, but if EBCDIC is enabled, they
399 case "$enable_newline" in
400 lf) ac_pcre_newline_value=10 ;;
401 cr) ac_pcre_newline_value=13 ;;
402 crlf) ac_pcre_newline_value=3338 ;;
403 anycrlf) ac_pcre_newline_value=-2 ;;
404 any) ac_pcre_newline_value=-1 ;;
406 AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
410 # --enable-ebcdic-nl25 implies --enable-ebcdic
411 if test "x$enable_ebcdic_nl25" = "xyes"; then
415 # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled,
416 # and the newline value is adjusted appropriately (CR is still 13, but LF is
417 # 21 or 37). Also check that UTF support is not requested, because PCRE cannot
418 # handle EBCDIC and UTF in the same build. To do so it would need to use
419 # different character constants depending on the mode.
421 if test "x$enable_ebcdic" = "xyes"; then
422 enable_rebuild_chartables=yes
424 if test "x$enable_utf" = "xyes"; then
425 AC_MSG_ERROR([support for EBCDIC and UTF-8/16/32 cannot be enabled at the same time])
428 if test "x$enable_ebcdic_nl25" = "xno"; then
429 case "$ac_pcre_newline_value" in
430 10) ac_pcre_newline_value=21 ;;
431 3338) ac_pcre_newline_value=3349 ;;
434 case "$ac_pcre_newline_value" in
435 10) ac_pcre_newline_value=37 ;;
436 3338) ac_pcre_newline_value=3365 ;;
441 # Check argument to --with-link-size
442 case "$with_link_size" in
445 AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
450 /* PCRE is written in Standard C, but there are a few non-standard things it
451 can cope with, allowing it to run on SunOS4 and other "close to standard"
454 In environments that support the GNU autotools, config.h.in is converted into
455 config.h by the "configure" script. In environments that use CMake,
456 config-cmake.in is converted into config.h. If you are going to build PCRE "by
457 hand" without using "configure" or CMake, you should copy the distributed
458 config.h.generic to config.h, and edit the macro definitions to be the way you
459 need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
460 so that config.h is included at the start of every source.
462 Alternatively, you can avoid editing by using -D on the compiler command line
463 to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
464 but if you do, default values will be taken from config.h for non-boolean
465 macros that are not defined on the command line.
467 Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE8 should either be defined
468 (conventionally to 1) for TRUE, and not defined at all for FALSE. All such
469 macros are listed as a commented #undef in config.h.generic. Macros such as
470 MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
471 surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
473 PCRE uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
474 HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
475 sure both macros are undefined; an emulation function will then be used. */])
477 # Checks for header files.
479 AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h)
480 AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
482 # The files below are C++ header files.
483 pcre_have_type_traits="0"
484 pcre_have_bits_type_traits="0"
486 if test "x$enable_cpp" = "xyes" -a -z "$CXX"; then
487 AC_MSG_ERROR([Invalid C++ compiler or C++ compiler flags])
490 if test "x$enable_cpp" = "xyes" -a -n "$CXX"
494 # Older versions of pcre defined pcrecpp::no_arg, but in new versions
495 # it's called pcrecpp::RE::no_arg. For backwards ABI compatibility,
496 # we want to make one an alias for the other. Different systems do
497 # this in different ways. Some systems, for instance, can do it via
498 # a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4).
499 OLD_LDFLAGS="$LDFLAGS"
500 for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \
501 "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do
502 AC_MSG_CHECKING([for alias support in the linker])
503 LDFLAGS="$OLD_LDFLAGS -Wl,$flag"
504 # We try to run the linker with this new ld flag. If the link fails,
505 # we give up and remove the new flag from LDFLAGS.
506 AC_LINK_IFELSE([AC_LANG_PROGRAM([namespace pcrecpp {
507 class RE { static int no_arg; };
511 [AC_MSG_RESULT([yes]);
512 EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag";
516 LDFLAGS="$OLD_LDFLAGS"
518 # We could be more clever here, given we're doing AC_SUBST with this
519 # (eg set a var to be the name of the include file we want). But we're not
520 # so it's easy to change back to 'regular' autoconf vars if we needed to.
521 AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],
522 [pcre_have_cpp_headers="0"])
523 AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],
524 [pcre_have_bits_type_traits="0"])
525 AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],
526 [pcre_have_type_traits="0"])
528 # (This isn't c++-specific, but is only used in pcrecpp.cc, so try this
529 # in a c++ context. This matters becuase strtoimax is C99 and may not
530 # be supported by the C++ compiler.)
531 # Figure out how to create a longlong from a string: strtoll and
532 # equiv. It's not enough to call AC_CHECK_FUNCS: hpux has a
533 # strtoll, for instance, but it only takes 2 args instead of 3!
534 # We have to call AH_TEMPLATE since AC_DEFINE_UNQUOTED below is complex.
535 AH_TEMPLATE(HAVE_STRTOQ, [Define to 1 if you have `strtoq'.])
536 AH_TEMPLATE(HAVE_STRTOLL, [Define to 1 if you have `strtoll'.])
537 AH_TEMPLATE(HAVE__STRTOI64, [Define to 1 if you have `_strtoi64'.])
538 AH_TEMPLATE(HAVE_STRTOIMAX, [Define to 1 if you have `strtoimax'.])
540 for fn in strtoq strtoll _strtoi64 strtoimax; do
541 AC_MSG_CHECKING([for $fn])
542 if test "$fn" = strtoimax; then
547 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <$include>],
548 [char* e; return $fn("100", &e, 10)])],
550 AC_DEFINE_UNQUOTED(HAVE_`echo $fn | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`, 1,
551 [Define to 1 if you have `$fn'.])
557 if test "$have_strto_fn" = 1; then
558 AC_CHECK_TYPES([long long],
559 [pcre_have_long_long="1"],
560 [pcre_have_long_long="0"])
561 AC_CHECK_TYPES([unsigned long long],
562 [pcre_have_ulong_long="1"],
563 [pcre_have_ulong_long="0"])
565 pcre_have_long_long="0"
566 pcre_have_ulong_long="0"
568 AC_SUBST(pcre_have_long_long)
569 AC_SUBST(pcre_have_ulong_long)
573 # Using AC_SUBST eliminates the need to include config.h in a public .h file
574 AC_SUBST(pcre_have_type_traits)
575 AC_SUBST(pcre_have_bits_type_traits)
577 # Conditional compilation
578 AM_CONDITIONAL(WITH_PCRE8, test "x$enable_pcre8" = "xyes")
579 AM_CONDITIONAL(WITH_PCRE16, test "x$enable_pcre16" = "xyes")
580 AM_CONDITIONAL(WITH_PCRE32, test "x$enable_pcre32" = "xyes")
581 AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes")
582 AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
583 AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
584 AM_CONDITIONAL(WITH_UTF, test "x$enable_utf" = "xyes")
585 AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
587 # Checks for typedefs, structures, and compiler characteristics.
592 # Checks for library functions.
594 AC_CHECK_FUNCS(bcopy memmove strerror)
596 # Check for the availability of libz (aka zlib)
598 AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
599 AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
601 # Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
602 # as for libz. However, this had the following problem, diagnosed and fixed by
605 # - libbz2 uses the Pascal calling convention (WINAPI) for the functions
607 # - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
608 # therefore missing the function definition.
609 # - The compiler thus generates a "C" signature for the test function.
610 # - The linker fails to find the "C" function.
611 # - PCRE fails to configure if asked to do so against libbz2.
615 # - Replace the AC_CHECK_LIB test with a custom test.
617 AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
619 # AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
621 # Custom test follows
623 AC_MSG_CHECKING([for libbz2])
626 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
630 [[return (int)BZ2_bzopen("conftest", "rb");]])],
631 [AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
635 # Check for the availabiity of libreadline
637 if test "$enable_pcretest_libreadline" = "yes"; then
638 AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
639 AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
640 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
641 [unset ac_cv_lib_readline_readline;
642 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
643 [unset ac_cv_lib_readline_readline;
644 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
645 [unset ac_cv_lib_readline_readline;
646 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
647 [unset ac_cv_lib_readline_readline;
648 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
649 [unset ac_cv_lib_readline_readline;
650 AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
657 AC_SUBST(LIBREADLINE)
658 if test -n "$LIBREADLINE"; then
659 if test "$LIBREADLINE" != "-lreadline"; then
660 echo "-lreadline needs $LIBREADLINE"
661 LIBREADLINE="-lreadline $LIBREADLINE"
667 # Check for the availability of libedit. Different distributions put its
668 # headers in different places. Try to cover the most common ones.
670 if test "$enable_pcretest_libedit" = "yes"; then
671 AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
672 [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1],
673 [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])])
674 AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
677 # This facilitates -ansi builds under Linux
678 dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
681 if test "x$enable_shared" = "xno" ; then
682 AC_DEFINE([PCRE_STATIC], [1], [
683 Define to any value if linking statically (TODO: make nice with Libtool)])
684 PCRE_STATIC_CFLAG="-DPCRE_STATIC"
686 AC_SUBST(PCRE_STATIC_CFLAG)
688 # Here is where pcre specific defines are handled
690 if test "$enable_pcre8" = "yes"; then
691 AC_DEFINE([SUPPORT_PCRE8], [], [
692 Define to any value to enable the 8 bit PCRE library.])
695 if test "$enable_pcre16" = "yes"; then
696 AC_DEFINE([SUPPORT_PCRE16], [], [
697 Define to any value to enable the 16 bit PCRE library.])
700 if test "$enable_pcre32" = "yes"; then
701 AC_DEFINE([SUPPORT_PCRE32], [], [
702 Define to any value to enable the 32 bit PCRE library.])
705 # Unless running under Windows, JIT support requires pthreads.
707 if test "$enable_jit" = "yes"; then
708 if test "$HAVE_WINDOWS_H" != "1"; then
709 AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
711 CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
712 LIBS="$PTHREAD_LIBS $LIBS"
714 AC_DEFINE([SUPPORT_JIT], [], [
715 Define to any value to enable support for Just-In-Time compiling.])
717 enable_pcregrep_jit="no"
720 if test "$enable_pcregrep_jit" = "yes"; then
721 AC_DEFINE([SUPPORT_PCREGREP_JIT], [], [
722 Define to any value to enable JIT support in pcregrep.])
725 if test "$enable_utf" = "yes"; then
726 AC_DEFINE([SUPPORT_UTF], [], [
727 Define to any value to enable support for the UTF-8/16/32 Unicode encoding.
728 This will work even in an EBCDIC environment, but it is incompatible
729 with the EBCDIC macro. That is, PCRE can support *either* EBCDIC
730 code *or* ASCII/UTF-8/16/32, but not both at once.])
733 if test "$enable_unicode_properties" = "yes"; then
734 AC_DEFINE([SUPPORT_UCP], [], [
735 Define to any value to enable support for Unicode properties.])
738 if test "$enable_stack_for_recursion" = "no"; then
739 AC_DEFINE([NO_RECURSE], [], [
740 PCRE uses recursive function calls to handle backtracking while
741 matching. This can sometimes be a problem on systems that have
742 stacks of limited size. Define NO_RECURSE to any value to get a
743 version that doesn't use recursion in the match() function; instead
744 it creates its own stack by steam using pcre_recurse_malloc() to obtain
745 memory from the heap. For more detail, see the comments and other stuff
746 just above the match() function.])
749 if test "$enable_pcregrep_libz" = "yes"; then
750 AC_DEFINE([SUPPORT_LIBZ], [], [
751 Define to any value to allow pcregrep to be linked with libz, so that it is
752 able to handle .gz files.])
755 if test "$enable_pcregrep_libbz2" = "yes"; then
756 AC_DEFINE([SUPPORT_LIBBZ2], [], [
757 Define to any value to allow pcregrep to be linked with libbz2, so that it
758 is able to handle .bz2 files.])
761 if test $with_pcregrep_bufsize -lt 8192 ; then
762 AC_MSG_WARN([$with_pcregrep_bufsize is too small for --with-pcregrep-bufsize; using 8192])
763 with_pcregrep_bufsize="8192"
765 if test $? -gt 1 ; then
766 AC_MSG_ERROR([Bad value for --with-pcregrep-bufsize])
770 AC_DEFINE_UNQUOTED([PCREGREP_BUFSIZE], [$with_pcregrep_bufsize], [
771 The value of PCREGREP_BUFSIZE determines the size of buffer used by pcregrep
772 to hold parts of the file it is searching. This is also the minimum value.
773 The actual amount of memory used by pcregrep is three times this number,
774 because it allows for the buffering of "before" and "after" lines.])
776 if test "$enable_pcretest_libedit" = "yes"; then
777 AC_DEFINE([SUPPORT_LIBEDIT], [], [
778 Define to any value to allow pcretest to be linked with libedit.])
779 LIBREADLINE="$LIBEDIT"
780 elif test "$enable_pcretest_libreadline" = "yes"; then
781 AC_DEFINE([SUPPORT_LIBREADLINE], [], [
782 Define to any value to allow pcretest to be linked with libreadline.])
785 AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
786 The value of NEWLINE determines the default newline character sequence. PCRE
787 client programs can override this by selecting other values at run time. In
788 ASCII environments, the value can be 10 (LF), 13 (CR), or 3338 (CRLF); in
789 EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or 3349 or 3365
790 (CRLF) because there are two alternative codepoints (0x15 and 0x25) that are
791 used as the NL line terminator that is equivalent to ASCII LF. In both ASCII
792 and EBCDIC environments the value can also be -1 (ANY), or -2 (ANYCRLF).])
794 if test "$enable_bsr_anycrlf" = "yes"; then
795 AC_DEFINE([BSR_ANYCRLF], [], [
796 By default, the \R escape sequence matches any Unicode line ending
797 character or sequence of characters. If BSR_ANYCRLF is defined (to any
798 value), this is changed so that backslash-R matches only CR, LF, or CRLF.
799 The build-time default can be overridden by the user of PCRE at runtime.])
802 AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
803 The value of LINK_SIZE determines the number of bytes used to store
804 links as offsets within the compiled regex. The default is 2, which
805 allows for compiled patterns up to 64K long. This covers the vast
806 majority of cases. However, PCRE can also be compiled to use 3 or 4
807 bytes instead. This allows for longer patterns in extreme cases.])
809 AC_DEFINE_UNQUOTED([POSIX_MALLOC_THRESHOLD], [$with_posix_malloc_threshold], [
810 When calling PCRE via the POSIX interface, additional working storage
811 is required for holding the pointers to capturing substrings because
812 PCRE requires three integers per substring, whereas the POSIX
813 interface provides only two. If the number of expected substrings is
814 small, the wrapper function uses space on the stack, because this is
815 faster than using malloc() for each call. The threshold above which
816 the stack is no longer used is defined by POSIX_MALLOC_THRESHOLD.])
818 AC_DEFINE_UNQUOTED([PARENS_NEST_LIMIT], [$with_parens_nest_limit], [
819 The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
820 parentheses (of any kind) in a pattern. This limits the amount of system
821 stack that is used while compiling a pattern.])
823 AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
824 The value of MATCH_LIMIT determines the default number of times the
825 internal match() function can be called during a single execution of
826 pcre_exec(). There is a runtime interface for setting a different
827 limit. The limit exists in order to catch runaway regular
828 expressions that take for ever to determine that they do not match.
829 The default is set very large so that it does not accidentally catch
832 AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
833 The above limit applies to all calls of match(), whether or not they
834 increase the recursion depth. In some environments it is desirable
835 to limit the depth of recursive calls of match() more strictly, in
836 order to restrict the maximum amount of stack (or heap, if
837 NO_RECURSE is defined) that is used. The value of
838 MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
839 have any useful effect, it must be less than the value of
840 MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
841 There is a runtime method for setting a different limit.])
843 AC_DEFINE([MAX_NAME_SIZE], [32], [
844 This limit is parameterized just in case anybody ever wants to
845 change it. Care must be taken if it is increased, because it guards
846 against integer overflow caused by enormously large patterns.])
848 AC_DEFINE([MAX_NAME_COUNT], [10000], [
849 This limit is parameterized just in case anybody ever wants to
850 change it. Care must be taken if it is increased, because it guards
851 against integer overflow caused by enormously large patterns.])
853 AH_VERBATIM([PCRE_EXP_DEFN], [
854 /* If you are compiling for a system other than a Unix-like system or
855 Win32, and it needs some magic to be inserted before the definition
856 of a function that is exported by the library, define this macro to
857 contain the relevant magic. If you do not define this macro, a suitable
858 __declspec value is used for Windows systems; in other environments
859 "extern" is used for a C compiler and "extern C" for a C++ compiler.
860 This macro apears at the start of every exported function that is part
861 of the external API. It does not appear on functions that are "external"
862 in the C sense, but which are internal to the library. */
863 #undef PCRE_EXP_DEFN])
865 if test "$enable_ebcdic" = "yes"; then
866 AC_DEFINE_UNQUOTED([EBCDIC], [], [
867 If you are compiling for a system that uses EBCDIC instead of ASCII
868 character codes, define this macro to any value. You must also edit the
869 NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
870 On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
871 automatically adjusted. When EBCDIC is set, PCRE assumes that all input
872 strings are in EBCDIC. If you do not define this macro, PCRE will assume
873 input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
874 a version of PCRE that supports both EBCDIC and UTF-8/16/32.])
877 if test "$enable_ebcdic_nl25" = "yes"; then
878 AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
879 In an EBCDIC environment, define this macro to any value to arrange for
880 the NL character to be 0x25 instead of the default 0x15. NL plays the role
881 that LF does in an ASCII/Unicode environment. The value must also be set in
882 the NEWLINE macro below. On systems that can use "configure" or CMake to
883 set EBCDIC_NL25, the adjustment of NEWLINE is automatic.])
886 if test "$enable_valgrind" = "yes"; then
887 AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
888 Define to any value for valgrind support to find invalid memory reads.])
891 # Platform specific issues
896 if test X"$enable_shared" = Xyes; then
897 NO_UNDEFINED="-no-undefined"
898 EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
903 # The extra LDFLAGS for each particular library
904 # (Note: The libpcre*_version bits are m4 variables, assigned above)
906 EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \
907 $NO_UNDEFINED -version-info libpcre_version"
909 EXTRA_LIBPCRE16_LDFLAGS="$EXTRA_LIBPCRE16_LDFLAGS \
910 $NO_UNDEFINED -version-info libpcre16_version"
912 EXTRA_LIBPCRE32_LDFLAGS="$EXTRA_LIBPCRE32_LDFLAGS \
913 $NO_UNDEFINED -version-info libpcre32_version"
915 EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
916 $NO_UNDEFINED -version-info libpcreposix_version"
918 EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \
919 $NO_UNDEFINED -version-info libpcrecpp_version \
922 AC_SUBST(EXTRA_LIBPCRE_LDFLAGS)
923 AC_SUBST(EXTRA_LIBPCRE16_LDFLAGS)
924 AC_SUBST(EXTRA_LIBPCRE32_LDFLAGS)
925 AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
926 AC_SUBST(EXTRA_LIBPCRECPP_LDFLAGS)
928 # When we run 'make distcheck', use these arguments. Turning off compiler
929 # optimization makes it run faster.
930 DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre16 --enable-pcre32 --enable-jit --enable-cpp --enable-unicode-properties"
931 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
933 # Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
934 # specified, the relevant library is available.
936 if test "$enable_pcregrep_libz" = "yes"; then
937 if test "$HAVE_ZLIB_H" != "1"; then
938 echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
941 if test "$HAVE_LIBZ" != "1"; then
942 echo "** Cannot --enable-pcregrep-libz because libz was not found"
949 if test "$enable_pcregrep_libbz2" = "yes"; then
950 if test "$HAVE_BZLIB_H" != "1"; then
951 echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
954 if test "$HAVE_LIBBZ2" != "1"; then
955 echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
962 # Similarly for --enable-pcretest-readline
964 if test "$enable_pcretest_libedit" = "yes"; then
965 if test "$enable_pcretest_libreadline" = "yes"; then
966 echo "** Cannot use both --enable-pcretest-libedit and --enable-pcretest-readline"
969 if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
970 "$HAVE_READLINE_READLINE_H" != "1"; then
971 echo "** Cannot --enable-pcretest-libedit because neither editline/readline.h"
972 echo "** nor readline/readline.h was found."
975 if test -z "$LIBEDIT"; then
976 echo "** Cannot --enable-pcretest-libedit because libedit library was not found."
981 if test "$enable_pcretest_libreadline" = "yes"; then
982 if test "$HAVE_READLINE_H" != "1"; then
983 echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
986 if test "$HAVE_HISTORY_H" != "1"; then
987 echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
990 if test -z "$LIBREADLINE"; then
991 echo "** Cannot --enable-pcretest-readline because readline library was not found."
996 # Handle valgrind support
998 if test "$enable_valgrind" = "yes"; then
999 m4_ifdef([PKG_CHECK_MODULES],
1000 [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
1001 [AC_MSG_ERROR([pkg-config not supported])])
1004 # Handle code coverage reporting support
1005 if test "$enable_coverage" = "yes"; then
1006 if test "x$GCC" != "xyes"; then
1007 AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
1010 # ccache is incompatible with gcov
1011 AC_PATH_PROG([SHTOOL],[shtool],[false])
1012 case `$SHTOOL path $CC` in
1013 *ccache*) cc_ccache=yes;;
1017 if test "$cc_ccache" = "yes"; then
1018 if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
1019 AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
1023 AC_ARG_VAR([LCOV],[the ltp lcov program])
1024 AC_PATH_PROG([LCOV],[lcov],[false])
1025 if test "x$LCOV" = "xfalse"; then
1026 AC_MSG_ERROR([lcov not found])
1029 AC_ARG_VAR([GENHTML],[the ltp genhtml program])
1030 AC_PATH_PROG([GENHTML],[genhtml],[false])
1031 if test "x$GENHTML" = "xfalse"; then
1032 AC_MSG_ERROR([genhtml not found])
1035 # Set flags needed for gcov
1036 GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1037 GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1039 AC_SUBST([GCOV_CFLAGS])
1040 AC_SUBST([GCOV_CXXFLAGS])
1041 AC_SUBST([GCOV_LIBS])
1042 fi # enable_coverage
1044 AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
1046 # Produce these files, in addition to config.h.
1060 # Make the generated script files executable.
1061 AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config])
1063 # Make sure that pcre_chartables.c is removed in case the method for
1064 # creating it was changed by reconfiguration.
1065 AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c])
1069 # Print out a nice little message after configure is run displaying the
1073 if test "$enable_ebcdic_nl25" = "yes"; then
1075 elif test "$enable_ebcdic" = "yes"; then
1081 $PACKAGE-$VERSION configuration summary:
1083 Install prefix .................. : ${prefix}
1084 C preprocessor .................. : ${CPP}
1085 C compiler ...................... : ${CC}
1086 C++ preprocessor ................ : ${CXXCPP}
1087 C++ compiler .................... : ${CXX}
1088 Linker .......................... : ${LD}
1089 C preprocessor flags ............ : ${CPPFLAGS}
1090 C compiler flags ................ : ${CFLAGS} ${VISIBILITY_CFLAGS}
1091 C++ compiler flags .............. : ${CXXFLAGS} ${VISIBILITY_CXXFLAGS}
1092 Linker flags .................... : ${LDFLAGS}
1093 Extra libraries ................. : ${LIBS}
1095 Build 8 bit pcre library ........ : ${enable_pcre8}
1096 Build 16 bit pcre library ....... : ${enable_pcre16}
1097 Build 32 bit pcre library ....... : ${enable_pcre32}
1098 Build C++ library ............... : ${enable_cpp}
1099 Enable JIT compiling support .... : ${enable_jit}
1100 Enable UTF-8/16/32 support ...... : ${enable_utf}
1101 Unicode properties .............. : ${enable_unicode_properties}
1102 Newline char/sequence ........... : ${enable_newline}
1103 \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
1104 EBCDIC coding ................... : ${enable_ebcdic}
1105 EBCDIC code for NL .............. : ${ebcdic_nl_code}
1106 Rebuild char tables ............. : ${enable_rebuild_chartables}
1107 Use stack recursion ............. : ${enable_stack_for_recursion}
1108 POSIX mem threshold ............. : ${with_posix_malloc_threshold}
1109 Internal link size .............. : ${with_link_size}
1110 Nested parentheses limit ........ : ${with_parens_nest_limit}
1111 Match limit ..................... : ${with_match_limit}
1112 Match limit recursion ........... : ${with_match_limit_recursion}
1113 Build shared libs ............... : ${enable_shared}
1114 Build static libs ............... : ${enable_static}
1115 Use JIT in pcregrep ............. : ${enable_pcregrep_jit}
1116 Buffer size for pcregrep ........ : ${with_pcregrep_bufsize}
1117 Link pcregrep with libz ......... : ${enable_pcregrep_libz}
1118 Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
1119 Link pcretest with libedit ...... : ${enable_pcretest_libedit}
1120 Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
1121 Valgrind support ................ : ${enable_valgrind}
1122 Code coverage ................... : ${enable_coverage}
1126 dnl end configure.ac