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

Contents of /code/trunk/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:eol-style native
svn:keywords "Author Date Id Revision Url"

  ViewVC Help
Powered by ViewVC 1.1.5