--- code/trunk/configure.ac 2007/03/06 12:27:42 99 +++ code/trunk/configure.ac 2007/12/26 10:11:56 290 @@ -7,9 +7,9 @@ dnl empty. m4_define(pcre_major, [7]) -m4_define(pcre_minor, [1]) -m4_define(pcre_prerelease, [-RC1]) -m4_define(pcre_date, [2007-03-05]) +m4_define(pcre_minor, [5]) +m4_define(pcre_prerelease, [-RC2]) +m4_define(pcre_date, [2007-12-26]) # Libtool shared library interface versions (current:revision:age) m4_define(libpcre_version, [0:1:0]) @@ -21,11 +21,50 @@ AC_CONFIG_SRCDIR([pcre.h.in]) AM_INIT_AUTOMAKE([dist-bzip2 dist-zip]) AC_CONFIG_HEADERS(config.h) + +# The default CFLAGS and CXXFLAGS in Autoconf are "-g -O2" for gcc and just +# "-g" for any other compiler. There doesn't seem to be a standard way of +# getting rid of the -g (which I don't think is needed for a production +# library). This fudge seems to achieve the necessary. First, we remember the +# externally set values of CFLAGS and CXXFLAGS. Then call the AC_PROG_CC and +# AC_PROG_CXX macros to find the compilers - if CFLAGS and CXXFLAGS are not +# set, they will be set to Autoconf's defaults. Afterwards, if the original +# values were not set, remove the -g from the Autoconf defaults. +# (PH 02-May-07) + +remember_set_CFLAGS="$CFLAGS" +remember_set_CXXFLAGS="$CXXFLAGS" + AC_PROG_CC AC_PROG_CXX + +if test "x$remember_set_CFLAGS" = "x" +then + if test "$CFLAGS" = "-g -O2" + then + CFLAGS="-O2" + elif test "$CFLAGS" = "-g" + then + CFLAGS="" + fi +fi + +if test "x$remember_set_CXXFLAGS" = "x" +then + if test "$CXXFLAGS" = "-g -O2" + then + CXXFLAGS="-O2" + elif test "$CXXFLAGS" = "-g" + then + CXXFLAGS="" + fi +fi + + AC_PROG_INSTALL AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL +AC_PROG_LN_S PCRE_MAJOR="pcre_major" PCRE_MINOR="pcre_minor" @@ -49,6 +88,12 @@ [disable C++ support]), , enable_cpp=yes) +# Handle --enable-rebuild-chartables +AC_ARG_ENABLE(rebuild-chartables, + AS_HELP_STRING([--enable-rebuild-chartables], + [rebuild character tables in current locale]), + , enable_rebuild_chartables=no) + # Handle --enable-utf8 (disabled by default) AC_ARG_ENABLE(utf8, AS_HELP_STRING([--enable-utf8], @@ -64,7 +109,7 @@ # Handle --enable-newline=NL dnl AC_ARG_ENABLE(newline, dnl AS_HELP_STRING([--enable-newline=NL], -dnl [use NL as newline (lf, cr, crlf, any; default=lf)]), +dnl [use NL as newline (lf, cr, crlf, anycrlf, any; default=lf)]), dnl , enable_newline=lf) # Separate newline options @@ -81,16 +126,26 @@ AS_HELP_STRING([--enable-newline-is-crlf], [use CRLF as newline sequence]), ac_pcre_newline=crlf) +AC_ARG_ENABLE(newline-is-anycrlf, + AS_HELP_STRING([--enable-newline-is-anycrlf], + [use CR, LF, or CRLF as newline sequence]), + ac_pcre_newline=anycrlf) AC_ARG_ENABLE(newline-is-any, AS_HELP_STRING([--enable-newline-is-any], [use any valid Unicode newline sequence]), 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]), + [assume EBCDIC coding rather than ASCII; use this only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]), , enable_ebcdic=no) # Handle --disable-stack-for-recursion @@ -99,6 +154,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], @@ -147,12 +220,20 @@ enable_utf8=no fi +# Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled. +# +if test "x$enable_ebcdic" = "xyes" +then + enable_rebuild_chartables=yes +fi + # Convert the newline identifier into the appropriate integer value. case "$enable_newline" in - lf) ac_pcre_newline_value=10 ;; - cr) ac_pcre_newline_value=13 ;; - crlf) ac_pcre_newline_value=3338 ;; - any) ac_pcre_newline_value=-1 ;; + lf) ac_pcre_newline_value=10 ;; + cr) ac_pcre_newline_value=13 ;; + crlf) ac_pcre_newline_value=3338 ;; + anycrlf) ac_pcre_newline_value=-2 ;; + any) ac_pcre_newline_value=-1 ;; *) AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option]) ;; @@ -167,20 +248,23 @@ esac AH_TOP([ -/* On Unix-like systems config.in is converted by "configure" into -config.h. Some other environments also support the use of "configure". -PCRE is written in Standard C, but there are a few non-standard things -it can cope with, allowing it to run on SunOS4 and other "close to -standard" systems. - -On a non-Unix-like system you should just copy this file into config.h, -and set up the macros the way you need them. You should normally change -the definitions of HAVE_STRERROR and HAVE_MEMMOVE to 1. Unfortunately, -because of the way autoconf works, these cannot be made the defaults. -If your system has bcopy() and not memmove(), change the definition of -HAVE_BCOPY instead of HAVE_MEMMOVE. If your system has neither bcopy() -nor memmove(), leave them both as 0; an emulation function will be -used. */]) +/* On Unix-like systems config.h.in is converted by "configure" into config.h. +Some other environments also support the use of "configure". PCRE is written in +Standard C, but there are a few non-standard things it can cope with, allowing +it to run on SunOS4 and other "close to standard" systems. + +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 +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 +them both to 0; an emulation function will be used. */]) # Checks for header files. AC_HEADER_STDC @@ -194,7 +278,7 @@ AC_LANG_PUSH(C++) # 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 +# (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. AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"], [pcre_have_cpp_headers="0"]) @@ -210,6 +294,7 @@ # Conditional compilation AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes") +AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes") # Checks for typedefs, structures, and compiler characteristics. @@ -227,7 +312,23 @@ # Checks for library functions. -AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll) +AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll _strtoi64) + +# 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]) @@ -252,8 +353,8 @@ if test "$enable_stack_for_recursion" = "no"; then AC_DEFINE([NO_RECURSE], [], [ PCRE uses recursive function calls to handle backtracking while - matching. This can sometimes be a problem on systems that have - stacks of limited size. Define NO_RECURSE to get a version that + matching. This can sometimes be a problem on systems that have + stacks of limited size. Define NO_RECURSE to get a version that doesn't use recursion in the match() function; instead it creates its own stack by steam using pcre_recurse_malloc() to obtain memory from the heap. For more detail, see the comments and other stuff @@ -262,11 +363,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. The default is - to leave it up to the compiler, but some sites want to force a - particular value. On Unix-like systems, "configure" can be used to - override this default.]) + The value of NEWLINE determines the newline character sequence. On + 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 @@ -290,7 +418,7 @@ AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [ The value of MATCH_LIMIT determines the default number of times the internal match() function can be called during a single execution of - pcre_exec(). There is a runtime interface for setting a different + pcre_exec(). There is a runtime interface for setting a different limit. The limit exists in order to catch runaway regular expressions that take for ever to determine that they do not match. The default is set very large so that it does not accidentally catch @@ -305,9 +433,9 @@ NO_RECURSE is defined) that is used. The value of MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To have any useful effect, it must be less than the value of - MATCH_LIMIT. There is a runtime method for setting a different - limit. On systems that support it, "configure" can be used to - override this default default.]) + MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT. + There is a runtime method for setting a different limit. On systems + that support it, "configure" can be used to override the default.]) AC_DEFINE([MAX_NAME_SIZE], [32], [ This limit is parameterized just in case anybody ever wants to @@ -319,12 +447,7 @@ change it. Care must be taken if it is increased, because it guards against integer overflow caused by enormously large patterns.]) -AC_DEFINE([MAX_DUPLENGTH], [30000], [ - This limit is parameterized just in case anybody ever wants to - change it. Care must be taken if it is increased, because it guards - against integer overflow caused by enormously large patterns.]) - -AH_VERBATIM([PCRE_DATA_SCOPE], [ +AH_VERBATIM([PCRE_EXP_DEFN], [ /* If you are compiling for a system other than a Unix-like system or Win32, and it needs some magic to be inserted before the definition of a function that is exported by the library, define this macro to @@ -334,7 +457,7 @@ every exported function that is part of the external API. It does not appear on functions that are "external" in the C sense, but which are internal to the library. */ -#undef PCRE_DATA_SCOPE]) +#undef PCRE_EXP_DEFN]) if test "$enable_ebcdic" = "yes"; then AC_DEFINE_UNQUOTED([EBCDIC], [], [ @@ -343,13 +466,6 @@ "configure", this can be done via --enable-ebcdic.]) fi -# Here is where pcre specific substs are handled -# These 3 are only used by RunTest.in. -# TODO: remove once RunTest uses pcretest -C instead. -AC_SUBST(LINK_SIZE, $with_link_size) -AC_SUBST(UTF8, $enable_utf8) -AC_SUBST(UCP, $enable_unicode_properties) - # Platform specific issues NO_UNDEFINED= EXPORT_ALL_SYMBOLS= @@ -379,11 +495,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 so, add it to LIBS. + +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 + if test "$LIBS" = ""; then LIBS=-lz; else LIBS="$LIBS -lz"; fi +fi + +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 + if test "$LIBS" = ""; then LIBS=-lbz2; else LIBS="$LIBS -lbz2"; fi +fi + +# 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 + if test "$LIBS" = ""; then LIBS=-lreadline; else LIBS="$LIBS -lreadline"; fi +fi + # Produce these files, in addition to config.h. AC_CONFIG_FILES( Makefile - RunGrepTest - RunTest libpcre.pc libpcrecpp.pc pcre-config @@ -393,41 +548,50 @@ ) # Make the generated script files executable. -AC_CONFIG_COMMANDS([script-chmod], [chmod a+x RunTest RunGrepTest pcre-config]) +AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config]) + +# Make sure that pcre_chartables.c is removed in case the method for +# creating it was changed by reconfiguration. +AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c]) AC_OUTPUT # Print out a nice little message after configure is run displaying your # chosen options. -# + cat <