/[pcre]/code/trunk/configure.ac
ViewVC logotype

Diff of /code/trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 93 by nigel, Sat Feb 24 21:41:42 2007 UTC revision 1320 by ph10, Wed May 1 16:39:35 2013 UTC
# Line 1  Line 1 
1  dnl Process this file with autoconf to produce a configure script.  dnl Process this file with autoconf to produce a configure script.
2    
3  dnl This configure.in file has been hacked around quite a lot as a result of  dnl NOTE FOR MAINTAINERS: Do not use minor version numbers 08 or 09 because
4  dnl patches that various people have sent to me (PH). Sometimes the information  dnl the leading zeros may cause them to be treated as invalid octal constants
5  dnl I get is contradictory. I've tried to put in comments that explain things,  dnl if a PCRE user writes code that uses PCRE_MINOR as a number. There is now
6  dnl but in some cases the information is second-hand and I have no way of  dnl a check further down that throws an error if 08 or 09 are used.
7  dnl verifying it. I am not an autoconf or libtool expert!  
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.
10    
11    m4_define(pcre_major, [8])
12    m4_define(pcre_minor, [33])
13    m4_define(pcre_prerelease, [-RC1])
14    m4_define(pcre_date, [2013-04-28])
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(libpcre_version, [3:1:2])
21    m4_define(libpcre16_version, [2:1:2])
22    m4_define(libpcre32_version, [0:1:0])
23    m4_define(libpcreposix_version, [0:2:0])
24    m4_define(libpcrecpp_version, [0:0:0])
25    
26  dnl This is required at the start; the name is the name of a file  AC_PREREQ(2.57)
27  dnl it should be seeing, to verify it is in the same directory.  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)
32    
33    # This is a new thing required to stop a warning from automake 1.12
34    m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
35    
36    # This was added at the suggestion of libtoolize (03-Jan-10)
37    AC_CONFIG_MACRO_DIR([m4])
38    
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.
47    # (PH 02-May-07)
48    
49  AC_INIT(dftables.c)  remember_set_CFLAGS="$CFLAGS"
50  AC_CONFIG_SRCDIR([pcre.h])  remember_set_CXXFLAGS="$CXXFLAGS"
51    
52  dnl A safety precaution  AC_PROG_CC
53    AC_PROG_CXX
54    AM_PROG_CC_C_O
55    
56  AC_PREREQ(2.57)  if test "x$remember_set_CFLAGS" = "x"
57    then
58      if test "$CFLAGS" = "-g -O2"
59      then
60        CFLAGS="-O2"
61      elif test "$CFLAGS" = "-g"
62      then
63        CFLAGS=""
64      fi
65    fi
66    
67    if test "x$remember_set_CXXFLAGS" = "x"
68    then
69      if test "$CXXFLAGS" = "-g -O2"
70      then
71        CXXFLAGS="-O2"
72      elif test "$CXXFLAGS" = "-g"
73      then
74        CXXFLAGS=""
75      fi
76    fi
77    
78  dnl Arrange to build config.h from config.h.in.  # AC_PROG_CXX will return "g++" even if no c++ compiler is installed.
79  dnl Manual says this macro should come right after AC_INIT.  # Check for that case, and just disable c++ code if g++ doesn't run.
80  AC_CONFIG_HEADER(config.h)  AC_LANG_PUSH(C++)
81    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],, CXX=""; CXXCP=""; CXXFLAGS="")
82    AC_LANG_POP
83    
84  dnl Default values for miscellaneous macros  # Check for a 64-bit integer type
85    AC_TYPE_INT64_T
86    
87  POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=10  AC_PROG_INSTALL
88    AC_LIBTOOL_WIN32_DLL
89    LT_INIT
90    AC_PROG_LN_S
91    
92    # Check for GCC visibility feature
93    
94  dnl Provide versioning information for libtool shared libraries that  PCRE_VISIBILITY
 dnl are built by default on Unix systems.  
95    
96  PCRE_LIB_VERSION=0:1:0  # Versioning
 PCRE_POSIXLIB_VERSION=0:0:0  
 PCRE_CPPLIB_VERSION=0:0:0  
97    
98  dnl Find the PCRE version from the pcre.h file. The PCRE_VERSION variable is  PCRE_MAJOR="pcre_major"
99  dnl substituted in pcre-config.in.  PCRE_MINOR="pcre_minor"
100    PCRE_PRERELEASE="pcre_prerelease"
101    PCRE_DATE="pcre_date"
102    
103  PCRE_MAJOR=`grep '#define PCRE_MAJOR' ${srcdir}/pcre.h | cut -c 29-`  if test "$PCRE_MINOR" = "08" -o "$PCRE_MINOR" = "09"
104  PCRE_MINOR=`grep '#define PCRE_MINOR' ${srcdir}/pcre.h | cut -c 29-`  then
105  PCRE_PRERELEASE=`grep '#define PCRE_PRERELEASE' ${srcdir}/pcre.h | cut -c 29-`    echo "***"
106  PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}${PCRE_PRERELEASE}    echo "*** Minor version number $PCRE_MINOR must not be used. ***"
107      echo "*** Use only 01 to 07 or 10 onwards, to avoid octal issues. ***"
108      echo "***"
109      exit 1
110    fi
111    
112    AC_SUBST(PCRE_MAJOR)
113    AC_SUBST(PCRE_MINOR)
114    AC_SUBST(PCRE_PRERELEASE)
115    AC_SUBST(PCRE_DATE)
116    
117    # Set a more sensible default value for $(htmldir).
118    if test "x$htmldir" = 'x${docdir}'
119    then
120      htmldir='${docdir}/html'
121    fi
122    
123  dnl Handle --disable-cpp  # Handle --disable-pcre8 (enabled by default)
124    AC_ARG_ENABLE(pcre8,
125                  AS_HELP_STRING([--disable-pcre8],
126                                 [disable 8 bit character support]),
127                  , enable_pcre8=unset)
128    AC_SUBST(enable_pcre8)
129    
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)
136    
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)
143    
144    # Handle --disable-cpp. The substitution of enable_cpp is needed for use in
145    # pcre-config.
146  AC_ARG_ENABLE(cpp,  AC_ARG_ENABLE(cpp,
147  [  --disable-cpp           disable C++ support],                AS_HELP_STRING([--disable-cpp],
148  want_cpp="$enableval", want_cpp=yes)                               [disable C++ support]),
149                  , enable_cpp=unset)
150    AC_SUBST(enable_cpp)
151    
152    # Handle --enable-jit (disabled by default)
153    AC_ARG_ENABLE(jit,
154                  AS_HELP_STRING([--enable-jit],
155                                 [enable Just-In-Time compiling support]),
156                  , enable_jit=no)
157    
158    # Handle --disable-pcregrep-jit (enabled by default)
159    AC_ARG_ENABLE(pcregrep-jit,
160                  AS_HELP_STRING([--disable-pcregrep-jit],
161                                 [disable JIT support in pcregrep]),
162                  , enable_pcregrep_jit=yes)
163    
164    # Handle --enable-rebuild-chartables
165    AC_ARG_ENABLE(rebuild-chartables,
166                  AS_HELP_STRING([--enable-rebuild-chartables],
167                                 [rebuild character tables in current locale]),
168                  , enable_rebuild_chartables=no)
169    
170  dnl Checks for programs.  # Handle --enable-utf8 (disabled by default)
171    AC_ARG_ENABLE(utf8,
172                  AS_HELP_STRING([--enable-utf8],
173                                 [another name for --enable-utf. Kept only for compatibility reasons]),
174                  , enable_utf8=unset)
175    
176    # Handle --enable-utf (disabled by default)
177    AC_ARG_ENABLE(utf,
178                  AS_HELP_STRING([--enable-utf],
179                                 [enable UTF-8/16/32 support (incompatible with --enable-ebcdic)]),
180                  , enable_utf=unset)
181    
182  AC_PROG_CC  # Handle --enable-unicode-properties
183    AC_ARG_ENABLE(unicode-properties,
184                  AS_HELP_STRING([--enable-unicode-properties],
185                                 [enable Unicode properties support (implies --enable-utf)]),
186                  , enable_unicode_properties=no)
187    
188  dnl Test for C++ for the C++ wrapper libpcrecpp. It seems, however, that  # Handle newline options
189  dnl AC_PROC_CXX will set $CXX to "g++" when no C++ compiler is installed, even  ac_pcre_newline=lf
190  dnl though that is completely bogus. (This may happen only on certain systems  AC_ARG_ENABLE(newline-is-cr,
191  dnl with certain versions of autoconf, of course.) An attempt to include this                AS_HELP_STRING([--enable-newline-is-cr],
192  dnl test inside a check for want_cpp was criticized by a libtool expert, who                               [use CR as newline character]),
193  dnl tells me that it isn't allowed.                ac_pcre_newline=cr)
194    AC_ARG_ENABLE(newline-is-lf,
195                  AS_HELP_STRING([--enable-newline-is-lf],
196                                 [use LF as newline character (default)]),
197                  ac_pcre_newline=lf)
198    AC_ARG_ENABLE(newline-is-crlf,
199                  AS_HELP_STRING([--enable-newline-is-crlf],
200                                 [use CRLF as newline sequence]),
201                  ac_pcre_newline=crlf)
202    AC_ARG_ENABLE(newline-is-anycrlf,
203                  AS_HELP_STRING([--enable-newline-is-anycrlf],
204                                 [use CR, LF, or CRLF as newline sequence]),
205                  ac_pcre_newline=anycrlf)
206    AC_ARG_ENABLE(newline-is-any,
207                  AS_HELP_STRING([--enable-newline-is-any],
208                                 [use any valid Unicode newline sequence]),
209                  ac_pcre_newline=any)
210    enable_newline="$ac_pcre_newline"
211    
212    # Handle --enable-bsr-anycrlf
213    AC_ARG_ENABLE(bsr-anycrlf,
214                  AS_HELP_STRING([--enable-bsr-anycrlf],
215                                 [\R matches only CR, LF, CRLF by default]),
216                  , enable_bsr_anycrlf=no)
217    
218  AC_PROG_CXX  # Handle --enable-ebcdic
219    AC_ARG_ENABLE(ebcdic,
220                  AS_HELP_STRING([--enable-ebcdic],
221                                 [assume EBCDIC coding rather than ASCII; incompatible with --enable-utf; use only in (uncommon) EBCDIC environments; it implies --enable-rebuild-chartables]),
222                  , enable_ebcdic=no)
223    
224    # Handle --enable-ebcdic-nl25
225    AC_ARG_ENABLE(ebcdic-nl25,
226                  AS_HELP_STRING([--enable-ebcdic-nl25],
227                                 [set EBCDIC code for NL to 0x25 instead of 0x15; it implies --enable-ebcdic]),
228                  , enable_ebcdic_nl25=no)
229    
230  dnl The icc compiler has the same options as gcc, so let the rest of the  # Handle --disable-stack-for-recursion
231  dnl configure script think it has gcc when setting up dnl options etc.  AC_ARG_ENABLE(stack-for-recursion,
232  dnl This is a nasty hack which no longer seems necessary with the update                AS_HELP_STRING([--disable-stack-for-recursion],
233  dnl to the latest libtool files, so I have commented it out.                               [don't use stack recursion when matching]),
234  dnl                , enable_stack_for_recursion=yes)
235  dnl if test "$CC" = "icc" ; then GCC=yes ; fi  
236    # Handle --enable-pcregrep-libz
237    AC_ARG_ENABLE(pcregrep-libz,
238                  AS_HELP_STRING([--enable-pcregrep-libz],
239                                 [link pcregrep with libz to handle .gz files]),
240                  , enable_pcregrep_libz=no)
241    
242    # Handle --enable-pcregrep-libbz2
243    AC_ARG_ENABLE(pcregrep-libbz2,
244                  AS_HELP_STRING([--enable-pcregrep-libbz2],
245                                 [link pcregrep with libbz2 to handle .bz2 files]),
246                  , enable_pcregrep_libbz2=no)
247    
248    # Handle --with-pcregrep-bufsize=N
249    AC_ARG_WITH(pcregrep-bufsize,
250                  AS_HELP_STRING([--with-pcregrep-bufsize=N],
251                                 [pcregrep buffer size (default=20480)]),
252                  , with_pcregrep_bufsize=20480)
253    
254    # Handle --enable-pcretest-libedit
255    AC_ARG_ENABLE(pcretest-libedit,
256                  AS_HELP_STRING([--enable-pcretest-libedit],
257                                 [link pcretest with libedit]),
258                  , enable_pcretest_libedit=no)
259    
260    # Handle --enable-pcretest-libreadline
261    AC_ARG_ENABLE(pcretest-libreadline,
262                  AS_HELP_STRING([--enable-pcretest-libreadline],
263                                 [link pcretest with libreadline]),
264                  , enable_pcretest_libreadline=no)
265    
266  AC_PROG_INSTALL  # Handle --with-posix-malloc-threshold=NBYTES
267  AC_LIBTOOL_WIN32_DLL  AC_ARG_WITH(posix-malloc-threshold,
268  AC_PROG_LIBTOOL              AS_HELP_STRING([--with-posix-malloc-threshold=NBYTES],
269                               [threshold for POSIX malloc usage (default=10)]),
270                , with_posix_malloc_threshold=10)
271    
272    # Handle --with-link-size=N
273    AC_ARG_WITH(link-size,
274                AS_HELP_STRING([--with-link-size=N],
275                               [internal link size (2, 3, or 4 allowed; default=2)]),
276                , with_link_size=2)
277    
278    # Handle --with-match-limit=N
279    AC_ARG_WITH(match-limit,
280                AS_HELP_STRING([--with-match-limit=N],
281                               [default limit on internal looping (default=10000000)]),
282                , with_match_limit=10000000)
283    
284    # Handle --with-match-limit_recursion=N
285    #
286    # Note: In config.h, the default is to define MATCH_LIMIT_RECURSION
287    # symbolically as MATCH_LIMIT, which in turn is defined to be some numeric
288    # value (e.g. 10000000). MATCH_LIMIT_RECURSION can otherwise be set to some
289    # different numeric value (or even the same numeric value as MATCH_LIMIT,
290    # though no longer defined in terms of the latter).
291    #
292    AC_ARG_WITH(match-limit-recursion,
293                AS_HELP_STRING([--with-match-limit-recursion=N],
294                               [default limit on internal recursion (default=MATCH_LIMIT)]),
295                , with_match_limit_recursion=MATCH_LIMIT)
296    
297    # Handle --enable-valgrind
298    AC_ARG_ENABLE(valgrind,
299                  AS_HELP_STRING([--enable-valgrind],
300                                 [valgrind support]),
301                  , enable_valgrind=no)
302    
303    # Enable code coverage reports using gcov
304    AC_ARG_ENABLE(coverage,
305                  AS_HELP_STRING([--enable-coverage],
306                                 [enable code coverage reports using gcov]),
307                  , enable_coverage=no)
308    
309  dnl We need to find a compiler for compiling a program to run on the local host  # Copy enable_utf8 value to enable_utf for compatibility reasons
310  dnl while building. It needs to be different from CC when cross-compiling.  if test "x$enable_utf8" != "xunset"
311  dnl There is a macro called AC_PROG_CC_FOR_BUILD in the GNU archive for  then
312  dnl figuring this out automatically. Unfortunately, it does not work with the    if test "x$enable_utf" != "xunset"
313  dnl latest versions of autoconf. So for the moment, we just default to the    then
314  dnl same values as the "main" compiler. People who are cross-compiling will      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.])
315  dnl just have to adjust the Makefile by hand or set these values when they    fi
316  dnl run "configure".    enable_utf=$enable_utf8
317    fi
318  CC_FOR_BUILD=${CC_FOR_BUILD:-'$(CC)'}  
319  CXX_FOR_BUILD=${CXX_FOR_BUILD:-'$(CXX)'}  # Set the default value for pcre8
320  CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:-'$(CFLAGS)'}  if test "x$enable_pcre8" = "xunset"
321  CPPFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD:-'$(CPPFLAGS)'}  then
322  CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD:-'$(CXXFLAGS)'}    enable_pcre8=yes
323  BUILD_EXEEXT=${BUILD_EXEEXT:-'$(EXEEXT)'}  fi
324  BUILD_OBJEXT=${BUILD_OBJEXT:-'$(OBJEXT)'}  
325    # Set the default value for pcre16
326    if test "x$enable_pcre16" = "xunset"
327    then
328      enable_pcre16=no
329    fi
330    
331    # Set the default value for pcre32
332    if test "x$enable_pcre32" = "xunset"
333    then
334      enable_pcre32=no
335    fi
336    
337    # Make sure enable_pcre8 or enable_pcre16 was set
338    if test "x$enable_pcre8$enable_pcre16$enable_pcre32" = "xnonono"
339    then
340      AC_MSG_ERROR([At least one of 8, 16 or 32 bit pcre library must be enabled])
341    fi
342    
343    # Make sure that if enable_unicode_properties was set, that UTF support is enabled.
344    if test "x$enable_unicode_properties" = "xyes"
345    then
346      if test "x$enable_utf" = "xno"
347      then
348        AC_MSG_ERROR([support for Unicode properties requires UTF-8/16/32 support])
349      fi
350      enable_utf=yes
351    fi
352    
353    # enable_utf is disabled by default.
354    if test "x$enable_utf" = "xunset"
355    then
356      enable_utf=no
357    fi
358    
359    # enable_cpp copies the value of enable_pcre8 by default
360    if test "x$enable_cpp" = "xunset"
361    then
362      enable_cpp=$enable_pcre8
363    fi
364    
365    # Make sure that if enable_cpp was set, that enable_pcre8 support is enabled
366    if test "x$enable_cpp" = "xyes"
367    then
368      if test "x$enable_pcre8" = "xno"
369      then
370        AC_MSG_ERROR([C++ library requires pcre library with 8 bit characters])
371      fi
372    fi
373    
374    # Convert the newline identifier into the appropriate integer value. The first
375    # three are ASCII values 0x0a, 0x0d, and 0x0d0a, but if EBCDIC is enabled, they
376    # are changed below.
377    
378    case "$enable_newline" in
379      lf)      ac_pcre_newline_value=10   ;;
380      cr)      ac_pcre_newline_value=13   ;;
381      crlf)    ac_pcre_newline_value=3338 ;;
382      anycrlf) ac_pcre_newline_value=-2   ;;
383      any)     ac_pcre_newline_value=-1   ;;
384      *)
385      AC_MSG_ERROR([invalid argument \"$enable_newline\" to --enable-newline option])
386      ;;
387    esac
388    
389  dnl Checks for header files.  # --enable-ebcdic-nl25 implies --enable-ebcdic
390    if test "x$enable_ebcdic_nl25" = "xyes"; then
391      enable_ebcdic=yes
392    fi
393    
394    # Make sure that if enable_ebcdic is set, rebuild_chartables is also enabled,
395    # and the newline value is adjusted appropriately (CR is still 13, but LF is
396    # 21 or 37). Also check that UTF support is not requested, because PCRE cannot
397    # handle EBCDIC and UTF in the same build. To do so it would need to use
398    # different character constants depending on the mode.
399    #
400    if test "x$enable_ebcdic" = "xyes"; then
401      enable_rebuild_chartables=yes
402    
403      if test "x$enable_utf" = "xyes"; then
404        AC_MSG_ERROR([support for EBCDIC and UTF-8/16/32 cannot be enabled at the same time])
405      fi
406    
407      if test "x$enable_ebcdic_nl25" = "xno"; then
408        case "$ac_pcre_newline_value" in
409          10)   ac_pcre_newline_value=21 ;;
410          3338) ac_pcre_newline_value=3349 ;;
411        esac
412      else
413        case "$ac_pcre_newline_value" in
414          10)   ac_pcre_newline_value=37 ;;
415          3338) ac_pcre_newline_value=3365 ;;
416        esac
417      fi
418    fi
419    
420    # Check argument to --with-link-size
421    case "$with_link_size" in
422      2|3|4) ;;
423      *)
424      AC_MSG_ERROR([invalid argument \"$with_link_size\" to --with-link-size option])
425      ;;
426    esac
427    
428    AH_TOP([
429    /* PCRE is written in Standard C, but there are a few non-standard things it
430    can cope with, allowing it to run on SunOS4 and other "close to standard"
431    systems.
432    
433    In environments that support the GNU autotools, config.h.in is converted into
434    config.h by the "configure" script. In environments that use CMake,
435    config-cmake.in is converted into config.h. If you are going to build PCRE "by
436    hand" without using "configure" or CMake, you should copy the distributed
437    config.h.generic to config.h, and edit the macro definitions to be the way you
438    need them. You must then add -DHAVE_CONFIG_H to all of your compile commands,
439    so that config.h is included at the start of every source.
440    
441    Alternatively, you can avoid editing by using -D on the compiler command line
442    to set the macro values. In this case, you do not have to set -DHAVE_CONFIG_H,
443    but if you do, default values will be taken from config.h for non-boolean
444    macros that are not defined on the command line.
445    
446    Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE8 should either be defined
447    (conventionally to 1) for TRUE, and not defined at all for FALSE. All such
448    macros are listed as a commented #undef in config.h.generic. Macros such as
449    MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
450    surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
451    
452    PCRE uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
453    HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
454    sure both macros are undefined; an emulation function will then be used. */])
455    
456    # Checks for header files.
457  AC_HEADER_STDC  AC_HEADER_STDC
458  AC_CHECK_HEADERS(limits.h)  AC_CHECK_HEADERS(limits.h sys/types.h sys/stat.h dirent.h windows.h)
459    
460  dnl The files below are C++ header files. One person told me (PH) that  # The files below are C++ header files.
461  dnl AC_LANG_CPLUSPLUS unsets CXX if it was explicitly set to something which  pcre_have_type_traits="0"
462  dnl doesn't work. However, this doesn't always seem to be the case.  pcre_have_bits_type_traits="0"
463    
464    if test "x$enable_cpp" = "xyes" -a -z "$CXX"; then
465       AC_MSG_ERROR([You need a C++ compiler for C++ support.])
466    fi
467    
468  if test "x$want_cpp" = "xyes" -a -n "$CXX"  if test "x$enable_cpp" = "xyes" -a -n "$CXX"
469  then  then
470  AC_LANG_SAVE  AC_LANG_PUSH(C++)
 AC_LANG_CPLUSPLUS  
471    
472  dnl We could be more clever here, given we're doing AC_SUBST with this  # Older versions of pcre defined pcrecpp::no_arg, but in new versions
473  dnl (eg set a var to be the name of the include file we want).  But we're not  # it's called pcrecpp::RE::no_arg.  For backwards ABI compatibility,
474  dnl so it's easy to change back to 'regular' autoconf vars if we needed to.  # we want to make one an alias for the other.  Different systems do
475    # this in different ways.  Some systems, for instance, can do it via
476    # a linker flag: -alias (for os x 10.5) or -i (for os x <=10.4).
477    OLD_LDFLAGS="$LDFLAGS"
478    for flag in "-alias,__ZN7pcrecpp2RE6no_argE,__ZN7pcrecpp6no_argE" \
479                "-i__ZN7pcrecpp6no_argE:__ZN7pcrecpp2RE6no_argE"; do
480      AC_MSG_CHECKING([for alias support in the linker])
481      LDFLAGS="$OLD_LDFLAGS -Wl,$flag"
482      # We try to run the linker with this new ld flag.  If the link fails,
483      # we give up and remove the new flag from LDFLAGS.
484      AC_LINK_IFELSE([AC_LANG_PROGRAM([namespace pcrecpp {
485                                        class RE { static int no_arg; };
486                                        int RE::no_arg;
487                                      }],
488                                     [])],
489                     [AC_MSG_RESULT([yes]);
490                      EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS -Wl,$flag";
491                      break;],
492                     AC_MSG_RESULT([no]))
493    done
494    LDFLAGS="$OLD_LDFLAGS"
495    
496    # We could be more clever here, given we're doing AC_SUBST with this
497    # (eg set a var to be the name of the include file we want). But we're not
498    # so it's easy to change back to 'regular' autoconf vars if we needed to.
499  AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],  AC_CHECK_HEADERS(string, [pcre_have_cpp_headers="1"],
500                           [pcre_have_cpp_headers="0"])                           [pcre_have_cpp_headers="0"])
501  AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],  AC_CHECK_HEADERS(bits/type_traits.h, [pcre_have_bits_type_traits="1"],
502                                       [pcre_have_bits_type_traits="0"])                                       [pcre_have_bits_type_traits="0"])
503  AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],  AC_CHECK_HEADERS(type_traits.h, [pcre_have_type_traits="1"],
504                                  [pcre_have_type_traits="0"])                                  [pcre_have_type_traits="0"])
 dnl Using AC_SUBST eliminates the need to include config.h in a public .h file  
 AC_SUBST(pcre_have_bits_type_traits)  
 AC_SUBST(pcre_have_type_traits)  
 AC_LANG_RESTORE  
 fi  
505    
506  dnl From the above, we now have enough info to know if C++ is fully installed  # (This isn't c++-specific, but is only used in pcrecpp.cc, so try this
507  if test "x$want_cpp" = "xyes" -a -n "$CXX" -a "$pcre_have_cpp_headers" = 1; then  # in a c++ context.  This matters becuase strtoimax is C99 and may not
508    MAYBE_CPP_TARGETS='$(CPP_TARGETS)'  # be supported by the C++ compiler.)
509    HAVE_CPP=  # Figure out how to create a longlong from a string: strtoll and
510    # equiv.  It's not enough to call AC_CHECK_FUNCS: hpux has a
511    # strtoll, for instance, but it only takes 2 args instead of 3!
512    # We have to call AH_TEMPLATE since AC_DEFINE_UNQUOTED below is complex.
513    AH_TEMPLATE(HAVE_STRTOQ, [Define to 1 if you have `strtoq'.])
514    AH_TEMPLATE(HAVE_STRTOLL, [Define to 1 if you have `strtoll'.])
515    AH_TEMPLATE(HAVE__STRTOI64, [Define to 1 if you have `_strtoi64'.])
516    AH_TEMPLATE(HAVE_STRTOIMAX, [Define to 1 if you have `strtoimax'.])
517    have_strto_fn=0
518    for fn in strtoq strtoll _strtoi64 strtoimax; do
519      AC_MSG_CHECKING([for $fn])
520      if test "$fn" = strtoimax; then
521        include=stdint.h
522      else
523        include=stdlib.h
524      fi
525      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <$include>],
526                                        [char* e; return $fn("100", &e, 10)])],
527                        [AC_MSG_RESULT(yes)
528                         AC_DEFINE_UNQUOTED(HAVE_`echo $fn | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`, 1,
529                                            [Define to 1 if you have `$fn'.])
530                         have_strto_fn=1
531                         break],
532                        [AC_MSG_RESULT(no)])
533    done
534    
535    if test "$have_strto_fn" = 1; then
536      AC_CHECK_TYPES([long long],
537                     [pcre_have_long_long="1"],
538                     [pcre_have_long_long="0"])
539      AC_CHECK_TYPES([unsigned long long],
540                     [pcre_have_ulong_long="1"],
541                     [pcre_have_ulong_long="0"])
542  else  else
543    MAYBE_CPP_TARGETS=    pcre_have_long_long="0"
544    HAVE_CPP="#"    pcre_have_ulong_long="0"
545  fi  fi
546  AC_SUBST(MAYBE_CPP_TARGETS)  AC_SUBST(pcre_have_long_long)
547  AC_SUBST(HAVE_CPP)  AC_SUBST(pcre_have_ulong_long)
548    
549    AC_LANG_POP
550    fi
551    # Using AC_SUBST eliminates the need to include config.h in a public .h file
552    AC_SUBST(pcre_have_type_traits)
553    AC_SUBST(pcre_have_bits_type_traits)
554    
555  dnl Checks for typedefs, structures, and compiler characteristics.  # Conditional compilation
556    AM_CONDITIONAL(WITH_PCRE8, test "x$enable_pcre8" = "xyes")
557    AM_CONDITIONAL(WITH_PCRE16, test "x$enable_pcre16" = "xyes")
558    AM_CONDITIONAL(WITH_PCRE32, test "x$enable_pcre32" = "xyes")
559    AM_CONDITIONAL(WITH_PCRE_CPP, test "x$enable_cpp" = "xyes")
560    AM_CONDITIONAL(WITH_REBUILD_CHARTABLES, test "x$enable_rebuild_chartables" = "xyes")
561    AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
562    AM_CONDITIONAL(WITH_UTF, test "x$enable_utf" = "xyes")
563    AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
564    
565    # Checks for typedefs, structures, and compiler characteristics.
566    
567  AC_C_CONST  AC_C_CONST
568  AC_TYPE_SIZE_T  AC_TYPE_SIZE_T
569    
570  AC_CHECK_TYPES([long long], [pcre_have_long_long="1"], [pcre_have_long_long="0"])  # Checks for library functions.
 AC_CHECK_TYPES([unsigned long long], [pcre_have_ulong_long="1"], [pcre_have_ulong_long="0"])  
 AC_SUBST(pcre_have_long_long)  
 AC_SUBST(pcre_have_ulong_long)  
571    
572  dnl Checks for library functions.  AC_CHECK_FUNCS(bcopy memmove strerror)
573    
574  AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll)  # Check for the availability of libz (aka zlib)
575    
576  dnl Handle --enable-utf8  AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
577    AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])
578    
579  AC_ARG_ENABLE(utf8,  # Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
580  [  --enable-utf8           enable UTF8 support],  # as for libz. However, this had the following problem, diagnosed and fixed by
581  if test "$enableval" = "yes"; then  # a user:
582    UTF8=-DSUPPORT_UTF8  #
583    #   - libbz2 uses the Pascal calling convention (WINAPI) for the functions
584    #     under Win32.
585    #   - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
586    #     therefore missing the function definition.
587    #   - The compiler thus generates a "C" signature for the test function.
588    #   - The linker fails to find the "C" function.
589    #   - PCRE fails to configure if asked to do so against libbz2.
590    #
591    # Solution:
592    #
593    #   - Replace the AC_CHECK_LIB test with a custom test.
594    
595    AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
596    # Original test
597    # AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
598    #
599    # Custom test follows
600    
601    AC_MSG_CHECKING([for libbz2])
602    OLD_LIBS="$LIBS"
603    LIBS="$LIBS -lbz2"
604    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
605    #ifdef HAVE_BZLIB_H
606    #include <bzlib.h>
607    #endif]],
608    [[return (int)BZ2_bzopen("conftest", "rb");]])],
609    [AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
610    AC_MSG_RESULT([no]))
611    LIBS="$OLD_LIBS"
612    
613    # Check for the availabiity of libreadline
614    
615    if test "$enable_pcretest_libreadline" = "yes"; then
616     AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])
617     AC_CHECK_HEADERS([readline/history.h], [HAVE_HISTORY_H=1])
618     AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lreadline"],
619       [unset ac_cv_lib_readline_readline;
620        AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltinfo"],
621         [unset ac_cv_lib_readline_readline;
622          AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lcurses"],
623           [unset ac_cv_lib_readline_readline;
624            AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncurses"],
625             [unset ac_cv_lib_readline_readline;
626              AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-lncursesw"],
627               [unset ac_cv_lib_readline_readline;
628                AC_CHECK_LIB([readline], [readline], [LIBREADLINE="-ltermcap"],
629                 [LIBREADLINE=""],
630                 [-ltermcap])],
631               [-lncursesw])],
632             [-lncurses])],
633           [-lcurses])],
634         [-ltinfo])])
635     AC_SUBST(LIBREADLINE)
636     if test -n "$LIBREADLINE"; then
637       if test "$LIBREADLINE" != "-lreadline"; then
638         echo "-lreadline needs $LIBREADLINE"
639         LIBREADLINE="-lreadline $LIBREADLINE"
640       fi
641     fi
642  fi  fi
 )  
643    
 dnl Handle --enable-unicode-properties  
644    
645  AC_ARG_ENABLE(unicode-properties,  # Check for the availability of libedit. Different distributions put its
646  [  --enable-unicode-properties  enable Unicode properties support],  # headers in different places. Try to cover the most common ones.
647  if test "$enableval" = "yes"; then  
648    UCP=-DSUPPORT_UCP  if test "$enable_pcretest_libedit" = "yes"; then
649      AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1],
650        [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1],
651          [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])])
652      AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
653  fi  fi
 )  
654    
655  dnl Handle --enable-newline-is-cr  # This facilitates -ansi builds under Linux
656    dnl AC_DEFINE([_GNU_SOURCE], [], [Enable GNU extensions in glibc])
657    
658  AC_ARG_ENABLE(newline-is-cr,  PCRE_STATIC_CFLAG=""
659  [  --enable-newline-is-cr  use CR as the newline character],  if test "x$enable_shared" = "xno" ; then
660  if test "$enableval" = "yes"; then    AC_DEFINE([PCRE_STATIC], [1], [
661    NEWLINE=-DNEWLINE=13      Define to any value if linking statically (TODO: make nice with Libtool)])
662      PCRE_STATIC_CFLAG="-DPCRE_STATIC"
663  fi  fi
664  )  AC_SUBST(PCRE_STATIC_CFLAG)
665    
666  dnl Handle --enable-newline-is-lf  # Here is where pcre specific defines are handled
667    
668  AC_ARG_ENABLE(newline-is-lf,  if test "$enable_pcre8" = "yes"; then
669  [  --enable-newline-is-lf  use LF as the newline character],    AC_DEFINE([SUPPORT_PCRE8], [], [
670  if test "$enableval" = "yes"; then      Define to any value to enable the 8 bit PCRE library.])
   NEWLINE=-DNEWLINE=10  
671  fi  fi
 )  
672    
673  dnl Handle --enable-newline-is-crlf  if test "$enable_pcre16" = "yes"; then
674      AC_DEFINE([SUPPORT_PCRE16], [], [
675        Define to any value to enable the 16 bit PCRE library.])
676    fi
677    
678  AC_ARG_ENABLE(newline-is-crlf,  if test "$enable_pcre32" = "yes"; then
679  [  --enable-newline-is-crlf  use CRLF as the newline sequence],    AC_DEFINE([SUPPORT_PCRE32], [], [
680  if test "$enableval" = "yes"; then      Define to any value to enable the 32 bit PCRE library.])
   NEWLINE=-DNEWLINE=3338  
681  fi  fi
 )  
682    
683  dnl Handle --enable-newline-is-any  if test "$enable_jit" = "yes"; then
684      AX_PTHREAD([], [AC_MSG_ERROR([JIT support requires pthreads])])
685      CC="$PTHREAD_CC"
686      CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
687      LIBS="$PTHREAD_LIBS $LIBS"
688      AC_DEFINE([SUPPORT_JIT], [], [
689        Define to any value to enable support for Just-In-Time compiling.])
690    else
691      enable_pcregrep_jit="no"
692    fi
693    
694  AC_ARG_ENABLE(newline-is-any,  if test "$enable_pcregrep_jit" = "yes"; then
695  [  --enable-newline-is-any  use any Unicode newline sequence],    AC_DEFINE([SUPPORT_PCREGREP_JIT], [], [
696  if test "$enableval" = "yes"; then      Define to any value to enable JIT support in pcregrep.])
   NEWLINE=-DNEWLINE=-1  
697  fi  fi
 )  
698    
699  dnl Handle --enable-ebcdic  if test "$enable_utf" = "yes"; then
700      AC_DEFINE([SUPPORT_UTF], [], [
701        Define to any value to enable support for the UTF-8/16/32 Unicode encoding.
702        This will work even in an EBCDIC environment, but it is incompatible
703        with the EBCDIC macro. That is, PCRE can support *either* EBCDIC
704        code *or* ASCII/UTF-8/16/32, but not both at once.])
705    fi
706    
707  AC_ARG_ENABLE(ebcdic,  if test "$enable_unicode_properties" = "yes"; then
708  [  --enable-ebcdic         assume EBCDIC coding rather than ASCII],    AC_DEFINE([SUPPORT_UCP], [], [
709  if test "$enableval" = "yes"; then      Define to any value to enable support for Unicode properties.])
   EBCDIC=-DEBCDIC=1  
710  fi  fi
 )  
711    
712  dnl Handle --disable-stack-for-recursion  if test "$enable_stack_for_recursion" = "no"; then
713      AC_DEFINE([NO_RECURSE], [], [
714        PCRE uses recursive function calls to handle backtracking while
715        matching. This can sometimes be a problem on systems that have
716        stacks of limited size. Define NO_RECURSE to any value to get a
717        version that doesn't use recursion in the match() function; instead
718        it creates its own stack by steam using pcre_recurse_malloc() to obtain
719        memory from the heap. For more detail, see the comments and other stuff
720        just above the match() function.])
721    fi
722    
723  AC_ARG_ENABLE(stack-for-recursion,  if test "$enable_pcregrep_libz" = "yes"; then
724  [  --disable-stack-for-recursion  disable use of stack recursion when matching],    AC_DEFINE([SUPPORT_LIBZ], [], [
725  if test "$enableval" = "no"; then      Define to any value to allow pcregrep to be linked with libz, so that it is
726    NO_RECURSE=-DNO_RECURSE      able to handle .gz files.])
727    fi
728    
729    if test "$enable_pcregrep_libbz2" = "yes"; then
730      AC_DEFINE([SUPPORT_LIBBZ2], [], [
731        Define to any value to allow pcregrep to be linked with libbz2, so that it
732        is able to handle .bz2 files.])
733  fi  fi
 )  
734    
735  dnl There doesn't seem to be a straightforward way of having parameters  if test $with_pcregrep_bufsize -lt 8192 ; then
736  dnl that set values, other than fudging the --with thing. So that's what    with_pcregrep_bufsize="8192"
737  dnl I've done.  fi
738    
739  dnl Handle --with-posix-malloc-threshold=n  AC_DEFINE_UNQUOTED([PCREGREP_BUFSIZE], [$with_pcregrep_bufsize], [
740      The value of PCREGREP_BUFSIZE determines the size of buffer used by pcregrep
741      to hold parts of the file it is searching. This is also the minimum value.
742      The actual amount of memory used by pcregrep is three times this number,
743      because it allows for the buffering of "before" and "after" lines.])
744    
745    if test "$enable_pcretest_libedit" = "yes"; then
746      AC_DEFINE([SUPPORT_LIBEDIT], [], [
747        Define to any value to allow pcretest to be linked with libedit.])
748      LIBREADLINE="$LIBEDIT"
749    elif test "$enable_pcretest_libreadline" = "yes"; then
750      AC_DEFINE([SUPPORT_LIBREADLINE], [], [
751        Define to any value to allow pcretest to be linked with libreadline.])
752    fi
753    
754  AC_ARG_WITH(posix-malloc-threshold,  AC_DEFINE_UNQUOTED([NEWLINE], [$ac_pcre_newline_value], [
755  [  --with-posix-malloc-threshold=10  threshold for POSIX malloc usage],    The value of NEWLINE determines the default newline character sequence. PCRE
756    POSIX_MALLOC_THRESHOLD=-DPOSIX_MALLOC_THRESHOLD=$withval    client programs can override this by selecting other values at run time. In
757  )    ASCII environments, the value can be 10 (LF), 13 (CR), or 3338 (CRLF); in
758      EBCDIC environments the value can be 21 or 37 (LF), 13 (CR), or 3349 or 3365
759      (CRLF) because there are two alternative codepoints (0x15 and 0x25) that are
760      used as the NL line terminator that is equivalent to ASCII LF. In both ASCII
761      and EBCDIC environments the value can also be -1 (ANY), or -2 (ANYCRLF).])
762    
763    if test "$enable_bsr_anycrlf" = "yes"; then
764      AC_DEFINE([BSR_ANYCRLF], [], [
765        By default, the \R escape sequence matches any Unicode line ending
766        character or sequence of characters. If BSR_ANYCRLF is defined (to any
767        value), this is changed so that backslash-R matches only CR, LF, or CRLF.
768        The build-time default can be overridden by the user of PCRE at runtime.])
769    fi
770    
771  dnl Handle --with-link-size=n  AC_DEFINE_UNQUOTED([LINK_SIZE], [$with_link_size], [
772      The value of LINK_SIZE determines the number of bytes used to store
773      links as offsets within the compiled regex. The default is 2, which
774      allows for compiled patterns up to 64K long. This covers the vast
775      majority of cases. However, PCRE can also be compiled to use 3 or 4
776      bytes instead. This allows for longer patterns in extreme cases.])
777    
778    AC_DEFINE_UNQUOTED([POSIX_MALLOC_THRESHOLD], [$with_posix_malloc_threshold], [
779      When calling PCRE via the POSIX interface, additional working storage
780      is required for holding the pointers to capturing substrings because
781      PCRE requires three integers per substring, whereas the POSIX
782      interface provides only two. If the number of expected substrings is
783      small, the wrapper function uses space on the stack, because this is
784      faster than using malloc() for each call. The threshold above which
785      the stack is no longer used is defined by POSIX_MALLOC_THRESHOLD.])
786    
787    AC_DEFINE_UNQUOTED([MATCH_LIMIT], [$with_match_limit], [
788      The value of MATCH_LIMIT determines the default number of times the
789      internal match() function can be called during a single execution of
790      pcre_exec(). There is a runtime interface for setting a different
791      limit. The limit exists in order to catch runaway regular
792      expressions that take for ever to determine that they do not match.
793      The default is set very large so that it does not accidentally catch
794      legitimate cases.])
795    
796    AC_DEFINE_UNQUOTED([MATCH_LIMIT_RECURSION], [$with_match_limit_recursion], [
797      The above limit applies to all calls of match(), whether or not they
798      increase the recursion depth. In some environments it is desirable
799      to limit the depth of recursive calls of match() more strictly, in
800      order to restrict the maximum amount of stack (or heap, if
801      NO_RECURSE is defined) that is used. The value of
802      MATCH_LIMIT_RECURSION applies only to recursive calls of match(). To
803      have any useful effect, it must be less than the value of
804      MATCH_LIMIT. The default is to use the same value as MATCH_LIMIT.
805      There is a runtime method for setting a different limit.])
806    
807    AC_DEFINE([MAX_NAME_SIZE], [32], [
808      This limit is parameterized just in case anybody ever wants to
809      change it. Care must be taken if it is increased, because it guards
810      against integer overflow caused by enormously large patterns.])
811    
812    AC_DEFINE([MAX_NAME_COUNT], [10000], [
813      This limit is parameterized just in case anybody ever wants to
814      change it. Care must be taken if it is increased, because it guards
815      against integer overflow caused by enormously large patterns.])
816    
817    AH_VERBATIM([PCRE_EXP_DEFN], [
818    /* If you are compiling for a system other than a Unix-like system or
819       Win32, and it needs some magic to be inserted before the definition
820       of a function that is exported by the library, define this macro to
821       contain the relevant magic. If you do not define this macro, a suitable
822        __declspec value is used for Windows systems; in other environments
823       "extern" is used for a C compiler and "extern C" for a C++ compiler.
824       This macro apears at the start of every exported function that is part
825       of the external API. It does not appear on functions that are "external"
826       in the C sense, but which are internal to the library. */
827    #undef PCRE_EXP_DEFN])
828    
829    if test "$enable_ebcdic" = "yes"; then
830      AC_DEFINE_UNQUOTED([EBCDIC], [], [
831        If you are compiling for a system that uses EBCDIC instead of ASCII
832        character codes, define this macro to any value. You must also edit the
833        NEWLINE macro below to set a suitable EBCDIC newline, commonly 21 (0x15).
834        On systems that can use "configure" or CMake to set EBCDIC, NEWLINE is
835        automatically adjusted. When EBCDIC is set, PCRE assumes that all input
836        strings are in EBCDIC. If you do not define this macro, PCRE will assume
837        input strings are ASCII or UTF-8/16/32 Unicode. It is not possible to build
838        a version of PCRE that supports both EBCDIC and UTF-8/16/32.])
839    fi
840    
841  AC_ARG_WITH(link-size,  if test "$enable_ebcdic_nl25" = "yes"; then
842  [  --with-link-size=2    internal link size (2, 3, or 4 allowed)],    AC_DEFINE_UNQUOTED([EBCDIC_NL25], [], [
843    LINK_SIZE=-DLINK_SIZE=$withval      In an EBCDIC environment, define this macro to any value to arrange for
844  )      the NL character to be 0x25 instead of the default 0x15. NL plays the role
845        that LF does in an ASCII/Unicode environment. The value must also be set in
846        the NEWLINE macro below. On systems that can use "configure" or CMake to
847        set EBCDIC_NL25, the adjustment of NEWLINE is automatic.])
848    fi
849    
850  dnl Handle --with-match-limit=n  if test "$enable_valgrind" = "yes"; then
851      AC_DEFINE_UNQUOTED([SUPPORT_VALGRIND], [], [
852         Define to any value for valgrind support to find invalid memory reads.])
853    fi
854    
855  AC_ARG_WITH(match-limit,  # Platform specific issues
856  [  --with-match-limit=10000000  default limit on internal looping],  NO_UNDEFINED=
857    MATCH_LIMIT=-DMATCH_LIMIT=$withval  EXPORT_ALL_SYMBOLS=
858  )  case $host_os in
859      cygwin* | mingw* )
860        if test X"$enable_shared" = Xyes; then
861          NO_UNDEFINED="-no-undefined"
862          EXPORT_ALL_SYMBOLS="-Wl,--export-all-symbols"
863        fi
864        ;;
865    esac
866    
867  dnl Handle --with-match-limit_recursion=n  # The extra LDFLAGS for each particular library
868    # (Note: The libpcre*_version bits are m4 variables, assigned above)
869    
870  AC_ARG_WITH(match-limit-recursion,  EXTRA_LIBPCRE_LDFLAGS="$EXTRA_LIBPCRE_LDFLAGS \
871  [  --with-match-limit-recursion=10000000  default limit on internal recursion],                         $NO_UNDEFINED -version-info libpcre_version"
   MATCH_LIMIT_RECURSION=-DMATCH_LIMIT_RECURSION=$withval  
 )  
872    
873  dnl Unicode character property support implies UTF-8 support  EXTRA_LIBPCRE16_LDFLAGS="$EXTRA_LIBPCRE16_LDFLAGS \
874                           $NO_UNDEFINED -version-info libpcre16_version"
875    
876  if test "$UCP" != "" ; then  EXTRA_LIBPCRE32_LDFLAGS="$EXTRA_LIBPCRE32_LDFLAGS \
877    UTF8=-DSUPPORT_UTF8                         $NO_UNDEFINED -version-info libpcre32_version"
878    
879    EXTRA_LIBPCREPOSIX_LDFLAGS="$EXTRA_LIBPCREPOSIX_LDFLAGS \
880                                $NO_UNDEFINED -version-info libpcreposix_version"
881    
882    EXTRA_LIBPCRECPP_LDFLAGS="$EXTRA_LIBPCRECPP_LDFLAGS \
883                              $NO_UNDEFINED -version-info libpcrecpp_version \
884                              $EXPORT_ALL_SYMBOLS"
885    
886    AC_SUBST(EXTRA_LIBPCRE_LDFLAGS)
887    AC_SUBST(EXTRA_LIBPCRE16_LDFLAGS)
888    AC_SUBST(EXTRA_LIBPCRE32_LDFLAGS)
889    AC_SUBST(EXTRA_LIBPCREPOSIX_LDFLAGS)
890    AC_SUBST(EXTRA_LIBPCRECPP_LDFLAGS)
891    
892    # When we run 'make distcheck', use these arguments. Turning off compiler
893    # optimization makes it run faster.
894    DISTCHECK_CONFIGURE_FLAGS="CFLAGS='' CXXFLAGS='' --enable-pcre16 --enable-pcre32 --enable-jit --enable-cpp --enable-unicode-properties"
895    AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
896    
897    # Check that, if --enable-pcregrep-libz or --enable-pcregrep-libbz2 is
898    # specified, the relevant library is available.
899    
900    if test "$enable_pcregrep_libz" = "yes"; then
901      if test "$HAVE_ZLIB_H" != "1"; then
902        echo "** Cannot --enable-pcregrep-libz because zlib.h was not found"
903        exit 1
904      fi
905      if test "$HAVE_LIBZ" != "1"; then
906        echo "** Cannot --enable-pcregrep-libz because libz was not found"
907        exit 1
908      fi
909      LIBZ="-lz"
910  fi  fi
911    AC_SUBST(LIBZ)
912    
913  dnl "Export" these variables  if test "$enable_pcregrep_libbz2" = "yes"; then
914      if test "$HAVE_BZLIB_H" != "1"; then
915        echo "** Cannot --enable-pcregrep-libbz2 because bzlib.h was not found"
916        exit 1
917      fi
918      if test "$HAVE_LIBBZ2" != "1"; then
919        echo "** Cannot --enable-pcregrep-libbz2 because libbz2 was not found"
920        exit 1
921      fi
922      LIBBZ2="-lbz2"
923    fi
924    AC_SUBST(LIBBZ2)
925    
926  AC_SUBST(BUILD_EXEEXT)  # Similarly for --enable-pcretest-readline
 AC_SUBST(BUILD_OBJEXT)  
 AC_SUBST(CC_FOR_BUILD)  
 AC_SUBST(CXX_FOR_BUILD)  
 AC_SUBST(CFLAGS_FOR_BUILD)  
 AC_SUBST(CXXFLAGS_FOR_BUILD)  
 AC_SUBST(CXXLDFLAGS)  
 AC_SUBST(EBCDIC)  
 AC_SUBST(HAVE_MEMMOVE)  
 AC_SUBST(HAVE_STRERROR)  
 AC_SUBST(LINK_SIZE)  
 AC_SUBST(MATCH_LIMIT)  
 AC_SUBST(MATCH_LIMIT_RECURSION)  
 AC_SUBST(NEWLINE)  
 AC_SUBST(NO_RECURSE)  
 AC_SUBST(PCRE_LIB_VERSION)  
 AC_SUBST(PCRE_POSIXLIB_VERSION)  
 AC_SUBST(PCRE_CPPLIB_VERSION)  
 AC_SUBST(PCRE_VERSION)  
 AC_SUBST(POSIX_MALLOC_THRESHOLD)  
 AC_SUBST(UCP)  
 AC_SUBST(UTF8)  
927    
928  dnl Stuff to make MinGW work better. Special treatment is no longer  if test "$enable_pcretest_libedit" = "yes"; then
929  dnl needed for Cygwin.    if test "$enable_pcretest_libreadline" = "yes"; then
930        echo "** Cannot use both --enable-pcretest-libedit and --enable-pcretest-readline"
931        exit 1
932      fi
933      if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \
934              "$HAVE_READLINE_READLINE_H" != "1"; then
935        echo "** Cannot --enable-pcretest-libedit because neither editline/readline.h"
936        echo "** nor readline/readline.h was found."
937        exit 1
938      fi
939      if test -z "$LIBEDIT"; then
940        echo "** Cannot --enable-pcretest-libedit because libedit library was not found."
941        exit 1
942      fi
943    fi
944    
945  case $host_os in  if test "$enable_pcretest_libreadline" = "yes"; then
946  mingw* )    if test "$HAVE_READLINE_H" != "1"; then
947      POSIX_OBJ=pcreposix.o      echo "** Cannot --enable-pcretest-readline because readline/readline.h was not found."
948      POSIX_LOBJ=pcreposix.lo      exit 1
949      POSIX_LIB=    fi
950      ON_WINDOWS=    if test "$HAVE_HISTORY_H" != "1"; then
951      NOT_ON_WINDOWS="#"      echo "** Cannot --enable-pcretest-readline because readline/history.h was not found."
952      WIN_PREFIX=      exit 1
953      ;;    fi
954  * )    if test -z "$LIBREADLINE"; then
955      ON_WINDOWS="#"      echo "** Cannot --enable-pcretest-readline because readline library was not found."
956      NOT_ON_WINDOWS=      exit 1
957      POSIX_OBJ=    fi
958      POSIX_LOBJ=  fi
     POSIX_LIB=libpcreposix.la  
     WIN_PREFIX=  
     ;;  
 esac  
 AC_SUBST(WIN_PREFIX)  
 AC_SUBST(ON_WINDOWS)  
 AC_SUBST(NOT_ON_WINDOWS)  
 AC_SUBST(POSIX_OBJ)  
 AC_SUBST(POSIX_LOBJ)  
 AC_SUBST(POSIX_LIB)  
959    
960  if test "x$enable_shared" = "xno" ; then  # Check for valgrind
961      AC_DEFINE([PCRE_STATIC],[1],[to link statically])  
962    if test "$enable_valgrind" = "yes"; then
963      m4_ifdef([PKG_CHECK_MODULES],
964               [PKG_CHECK_MODULES([VALGRIND],[valgrind])],
965               [AC_MSG_ERROR([pkg-config not supported])])
966  fi  fi
967    
968  dnl This must be last; it determines what files are written as well as config.h  # test code coverage reporting
969  AC_OUTPUT(Makefile pcre-config:pcre-config.in libpcre.pc:libpcre.pc.in libpcrecpp.pc:libpcrecpp.pc.in pcrecpparg.h:pcrecpparg.h.in pcre_stringpiece.h:pcre_stringpiece.h.in RunGrepTest:RunGrepTest.in RunTest:RunTest.in,[chmod a+x RunTest RunGrepTest pcre-config])  if test "$enable_coverage" = "yes"; then
970      if test "x$GCC" != "xyes"; then
971        AC_MSG_ERROR([Code coverage reports can only be generated when using GCC])
972      fi
973    
974      # ccache is incompatible with gcov
975      AC_PATH_PROG([SHTOOL],[shtool],[false])
976      case `$SHTOOL path $CC` in
977        *ccache*) cc_ccache=yes;;
978        *) cc_ccache=no;;
979      esac
980    
981      if test "$cc_ccache" = "yes"; then
982        if test -z "$CCACHE_DISABLE" -o "$CCACHE_DISABLE" != "1"; then
983          AC_MSG_ERROR([must export CCACHE_DISABLE=1 to disable ccache for code coverage])
984        fi
985      fi
986    
987      AC_ARG_VAR([LCOV],[the ltp lcov program])
988      AC_PATH_PROG([LCOV],[lcov],[false])
989      if test "x$LCOV" = "xfalse"; then
990        AC_MSG_ERROR([lcov not found])
991      fi
992    
993      AC_ARG_VAR([GENHTML],[the ltp genhtml program])
994      AC_PATH_PROG([GENHTML],[genhtml],[false])
995      if test "x$GENHTML" = "xfalse"; then
996        AC_MSG_ERROR([genhtml not found])
997      fi
998    
999      AC_DEFINE([SUPPORT_GCOV],[1], [
1000        Define to allow pcretest and pcregrep to be linked with gcov, so that they
1001        are able to generate code coverage reports.])
1002    
1003      # And add flags needed for gcov
1004      GCOV_CFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1005      GCOV_CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
1006      GCOV_LIBS="-lgcov"
1007      AC_SUBST([GCOV_CFLAGS])
1008      AC_SUBST([GCOV_CXXFLAGS])
1009      AC_SUBST([GCOV_LIBS])
1010    fi # enable_coverage
1011    
1012    AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
1013    
1014    # Produce these files, in addition to config.h.
1015    AC_CONFIG_FILES(
1016            Makefile
1017            libpcre.pc
1018            libpcre16.pc
1019            libpcre32.pc
1020            libpcreposix.pc
1021            libpcrecpp.pc
1022            pcre-config
1023            pcre.h
1024            pcre_stringpiece.h
1025            pcrecpparg.h
1026    )
1027    
1028    # Make the generated script files executable.
1029    AC_CONFIG_COMMANDS([script-chmod], [chmod a+x pcre-config])
1030    
1031    # Make sure that pcre_chartables.c is removed in case the method for
1032    # creating it was changed by reconfiguration.
1033    AC_CONFIG_COMMANDS([delete-old-chartables], [rm -f pcre_chartables.c])
1034    
1035    AC_OUTPUT
1036    
1037    # Print out a nice little message after configure is run displaying the
1038    # chosen options.
1039    
1040    ebcdic_nl_code=n/a
1041    if test "$enable_ebcdic_nl25" = "yes"; then
1042      ebcdic_nl_code=0x25
1043    elif test "$enable_ebcdic" = "yes"; then
1044      ebcdic_nl_code=0x15
1045    fi
1046    
1047    cat <<EOF
1048    
1049    $PACKAGE-$VERSION configuration summary:
1050    
1051        Install prefix .................. : ${prefix}
1052        C preprocessor .................. : ${CPP}
1053        C compiler ...................... : ${CC}
1054        C++ preprocessor ................ : ${CXXCPP}
1055        C++ compiler .................... : ${CXX}
1056        Linker .......................... : ${LD}
1057        C preprocessor flags ............ : ${CPPFLAGS}
1058        C compiler flags ................ : ${CFLAGS} ${VISIBILITY_CFLAGS}
1059        C++ compiler flags .............. : ${CXXFLAGS} ${VISIBILITY_CXXFLAGS}
1060        Linker flags .................... : ${LDFLAGS}
1061        Extra libraries ................. : ${LIBS}
1062    
1063        Build 8 bit pcre library ........ : ${enable_pcre8}
1064        Build 16 bit pcre library ....... : ${enable_pcre16}
1065        Build 32 bit pcre library ....... : ${enable_pcre32}
1066        Build C++ library ............... : ${enable_cpp}
1067        Enable JIT compiling support .... : ${enable_jit}
1068        Enable UTF-8/16/32 support ...... : ${enable_utf}
1069        Unicode properties .............. : ${enable_unicode_properties}
1070        Newline char/sequence ........... : ${enable_newline}
1071        \R matches only ANYCRLF ......... : ${enable_bsr_anycrlf}
1072        EBCDIC coding ................... : ${enable_ebcdic}
1073        EBCDIC code for NL .............. : ${ebcdic_nl_code}
1074        Rebuild char tables ............. : ${enable_rebuild_chartables}
1075        Use stack recursion ............. : ${enable_stack_for_recursion}
1076        POSIX mem threshold ............. : ${with_posix_malloc_threshold}
1077        Internal link size .............. : ${with_link_size}
1078        Match limit ..................... : ${with_match_limit}
1079        Match limit recursion ........... : ${with_match_limit_recursion}
1080        Build shared libs ............... : ${enable_shared}
1081        Build static libs ............... : ${enable_static}
1082        Use JIT in pcregrep ............. : ${enable_pcregrep_jit}
1083        Buffer size for pcregrep ........ : ${with_pcregrep_bufsize}
1084        Link pcregrep with libz ......... : ${enable_pcregrep_libz}
1085        Link pcregrep with libbz2 ....... : ${enable_pcregrep_libbz2}
1086        Link pcretest with libedit ...... : ${enable_pcretest_libedit}
1087        Link pcretest with libreadline .. : ${enable_pcretest_libreadline}
1088        Valgrind support ................ : ${enable_valgrind}
1089        Code coverage ................... : ${enable_coverage}
1090    
1091    EOF
1092    
1093    dnl end configure.ac

Legend:
Removed from v.93  
changed lines
  Added in v.1320

  ViewVC Help
Powered by ViewVC 1.1.5