/[pcre]/code/trunk/doc/pcrebuild.3
ViewVC logotype

Contents of /code/trunk/doc/pcrebuild.3

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1221 - (show annotations)
Sun Nov 11 20:27:03 2012 UTC (7 years ago) by ph10
File size: 18876 byte(s)
File tidies, preparing for 8.32-RC1.
1 .TH PCREBUILD 3 "30 October 2012" "PCRE 8.32"
2 .SH NAME
3 PCRE - Perl-compatible regular expressions
4 .
5 .
6 .SH "PCRE BUILD-TIME OPTIONS"
7 .rs
8 .sp
9 This document describes the optional features of PCRE that can be selected when
10 the library is compiled. It assumes use of the \fBconfigure\fP script, where
11 the optional features are selected or deselected by providing options to
12 \fBconfigure\fP before running the \fBmake\fP command. However, the same
13 options can be selected in both Unix-like and non-Unix-like environments using
14 the GUI facility of \fBcmake-gui\fP if you are using \fBCMake\fP instead of
15 \fBconfigure\fP to build PCRE.
16 .P
17 There is a lot more information about building PCRE without using
18 \fBconfigure\fP (including information about using \fBCMake\fP or building "by
19 hand") in the file called \fINON-AUTOTOOLS-BUILD\fP, which is part of the PCRE
20 distribution. You should consult this file as well as the \fIREADME\fP file if
21 you are building in a non-Unix-like environment.
22 .P
23 The complete list of options for \fBconfigure\fP (which includes the standard
24 ones such as the selection of the installation directory) can be obtained by
25 running
26 .sp
27 ./configure --help
28 .sp
29 The following sections include descriptions of options whose names begin with
30 --enable or --disable. These settings specify changes to the defaults for the
31 \fBconfigure\fP command. Because of the way that \fBconfigure\fP works,
32 --enable and --disable always come in pairs, so the complementary option always
33 exists as well, but as it specifies the default, it is not described.
34 .
35 .
36 .SH "BUILDING 8-BIT, 16-BIT AND 32-BIT LIBRARIES"
37 .rs
38 .sp
39 By default, a library called \fBlibpcre\fP is built, containing functions that
40 take string arguments contained in vectors of bytes, either as single-byte
41 characters, or interpreted as UTF-8 strings. You can also build a separate
42 library, called \fBlibpcre16\fP, in which strings are contained in vectors of
43 16-bit data units and interpreted either as single-unit characters or UTF-16
44 strings, by adding
45 .sp
46 --enable-pcre16
47 .sp
48 to the \fBconfigure\fP command. You can also build a separate
49 library, called \fBlibpcre32\fP, in which strings are contained in vectors of
50 32-bit data units and interpreted either as single-unit characters or UTF-32
51 strings, by adding
52 .sp
53 --enable-pcre32
54 .sp
55 to the \fBconfigure\fP command. If you do not want the 8-bit library, add
56 .sp
57 --disable-pcre8
58 .sp
59 as well. At least one of the three libraries must be built. Note that the C++
60 and POSIX wrappers are for the 8-bit library only, and that \fBpcregrep\fP is
61 an 8-bit program. None of these are built if you select only the 16-bit or
62 32-bit libraries.
63 .
64 .
65 .SH "BUILDING SHARED AND STATIC LIBRARIES"
66 .rs
67 .sp
68 The PCRE building process uses \fBlibtool\fP to build both shared and static
69 Unix libraries by default. You can suppress one of these by adding one of
70 .sp
71 --disable-shared
72 --disable-static
73 .sp
74 to the \fBconfigure\fP command, as required.
75 .
76 .
77 .SH "C++ SUPPORT"
78 .rs
79 .sp
80 By default, if the 8-bit library is being built, the \fBconfigure\fP script
81 will search for a C++ compiler and C++ header files. If it finds them, it
82 automatically builds the C++ wrapper library (which supports only 8-bit
83 strings). You can disable this by adding
84 .sp
85 --disable-cpp
86 .sp
87 to the \fBconfigure\fP command.
88 .
89 .
90 .SH "UTF-8, UTF-16 AND UTF-32 SUPPORT"
91 .rs
92 .sp
93 To build PCRE with support for UTF Unicode character strings, add
94 .sp
95 --enable-utf
96 .sp
97 to the \fBconfigure\fP command. This setting applies to all three libraries,
98 adding support for UTF-8 to the 8-bit library, support for UTF-16 to the 16-bit
99 library, and support for UTF-32 to the to the 32-bit library. There are no
100 separate options for enabling UTF-8, UTF-16 and UTF-32 independently because
101 that would allow ridiculous settings such as requesting UTF-16 support while
102 building only the 8-bit library. It is not possible to build one library with
103 UTF support and another without in the same configuration. (For backwards
104 compatibility, --enable-utf8 is a synonym of --enable-utf.)
105 .P
106 Of itself, this setting does not make PCRE treat strings as UTF-8, UTF-16 or
107 UTF-32. As well as compiling PCRE with this option, you also have have to set
108 the PCRE_UTF8, PCRE_UTF16 or PCRE_UTF32 option (as appropriate) when you call
109 one of the pattern compiling functions.
110 .P
111 If you set --enable-utf when compiling in an EBCDIC environment, PCRE expects
112 its input to be either ASCII or UTF-8 (depending on the run-time option). It is
113 not possible to support both EBCDIC and UTF-8 codes in the same version of the
114 library. Consequently, --enable-utf and --enable-ebcdic are mutually
115 exclusive.
116 .
117 .
118 .SH "UNICODE CHARACTER PROPERTY SUPPORT"
119 .rs
120 .sp
121 UTF support allows the libraries to process character codepoints up to 0x10ffff
122 in the strings that they handle. On its own, however, it does not provide any
123 facilities for accessing the properties of such characters. If you want to be
124 able to use the pattern escapes \eP, \ep, and \eX, which refer to Unicode
125 character properties, you must add
126 .sp
127 --enable-unicode-properties
128 .sp
129 to the \fBconfigure\fP command. This implies UTF support, even if you have
130 not explicitly requested it.
131 .P
132 Including Unicode property support adds around 30K of tables to the PCRE
133 library. Only the general category properties such as \fILu\fP and \fINd\fP are
134 supported. Details are given in the
135 .\" HREF
136 \fBpcrepattern\fP
137 .\"
138 documentation.
139 .
140 .
141 .SH "JUST-IN-TIME COMPILER SUPPORT"
142 .rs
143 .sp
144 Just-in-time compiler support is included in the build by specifying
145 .sp
146 --enable-jit
147 .sp
148 This support is available only for certain hardware architectures. If this
149 option is set for an unsupported architecture, a compile time error occurs.
150 See the
151 .\" HREF
152 \fBpcrejit\fP
153 .\"
154 documentation for a discussion of JIT usage. When JIT support is enabled,
155 pcregrep automatically makes use of it, unless you add
156 .sp
157 --disable-pcregrep-jit
158 .sp
159 to the "configure" command.
160 .
161 .
162 .SH "CODE VALUE OF NEWLINE"
163 .rs
164 .sp
165 By default, PCRE interprets the linefeed (LF) character as indicating the end
166 of a line. This is the normal newline character on Unix-like systems. You can
167 compile PCRE to use carriage return (CR) instead, by adding
168 .sp
169 --enable-newline-is-cr
170 .sp
171 to the \fBconfigure\fP command. There is also a --enable-newline-is-lf option,
172 which explicitly specifies linefeed as the newline character.
173 .sp
174 Alternatively, you can specify that line endings are to be indicated by the two
175 character sequence CRLF. If you want this, add
176 .sp
177 --enable-newline-is-crlf
178 .sp
179 to the \fBconfigure\fP command. There is a fourth option, specified by
180 .sp
181 --enable-newline-is-anycrlf
182 .sp
183 which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
184 indicating a line ending. Finally, a fifth option, specified by
185 .sp
186 --enable-newline-is-any
187 .sp
188 causes PCRE to recognize any Unicode newline sequence.
189 .P
190 Whatever line ending convention is selected when PCRE is built can be
191 overridden when the library functions are called. At build time it is
192 conventional to use the standard for your operating system.
193 .
194 .
195 .SH "WHAT \eR MATCHES"
196 .rs
197 .sp
198 By default, the sequence \eR in a pattern matches any Unicode newline sequence,
199 whatever has been selected as the line ending sequence. If you specify
200 .sp
201 --enable-bsr-anycrlf
202 .sp
203 the default is changed so that \eR matches only CR, LF, or CRLF. Whatever is
204 selected when PCRE is built can be overridden when the library functions are
205 called.
206 .
207 .
208 .SH "POSIX MALLOC USAGE"
209 .rs
210 .sp
211 When the 8-bit library is called through the POSIX interface (see the
212 .\" HREF
213 \fBpcreposix\fP
214 .\"
215 documentation), additional working storage is required for holding the pointers
216 to capturing substrings, because PCRE requires three integers per substring,
217 whereas the POSIX interface provides only two. If the number of expected
218 substrings is small, the wrapper function uses space on the stack, because this
219 is faster than using \fBmalloc()\fP for each call. The default threshold above
220 which the stack is no longer used is 10; it can be changed by adding a setting
221 such as
222 .sp
223 --with-posix-malloc-threshold=20
224 .sp
225 to the \fBconfigure\fP command.
226 .
227 .
228 .SH "HANDLING VERY LARGE PATTERNS"
229 .rs
230 .sp
231 Within a compiled pattern, offset values are used to point from one part to
232 another (for example, from an opening parenthesis to an alternation
233 metacharacter). By default, in the 8-bit and 16-bit libraries, two-byte values
234 are used for these offsets, leading to a maximum size for a compiled pattern of
235 around 64K. This is sufficient to handle all but the most gigantic patterns.
236 Nevertheless, some people do want to process truly enormous patterns, so it is
237 possible to compile PCRE to use three-byte or four-byte offsets by adding a
238 setting such as
239 .sp
240 --with-link-size=3
241 .sp
242 to the \fBconfigure\fP command. The value given must be 2, 3, or 4. For the
243 16-bit library, a value of 3 is rounded up to 4. In these libraries, using
244 longer offsets slows down the operation of PCRE because it has to load
245 additional data when handling them. For the 32-bit library the value is always
246 4 and cannot be overridden; the value of --with-link-size is ignored.
247 .
248 .
249 .SH "AVOIDING EXCESSIVE STACK USAGE"
250 .rs
251 .sp
252 When matching with the \fBpcre_exec()\fP function, PCRE implements backtracking
253 by making recursive calls to an internal function called \fBmatch()\fP. In
254 environments where the size of the stack is limited, this can severely limit
255 PCRE's operation. (The Unix environment does not usually suffer from this
256 problem, but it may sometimes be necessary to increase the maximum stack size.
257 There is a discussion in the
258 .\" HREF
259 \fBpcrestack\fP
260 .\"
261 documentation.) An alternative approach to recursion that uses memory from the
262 heap to remember data, instead of using recursive function calls, has been
263 implemented to work round the problem of limited stack size. If you want to
264 build a version of PCRE that works this way, add
265 .sp
266 --disable-stack-for-recursion
267 .sp
268 to the \fBconfigure\fP command. With this configuration, PCRE will use the
269 \fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP variables to call memory
270 management functions. By default these point to \fBmalloc()\fP and
271 \fBfree()\fP, but you can replace the pointers so that your own functions are
272 used instead.
273 .P
274 Separate functions are provided rather than using \fBpcre_malloc\fP and
275 \fBpcre_free\fP because the usage is very predictable: the block sizes
276 requested are always the same, and the blocks are always freed in reverse
277 order. A calling program might be able to implement optimized functions that
278 perform better than \fBmalloc()\fP and \fBfree()\fP. PCRE runs noticeably more
279 slowly when built in this way. This option affects only the \fBpcre_exec()\fP
280 function; it is not relevant for \fBpcre_dfa_exec()\fP.
281 .
282 .
283 .SH "LIMITING PCRE RESOURCE USAGE"
284 .rs
285 .sp
286 Internally, PCRE has a function called \fBmatch()\fP, which it calls repeatedly
287 (sometimes recursively) when matching a pattern with the \fBpcre_exec()\fP
288 function. By controlling the maximum number of times this function may be
289 called during a single matching operation, a limit can be placed on the
290 resources used by a single call to \fBpcre_exec()\fP. The limit can be changed
291 at run time, as described in the
292 .\" HREF
293 \fBpcreapi\fP
294 .\"
295 documentation. The default is 10 million, but this can be changed by adding a
296 setting such as
297 .sp
298 --with-match-limit=500000
299 .sp
300 to the \fBconfigure\fP command. This setting has no effect on the
301 \fBpcre_dfa_exec()\fP matching function.
302 .P
303 In some environments it is desirable to limit the depth of recursive calls of
304 \fBmatch()\fP more strictly than the total number of calls, in order to
305 restrict the maximum amount of stack (or heap, if --disable-stack-for-recursion
306 is specified) that is used. A second limit controls this; it defaults to the
307 value that is set for --with-match-limit, which imposes no additional
308 constraints. However, you can set a lower limit by adding, for example,
309 .sp
310 --with-match-limit-recursion=10000
311 .sp
312 to the \fBconfigure\fP command. This value can also be overridden at run time.
313 .
314 .
315 .SH "CREATING CHARACTER TABLES AT BUILD TIME"
316 .rs
317 .sp
318 PCRE uses fixed tables for processing characters whose code values are less
319 than 256. By default, PCRE is built with a set of tables that are distributed
320 in the file \fIpcre_chartables.c.dist\fP. These tables are for ASCII codes
321 only. If you add
322 .sp
323 --enable-rebuild-chartables
324 .sp
325 to the \fBconfigure\fP command, the distributed tables are no longer used.
326 Instead, a program called \fBdftables\fP is compiled and run. This outputs the
327 source for new set of tables, created in the default locale of your C run-time
328 system. (This method of replacing the tables does not work if you are cross
329 compiling, because \fBdftables\fP is run on the local host. If you need to
330 create alternative tables when cross compiling, you will have to do so "by
331 hand".)
332 .
333 .
334 .SH "USING EBCDIC CODE"
335 .rs
336 .sp
337 PCRE assumes by default that it will run in an environment where the character
338 code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
339 most computer operating systems. PCRE can, however, be compiled to run in an
340 EBCDIC environment by adding
341 .sp
342 --enable-ebcdic
343 .sp
344 to the \fBconfigure\fP command. This setting implies
345 --enable-rebuild-chartables. You should only use it if you know that you are in
346 an EBCDIC environment (for example, an IBM mainframe operating system). The
347 --enable-ebcdic option is incompatible with --enable-utf.
348 .P
349 The EBCDIC character that corresponds to an ASCII LF is assumed to have the
350 value 0x15 by default. However, in some EBCDIC environments, 0x25 is used. In
351 such an environment you should use
352 .sp
353 --enable-ebcdic-nl25
354 .sp
355 as well as, or instead of, --enable-ebcdic. The EBCDIC character for CR has the
356 same value as in ASCII, namely, 0x0d. Whichever of 0x15 and 0x25 is \fInot\fP
357 chosen as LF is made to correspond to the Unicode NEL character (which, in
358 Unicode, is 0x85).
359 .P
360 The options that select newline behaviour, such as --enable-newline-is-cr,
361 and equivalent run-time options, refer to these character values in an EBCDIC
362 environment.
363 .
364 .
365 .SH "PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT"
366 .rs
367 .sp
368 By default, \fBpcregrep\fP reads all files as plain text. You can build it so
369 that it recognizes files whose names end in \fB.gz\fP or \fB.bz2\fP, and reads
370 them with \fBlibz\fP or \fBlibbz2\fP, respectively, by adding one or both of
371 .sp
372 --enable-pcregrep-libz
373 --enable-pcregrep-libbz2
374 .sp
375 to the \fBconfigure\fP command. These options naturally require that the
376 relevant libraries are installed on your system. Configuration will fail if
377 they are not.
378 .
379 .
380 .SH "PCREGREP BUFFER SIZE"
381 .rs
382 .sp
383 \fBpcregrep\fP uses an internal buffer to hold a "window" on the file it is
384 scanning, in order to be able to output "before" and "after" lines when it
385 finds a match. The size of the buffer is controlled by a parameter whose
386 default value is 20K. The buffer itself is three times this size, but because
387 of the way it is used for holding "before" lines, the longest line that is
388 guaranteed to be processable is the parameter size. You can change the default
389 parameter value by adding, for example,
390 .sp
391 --with-pcregrep-bufsize=50K
392 .sp
393 to the \fBconfigure\fP command. The caller of \fPpcregrep\fP can, however,
394 override this value by specifying a run-time option.
395 .
396 .
397 .SH "PCRETEST OPTION FOR LIBREADLINE SUPPORT"
398 .rs
399 .sp
400 If you add
401 .sp
402 --enable-pcretest-libreadline
403 .sp
404 to the \fBconfigure\fP command, \fBpcretest\fP is linked with the
405 \fBlibreadline\fP library, and when its input is from a terminal, it reads it
406 using the \fBreadline()\fP function. This provides line-editing and history
407 facilities. Note that \fBlibreadline\fP is GPL-licensed, so if you distribute a
408 binary of \fBpcretest\fP linked in this way, there may be licensing issues.
409 .P
410 Setting this option causes the \fB-lreadline\fP option to be added to the
411 \fBpcretest\fP build. In many operating environments with a sytem-installed
412 \fBlibreadline\fP this is sufficient. However, in some environments (e.g.
413 if an unmodified distribution version of readline is in use), some extra
414 configuration may be necessary. The INSTALL file for \fBlibreadline\fP says
415 this:
416 .sp
417 "Readline uses the termcap functions, but does not link with the
418 termcap or curses library itself, allowing applications which link
419 with readline the to choose an appropriate library."
420 .sp
421 If your environment has not been set up so that an appropriate library is
422 automatically included, you may need to add something like
423 .sp
424 LIBS="-ncurses"
425 .sp
426 immediately before the \fBconfigure\fP command.
427 .
428 .
429 .SH "DEBUGGING WITH VALGRIND SUPPORT"
430 .rs
431 .sp
432 By adding the
433 .sp
434 --enable-valgrind
435 .sp
436 option to to the \fBconfigure\fP command, PCRE will use valgrind annotations
437 to mark certain memory regions as unaddressable. This allows it to detect
438 invalid memory accesses, and is mostly useful for debugging PCRE itself.
439 .
440 .
441 .SH "CODE COVERAGE REPORTING"
442 .rs
443 .sp
444 If your C compiler is gcc, you can build a version of PCRE that can generate a
445 code coverage report for its test suite. To enable this, you must install
446 \fBlcov\fP version 1.6 or above. Then specify
447 .sp
448 --enable-coverage
449 .sp
450 to the \fBconfigure\fP command and build PCRE in the usual way.
451 .P
452 Note that using \fBccache\fP (a caching C compiler) is incompatible with code
453 coverage reporting. If you have configured \fBccache\fP to run automatically
454 on your system, you must set the environment variable
455 .sp
456 CCACHE_DISABLE=1
457 .sp
458 before running \fBmake\fP to build PCRE, so that \fBccache\fP is not used.
459 .P
460 When --enable-coverage is used, the following addition targets are added to the
461 \fIMakefile\fP:
462 .sp
463 make coverage
464 .sp
465 This creates a fresh coverage report for the PCRE test suite. It is equivalent
466 to running "make coverage-reset", "make coverage-baseline", "make check", and
467 then "make coverage-report".
468 .sp
469 make coverage-reset
470 .sp
471 This zeroes the coverage counters, but does nothing else.
472 .sp
473 make coverage-baseline
474 .sp
475 This captures baseline coverage information.
476 .sp
477 make coverage-report
478 .sp
479 This creates the coverage report.
480 .sp
481 make coverage-clean-report
482 .sp
483 This removes the generated coverage report without cleaning the coverage data
484 itself.
485 .sp
486 make coverage-clean-data
487 .sp
488 This removes the captured coverage data without removing the coverage files
489 created at compile time (*.gcno).
490 .sp
491 make coverage-clean
492 .sp
493 This cleans all coverage data including the generated coverage report. For more
494 information about code coverage, see the \fBgcov\fP and \fBlcov\fP
495 documentation.
496 .
497 .
498 .SH "SEE ALSO"
499 .rs
500 .sp
501 \fBpcreapi\fP(3), \fBpcre16\fP, \fBpcre32\fP, \fBpcre_config\fP(3).
502 .
503 .
504 .SH AUTHOR
505 .rs
506 .sp
507 .nf
508 Philip Hazel
509 University Computing Service
510 Cambridge CB2 3QH, England.
511 .fi
512 .
513 .
514 .SH REVISION
515 .rs
516 .sp
517 .nf
518 Last updated: 30 October 2012
519 Copyright (c) 1997-2012 University of Cambridge.
520 .fi

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5