Home | History | Annotate | Download | only in dist2
      1 dnl Process this file with autoconf to produce a configure script.
      2 
      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 PCRE2 user writes code that uses PCRE2_MINOR as a number. There is now
      6 dnl a check further down that throws an error if 08 or 09 are used.
      7 
      8 dnl The PCRE2_PRERELEASE feature is for identifying release candidates. It might
      9 dnl be defined as -RC2, for example. For real releases, it should be empty.
     10 
     11 m4_define(pcre2_major, [10])
     12 m4_define(pcre2_minor, [22])
     13 m4_define(pcre2_prerelease, [])
     14 m4_define(pcre2_date, [2016-07-29])
     15 
     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.
     18 
     19 # Libtool shared library interface versions (current:revision:age)
     20 m4_define(libpcre2_8_version,     [4:0:4])
     21 m4_define(libpcre2_16_version,    [4:0:4])
     22 m4_define(libpcre2_32_version,    [4:0:4])
     23 m4_define(libpcre2_posix_version, [1:0:0])
     24 
     25 AC_PREREQ(2.57)
     26 AC_INIT(PCRE2, pcre2_major.pcre2_minor[]pcre2_prerelease, , pcre2)
     27 AC_CONFIG_SRCDIR([src/pcre2.h.in])
     28 AM_INIT_AUTOMAKE([dist-bzip2 dist-zip])
     29 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
     30 AC_CONFIG_HEADERS(src/config.h)
     31 
     32 # This is a new thing required to stop a warning from automake 1.12
     33 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
     34 
     35 # This was added at the suggestion of libtoolize (03-Jan-10)
     36 AC_CONFIG_MACRO_DIR([m4])
     37 
     38 # The default CFLAGS in Autoconf are "-g -O2" for gcc and just "-g" for any
     39 # other compiler. There doesn't seem to be a standard way of getting rid of the
     40 # -g (which I don't think is needed for a production library). This fudge seems
     41 # to achieve the necessary. First, we remember the externally set values of
     42 # CFLAGS. Then call the AC_PROG_CC macro to find the compiler - if CFLAGS is
     43 # not set, it will be set to Autoconf's defaults. Afterwards, if the original
     44 # values were not set, remove the -g from the Autoconf defaults.
     45 
     46 remember_set_CFLAGS="$CFLAGS"
     47 
     48 AC_PROG_CC
     49 AM_PROG_CC_C_O
     50 
     51 if test "x$remember_set_CFLAGS" = "x"
     52 then
     53   if test "$CFLAGS" = "-g -O2"
     54   then
     55     CFLAGS="-O2"
     56   elif test "$CFLAGS" = "-g"
     57   then
     58     CFLAGS=""
     59   fi
     60 fi
     61 
     62 # Check for a 64-bit integer type
     63 AC_TYPE_INT64_T
     64 
     65 AC_PROG_INSTALL
     66 AC_LIBTOOL_WIN32_DLL
     67 LT_INIT
     68 AC_PROG_LN_S
     69 
     70 # Check for GCC visibility feature
     71 
     72 PCRE2_VISIBILITY
     73 
     74 # Versioning
     75 
     76 PCRE2_MAJOR="pcre2_major"
     77 PCRE2_MINOR="pcre2_minor"
     78 PCRE2_PRERELEASE="pcre2_prerelease"
     79 PCRE2_DATE="pcre2_date"
     80 
     81 if test "$PCRE2_MINOR" = "08" -o "$PCRE2_MINOR" = "09"
     82 then
     83   echo "***"
     84   echo "*** Minor version number $PCRE2_MINOR must not be used. ***"
     85   echo "*** Use only 00 to 07 or 10 onwards, to avoid octal issues. ***"
     86   echo "***"
     87   exit 1
     88 fi
     89 
     90 AC_SUBST(PCRE2_MAJOR)
     91 AC_SUBST(PCRE2_MINOR)
     92 AC_SUBST(PCRE2_PRERELEASE)
     93 AC_SUBST(PCRE2_DATE)
     94 
     95 # Set a more sensible default value for $(htmldir).
     96 if test "x$htmldir" = 'x${docdir}'
     97 then
     98   htmldir='${docdir}/html'
     99 fi
    100 
    101 # Force an error for PCRE1 size options
    102 AC_ARG_ENABLE(pcre8,,,enable_pcre8=no)
    103 AC_ARG_ENABLE(pcre16,,,enable_pcre16=no)
    104 AC_ARG_ENABLE(pcre32,,,enable_pcre32=no)
    105 
    106 if test "$enable_pcre8$enable_pcre16$enable_pcre32" != "nonono"
    107 then
    108   echo "** ERROR: Use --[[en|dis]]able-pcre2-[[8|16|32]], not --[[en|dis]]able-pcre[[8|16|32]]"
    109   exit 1
    110 fi
    111 
    112 # Handle --disable-pcre2-8 (enabled by default)
    113 AC_ARG_ENABLE(pcre2-8,
    114               AS_HELP_STRING([--disable-pcre2-8],
    115                              [disable 8 bit character support]),
    116               , enable_pcre2_8=unset)
    117 AC_SUBST(enable_pcre2_8)
    118 
    119 # Handle --enable-pcre2-16 (disabled by default)
    120 AC_ARG_ENABLE(pcre2-16,
    121               AS_HELP_STRING([--enable-pcre2-16],
    122                              [enable 16 bit character support]),
    123               , enable_pcre2_16=unset)
    124 AC_SUBST(enable_pcre2_16)
    125 
    126 # Handle --enable-pcre2-32 (disabled by default)
    127 AC_ARG_ENABLE(pcre2-32,
    128               AS_HELP_STRING([--enable-pcre2-32],
    129                              [enable 32 bit character support]),
    130               , enable_pcre2_32=unset)
    131 AC_SUBST(enable_pcre2_32)
    132 
    133 # Handle --dnable-debug (disabled by default)
    134 AC_ARG_ENABLE(debug,
    135               AS_HELP_STRING([--enable-debug],
    136                              [enable debugging code]),
    137               , enable_debug=no)
    138 
    139 # Handle --enable-jit (disabled by default)
    140 AC_ARG_ENABLE(jit,
    141               AS_HELP_STRING([--enable-jit],
    142                              [enable Just-In-Time compiling support]),
    143               , enable_jit=no)
    144 
    145 # Handle --disable-pcre2grep-jit (enabled by default)
    146 AC_ARG_ENABLE(pcre2grep-jit,
    147               AS_HELP_STRING([--disable-pcre2grep-jit],
    148                              [disable JIT support in pcre2grep]),
    149               , enable_pcre2grep_jit=yes)
    150 
    151 # Handle --disable-pcre2grep-callout (enabled by default) but not supported
    152 # for Windows.
    153 if test "$HAVE_WINDOWS_H" != "1"; then
    154   AC_ARG_ENABLE(pcre2grep-callout,
    155                 AS_HELP_STRING([--disable-pcre2grep-callout],
    156                                [disable callout script support in pcre2grep]),
    157                 , enable_pcre2grep_callout=yes)
    158 else
    159   enable_pcre2grep_callout=no
    160 fi
    161 
    162 # Handle --enable-rebuild-chartables
    163 AC_ARG_ENABLE(rebuild-chartables,
    164               AS_HELP_STRING([--enable-rebuild-chartables],
    165                              [rebuild character tables in current locale]),
    166               , enable_rebuild_chartables=no)
    167 
    168 # Handle --disable-unicode (enabled by default)
    169 AC_ARG_ENABLE(unicode,
    170               AS_HELP_STRING([--disable-unicode],
    171                              [disable Unicode support]),
    172               , enable_unicode=unset)
    173 
    174 # Handle newline options
    175 ac_pcre2_newline=lf
    176 AC_ARG_ENABLE(newline-is-cr,
    177               AS_HELP_STRING([--enable-newline-is-cr],
    178                              [use CR as newline character]),
    179               ac_pcre2_newline=cr)
    180 AC_ARG_ENABLE(newline-is-lf,
    181               AS_HELP_STRING([--enable-newline-is-lf],
    182                              [use LF as newline character (default)]),
    183               ac_pcre2_newline=lf)
    184 AC_ARG_ENABLE(newline-is-crlf,
    185               AS_HELP_STRING([--enable-newline-is-crlf],
    186                              [use CRLF as newline sequence]),
    187               ac_pcre2_newline=crlf)
    188 AC_ARG_ENABLE(newline-is-anycrlf,
    189               AS_HELP_STRING([--enable-newline-is-anycrlf],
    190                              [use CR, LF, or CRLF as newline sequence]),
    191               ac_pcre2_newline=anycrlf)
    192 AC_ARG_ENABLE(newline-is-any,
    193               AS_HELP_STRING([--enable-newline-is-any],
    194                              [use any valid Unicode newline sequence]),
    195               ac_pcre2_newline=any)
    196 enable_newline="$ac_pcre2_newline"
    197 
    198 # Handle --enable-bsr-anycrlf
    199 AC_ARG_ENABLE(bsr-anycrlf,
    200               AS_HELP_STRING([--enable-bsr-anycrlf],
    201                              [\R matches only CR, LF, CRLF by default]),
    202               , enable_bsr_anycrlf=no)
    203 
    204 # Handle --enable-never-backslash-C
    205 AC_ARG_ENABLE(never-backslash-C,
    206               AS_HELP_STRING([--enable-never-backslash-C],
    207                              [use of \C causes an error]),
    208               , enable_never_backslash_C=no)
    209 
    210 # Handle --enable-ebcdic
    211 AC_ARG_ENABLE(ebcdic,
    212               AS_HELP_STRING([--enable-ebcdic],
    213                              [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
    214               , enable_ebcdic=no)
    215 
    216 # Handle --enable-ebcdic-nl25
    217 AC_ARG_ENABLE(ebcdic-nl25,
    218               AS_HELP_STRING([--enable-ebcdic-nl25],
    219                              [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
    220               , enable_ebcdic_nl25=no)
    221 
    222 # Handle --disable-stack-for-recursion
    223 AC_ARG_ENABLE(stack-for-recursion,
    224               AS_HELP_STRING([--disable-stack-for-recursion],
    225                              [don't use stack recursion when matching]),
    226               , enable_stack_for_recursion=yes)
    227 
    228 # Handle --enable-pcre2grep-libz
    229 AC_ARG_ENABLE(pcre2grep-libz,
    230               AS_HELP_STRING([--enable-pcre2grep-libz],
    231                              [link pcre2grep with libz to handle .gz files]),
    232               , enable_pcre2grep_libz=no)
    233 
    234 # Handle --enable-pcre2grep-libbz2
    235 AC_ARG_ENABLE(pcre2grep-libbz2,
    236               AS_HELP_STRING([--enable-pcre2grep-libbz2],
    237                              [link pcre2grep with libbz2 to handle .bz2 files]),
    238               , enable_pcre2grep_libbz2=no)
    239 
    240 # Handle --with-pcre2grep-bufsize=N
    241 AC_ARG_WITH(pcre2grep-bufsize,
    242               AS_HELP_STRING([--with-pcre2grep-bufsize=N],
    243                              [pcre2grep buffer size (default=20480, minimum=8192)]),
    244               , with_pcre2grep_bufsize=20480)
    245 
    246 # Handle --enable-pcre2test-libedit
    247 AC_ARG_ENABLE(pcre2test-libedit,
    248               AS_HELP_STRING([--enable-pcre2test-libedit],
    249                              [link pcre2test with libedit]),
    250               , enable_pcre2test_libedit=no)
    251 
    252 # Handle --enable-pcre2test-libreadline
    253 AC_ARG_ENABLE(pcre2test-libreadline,
    254               AS_HELP_STRING([--enable-pcre2test-libreadline],
    255                              [link pcre2test with libreadline]),
    256               , enable_pcre2test_libreadline=no)
    257 
    258 # Handle --with-link-size=N
    259 AC_ARG_WITH(link-size,
    260             AS_HELP_STRING([--with-link-size=N],
    261                            [internal link size (2, 3, or 4 allowed; default=2)]),
    262             , with_link_size=2)
    263 
    264 # Handle --with-parens-nest-limit=N
    265 AC_ARG_WITH(parens-nest-limit,
    266             AS_HELP_STRING([--with-parens-nest-limit=N],
    267                            [nested parentheses limit (default=250)]),
    268             , with_parens_nest_limit=250)
    269 
    270 # Handle --with-match-limit=N
    271 AC_ARG_WITH(match-limit,
    272             AS_HELP_STRING([--with-match-limit=N],
    273                            [default limit on internal looping (default=10000000)]),
    274             , with_match_limit=10000000)
    275 
    276 # Handle --with-match-limit_recursion=N
    277 #
    278 # Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
    279 # symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
    280 # value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
    281 # different numeric value (or even the same numeric value as MATCH_LIMIT,
    282 # though no longer defined in terms of the latter).
    283 #
    284 AC_ARG_WITH(match-limit-recursion,
    285             AS_HELP_STRING([--with-match-limit-recursion=N],
    286                            [default limit on internal recursion (default=MATCH_LIMIT)]),
    287             , with_match_limit_recursion=MATCH_LIMIT)
    288 
    289 # Handle --enable-valgrind
    290 AC_ARG_ENABLE(valgrind,
    291               AS_HELP_STRING([--enable-valgrind],
    292                              [valgrind support]),
    293               , enable_valgrind=no)
    294 
    295 # Enable code coverage reports using gcov
    296 AC_ARG_ENABLE(coverage,
    297               AS_HELP_STRING([--enable-coverage],
    298                              [enable code coverage reports using gcov]),
    299               , enable_coverage=no)
    300 
    301 # Set the default value for pcre2-8
    302 if test "x$enable_pcre2_8" = "xunset"
    303 then
    304   enable_pcre2_8=yes
    305 fi
    306 
    307 # Set the default value for pcre2-16
    308 if test "x$enable_pcre2_16" = "xunset"
    309 then
    310   enable_pcre2_16=no
    311 fi
    312 
    313 # Set the default value for pcre2-32
    314 if test "x$enable_pcre2_32" = "xunset"
    315 then
    316   enable_pcre2_32=no
    317 fi
    318 
    319 # Make sure at least one library is selected
    320 if test "x$enable_pcre2_8$enable_pcre2_16$enable_pcre2_32" = "xnonono"
    321 then
    322   AC_MSG_ERROR([At least one of the 8, 16 or 32 bit libraries must be enabled])
    323 fi
    324 
    325 # Unicode is enabled by default.
    326 if test "x$enable_unicode" = "xunset"
    327 then
    328   enable_unicode=yes
    329 fi
    330 
    331 # Convert the newline identifier into the appropriate integer value. These must
    332 # agree with the PCRE2_NEWLINE_xxx values in pcre2.h.
    333 
    334 case "$enable_newline" in
    335   cr)      ac_pcre2_newline_value=1 ;;
    336   lf)      ac_pcre2_newline_value=2 ;;
    337   crlf)    ac_pcre2_newline_value=3 ;;
    338   any)     ac_pcre2_newline_value=4 ;;
    339   anycrlf) ac_pcre2_newline_value=5 ;;
    340   *)
    341   AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
    342   ;;
    343 esac
    344 
    345 # --enable-ebcdic-nl25 implies --enable-ebcdic
    346 if test "x$enable_ebcdic_nl25" = "xyes"; then
    347   enable_ebcdic=yes
    348 fi
    349 
    350 # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled.
    351 # Also check that UTF support is not requested, because PCRE2 cannot handle
    352 # EBCDIC and UTF in the same build. To do so it would need to use different
    353 # character constants depending on the mode. Also, EBCDIC cannot be used with
    354 # 16-bit and 32-bit libraries.
    355 #
    356 if test "x$enable_ebcdic" = "xyes"; then
    357   enable_rebuild_chartables=yes
    358   if test "x$enable_unicode" = "xyes"; then
    359     AC_MSG_ERROR([support for EBCDIC and Unicode cannot be enabled at the same time])
    360   fi
    361   if test "x$enable_pcre2_16" = "xyes" -o "x$enable_pcre2_32" = "xyes"; then
    362     AC_MSG_ERROR([EBCDIC support is available only for the 8-bit library])
    363   fi
    364 fi
    365 
    366 # Check argument to --with-link-size
    367 case "$with_link_size" in
    368   2|3|4) ;;
    369   *)
    370   AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
    371   ;;
    372 esac
    373 
    374 AH_TOP([
    375 /* PCRE2 is written in Standard C, but there are a few non-standard things it
    376 can cope with, allowing it to run on SunOS4 and other "close to standard"
    377 systems.
    378 
    379 In environments that support the GNU autotools, config.h.in is converted into
    380 config.h by the "configure" script. In environments that use CMake,
    381 config-cmake.in is converted into config.h. If you are going to build PCRE2 "by
    382 hand" without using "configure" or CMake, you should copy the distributed
    383 config.h.generic to config.h, and edit the macro definitions to be the way you
    384 need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
    385 so that config.h is included at the start of every source.
    386 
    387 Alternatively, you can avoid editing by using -D on the compiler command line
    388 to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
    389 but if you do, default values will be taken from config.h for non-boolean
    390 macros that are not defined on the command line.
    391 
    392 Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be defined
    393 (conventionally to 1) for TRUE, and not defined at all for FALSE. All such
    394 macros are listed as a commented #undef in config.h.generic. Macros such as
    395 MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
    396 surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
    397 
    398 PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
    399 HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
    400 sure both macros are undefined; an emulation function will then be used. */])
    401 
    402 # Checks for header files.
    403 AC_HEADER_STDC
    404 AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h)
    405 AC_CHECK_HEADERS([windows.h], [HAVE_WINDOWS_H=1])
    406 AC_CHECK_HEADERS([sys/wait.h], [HAVE_SYS_WAIT_H=1])
    407 
    408 # Conditional compilation
    409 AM_CONDITIONAL(WITH_PCRE2_8, test "x$enable_pcre2_8" = "xyes")
    410 AM_CONDITIONAL(WITH_PCRE2_16, test "x$enable_pcre2_16" = "xyes")
    411 AM_CONDITIONAL(WITH_PCRE2_32, test "x$enable_pcre2_32" = "xyes")
    412 AM_CONDITIONAL(WITH_DEBUG, test "x$enable_debug" = "xyes")
    413 AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
    414 AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
    415 AM_CONDITIONAL(WITH_UNICODE, test "x$enable_unicode" = "xyes")
    416 AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
    417 
    418 # Checks for typedefs, structures, and compiler characteristics.
    419 
    420 AC_C_CONST
    421 AC_TYPE_SIZE_T
    422 
    423 # Checks for library functions.
    424 
    425 AC_CHECK_FUNCS(bcopy memmove strerror)
    426 
    427 # Check for the availability of libz (aka zlib)
    428 
    429 AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
    430 AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
    431 
    432 # Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
    433 # as for libz. However, this had the following problem, diagnosed and fixed by
    434 # a user:
    435 #
    436 #   - libbz2 uses the Pascal calling convention (WINAPI) for the functions
    437 #     under Win32.
    438 #   - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
    439 #     therefore missing the function definition.
    440 #   - The compiler thus generates a "C" signature for the test function.
    441 #   - The linker fails to find the "C" function.
    442 #   - PCRE2 fails to configure if asked to do so against libbz2.
    443 #
    444 # Solution:
    445 #
    446 #   - Replace the AC_CHECK_LIB test with a custom test.
    447 
    448 AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
    449 # Original test
    450 # AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
    451 #
    452 # Custom test follows
    453 
    454 AC_MSG_CHECKING([for libbz2])
    455 OLD_LIBS="$LIBS"
    456 LIBS="$LIBS -lbz2"
    457 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
    458 #ifdef HAVE_BZLIB_H
    459 #include <bzlib.h>
    460 #endif]],
    461 [[return (int)BZ2_bzopen("conftest", "rb");]])],
    462 [AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
    463 AC_MSG_RESULT([no]))
    464 LIBS="$OLD_LIBS"
    465 
    466 # Check for the availabiity of libreadline
    467 
    468 if test "$enable_pcre2test_libreadline" = "yes"; then
    469  AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
    470  AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
    471  AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
    472    [unset ac_cv_lib_readline_readline;
    473     AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
    474      [unset ac_cv_lib_readline_readline;
    475       AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
    476        [unset ac_cv_lib_readline_readline;
    477         AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
    478          [unset ac_cv_lib_readline_readline;
    479 	  AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
    480            [unset ac_cv_lib_readline_readline;
    481 	    AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
    482              [LIBREADLINE=""],
    483              [-ltermcap])],
    484            [-lncursesw])],
    485          [-lncurses])],
    486        [-lcurses])],
    487      [-ltinfo])])
    488  AC_SUBST(LIBREADLINE)
    489  if test -n "$LIBREADLINE"; then
    490    if test "$LIBREADLINE" != "-lreadline"; then
    491      echo "-lreadline needs $LIBREADLINE"
    492      LIBREADLINE="-lreadline $LIBREADLINE"
    493    fi
    494  fi
    495 fi
    496 
    497 
    498 # Check for the availability of libedit. Different distributions put its
    499 # headers in different places. Try to cover the most common ones.
    500 
    501 if test "$enable_pcre2test_libedit" = "yes"; then
    502   AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
    503     [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1],
    504       [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])])
    505   AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
    506 fi
    507 
    508 # This facilitates -ansi builds under Linux
    509 dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
    510 
    511 PCRE2_STATIC_CFLAG=""
    512 if test "x$enable_shared" = "xno" ; then
    513   AC_DEFINE([PCRE2_STATIC], [1], [
    514     Define to any value if linking statically (TODO: make nice with Libtool)])
    515   PCRE2_STATIC_CFLAG="-DPCRE2_STATIC"
    516 fi
    517 AC_SUBST(PCRE2_STATIC_CFLAG)
    518 
    519 # Here is where PCRE2-specific defines are handled
    520 
    521 if test "$enable_pcre2_8" = "yes"; then
    522   AC_DEFINE([SUPPORT_PCRE2_8], [], [
    523     Define to any value to enable the 8 bit PCRE2 library.])
    524 fi
    525 
    526 if test "$enable_pcre2_16" = "yes"; then
    527   AC_DEFINE([SUPPORT_PCRE2_16], [], [
    528     Define to any value to enable the 16 bit PCRE2 library.])
    529 fi
    530 
    531 if test "$enable_pcre2_32" = "yes"; then
    532   AC_DEFINE([SUPPORT_PCRE2_32], [], [
    533     Define to any value to enable the 32 bit PCRE2 library.])
    534 fi
    535 
    536 if test "$enable_debug" = "yes"; then
    537   AC_DEFINE([PCRE2_DEBUG], [], [
    538     Define to any value to include debugging code.])
    539 fi
    540 
    541 # Unless running under Windows, JIT support requires pthreads.
    542 
    543 if test "$enable_jit" = "yes"; then
    544   if test "$HAVE_WINDOWS_H" != "1"; then
    545     AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
    546     CC="$PTHREAD_CC"
    547     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
    548     LIBS="$PTHREAD_LIBS $LIBS"
    549   fi
    550   AC_DEFINE([SUPPORT_JIT], [], [
    551     Define to any value to enable support for Just-In-Time compiling.])
    552 else
    553   enable_pcre2grep_jit="no"
    554 fi
    555 
    556 if test "$enable_pcre2grep_jit" = "yes"; then
    557   AC_DEFINE([SUPPORT_PCRE2GREP_JIT], [], [
    558     Define to any value to enable JIT support in pcre2grep.])
    559 fi
    560 
    561 # Currently pcre2grep callout string is not supported under Windows.
    562 
    563 if test "$enable_pcre2grep_callout" = "yes"; then
    564   if test "$HAVE_WINDOWS_H" != "1"; then
    565     if test "$HAVE_SYS_WAIT_H" != "1"; then
    566       AC_MSG_ERROR([Callout script support needs sys/wait.h.])
    567     fi
    568     AC_DEFINE([SUPPORT_PCRE2GREP_CALLOUT], [], [
    569       Define to any value to enable callout script support in pcre2grep.])
    570   else
    571     AC_MSG_WARN([Callout script support is not available for Windows: disabled])
    572     enable_pcre2grep_callout=no
    573   fi
    574 fi
    575 
    576 if test "$enable_unicode" = "yes"; then
    577   AC_DEFINE([SUPPORT_UNICODE], [], [
    578     Define to any value to enable support for Unicode and UTF encoding.
    579     This will work even in an EBCDIC environment, but it is incompatible
    580     with the EBCDIC macro. That is, PCRE2 can support *either* EBCDIC
    581     code *or* ASCII/Unicode, but not both at once.])
    582 fi
    583 
    584 if test "$enable_stack_for_recursion" = "no"; then
    585   AC_DEFINE([HEAP_MATCH_RECURSE], [], [
    586     PCRE2 uses recursive function calls to handle backtracking while
    587     matching. This can sometimes be a problem on systems that have
    588     stacks of limited size. Define HEAP_MATCH_RECURSE to any value to get a
    589     version that doesn't use recursion in the match() function; instead
    590     it creates its own stack by steam using memory from the heap. For more
    591     detail, see the comments and other stuff just above the match() function.])
    592 fi
    593 
    594 if test "$enable_pcre2grep_libz" = "yes"; then
    595   AC_DEFINE([SUPPORT_LIBZ], [], [
    596     Define to any value to allow pcre2grep to be linked with libz, so that it is
    597     able to handle .gz files.])
    598 fi
    599 
    600 if test "$enable_pcre2grep_libbz2" = "yes"; then
    601   AC_DEFINE([SUPPORT_LIBBZ2], [], [
    602     Define to any value to allow pcre2grep to be linked with libbz2, so that it
    603     is able to handle .bz2 files.])
    604 fi
    605 
    606 if test $with_pcre2grep_bufsize -lt 8192 ; then
    607   AC_MSG_WARN([$with_pcre2grep_bufsize is too small for --with-pcre2grep-bufsize; using 8192])
    608   with_pcre2grep_bufsize="8192"
    609 else
    610   if test $? -gt 1 ; then
    611   AC_MSG_ERROR([Bad value for  --with-pcre2grep-bufsize])
    612   fi
    613 fi
    614 
    615 AC_DEFINE_UNQUOTED([PCRE2GREP_BUFSIZE], [$with_pcre2grep_bufsize], [
    616   The value of PCRE2GREP_BUFSIZE determines the size of buffer used by pcre2grep
    617   to hold parts of the file it is searching. This is also the minimum value.
    618   The actual amount of memory used by pcre2grep is three times this number,
    619   because it allows for the buffering of "before" and "after" lines.])
    620 
    621 if test "$enable_pcre2test_libedit" = "yes"; then
    622   AC_DEFINE([SUPPORT_LIBEDIT], [], [
    623     Define to any value to allow pcre2test to be linked with libedit.])
    624   LIBREADLINE="$LIBEDIT"
    625 elif test "$enable_pcre2test_libreadline" = "yes"; then
    626   AC_DEFINE([SUPPORT_LIBREADLINE], [], [
    627     Define to any value to allow pcre2test to be linked with libreadline.])
    628 fi
    629 
    630 AC_DEFINE_UNQUOTED([NEWLINE_DEFAULT], [$ac_pcre2_newline_value], [
    631   The value of NEWLINE_DEFAULT determines the default newline character
    632   sequence. PCRE2 client programs can override this by selecting other values
    633   at run time. The valid values are 1 (CR), 2 (LF), 3 (CRLF), 4 (ANY),
    634   and 5 (ANYCRLF).])
    635 
    636 if test "$enable_bsr_anycrlf" = "yes"; then
    637   AC_DEFINE([BSR_ANYCRLF], [], [
    638     By default, the \R escape sequence matches any Unicode line ending
    639     character or sequence of characters. If BSR_ANYCRLF is defined (to any
    640     value), this is changed so that backslash-R matches only CR, LF, or CRLF.
    641     The build-time default can be overridden by the user of PCRE2 at runtime.])
    642 fi
    643 
    644 if test "$enable_never_backslash_C" = "yes"; then
    645   AC_DEFINE([NEVER_BACKSLASH_C], [], [
    646     Defining NEVER_BACKSLASH_C locks out the use of \C in all patterns.])
    647 fi
    648 
    649 AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
    650   The value of LINK_SIZE determines the number of bytes used to store
    651   links as offsets within the compiled regex. The default is 2, which
    652   allows for compiled patterns up to 64K long. This covers the vast
    653   majority of cases. However, PCRE2 can also be compiled to use 3 or 4
    654   bytes instead. This allows for longer patterns in extreme cases.])
    655 
    656 AC_DEFINE_UNQUOTED([PARENS_NEST_LIMIT], [$with_parens_nest_limit], [
    657   The value of PARENS_NEST_LIMIT specifies the maximum depth of nested
    658   parentheses (of any kind) in a pattern. This limits the amount of system
    659   stack that is used while compiling a pattern.])
    660 
    661 AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
    662   The value of MATCH_LIMIT determines the default number of times the
    663   internal match() function can be called during a single execution of
    664   pcre2_match(). There is a runtime interface for setting a different
    665   limit. The limit exists in order to catch runaway regular
    666   expressions that take for ever to determine that they do not match.
    667   The default is set very large so that it does not accidentally catch
    668   legitimate cases.])
    669 
    670 AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
    671   The above limit applies to all calls of match(), whether or not they
    672   increase the recursion depth. In some environments it is desirable
    673   to limit the depth of recursive calls of match() more strictly, in
    674   order to restrict the maximum amount of stack (or heap, if
    675   HEAP_MATCH_RECURSE is defined) that is used. The value of
    676   MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
    677   have any useful effect, it must be less than the value of
    678   MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
    679   There is a runtime method for setting a different limit.])
    680 
    681 AC_DEFINE([MAX_NAME_SIZE], [32], [
    682   This limit is parameterized just in case anybody ever wants to
    683   change it. Care must be taken if it is increased, because it guards
    684   against integer overflow caused by enormously large patterns.])
    685 
    686 AC_DEFINE([MAX_NAME_COUNT], [10000], [
    687   This limit is parameterized just in case anybody ever wants to
    688   change it. Care must be taken if it is increased, because it guards
    689   against integer overflow caused by enormously large patterns.])
    690 
    691 AH_VERBATIM([PCRE2_EXP_DEFN], [
    692 /* If you are compiling for a system other than a Unix-like system or
    693    Win32, and it needs some magic to be inserted before the definition
    694    of a function that is exported by the library, define this macro to
    695    contain the relevant magic. If you do not define this macro, a suitable
    696     __declspec value is used for Windows systems; in other environments
    697    "extern" is used for a C compiler and "extern C" for a C++ compiler.
    698    This macro apears at the start of every exported function that is part
    699    of the external API. It does not appear on functions that are "external"
    700    in the C sense, but which are internal to the library. */
    701 #undef PCRE2_EXP_DEFN])
    702 
    703 if test "$enable_ebcdic" = "yes"; then
    704   AC_DEFINE_UNQUOTED([EBCDIC], [], [
    705     If you are compiling for a system that uses EBCDIC instead of ASCII
    706     character codes, define this macro to any value. When EBCDIC is set, PCRE2
    707     assumes that all input strings are in EBCDIC. If you do not define this
    708     macro, PCRE2 will assume input strings are ASCII or UTF-8/16/32 Unicode. It
    709     is not possible to build a version of PCRE2 that supports both EBCDIC and
    710     UTF-8/16/32.])
    711 fi
    712 
    713 if test "$enable_ebcdic_nl25" = "yes"; then
    714   AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
    715     In an EBCDIC environment, define this macro to any value to arrange for
    716     the NL character to be 0x25 instead of the default 0x15. NL plays the role
    717     that LF does in an ASCII/Unicode environment.])
    718 fi
    719 
    720 if test "$enable_valgrind" = "yes"; then
    721   AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
    722      Define to any value for valgrind support to find invalid memory reads.])
    723 fi
    724 
    725 # Platform specific issues
    726 NO_UNDEFINED=
    727 EXPORT_ALL_SYMBOLS=
    728 case $host_os in
    729   cygwin* | mingw* )
    730     if test X"$enable_shared" = Xyes; then
    731       NO_UNDEFINED="-no-undefined"
    732       EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
    733     fi
    734     ;;
    735 esac
    736 
    737 # The extra LDFLAGS for each particular library. The libpcre2*_version values
    738 # are m4 variables, assigned above.
    739 
    740 EXTRA_LIBPCRE2_8_LDFLAGS="$EXTRA_LIBPCRE2_8_LDFLAGS \
    741   $NO_UNDEFINED -version-info libpcre2_8_version"
    742 
    743 EXTRA_LIBPCRE2_16_LDFLAGS="$EXTRA_LIBPCRE2_16_LDFLAGS \
    744   $NO_UNDEFINED -version-info libpcre2_16_version"
    745 
    746 EXTRA_LIBPCRE2_32_LDFLAGS="$EXTRA_LIBPCRE2_32_LDFLAGS \
    747   $NO_UNDEFINED -version-info libpcre2_32_version"
    748 
    749 EXTRA_LIBPCRE2_POSIX_LDFLAGS="$EXTRA_LIBPCRE2_POSIX_LDFLAGS \
    750   $NO_UNDEFINED -version-info libpcre2_posix_version"
    751 
    752 AC_SUBST(EXTRA_LIBPCRE2_8_LDFLAGS)
    753 AC_SUBST(EXTRA_LIBPCRE2_16_LDFLAGS)
    754 AC_SUBST(EXTRA_LIBPCRE2_32_LDFLAGS)
    755 AC_SUBST(EXTRA_LIBPCRE2_POSIX_LDFLAGS)
    756 
    757 # When we run 'make distcheck', use these arguments. Turning off compiler
    758 # optimization makes it run faster.
    759 DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre2-16 --enable-pcre2-32 --enable-jit --enable-utf"
    760 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
    761 
    762 # Check that, if --enable-pcre2grep-libz or --enable-pcre2grep-libbz2 is
    763 # specified, the relevant library is available.
    764 
    765 if test "$enable_pcre2grep_libz" = "yes"; then
    766   if test "$HAVE_ZLIB_H" != "1"; then
    767     echo "** Cannot --enable-pcre2grep-libz because zlib.h was not found"
    768     exit 1
    769   fi
    770   if test "$HAVE_LIBZ" != "1"; then
    771     echo "** Cannot --enable-pcre2grep-libz because libz was not found"
    772     exit 1
    773   fi
    774   LIBZ="-lz"
    775 fi
    776 AC_SUBST(LIBZ)
    777 
    778 if test "$enable_pcre2grep_libbz2" = "yes"; then
    779   if test "$HAVE_BZLIB_H" != "1"; then
    780     echo "** Cannot --enable-pcre2grep-libbz2 because bzlib.h was not found"
    781     exit 1
    782   fi
    783   if test "$HAVE_LIBBZ2" != "1"; then
    784     echo "** Cannot --enable-pcre2grep-libbz2 because libbz2 was not found"
    785     exit 1
    786   fi
    787   LIBBZ2="-lbz2"
    788 fi
    789 AC_SUBST(LIBBZ2)
    790 
    791 # Similarly for --enable-pcre2test-readline
    792 
    793 if test "$enable_pcre2test_libedit" = "yes"; then
    794   if test "$enable_pcre2test_libreadline" = "yes"; then
    795     echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline"
    796     exit 1
    797   fi
    798   if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
    799           "$HAVE_READLINE_READLINE_H" != "1"; then
    800     echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h"
    801     echo "** nor readline/readline.h was found."
    802     exit 1
    803   fi
    804   if test -z "$LIBEDIT"; then
    805     echo "** Cannot --enable-pcre2test-libedit because libedit library was not found."
    806     exit 1
    807   fi
    808 fi
    809 
    810 if test "$enable_pcre2test_libreadline" = "yes"; then
    811   if test "$HAVE_READLINE_H" != "1"; then
    812     echo "** Cannot --enable-pcre2test-readline because readline/readline.h was not found."
    813     exit 1
    814   fi
    815   if test "$HAVE_HISTORY_H" != "1"; then
    816     echo "** Cannot --enable-pcre2test-readline because readline/history.h was not found."
    817     exit 1
    818   fi
    819   if test -z "$LIBREADLINE"; then
    820     echo "** Cannot --enable-pcre2test-readline because readline library was not found."
    821     exit 1
    822   fi
    823 fi
    824 
    825 # Handle valgrind support
    826 
    827 if test "$enable_valgrind" = "yes"; then
    828   m4_ifdef([PKG_CHECK_MODULES],
    829            [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
    830            [AC_MSG_ERROR([pkg-config not supported])])
    831 fi
    832 
    833 # Handle code coverage reporting support
    834 if test "$enable_coverage" = "yes"; then
    835   if test "x$GCC" != "xyes"; then
    836     AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
    837   fi
    838 
    839   # ccache is incompatible with gcov
    840   AC_PATH_PROG([SHTOOL],[shtool],[false])
    841   case `$SHTOOL path $CC` in
    842     *ccache*) cc_ccache=yes;;
    843     *) cc_ccache=no;;
    844   esac
    845 
    846   if test "$cc_ccache" = "yes"; then
    847     if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
    848       AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
    849     fi
    850   fi
    851 
    852   AC_ARG_VAR([LCOV],[the ltp lcov program])
    853   AC_PATH_PROG([LCOV],[lcov],[false])
    854   if test "x$LCOV" = "xfalse"; then
    855     AC_MSG_ERROR([lcov not found])
    856   fi
    857 
    858   AC_ARG_VAR([GENHTML],[the ltp genhtml program])
    859   AC_PATH_PROG([GENHTML],[genhtml],[false])
    860   if test "x$GENHTML" = "xfalse"; then
    861     AC_MSG_ERROR([genhtml not found])
    862   fi
    863 
    864   # Set flags needed for gcov
    865   GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
    866   GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
    867   GCOV_LIBS="-lgcov"
    868   AC_SUBST([GCOV_CFLAGS])
    869   AC_SUBST([GCOV_CXXFLAGS])
    870   AC_SUBST([GCOV_LIBS])
    871 fi # enable_coverage
    872 
    873 AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
    874 
    875 # Produce these files, in addition to config.h.
    876 AC_CONFIG_FILES(
    877 	Makefile
    878 	libpcre2-8.pc
    879 	libpcre2-16.pc
    880 	libpcre2-32.pc
    881 	libpcre2-posix.pc
    882 	pcre2-config
    883 	src/pcre2.h
    884 )
    885 
    886 # Make the generated script files executable.
    887 AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre2-config])
    888 
    889 # Make sure that pcre2_chartables.c is removed in case the method for
    890 # creating it was changed by reconfiguration.
    891 AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre2_chartables.c])
    892 
    893 AC_OUTPUT
    894 
    895 # Print out a nice little message after configure is run displaying the
    896 # chosen options.
    897 
    898 ebcdic_nl_code=n/a
    899 if test "$enable_ebcdic_nl25" = "yes"; then
    900   ebcdic_nl_code=0x25
    901 elif test "$enable_ebcdic" = "yes"; then
    902   ebcdic_nl_code=0x15
    903 fi
    904 
    905 cat <<EOF
    906 
    907 $PACKAGE-$VERSION configuration summary:
    908 
    909     Install prefix .................. : ${prefix}
    910     C preprocessor .................. : ${CPP}
    911     C compiler ...................... : ${CC}
    912     Linker .......................... : ${LD}
    913     C preprocessor flags ............ : ${CPPFLAGS}
    914     C compiler flags ................ : ${CFLAGS} ${VISIBILITY_CFLAGS}
    915     Linker flags .................... : ${LDFLAGS}
    916     Extra libraries ................. : ${LIBS}
    917 
    918     Build 8-bit pcre2 library ....... : ${enable_pcre2_8}
    919     Build 16-bit pcre2 library ...... : ${enable_pcre2_16}
    920     Build 32-bit pcre2 library ...... : ${enable_pcre2_32}
    921     Include debugging code .......... : ${enable_debug}
    922     Enable JIT compiling support .... : ${enable_jit}
    923     Enable Unicode support .......... : ${enable_unicode}
    924     Newline char/sequence ........... : ${enable_newline}
    925     \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
    926     \C is disabled .................. : ${enable_never_backslash_C}
    927     EBCDIC coding ................... : ${enable_ebcdic}
    928     EBCDIC code for NL .............. : ${ebcdic_nl_code}
    929     Rebuild char tables ............. : ${enable_rebuild_chartables}
    930     Use stack recursion ............. : ${enable_stack_for_recursion}
    931     Internal link size .............. : ${with_link_size}
    932     Nested parentheses limit ........ : ${with_parens_nest_limit}
    933     Match limit ..................... : ${with_match_limit}
    934     Match limit recursion ........... : ${with_match_limit_recursion}
    935     Build shared libs ............... : ${enable_shared}
    936     Build static libs ............... : ${enable_static}
    937     Use JIT in pcre2grep ............ : ${enable_pcre2grep_jit}
    938     Enable callouts in pcre2grep .... : ${enable_pcre2grep_callout}
    939     Buffer size for pcre2grep ....... : ${with_pcre2grep_bufsize}
    940     Link pcre2grep with libz ........ : ${enable_pcre2grep_libz}
    941     Link pcre2grep with libbz2 ...... : ${enable_pcre2grep_libbz2}
    942     Link pcre2test with libedit ..... : ${enable_pcre2test_libedit}
    943     Link pcre2test with libreadline . : ${enable_pcre2test_libreadline}
    944     Valgrind support ................ : ${enable_valgrind}
    945     Code coverage ................... : ${enable_coverage}
    946 
    947 EOF
    948 
    949 dnl end configure.ac
    950