--- code/trunk/configure.ac 2007/08/20 11:07:53 223 +++ code/trunk/configure.ac 2009/04/10 15:40:21 411 @@ -7,9 +7,9 @@ dnl empty. m4_define(pcre_major, [7]) -m4_define(pcre_minor, [3]) -m4_define(pcre_prerelease, [-RC8]) -m4_define(pcre_date, [2007-08-20]) +m4_define(pcre_minor, [9]) +m4_define(pcre_prerelease, []) +m4_define(pcre_date, [2009-04-10]) # Libtool shared library interface versions (current:revision:age) m4_define(libpcre_version, [0:1:0]) @@ -60,6 +60,11 @@ fi fi +# AC_PROG_CXX will return "g++" even if no c++ compiler is installed. +# Check for that case, and just disable c++ code if g++ doesn't run. +AC_LANG_PUSH(C++) +AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[]),, CXX=""; CXXCP=""; CXXFLAGS="") +AC_LANG_POP AC_PROG_INSTALL AC_LIBTOOL_WIN32_DLL @@ -97,7 +102,7 @@ # Handle --enable-utf8 (disabled by default) AC_ARG_ENABLE(utf8, AS_HELP_STRING([--enable-utf8], - [enable UTF-8 support]), + [enable UTF-8 support (incompatible with --enable-ebcdic)]), , enable_utf8=unset) # Handle --enable-unicode-properties @@ -136,10 +141,16 @@ ac_pcre_newline=any) enable_newline="$ac_pcre_newline" +# Handle --enable-bsr-anycrlf +AC_ARG_ENABLE(bsr-anycrlf, + AS_HELP_STRING([--enable-bsr-anycrlf], + [\R matches only CR, LF, CRLF by default]), + , enable_bsr_anycrlf=no) + # Handle --enable-ebcdic AC_ARG_ENABLE(ebcdic, AS_HELP_STRING([--enable-ebcdic], - [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]), + [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf8; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]), , enable_ebcdic=no) # Handle --disable-stack-for-recursion @@ -148,6 +159,24 @@ [don't use stack recursion when matching]), , enable_stack_for_recursion=yes) +# Handle --enable-pcregrep-libz +AC_ARG_ENABLE(pcregrep-libz, + AS_HELP_STRING([--enable-pcregrep-libz], + [link pcregrep with libz to handle .gz files]), + , enable_pcregrep_libz=no) + +# Handle --enable-pcregrep-libbz2 +AC_ARG_ENABLE(pcregrep-libbz2, + AS_HELP_STRING([--enable-pcregrep-libbz2], + [link pcregrep with libbz2 to handle .bz2 files]), + , enable_pcregrep_libbz2=no) + +# Handle --enable-pcretest-libreadline +AC_ARG_ENABLE(pcretest-libreadline, + AS_HELP_STRING([--enable-pcretest-libreadline], + [link pcretest with libreadline]), + , enable_pcretest_libreadline=no) + # Handle --with-posix-malloc-threshold=NBYTES AC_ARG_WITH(posix-malloc-threshold, AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES], @@ -197,10 +226,17 @@ fi # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled. +# Also check that UTF-8 support is not requested, because PCRE cannot handle +# EBCDIC and UTF-8 in the same build. To do so it would need to use different +# character constants depending on the mode. # if test "x$enable_ebcdic" = "xyes" then enable_rebuild_chartables=yes + if test "x$enable_utf8" = "xyes" + then + AC_MSG_ERROR([support for EBCDIC and UTF-8 cannot be enabled at the same time]) + fi fi # Convert the newline identifier into the appropriate integer value. @@ -231,8 +267,12 @@ If you are going to build PCRE "by hand" on a system without "configure" you should copy the distributed config.h.generic to config.h, and then set up the -macros the way you need them. Alternatively, you can avoid editing by using -D -on the compiler command line to set the macro values. +macro definitions the way you need them. You must then add -DHAVE_CONFIG_H to +all of your compile commands, so that config.h is included at the start of +every source. + +Alternatively, you can avoid editing by using -D on the compiler command line +to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H. PCRE uses memmove() if HAVE_MEMMOVE is set to 1; otherwise it uses bcopy() if HAVE_BCOPY is set to 1. If your system has neither bcopy() nor memmove(), set @@ -249,6 +289,30 @@ then AC_LANG_PUSH(C++) +# Older versions of pcre defined pcrecpp::no_arg, but in new versions +# it's called pcrecpp::RE::no_arg. For backwards ABI compatibility, +# we want to make one an alias for the other. Different systems do +# this in different ways. Some systems, for instance, can do it via +# a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4). +OLD_LDFLAGS="$LDFLAGS" +for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \ + "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do + AC_MSG_CHECKING([for alias support in the linker]) + LDFLAGS="$OLD_LDFLAGS -Wl,$flag" + # We try to run the linker with this new ld flag. If the link fails, + # we give up and remove the new flag from LDFLAGS. + AC_LINK_IFELSE(AC_LANG_PROGRAM([namespace pcrecpp { + class RE { static int no_arg; }; + int RE::no_arg; + }], + []), + [AC_MSG_RESULT([yes]); + EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag"; + break;], + AC_MSG_RESULT([no])) +done +LDFLAGS="$OLD_LDFLAGS" + # We could be more clever here, given we're doing AC_SUBST with this # (eg set a var to be the name of the include file we want). But we're not # so it's easy to change back to 'regular' autoconf vars if we needed to. @@ -258,6 +322,7 @@ [pcre_have_bits_type_traits="0"]) AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"], [pcre_have_type_traits="0"]) + AC_LANG_POP fi # Using AC_SUBST eliminates the need to include config.h in a public .h file @@ -273,18 +338,43 @@ AC_C_CONST AC_TYPE_SIZE_T -AC_CHECK_TYPES([long long], - [pcre_have_long_long="1"], - [pcre_have_long_long="0"]) -AC_CHECK_TYPES([unsigned long long], - [pcre_have_ulong_long="1"], - [pcre_have_ulong_long="0"]) +pcre_have_strotolonglong=0 +AC_CHECK_FUNCS(strtoq strtoll _strtoi64, [pcre_have_strotolonglong="1"; break]) +# If we can't convert a string to a long long, pretend we don't even +# have a long long. +if test $pcre_have_strotolonglong = "0"; then + pcre_have_long_long="0" + pcre_have_ulong_long="0" +else + AC_CHECK_TYPES([long long], + [pcre_have_long_long="1"], + [pcre_have_long_long="0"]) + AC_CHECK_TYPES([unsigned long long], + [pcre_have_ulong_long="1"], + [pcre_have_ulong_long="0"]) +fi AC_SUBST(pcre_have_long_long) AC_SUBST(pcre_have_ulong_long) # Checks for library functions. -AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll) +AC_CHECK_FUNCS(bcopy memmove strerror) + +# Check for the availability of libz (aka zlib) + +AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1]) +AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1]) + +# Check for the availability of libbz2 + +AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1]) +AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1]) + +# Check for the availabiity of libreadline + +AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1]) +AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1]) +AC_CHECK_LIB([readline], [readline], [HAVE_LIB_READLINE=1]) # This facilitates -ansi builds under Linux dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc]) @@ -298,7 +388,10 @@ if test "$enable_utf8" = "yes"; then AC_DEFINE([SUPPORT_UTF8], [], [ - Define to enable support for the UTF-8 Unicode encoding.]) + Define to enable support for the UTF-8 Unicode encoding. This will + work even in an EBCDIC environment, but it is incompatible with + the EBCDIC macro. That is, PCRE can support *either* EBCDIC code + *or* ASCII/UTF-8, but not both at once.]) fi if test "$enable_unicode_properties" = "yes"; then @@ -319,11 +412,38 @@ (use --disable-stack-for-recursion).]) fi +if test "$enable_pcregrep_libz" = "yes"; then + AC_DEFINE([SUPPORT_LIBZ], [], [ + Define to allow pcregrep to be linked with libz, so that it is + able to handle .gz files.]) +fi + +if test "$enable_pcregrep_libbz2" = "yes"; then + AC_DEFINE([SUPPORT_LIBBZ2], [], [ + Define to allow pcregrep to be linked with libbz2, so that it is + able to handle .bz2 files.]) +fi + +if test "$enable_pcretest_libreadline" = "yes"; then + AC_DEFINE([SUPPORT_LIBREADLINE], [], [ + Define to allow pcretest to be linked with libreadline.]) +fi + AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [ The value of NEWLINE determines the newline character sequence. On - Unix-like systems, "configure" can be used to override the default, - which is 10. The possible values are 10 (LF), 13 (CR), 3338 (CRLF), - -1 (ANY), or -2 (ANYCRLF).]) + systems that support it, "configure" can be used to override the + default, which is 10. The possible values are 10 (LF), 13 (CR), + 3338 (CRLF), -1 (ANY), or -2 (ANYCRLF).]) + +if test "$enable_bsr_anycrlf" = "yes"; then + AC_DEFINE([BSR_ANYCRLF], [], [ + By default, the \R escape sequence matches any Unicode line ending + character or sequence of characters. If BSR_ANYCRLF is defined, this is + changed so that backslash-R matches only CR, LF, or CRLF. The build- + time default can be overridden by the user of PCRE at runtime. On + systems that support it, "configure" can be used to override the + default.]) +fi AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [ The value of LINK_SIZE determines the number of bytes used to store @@ -392,7 +512,11 @@ AC_DEFINE_UNQUOTED([EBCDIC], [], [ If you are compiling for a system that uses EBCDIC instead of ASCII character codes, define this macro as 1. On systems that can use - "configure", this can be done via --enable-ebcdic.]) + "configure", this can be done via --enable-ebcdic. PCRE will then + assume that all input strings are in EBCDIC. If you do not define + this macro, PCRE will assume input strings are ASCII or UTF-8 Unicode. + It is not possible to build a version of PCRE that supports both + EBCDIC and UTF-8.]) fi # Platform specific issues @@ -410,11 +534,15 @@ # The extra LDFLAGS for each particular library # (Note: The libpcre*_version bits are m4 variables, assigned above) -EXTRA_LIBPCRE_LDFLAGS="$NO_UNDEFINED -version-info libpcre_version" +EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \ + $NO_UNDEFINED -version-info libpcre_version" -EXTRA_LIBPCREPOSIX_LDFLAGS="$NO_UNDEFINED -version-info libpcreposix_version" +EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \ + $NO_UNDEFINED -version-info libpcreposix_version" -EXTRA_LIBPCRECPP_LDFLAGS="$NO_UNDEFINED $EXPORT_ALL_SYMBOLS -version-info libpcrecpp_version" +EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \ + $NO_UNDEFINED -version-info libpcrecpp_version \ + $EXPORT_ALL_SYMBOLS" AC_SUBST(EXTRA_LIBPCRE_LDFLAGS) AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS) @@ -424,6 +552,50 @@ DISTCHECK_CONFIGURE_FLAGS="--enable-cpp --enable-unicode-properties" AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) +# Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is +# specified, the relevant library is available. + +if test "$enable_pcregrep_libz" = "yes"; then + if test "$HAVE_ZLIB_H" != "1"; then + echo "** Cannot --enable-pcregrep-libz because zlib.h was not found" + exit 1 + fi + if test "$HAVE_LIBZ" != "1"; then + echo "** Cannot --enable-pcregrep-libz because libz was not found" + exit 1 + fi + LIBZ="-lz" +fi +AC_SUBST(LIBZ) + +if test "$enable_pcregrep_libbz2" = "yes"; then + if test "$HAVE_BZLIB_H" != "1"; then + echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found" + exit 1 + fi + if test "$HAVE_LIBBZ2" != "1"; then + echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found" + exit 1 + fi + LIBBZ2="-lbz2" +fi +AC_SUBST(LIBBZ2) + +# Similarly for --enable-pcretest-readline + +if test "$enable_pcretest_libreadline" = "yes"; then + if test "$HAVE_READLINE_H" != "1"; then + echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found." + exit 1 + fi + if test "$HAVE_HISTORY_H" != "1"; then + echo "** Cannot --enable-pcretest-readline because readline/history.h was not found." + exit 1 + fi + LIBREADLINE="-lreadline" +fi +AC_SUBST(LIBREADLINE) + # Produce these files, in addition to config.h. AC_CONFIG_FILES( Makefile @@ -446,36 +618,40 @@ # Print out a nice little message after configure is run displaying your # chosen options. -# + cat <