blob: 664812d81f5afe24084ea934f0c00f837c018d96 [file] [log] [blame]
Tristan Matthews04616462013-11-14 16:09:34 -05001<html>
2<head>
3<title>pcrebuild specification</title>
4</head>
5<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6<h1>pcrebuild man page</h1>
7<p>
8Return to the <a href="index.html">PCRE index page</a>.
9</p>
10<p>
11This page is part of the PCRE HTML documentation. It was generated automatically
12from the original man page. If there is any nonsense in it, please consult the
13man page, in case the conversion went wrong.
14<br>
15<ul>
16<li><a name="TOC1" href="#SEC1">PCRE BUILD-TIME OPTIONS</a>
17<li><a name="TOC2" href="#SEC2">BUILDING SHARED AND STATIC LIBRARIES</a>
18<li><a name="TOC3" href="#SEC3">C++ SUPPORT</a>
19<li><a name="TOC4" href="#SEC4">UTF-8 SUPPORT</a>
20<li><a name="TOC5" href="#SEC5">UNICODE CHARACTER PROPERTY SUPPORT</a>
21<li><a name="TOC6" href="#SEC6">JUST-IN-TIME COMPILER SUPPORT</a>
22<li><a name="TOC7" href="#SEC7">CODE VALUE OF NEWLINE</a>
23<li><a name="TOC8" href="#SEC8">WHAT \R MATCHES</a>
24<li><a name="TOC9" href="#SEC9">POSIX MALLOC USAGE</a>
25<li><a name="TOC10" href="#SEC10">HANDLING VERY LARGE PATTERNS</a>
26<li><a name="TOC11" href="#SEC11">AVOIDING EXCESSIVE STACK USAGE</a>
27<li><a name="TOC12" href="#SEC12">LIMITING PCRE RESOURCE USAGE</a>
28<li><a name="TOC13" href="#SEC13">CREATING CHARACTER TABLES AT BUILD TIME</a>
29<li><a name="TOC14" href="#SEC14">USING EBCDIC CODE</a>
30<li><a name="TOC15" href="#SEC15">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a>
31<li><a name="TOC16" href="#SEC16">PCREGREP BUFFER SIZE</a>
32<li><a name="TOC17" href="#SEC17">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a>
33<li><a name="TOC18" href="#SEC18">SEE ALSO</a>
34<li><a name="TOC19" href="#SEC19">AUTHOR</a>
35<li><a name="TOC20" href="#SEC20">REVISION</a>
36</ul>
37<br><a name="SEC1" href="#TOC1">PCRE BUILD-TIME OPTIONS</a><br>
38<P>
39This document describes the optional features of PCRE that can be selected when
40the library is compiled. It assumes use of the <b>configure</b> script, where
41the optional features are selected or deselected by providing options to
42<b>configure</b> before running the <b>make</b> command. However, the same
43options can be selected in both Unix-like and non-Unix-like environments using
44the GUI facility of <b>cmake-gui</b> if you are using <b>CMake</b> instead of
45<b>configure</b> to build PCRE.
46</P>
47<P>
48There is a lot more information about building PCRE in non-Unix-like
49environments in the file called <i>NON_UNIX_USE</i>, which is part of the PCRE
50distribution. You should consult this file as well as the <i>README</i> file if
51you are building in a non-Unix-like environment.
52</P>
53<P>
54The complete list of options for <b>configure</b> (which includes the standard
55ones such as the selection of the installation directory) can be obtained by
56running
57<pre>
58 ./configure --help
59</pre>
60The following sections include descriptions of options whose names begin with
61--enable or --disable. These settings specify changes to the defaults for the
62<b>configure</b> command. Because of the way that <b>configure</b> works,
63--enable and --disable always come in pairs, so the complementary option always
64exists as well, but as it specifies the default, it is not described.
65</P>
66<br><a name="SEC2" href="#TOC1">BUILDING SHARED AND STATIC LIBRARIES</a><br>
67<P>
68The PCRE building process uses <b>libtool</b> to build both shared and static
69Unix libraries by default. You can suppress one of these by adding one of
70<pre>
71 --disable-shared
72 --disable-static
73</pre>
74to the <b>configure</b> command, as required.
75</P>
76<br><a name="SEC3" href="#TOC1">C++ SUPPORT</a><br>
77<P>
78By default, the <b>configure</b> script will search for a C++ compiler and C++
79header files. If it finds them, it automatically builds the C++ wrapper library
80for PCRE. You can disable this by adding
81<pre>
82 --disable-cpp
83</pre>
84to the <b>configure</b> command.
85</P>
86<br><a name="SEC4" href="#TOC1">UTF-8 SUPPORT</a><br>
87<P>
88To build PCRE with support for UTF-8 Unicode character strings, add
89<pre>
90 --enable-utf8
91</pre>
92to the <b>configure</b> command. Of itself, this does not make PCRE treat
93strings as UTF-8. As well as compiling PCRE with this option, you also have
94have to set the PCRE_UTF8 option when you call the <b>pcre_compile()</b>
95or <b>pcre_compile2()</b> functions.
96</P>
97<P>
98If you set --enable-utf8 when compiling in an EBCDIC environment, PCRE expects
99its input to be either ASCII or UTF-8 (depending on the runtime option). It is
100not possible to support both EBCDIC and UTF-8 codes in the same version of the
101library. Consequently, --enable-utf8 and --enable-ebcdic are mutually
102exclusive.
103</P>
104<br><a name="SEC5" href="#TOC1">UNICODE CHARACTER PROPERTY SUPPORT</a><br>
105<P>
106UTF-8 support allows PCRE to process character values greater than 255 in the
107strings that it handles. On its own, however, it does not provide any
108facilities for accessing the properties of such characters. If you want to be
109able to use the pattern escapes \P, \p, and \X, which refer to Unicode
110character properties, you must add
111<pre>
112 --enable-unicode-properties
113</pre>
114to the <b>configure</b> command. This implies UTF-8 support, even if you have
115not explicitly requested it.
116</P>
117<P>
118Including Unicode property support adds around 30K of tables to the PCRE
119library. Only the general category properties such as <i>Lu</i> and <i>Nd</i> are
120supported. Details are given in the
121<a href="pcrepattern.html"><b>pcrepattern</b></a>
122documentation.
123</P>
124<br><a name="SEC6" href="#TOC1">JUST-IN-TIME COMPILER SUPPORT</a><br>
125<P>
126Just-in-time compiler support is included in the build by specifying
127<pre>
128 --enable-jit
129</pre>
130This support is available only for certain hardware architectures. If this
131option is set for an unsupported architecture, a compile time error occurs.
132See the
133<a href="pcrejit.html"><b>pcrejit</b></a>
134documentation for a discussion of JIT usage. When JIT support is enabled,
135pcregrep automatically makes use of it, unless you add
136<pre>
137 --disable-pcregrep-jit
138</pre>
139to the "configure" command.
140</P>
141<br><a name="SEC7" href="#TOC1">CODE VALUE OF NEWLINE</a><br>
142<P>
143By default, PCRE interprets the linefeed (LF) character as indicating the end
144of a line. This is the normal newline character on Unix-like systems. You can
145compile PCRE to use carriage return (CR) instead, by adding
146<pre>
147 --enable-newline-is-cr
148</pre>
149to the <b>configure</b> command. There is also a --enable-newline-is-lf option,
150which explicitly specifies linefeed as the newline character.
151<br>
152<br>
153Alternatively, you can specify that line endings are to be indicated by the two
154character sequence CRLF. If you want this, add
155<pre>
156 --enable-newline-is-crlf
157</pre>
158to the <b>configure</b> command. There is a fourth option, specified by
159<pre>
160 --enable-newline-is-anycrlf
161</pre>
162which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
163indicating a line ending. Finally, a fifth option, specified by
164<pre>
165 --enable-newline-is-any
166</pre>
167causes PCRE to recognize any Unicode newline sequence.
168</P>
169<P>
170Whatever line ending convention is selected when PCRE is built can be
171overridden when the library functions are called. At build time it is
172conventional to use the standard for your operating system.
173</P>
174<br><a name="SEC8" href="#TOC1">WHAT \R MATCHES</a><br>
175<P>
176By default, the sequence \R in a pattern matches any Unicode newline sequence,
177whatever has been selected as the line ending sequence. If you specify
178<pre>
179 --enable-bsr-anycrlf
180</pre>
181the default is changed so that \R matches only CR, LF, or CRLF. Whatever is
182selected when PCRE is built can be overridden when the library functions are
183called.
184</P>
185<br><a name="SEC9" href="#TOC1">POSIX MALLOC USAGE</a><br>
186<P>
187When PCRE is called through the POSIX interface (see the
188<a href="pcreposix.html"><b>pcreposix</b></a>
189documentation), additional working storage is required for holding the pointers
190to capturing substrings, because PCRE requires three integers per substring,
191whereas the POSIX interface provides only two. If the number of expected
192substrings is small, the wrapper function uses space on the stack, because this
193is faster than using <b>malloc()</b> for each call. The default threshold above
194which the stack is no longer used is 10; it can be changed by adding a setting
195such as
196<pre>
197 --with-posix-malloc-threshold=20
198</pre>
199to the <b>configure</b> command.
200</P>
201<br><a name="SEC10" href="#TOC1">HANDLING VERY LARGE PATTERNS</a><br>
202<P>
203Within a compiled pattern, offset values are used to point from one part to
204another (for example, from an opening parenthesis to an alternation
205metacharacter). By default, two-byte values are used for these offsets, leading
206to a maximum size for a compiled pattern of around 64K. This is sufficient to
207handle all but the most gigantic patterns. Nevertheless, some people do want to
208process truyl enormous patterns, so it is possible to compile PCRE to use
209three-byte or four-byte offsets by adding a setting such as
210<pre>
211 --with-link-size=3
212</pre>
213to the <b>configure</b> command. The value given must be 2, 3, or 4. Using
214longer offsets slows down the operation of PCRE because it has to load
215additional bytes when handling them.
216</P>
217<br><a name="SEC11" href="#TOC1">AVOIDING EXCESSIVE STACK USAGE</a><br>
218<P>
219When matching with the <b>pcre_exec()</b> function, PCRE implements backtracking
220by making recursive calls to an internal function called <b>match()</b>. In
221environments where the size of the stack is limited, this can severely limit
222PCRE's operation. (The Unix environment does not usually suffer from this
223problem, but it may sometimes be necessary to increase the maximum stack size.
224There is a discussion in the
225<a href="pcrestack.html"><b>pcrestack</b></a>
226documentation.) An alternative approach to recursion that uses memory from the
227heap to remember data, instead of using recursive function calls, has been
228implemented to work round the problem of limited stack size. If you want to
229build a version of PCRE that works this way, add
230<pre>
231 --disable-stack-for-recursion
232</pre>
233to the <b>configure</b> command. With this configuration, PCRE will use the
234<b>pcre_stack_malloc</b> and <b>pcre_stack_free</b> variables to call memory
235management functions. By default these point to <b>malloc()</b> and
236<b>free()</b>, but you can replace the pointers so that your own functions are
237used instead.
238</P>
239<P>
240Separate functions are provided rather than using <b>pcre_malloc</b> and
241<b>pcre_free</b> because the usage is very predictable: the block sizes
242requested are always the same, and the blocks are always freed in reverse
243order. A calling program might be able to implement optimized functions that
244perform better than <b>malloc()</b> and <b>free()</b>. PCRE runs noticeably more
245slowly when built in this way. This option affects only the <b>pcre_exec()</b>
246function; it is not relevant for <b>pcre_dfa_exec()</b>.
247</P>
248<br><a name="SEC12" href="#TOC1">LIMITING PCRE RESOURCE USAGE</a><br>
249<P>
250Internally, PCRE has a function called <b>match()</b>, which it calls repeatedly
251(sometimes recursively) when matching a pattern with the <b>pcre_exec()</b>
252function. By controlling the maximum number of times this function may be
253called during a single matching operation, a limit can be placed on the
254resources used by a single call to <b>pcre_exec()</b>. The limit can be changed
255at run time, as described in the
256<a href="pcreapi.html"><b>pcreapi</b></a>
257documentation. The default is 10 million, but this can be changed by adding a
258setting such as
259<pre>
260 --with-match-limit=500000
261</pre>
262to the <b>configure</b> command. This setting has no effect on the
263<b>pcre_dfa_exec()</b> matching function.
264</P>
265<P>
266In some environments it is desirable to limit the depth of recursive calls of
267<b>match()</b> more strictly than the total number of calls, in order to
268restrict the maximum amount of stack (or heap, if --disable-stack-for-recursion
269is specified) that is used. A second limit controls this; it defaults to the
270value that is set for --with-match-limit, which imposes no additional
271constraints. However, you can set a lower limit by adding, for example,
272<pre>
273 --with-match-limit-recursion=10000
274</pre>
275to the <b>configure</b> command. This value can also be overridden at run time.
276</P>
277<br><a name="SEC13" href="#TOC1">CREATING CHARACTER TABLES AT BUILD TIME</a><br>
278<P>
279PCRE uses fixed tables for processing characters whose code values are less
280than 256. By default, PCRE is built with a set of tables that are distributed
281in the file <i>pcre_chartables.c.dist</i>. These tables are for ASCII codes
282only. If you add
283<pre>
284 --enable-rebuild-chartables
285</pre>
286to the <b>configure</b> command, the distributed tables are no longer used.
287Instead, a program called <b>dftables</b> is compiled and run. This outputs the
288source for new set of tables, created in the default locale of your C runtime
289system. (This method of replacing the tables does not work if you are cross
290compiling, because <b>dftables</b> is run on the local host. If you need to
291create alternative tables when cross compiling, you will have to do so "by
292hand".)
293</P>
294<br><a name="SEC14" href="#TOC1">USING EBCDIC CODE</a><br>
295<P>
296PCRE assumes by default that it will run in an environment where the character
297code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
298most computer operating systems. PCRE can, however, be compiled to run in an
299EBCDIC environment by adding
300<pre>
301 --enable-ebcdic
302</pre>
303to the <b>configure</b> command. This setting implies
304--enable-rebuild-chartables. You should only use it if you know that you are in
305an EBCDIC environment (for example, an IBM mainframe operating system). The
306--enable-ebcdic option is incompatible with --enable-utf8.
307</P>
308<br><a name="SEC15" href="#TOC1">PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT</a><br>
309<P>
310By default, <b>pcregrep</b> reads all files as plain text. You can build it so
311that it recognizes files whose names end in <b>.gz</b> or <b>.bz2</b>, and reads
312them with <b>libz</b> or <b>libbz2</b>, respectively, by adding one or both of
313<pre>
314 --enable-pcregrep-libz
315 --enable-pcregrep-libbz2
316</pre>
317to the <b>configure</b> command. These options naturally require that the
318relevant libraries are installed on your system. Configuration will fail if
319they are not.
320</P>
321<br><a name="SEC16" href="#TOC1">PCREGREP BUFFER SIZE</a><br>
322<P>
323<b>pcregrep</b> uses an internal buffer to hold a "window" on the file it is
324scanning, in order to be able to output "before" and "after" lines when it
325finds a match. The size of the buffer is controlled by a parameter whose
326default value is 20K. The buffer itself is three times this size, but because
327of the way it is used for holding "before" lines, the longest line that is
328guaranteed to be processable is the parameter size. You can change the default
329parameter value by adding, for example,
330<pre>
331 --with-pcregrep-bufsize=50K
332</pre>
333to the <b>configure</b> command. The caller of \fPpcregrep\fP can, however,
334override this value by specifying a run-time option.
335</P>
336<br><a name="SEC17" href="#TOC1">PCRETEST OPTION FOR LIBREADLINE SUPPORT</a><br>
337<P>
338If you add
339<pre>
340 --enable-pcretest-libreadline
341</pre>
342to the <b>configure</b> command, <b>pcretest</b> is linked with the
343<b>libreadline</b> library, and when its input is from a terminal, it reads it
344using the <b>readline()</b> function. This provides line-editing and history
345facilities. Note that <b>libreadline</b> is GPL-licensed, so if you distribute a
346binary of <b>pcretest</b> linked in this way, there may be licensing issues.
347</P>
348<P>
349Setting this option causes the <b>-lreadline</b> option to be added to the
350<b>pcretest</b> build. In many operating environments with a sytem-installed
351<b>libreadline</b> this is sufficient. However, in some environments (e.g.
352if an unmodified distribution version of readline is in use), some extra
353configuration may be necessary. The INSTALL file for <b>libreadline</b> says
354this:
355<pre>
356 "Readline uses the termcap functions, but does not link with the
357 termcap or curses library itself, allowing applications which link
358 with readline the to choose an appropriate library."
359</pre>
360If your environment has not been set up so that an appropriate library is
361automatically included, you may need to add something like
362<pre>
363 LIBS="-ncurses"
364</pre>
365immediately before the <b>configure</b> command.
366</P>
367<br><a name="SEC18" href="#TOC1">SEE ALSO</a><br>
368<P>
369<b>pcreapi</b>(3), <b>pcre_config</b>(3).
370</P>
371<br><a name="SEC19" href="#TOC1">AUTHOR</a><br>
372<P>
373Philip Hazel
374<br>
375University Computing Service
376<br>
377Cambridge CB2 3QH, England.
378<br>
379</P>
380<br><a name="SEC20" href="#TOC1">REVISION</a><br>
381<P>
382Last updated: 06 September 2011
383<br>
384Copyright &copy; 1997-2011 University of Cambridge.
385<br>
386<p>
387Return to the <a href="index.html">PCRE index page</a>.
388</p>