1 dnl Process this file with autoconf to produce a configure script.
3 dnl NOTE FOR MAINTAINERS: Do not use major or minor version numbers with
4 dnl leading zeros, because they may be treated as octal constants. The
5 dnl PCRE_PRERELEASE feature is for identifying release candidates. It might
6 dnl be defined as -RC2, for example. For real releases, it should be defined
9 m4_define(pcre_major, [7])
10 m4_define(pcre_minor, [6])
11 m4_define(pcre_prerelease, [])
12 m4_define(pcre_date, [2008-01-28])
14 # Libtool shared library interface versions (current:revision:age)
15 m4_define(libpcre_version, [0:1:0])
16 m4_define(libpcreposix_version, [0:0:0])
17 m4_define(libpcrecpp_version, [0:0:0])
20 AC_INIT(PCRE, pcre_major.pcre_minor[]pcre_prerelease, , pcre)
21 AC_CONFIG_SRCDIR([pcre.h.in])
22 AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
23 AC_CONFIG_HEADERS(config.h)
25 # The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just
26 # "-g" for any other compiler. There doesn't seem to be a standard way of
27 # getting rid of the -g (which I don't think is needed for a production
28 # library). This fudge seems to achieve the necessary. First, we remember the
29 # externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and
30 # AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not
31 # set, they will be set to Autoconf's defaults. Afterwards, if the original
32 # values were not set, remove the -g from the Autoconf defaults.
35 remember_set_CFLAGS="$CFLAGS"
36 remember_set_CXXFLAGS="$CXXFLAGS"
41 if test "x$remember_set_CFLAGS" = "x"
43 if test "$CFLAGS" = "-g -O2"
46 elif test "$CFLAGS" = "-g"
52 if test "x$remember_set_CXXFLAGS" = "x"
54 if test "$CXXFLAGS" = "-g -O2"
57 elif test "$CXXFLAGS" = "-g"
69 PCRE_MAJOR="pcre_major"
70 PCRE_MINOR="pcre_minor"
71 PCRE_PRERELEASE="pcre_prerelease"
76 AC_SUBST(PCRE_PRERELEASE)
79 # Set a more sensible default value for $(htmldir).
80 if test "x$htmldir" = 'x${docdir}'
82 htmldir='${docdir}/html'
85 # Handle --disable-cpp
87 AS_HELP_STRING([--disable-cpp],
88 [disable C++ support]),
91 # Handle --enable-rebuild-chartables
92 AC_ARG_ENABLE(rebuild-chartables,
93 AS_HELP_STRING([--enable-rebuild-chartables],
94 [rebuild character tables in current locale]),
95 , enable_rebuild_chartables=no)
97 # Handle --enable-utf8 (disabled by default)
99 AS_HELP_STRING([--enable-utf8],
100 [enable UTF-8 support]),
103 # Handle --enable-unicode-properties
104 AC_ARG_ENABLE(unicode-properties,
105 AS_HELP_STRING([--enable-unicode-properties],
106 [enable Unicode properties support (implies --enable-utf8)]),
107 , enable_unicode_properties=no)
109 # Handle --enable-newline=NL
110 dnl AC_ARG_ENABLE(newline,
111 dnl AS_HELP_STRING([--enable-newline=NL],
112 dnl [use NL as newline (lf, cr, crlf, anycrlf, any; default=lf)]),
113 dnl , enable_newline=lf)
115 # Separate newline options
117 AC_ARG_ENABLE(newline-is-cr,
118 AS_HELP_STRING([--enable-newline-is-cr],
119 [use CR as newline character]),
121 AC_ARG_ENABLE(newline-is-lf,
122 AS_HELP_STRING([--enable-newline-is-lf],
123 [use LF as newline character (default)]),
125 AC_ARG_ENABLE(newline-is-crlf,
126 AS_HELP_STRING([--enable-newline-is-crlf],
127 [use CRLF as newline sequence]),
128 ac_pcre_newline=crlf)
129 AC_ARG_ENABLE(newline-is-anycrlf,
130 AS_HELP_STRING([--enable-newline-is-anycrlf],
131 [use CR, LF, or CRLF as newline sequence]),
132 ac_pcre_newline=anycrlf)
133 AC_ARG_ENABLE(newline-is-any,
134 AS_HELP_STRING([--enable-newline-is-any],
135 [use any valid Unicode newline sequence]),
137 enable_newline="$ac_pcre_newline"
139 # Handle --enable-bsr-anycrlf
140 AC_ARG_ENABLE(bsr-anycrlf,
141 AS_HELP_STRING([--enable-bsr-anycrlf],
142 [\R matches only CR, LF, CRLF by default]),
143 , enable_bsr_anycrlf=no)
145 # Handle --enable-ebcdic
146 AC_ARG_ENABLE(ebcdic,
147 AS_HELP_STRING([--enable-ebcdic],
148 [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
151 # Handle --disable-stack-for-recursion
152 AC_ARG_ENABLE(stack-for-recursion,
153 AS_HELP_STRING([--disable-stack-for-recursion],
154 [don't use stack recursion when matching]),
155 , enable_stack_for_recursion=yes)
157 # Handle --enable-pcregrep-libz
158 AC_ARG_ENABLE(pcregrep-libz,
159 AS_HELP_STRING([--enable-pcregrep-libz],
160 [link pcregrep with libz to handle .gz files]),
161 , enable_pcregrep_libz=no)
163 # Handle --enable-pcregrep-libbz2
164 AC_ARG_ENABLE(pcregrep-libbz2,
165 AS_HELP_STRING([--enable-pcregrep-libbz2],
166 [link pcregrep with libbz2 to handle .bz2 files]),
167 , enable_pcregrep_libbz2=no)
169 # Handle --enable-pcretest-libreadline
170 AC_ARG_ENABLE(pcretest-libreadline,
171 AS_HELP_STRING([--enable-pcretest-libreadline],
172 [link pcretest with libreadline]),
173 , enable_pcretest_libreadline=no)
175 # Handle --with-posix-malloc-threshold=NBYTES
176 AC_ARG_WITH(posix-malloc-threshold,
177 AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES],
178 [threshold for POSIX malloc usage (default=10)]),
179 , with_posix_malloc_threshold=10)
181 # Handle --with-link-size=N
182 AC_ARG_WITH(link-size,
183 AS_HELP_STRING([--with-link-size=N],
184 [internal link size (2, 3, or 4 allowed; default=2)]),
187 # Handle --with-match-limit=N
188 AC_ARG_WITH(match-limit,
189 AS_HELP_STRING([--with-match-limit=N],
190 [default limit on internal looping (default=10000000)]),
191 , with_match_limit=10000000)
193 # Handle --with-match-limit_recursion=N
195 # Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
196 # symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
197 # value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
198 # different numeric value (or even the same numeric value as MATCH_LIMIT,
199 # though no longer defined in terms of the latter).
201 AC_ARG_WITH(match-limit-recursion,
202 AS_HELP_STRING([--with-match-limit-recursion=N],
203 [default limit on internal recursion (default=MATCH_LIMIT)]),
204 , with_match_limit_recursion=MATCH_LIMIT)
206 # Make sure that if enable_unicode_properties was set, that UTF-8 support
209 if test "x$enable_unicode_properties" = "xyes"
211 if test "x$enable_utf8" = "xno"
213 AC_MSG_ERROR([support for Unicode properties requires UTF-8 support])
218 if test "x$enable_utf8" = "xunset"
223 # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
225 if test "x$enable_ebcdic" = "xyes"
227 enable_rebuild_chartables=yes
230 # Convert the newline identifier into the appropriate integer value.
231 case "$enable_newline" in
232 lf) ac_pcre_newline_value=10 ;;
233 cr) ac_pcre_newline_value=13 ;;
234 crlf) ac_pcre_newline_value=3338 ;;
235 anycrlf) ac_pcre_newline_value=-2 ;;
236 any) ac_pcre_newline_value=-1 ;;
238 AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
242 # Check argument to --with-link-size
243 case "$with_link_size" in
246 AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
251 /* On Unix-like systems config.h.in is converted by "configure" into config.h.
252 Some other environments also support the use of "configure". PCRE is written in
253 Standard C, but there are a few non-standard things it can cope with, allowing
254 it to run on SunOS4 and other "close to standard" systems.
256 If you are going to build PCRE "by hand" on a system without "configure" you
257 should copy the distributed config.h.generic to config.h, and then set up the
258 macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to
259 all of your compile commands, so that config.h is included at the start of
262 Alternatively, you can avoid editing by using -D on the compiler command line
263 to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H.
265 PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if
266 HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set
267 them both to 0; an emulation function will be used. */])
269 # Checks for header files.
271 AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h windows.h)
273 # The files below are C++ header files.
274 pcre_have_type_traits="0"
275 pcre_have_bits_type_traits="0"
276 if test "x$enable_cpp" = "xyes" -a -n "$CXX"
280 # We could be more clever here, given we're doing AC_SUBST with this
281 # (eg set a var to be the name of the include file we want). But we're not
282 # so it's easy to change back to 'regular' autoconf vars if we needed to.
283 AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],
284 [pcre_have_cpp_headers="0"])
285 AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],
286 [pcre_have_bits_type_traits="0"])
287 AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],
288 [pcre_have_type_traits="0"])
291 # Using AC_SUBST eliminates the need to include config.h in a public .h file
292 AC_SUBST(pcre_have_type_traits)
293 AC_SUBST(pcre_have_bits_type_traits)
295 # Conditional compilation
296 AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes")
297 AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
299 # Checks for typedefs, structures, and compiler characteristics.
304 AC_CHECK_TYPES([long long],
305 [pcre_have_long_long="1"],
306 [pcre_have_long_long="0"])
307 AC_CHECK_TYPES([unsigned long long],
308 [pcre_have_ulong_long="1"],
309 [pcre_have_ulong_long="0"])
310 AC_SUBST(pcre_have_long_long)
311 AC_SUBST(pcre_have_ulong_long)
313 # Checks for library functions.
315 AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll _strtoi64)
317 # Check for the availability of libz (aka zlib)
319 AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
320 AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
322 # Check for the availability of libbz2
324 AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
325 AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
327 # Check for the availabiity of libreadline
329 AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
330 AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
331 AC_CHECK_LIB([readline], [readline], [HAVE_LIB_READLINE=1])
333 # This facilitates -ansi builds under Linux
334 dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
336 if test "x$enable_shared" = "xno" ; then
337 AC_DEFINE([PCRE_STATIC], [1], [
338 Define if linking statically (TODO: make nice with Libtool)])
341 # Here is where pcre specific defines are handled
343 if test "$enable_utf8" = "yes"; then
344 AC_DEFINE([SUPPORT_UTF8], [], [
345 Define to enable support for the UTF-8 Unicode encoding.])
348 if test "$enable_unicode_properties" = "yes"; then
349 AC_DEFINE([SUPPORT_UCP], [], [
350 Define to enable support for Unicode properties])
353 if test "$enable_stack_for_recursion" = "no"; then
354 AC_DEFINE([NO_RECURSE], [], [
355 PCRE uses recursive function calls to handle backtracking while
356 matching. This can sometimes be a problem on systems that have
357 stacks of limited size. Define NO_RECURSE to get a version that
358 doesn't use recursion in the match() function; instead it creates
359 its own stack by steam using pcre_recurse_malloc() to obtain memory
360 from the heap. For more detail, see the comments and other stuff
361 just above the match() function. On systems that support it,
362 "configure" can be used to set this in the Makefile
363 (use --disable-stack-for-recursion).])
366 if test "$enable_pcregrep_libz" = "yes"; then
367 AC_DEFINE([SUPPORT_LIBZ], [], [
368 Define to allow pcregrep to be linked with libz, so that it is
369 able to handle .gz files.])
372 if test "$enable_pcregrep_libbz2" = "yes"; then
373 AC_DEFINE([SUPPORT_LIBBZ2], [], [
374 Define to allow pcregrep to be linked with libbz2, so that it is
375 able to handle .bz2 files.])
378 if test "$enable_pcretest_libreadline" = "yes"; then
379 AC_DEFINE([SUPPORT_LIBREADLINE], [], [
380 Define to allow pcretest to be linked with libreadline.])
383 AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
384 The value of NEWLINE determines the newline character sequence. On
385 systems that support it, "configure" can be used to override the
386 default, which is 10. The possible values are 10 (LF), 13 (CR),
387 3338 (CRLF), -1 (ANY), or -2 (ANYCRLF).])
389 if test "$enable_bsr_anycrlf" = "yes"; then
390 AC_DEFINE([BSR_ANYCRLF], [], [
391 By default, the \R escape sequence matches any Unicode line ending
392 character or sequence of characters. If BSR_ANYCRLF is defined, this is
393 changed so that backslash-R matches only CR, LF, or CRLF. The build-
394 time default can be overridden by the user of PCRE at runtime. On
395 systems that support it, "configure" can be used to override the
399 AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
400 The value of LINK_SIZE determines the number of bytes used to store
401 links as offsets within the compiled regex. The default is 2, which
402 allows for compiled patterns up to 64K long. This covers the vast
403 majority of cases. However, PCRE can also be compiled to use 3 or 4
404 bytes instead. This allows for longer patterns in extreme cases. On
405 systems that support it, "configure" can be used to override this default.])
407 AC_DEFINE_UNQUOTED([POSIX_MALLOC_THRESHOLD], [$with_posix_malloc_threshold], [
408 When calling PCRE via the POSIX interface, additional working storage
409 is required for holding the pointers to capturing substrings because
410 PCRE requires three integers per substring, whereas the POSIX
411 interface provides only two. If the number of expected substrings is
412 small, the wrapper function uses space on the stack, because this is
413 faster than using malloc() for each call. The threshold above which
414 the stack is no longer used is defined by POSIX_MALLOC_THRESHOLD. On
415 systems that support it, "configure" can be used to override this
418 AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
419 The value of MATCH_LIMIT determines the default number of times the
420 internal match() function can be called during a single execution of
421 pcre_exec(). There is a runtime interface for setting a different
422 limit. The limit exists in order to catch runaway regular
423 expressions that take for ever to determine that they do not match.
424 The default is set very large so that it does not accidentally catch
425 legitimate cases. On systems that support it, "configure" can be
426 used to override this default default.])
428 AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
429 The above limit applies to all calls of match(), whether or not they
430 increase the recursion depth. In some environments it is desirable
431 to limit the depth of recursive calls of match() more strictly, in
432 order to restrict the maximum amount of stack (or heap, if
433 NO_RECURSE is defined) that is used. The value of
434 MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
435 have any useful effect, it must be less than the value of
436 MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
437 There is a runtime method for setting a different limit. On systems
438 that support it, "configure" can be used to override the default.])
440 AC_DEFINE([MAX_NAME_SIZE], [32], [
441 This limit is parameterized just in case anybody ever wants to
442 change it. Care must be taken if it is increased, because it guards
443 against integer overflow caused by enormously large patterns.])
445 AC_DEFINE([MAX_NAME_COUNT], [10000], [
446 This limit is parameterized just in case anybody ever wants to
447 change it. Care must be taken if it is increased, because it guards
448 against integer overflow caused by enormously large patterns.])
450 AH_VERBATIM([PCRE_EXP_DEFN], [
451 /* If you are compiling for a system other than a Unix-like system or
452 Win32, and it needs some magic to be inserted before the definition
453 of a function that is exported by the library, define this macro to
454 contain the relevant magic. If you do not define this macro, it
455 defaults to "extern" for a C compiler and "extern C" for a C++
456 compiler on non-Win32 systems. This macro apears at the start of
457 every exported function that is part of the external API. It does
458 not appear on functions that are "external" in the C sense, but
459 which are internal to the library. */
460 #undef PCRE_EXP_DEFN])
462 if test "$enable_ebcdic" = "yes"; then
463 AC_DEFINE_UNQUOTED([EBCDIC], [], [
464 If you are compiling for a system that uses EBCDIC instead of ASCII
465 character codes, define this macro as 1. On systems that can use
466 "configure", this can be done via --enable-ebcdic.])
469 # Platform specific issues
474 if test X"$enable_shared" = Xyes; then
475 NO_UNDEFINED="-no-undefined"
476 EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
481 # The extra LDFLAGS for each particular library
482 # (Note: The libpcre*_version bits are m4 variables, assigned above)
484 EXTRA_LIBPCRE_LDFLAGS="$NO_UNDEFINED -version-info libpcre_version"
486 EXTRA_LIBPCREPOSIX_LDFLAGS="$NO_UNDEFINED -version-info libpcreposix_version"
488 EXTRA_LIBPCRECPP_LDFLAGS="$NO_UNDEFINED $EXPORT_ALL_SYMBOLS -version-info libpcrecpp_version"
490 AC_SUBST(EXTRA_LIBPCRE_LDFLAGS)
491 AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
492 AC_SUBST(EXTRA_LIBPCRECPP_LDFLAGS)
494 # When we run 'make distcheck', use these arguments.
495 DISTCHECK_CONFIGURE_FLAGS="--enable-cpp --enable-unicode-properties"
496 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
498 # Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
499 # specified, the relevant library is available. If so, add it to LIBS.
501 if test "$enable_pcregrep_libz" = "yes"; then
502 if test "$HAVE_ZLIB_H" != "1"; then
503 echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
506 if test "$HAVE_LIBZ" != "1"; then
507 echo "** Cannot --enable-pcregrep-libz because libz was not found"
510 if test "$LIBS" = ""; then LIBS=-lz; else LIBS="$LIBS -lz"; fi
513 if test "$enable_pcregrep_libbz2" = "yes"; then
514 if test "$HAVE_BZLIB_H" != "1"; then
515 echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
518 if test "$HAVE_LIBBZ2" != "1"; then
519 echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
522 if test "$LIBS" = ""; then LIBS=-lbz2; else LIBS="$LIBS -lbz2"; fi
525 # Similarly for --enable-pcretest-readline
527 if test "$enable_pcretest_libreadline" = "yes"; then
528 if test "$HAVE_READLINE_H" != "1"; then
529 echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
532 if test "$HAVE_HISTORY_H" != "1"; then
533 echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
536 if test "$LIBS" = ""; then LIBS=-lreadline; else LIBS="$LIBS -lreadline"; fi
539 # Produce these files, in addition to config.h.
550 # Make the generated script files executable.
551 AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config])
553 # Make sure that pcre_chartables.c is removed in case the method for
554 # creating it was changed by reconfiguration.
555 AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c])
559 # Print out a nice little message after configure is run displaying your
564 $PACKAGE-$VERSION configuration summary:
566 Install prefix .................. : ${prefix}
567 C preprocessor .................. : ${CPP}
568 C compiler ...................... : ${CC}
569 C++ preprocessor ................ : ${CXXCPP}
570 C++ compiler .................... : ${CXX}
571 Linker .......................... : ${LD}
572 C preprocessor flags ............ : ${CPPFLAGS}
573 C compiler flags ................ : ${CFLAGS}
574 C++ compiler flags .............. : ${CXXFLAGS}
575 Linker flags .................... : ${LDFLAGS}
576 Extra libraries ................. : ${LIBS}
578 Build C++ library ............... : ${enable_cpp}
579 Enable UTF-8 support ............ : ${enable_utf8}
580 Unicode properties .............. : ${enable_unicode_properties}
581 Newline char/sequence ........... : ${enable_newline}
582 \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
583 EBCDIC coding ................... : ${enable_ebcdic}
584 Rebuild char tables ............. : ${enable_rebuild_chartables}
585 Use stack recursion ............. : ${enable_stack_for_recursion}
586 POSIX mem threshold ............. : ${with_posix_malloc_threshold}
587 Internal link size .............. : ${with_link_size}
588 Match limit ..................... : ${with_match_limit}
589 Match limit recursion ........... : ${with_match_limit_recursion}
590 Build shared libs ............... : ${enable_shared}
591 Build static libs ............... : ${enable_static}
592 Link pcregrep with libz ......... : ${enable_pcregrep_libz}
593 Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
594 Link pcretest with libreadline .. : ${enable_pcretest_libreadline}