xref: /aosp_15_r20/external/pcre/doc/html/NON-AUTOTOOLS-BUILD.txt (revision 22dc650d8ae982c6770746019a6f94af92b0f024)
1*22dc650dSSadaf EbrahimiBuilding PCRE2 without using autotools
2*22dc650dSSadaf Ebrahimi--------------------------------------
3*22dc650dSSadaf Ebrahimi
4*22dc650dSSadaf EbrahimiThis document contains the following sections:
5*22dc650dSSadaf Ebrahimi
6*22dc650dSSadaf Ebrahimi  General
7*22dc650dSSadaf Ebrahimi  Generic instructions for the PCRE2 C libraries
8*22dc650dSSadaf Ebrahimi  Stack size in Windows environments
9*22dc650dSSadaf Ebrahimi  Linking programs in Windows environments
10*22dc650dSSadaf Ebrahimi  Calling conventions in Windows environments
11*22dc650dSSadaf Ebrahimi  Comments about Win32 builds
12*22dc650dSSadaf Ebrahimi  Building PCRE2 on Windows with CMake
13*22dc650dSSadaf Ebrahimi  Building PCRE2 on Windows with Visual Studio
14*22dc650dSSadaf Ebrahimi  Testing with RunTest.bat
15*22dc650dSSadaf Ebrahimi  Building PCRE2 on native z/OS and z/VM
16*22dc650dSSadaf Ebrahimi  Building PCRE2 under VMS
17*22dc650dSSadaf Ebrahimi
18*22dc650dSSadaf Ebrahimi
19*22dc650dSSadaf EbrahimiGENERAL
20*22dc650dSSadaf Ebrahimi
21*22dc650dSSadaf EbrahimiThe source of the PCRE2 libraries consists entirely of code written in Standard
22*22dc650dSSadaf EbrahimiC, and so should compile successfully on any system that has a Standard C
23*22dc650dSSadaf Ebrahimicompiler and library.
24*22dc650dSSadaf Ebrahimi
25*22dc650dSSadaf EbrahimiThe PCRE2 distribution includes a "configure" file for use by the
26*22dc650dSSadaf Ebrahimiconfigure/make (autotools) build system, as found in many Unix-like
27*22dc650dSSadaf Ebrahimienvironments. The README file contains information about the options for
28*22dc650dSSadaf Ebrahimi"configure".
29*22dc650dSSadaf Ebrahimi
30*22dc650dSSadaf EbrahimiThere is also support for CMake, which some users prefer, especially in Windows
31*22dc650dSSadaf Ebrahimienvironments, though it can also be run in Unix-like environments. See the
32*22dc650dSSadaf Ebrahimisection entitled "Building PCRE2 on Windows with CMake" below.
33*22dc650dSSadaf Ebrahimi
34*22dc650dSSadaf EbrahimiVersions of src/config.h and src/pcre2.h are distributed in the PCRE2 tarballs
35*22dc650dSSadaf Ebrahimiunder the names src/config.h.generic and src/pcre2.h.generic. These are
36*22dc650dSSadaf Ebrahimiprovided for those who build PCRE2 without using "configure" or CMake. If you
37*22dc650dSSadaf Ebrahimiuse "configure" or CMake, the .generic versions are not used.
38*22dc650dSSadaf Ebrahimi
39*22dc650dSSadaf Ebrahimi
40*22dc650dSSadaf EbrahimiGENERIC INSTRUCTIONS FOR THE PCRE2 C LIBRARIES
41*22dc650dSSadaf Ebrahimi
42*22dc650dSSadaf EbrahimiThere are three possible PCRE2 libraries, each handling data with a specific
43*22dc650dSSadaf Ebrahimicode unit width: 8, 16, or 32 bits. You can build any combination of them. The
44*22dc650dSSadaf Ebrahimifollowing are generic instructions for building a PCRE2 C library "by hand". If
45*22dc650dSSadaf Ebrahimiyou are going to use CMake, this section does not apply to you; you can skip
46*22dc650dSSadaf Ebrahimiahead to the CMake section. Note that the settings concerned with 8-bit,
47*22dc650dSSadaf Ebrahimi16-bit, and 32-bit code units relate to the type of data string that PCRE2
48*22dc650dSSadaf Ebrahimiprocesses. They are NOT referring to the underlying operating system bit width.
49*22dc650dSSadaf EbrahimiYou do not have to do anything special to compile in a 64-bit environment, for
50*22dc650dSSadaf Ebrahimiexample.
51*22dc650dSSadaf Ebrahimi
52*22dc650dSSadaf Ebrahimi (1) Copy or rename the file src/config.h.generic as src/config.h, and edit the
53*22dc650dSSadaf Ebrahimi     macro settings that it contains to whatever is appropriate for your
54*22dc650dSSadaf Ebrahimi     environment. In particular, you can alter the definition of the NEWLINE
55*22dc650dSSadaf Ebrahimi     macro to specify what character(s) you want to be interpreted as line
56*22dc650dSSadaf Ebrahimi     terminators by default. You need to #define at least one of
57*22dc650dSSadaf Ebrahimi     SUPPORT_PCRE2_8, SUPPORT_PCRE2_16, or SUPPORT_PCRE2_32, depending on which
58*22dc650dSSadaf Ebrahimi     libraries you are going to build. You must set all that apply.
59*22dc650dSSadaf Ebrahimi
60*22dc650dSSadaf Ebrahimi     When you subsequently compile any of the PCRE2 modules, you must specify
61*22dc650dSSadaf Ebrahimi     -DHAVE_CONFIG_H to your compiler so that src/config.h is included in the
62*22dc650dSSadaf Ebrahimi     sources.
63*22dc650dSSadaf Ebrahimi
64*22dc650dSSadaf Ebrahimi     An alternative approach is not to edit src/config.h, but to use -D on the
65*22dc650dSSadaf Ebrahimi     compiler command line to make any changes that you need to the
66*22dc650dSSadaf Ebrahimi     configuration options. In this case -DHAVE_CONFIG_H must not be set.
67*22dc650dSSadaf Ebrahimi
68*22dc650dSSadaf Ebrahimi     NOTE: There have been occasions when the way in which certain parameters
69*22dc650dSSadaf Ebrahimi     in src/config.h are used has changed between releases. (In the
70*22dc650dSSadaf Ebrahimi     configure/make world, this is handled automatically.) When upgrading to a
71*22dc650dSSadaf Ebrahimi     new release, you are strongly advised to review src/config.h.generic
72*22dc650dSSadaf Ebrahimi     before re-using what you had previously.
73*22dc650dSSadaf Ebrahimi
74*22dc650dSSadaf Ebrahimi     Note also that the src/config.h.generic file is created from a config.h
75*22dc650dSSadaf Ebrahimi     that was generated by Autotools, which automatically includes settings of
76*22dc650dSSadaf Ebrahimi     a number of macros that are not actually used by PCRE2 (for example,
77*22dc650dSSadaf Ebrahimi     HAVE_DLFCN_H).
78*22dc650dSSadaf Ebrahimi
79*22dc650dSSadaf Ebrahimi (2) Copy or rename the file src/pcre2.h.generic as src/pcre2.h.
80*22dc650dSSadaf Ebrahimi
81*22dc650dSSadaf Ebrahimi (3) EITHER:
82*22dc650dSSadaf Ebrahimi       Copy or rename file src/pcre2_chartables.c.dist as
83*22dc650dSSadaf Ebrahimi       src/pcre2_chartables.c.
84*22dc650dSSadaf Ebrahimi
85*22dc650dSSadaf Ebrahimi     OR:
86*22dc650dSSadaf Ebrahimi       Compile src/pcre2_dftables.c as a stand-alone program (using
87*22dc650dSSadaf Ebrahimi       -DHAVE_CONFIG_H if you have set up src/config.h), and then run it with
88*22dc650dSSadaf Ebrahimi       the single argument "src/pcre2_chartables.c". This generates a set of
89*22dc650dSSadaf Ebrahimi       standard character tables and writes them to that file. The tables are
90*22dc650dSSadaf Ebrahimi       generated using the default C locale for your system. If you want to use
91*22dc650dSSadaf Ebrahimi       a locale that is specified by LC_xxx environment variables, add the -L
92*22dc650dSSadaf Ebrahimi       option to the pcre2_dftables command. You must use this method if you
93*22dc650dSSadaf Ebrahimi       are building on a system that uses EBCDIC code.
94*22dc650dSSadaf Ebrahimi
95*22dc650dSSadaf Ebrahimi     The tables in src/pcre2_chartables.c are defaults. The caller of PCRE2 can
96*22dc650dSSadaf Ebrahimi     specify alternative tables at run time.
97*22dc650dSSadaf Ebrahimi
98*22dc650dSSadaf Ebrahimi (4) For a library that supports 8-bit code units in the character strings that
99*22dc650dSSadaf Ebrahimi     it processes, compile the following source files from the src directory,
100*22dc650dSSadaf Ebrahimi     setting -DPCRE2_CODE_UNIT_WIDTH=8 as a compiler option. Also set
101*22dc650dSSadaf Ebrahimi     -DHAVE_CONFIG_H if you have set up src/config.h with your configuration,
102*22dc650dSSadaf Ebrahimi     or else use other -D settings to change the configuration as required.
103*22dc650dSSadaf Ebrahimi
104*22dc650dSSadaf Ebrahimi       pcre2_auto_possess.c
105*22dc650dSSadaf Ebrahimi       pcre2_chkdint.c
106*22dc650dSSadaf Ebrahimi       pcre2_chartables.c
107*22dc650dSSadaf Ebrahimi       pcre2_compile.c
108*22dc650dSSadaf Ebrahimi       pcre2_config.c
109*22dc650dSSadaf Ebrahimi       pcre2_context.c
110*22dc650dSSadaf Ebrahimi       pcre2_convert.c
111*22dc650dSSadaf Ebrahimi       pcre2_dfa_match.c
112*22dc650dSSadaf Ebrahimi       pcre2_error.c
113*22dc650dSSadaf Ebrahimi       pcre2_extuni.c
114*22dc650dSSadaf Ebrahimi       pcre2_find_bracket.c
115*22dc650dSSadaf Ebrahimi       pcre2_jit_compile.c
116*22dc650dSSadaf Ebrahimi       pcre2_maketables.c
117*22dc650dSSadaf Ebrahimi       pcre2_match.c
118*22dc650dSSadaf Ebrahimi       pcre2_match_data.c
119*22dc650dSSadaf Ebrahimi       pcre2_newline.c
120*22dc650dSSadaf Ebrahimi       pcre2_ord2utf.c
121*22dc650dSSadaf Ebrahimi       pcre2_pattern_info.c
122*22dc650dSSadaf Ebrahimi       pcre2_script_run.c
123*22dc650dSSadaf Ebrahimi       pcre2_serialize.c
124*22dc650dSSadaf Ebrahimi       pcre2_string_utils.c
125*22dc650dSSadaf Ebrahimi       pcre2_study.c
126*22dc650dSSadaf Ebrahimi       pcre2_substitute.c
127*22dc650dSSadaf Ebrahimi       pcre2_substring.c
128*22dc650dSSadaf Ebrahimi       pcre2_tables.c
129*22dc650dSSadaf Ebrahimi       pcre2_ucd.c
130*22dc650dSSadaf Ebrahimi       pcre2_valid_utf.c
131*22dc650dSSadaf Ebrahimi       pcre2_xclass.c
132*22dc650dSSadaf Ebrahimi
133*22dc650dSSadaf Ebrahimi     Make sure that you include -I. in the compiler command (or equivalent for
134*22dc650dSSadaf Ebrahimi     an unusual compiler) so that all included PCRE2 header files are first
135*22dc650dSSadaf Ebrahimi     sought in the src directory under the current directory. Otherwise you run
136*22dc650dSSadaf Ebrahimi     the risk of picking up a previously-installed file from somewhere else.
137*22dc650dSSadaf Ebrahimi
138*22dc650dSSadaf Ebrahimi     Note that you must compile pcre2_jit_compile.c, even if you have not
139*22dc650dSSadaf Ebrahimi     defined SUPPORT_JIT in src/config.h, because when JIT support is not
140*22dc650dSSadaf Ebrahimi     configured, dummy functions are compiled. When JIT support IS configured,
141*22dc650dSSadaf Ebrahimi     pcre2_jit_compile.c #includes other files from the sljit subdirectory,
142*22dc650dSSadaf Ebrahimi     all of whose names begin with "sljit". It also #includes
143*22dc650dSSadaf Ebrahimi     src/pcre2_jit_match.c and src/pcre2_jit_misc.c, so you should not compile
144*22dc650dSSadaf Ebrahimi     those yourself.
145*22dc650dSSadaf Ebrahimi
146*22dc650dSSadaf Ebrahimi     Note also that the pcre2_fuzzsupport.c file contains special code that is
147*22dc650dSSadaf Ebrahimi     useful to those who want to run fuzzing tests on the PCRE2 library. Unless
148*22dc650dSSadaf Ebrahimi     you are doing that, you can ignore it.
149*22dc650dSSadaf Ebrahimi
150*22dc650dSSadaf Ebrahimi (5) Now link all the compiled code into an object library in whichever form
151*22dc650dSSadaf Ebrahimi     your system keeps such libraries. This is the PCRE2 C 8-bit library,
152*22dc650dSSadaf Ebrahimi     typically called something like libpcre2-8. If your system has static and
153*22dc650dSSadaf Ebrahimi     shared libraries, you may have to do this once for each type.
154*22dc650dSSadaf Ebrahimi
155*22dc650dSSadaf Ebrahimi (6) If you want to build a library that supports 16-bit or 32-bit code units,
156*22dc650dSSadaf Ebrahimi     set 16 or 32 as the value of -DPCRE2_CODE_UNIT_WIDTH when obeying step 4
157*22dc650dSSadaf Ebrahimi     above. If you want to build more than one PCRE2 library, repeat steps 4
158*22dc650dSSadaf Ebrahimi     and 5 as necessary.
159*22dc650dSSadaf Ebrahimi
160*22dc650dSSadaf Ebrahimi (7) If you want to build the POSIX wrapper functions (which apply only to the
161*22dc650dSSadaf Ebrahimi     8-bit library), ensure that you have the src/pcre2posix.h file and then
162*22dc650dSSadaf Ebrahimi     compile src/pcre2posix.c. Link the result (on its own) as the pcre2posix
163*22dc650dSSadaf Ebrahimi     library. If targeting a DLL in Windows, make sure to include
164*22dc650dSSadaf Ebrahimi     -DPCRE2POSIX_SHARED with your compiler flags.
165*22dc650dSSadaf Ebrahimi
166*22dc650dSSadaf Ebrahimi (8) The pcre2test program can be linked with any combination of the 8-bit,
167*22dc650dSSadaf Ebrahimi     16-bit and 32-bit libraries (depending on what you specfied in
168*22dc650dSSadaf Ebrahimi     src/config.h) . Compile src/pcre2test.c; don't forget -DHAVE_CONFIG_H if
169*22dc650dSSadaf Ebrahimi     necessary, but do NOT define PCRE2_CODE_UNIT_WIDTH. Then link with the
170*22dc650dSSadaf Ebrahimi     appropriate library/ies. If you compiled an 8-bit library, pcre2test also
171*22dc650dSSadaf Ebrahimi     needs the pcre2posix wrapper library.
172*22dc650dSSadaf Ebrahimi
173*22dc650dSSadaf Ebrahimi (9) Run pcre2test on the testinput files in the testdata directory, and check
174*22dc650dSSadaf Ebrahimi     that the output matches the corresponding testoutput files. There are
175*22dc650dSSadaf Ebrahimi     comments about what each test does in the section entitled "Testing PCRE2"
176*22dc650dSSadaf Ebrahimi     in the README file. If you compiled more than one of the 8-bit, 16-bit and
177*22dc650dSSadaf Ebrahimi     32-bit libraries, you need to run pcre2test with the -16 option to do
178*22dc650dSSadaf Ebrahimi     16-bit tests and with the -32 option to do 32-bit tests.
179*22dc650dSSadaf Ebrahimi
180*22dc650dSSadaf Ebrahimi     Some tests are relevant only when certain build-time options are selected.
181*22dc650dSSadaf Ebrahimi     For example, test 4 is for Unicode support, and will not run if you have
182*22dc650dSSadaf Ebrahimi     built PCRE2 without it. See the comments at the start of each testinput
183*22dc650dSSadaf Ebrahimi     file. If you have a suitable Unix-like shell, the RunTest script will run
184*22dc650dSSadaf Ebrahimi     the appropriate tests for you. The command "RunTest list" will output a
185*22dc650dSSadaf Ebrahimi     list of all the tests.
186*22dc650dSSadaf Ebrahimi
187*22dc650dSSadaf Ebrahimi     Note that the supplied files are in Unix format, with just LF characters
188*22dc650dSSadaf Ebrahimi     as line terminators. You may need to edit them to change this if your
189*22dc650dSSadaf Ebrahimi     system uses a different convention.
190*22dc650dSSadaf Ebrahimi
191*22dc650dSSadaf Ebrahimi(10) If you have built PCRE2 with SUPPORT_JIT, the JIT features can be tested
192*22dc650dSSadaf Ebrahimi     by running pcre2test with the -jit option. This is done automatically by
193*22dc650dSSadaf Ebrahimi     the RunTest script. You might also like to build and run the freestanding
194*22dc650dSSadaf Ebrahimi     JIT test program, src/pcre2_jit_test.c.
195*22dc650dSSadaf Ebrahimi
196*22dc650dSSadaf Ebrahimi(11) The pcre2test program tests the POSIX wrapper library, but there is also a
197*22dc650dSSadaf Ebrahimi     freestanding test program in src/pcre2posix_test.c. It must be linked with
198*22dc650dSSadaf Ebrahimi     both the pcre2posix library and the 8-bit PCRE2 library.
199*22dc650dSSadaf Ebrahimi
200*22dc650dSSadaf Ebrahimi(12) If you want to use the pcre2grep command, compile and link
201*22dc650dSSadaf Ebrahimi     src/pcre2grep.c; it uses only the 8-bit PCRE2 library (it does not need
202*22dc650dSSadaf Ebrahimi     the pcre2posix library). If you have built the PCRE2 library with JIT
203*22dc650dSSadaf Ebrahimi     support by defining SUPPORT_JIT in src/config.h, you can also define
204*22dc650dSSadaf Ebrahimi     SUPPORT_PCRE2GREP_JIT, which causes pcre2grep to make use of JIT (unless
205*22dc650dSSadaf Ebrahimi     it is run with --no-jit). If you define SUPPORT_PCRE2GREP_JIT without
206*22dc650dSSadaf Ebrahimi     defining SUPPORT_JIT, pcre2grep does not try to make use of JIT.
207*22dc650dSSadaf Ebrahimi
208*22dc650dSSadaf Ebrahimi
209*22dc650dSSadaf EbrahimiSTACK SIZE IN WINDOWS ENVIRONMENTS
210*22dc650dSSadaf Ebrahimi
211*22dc650dSSadaf EbrahimiPrior to release 10.30 the default system stack size of 1MiB in some Windows
212*22dc650dSSadaf Ebrahimienvironments caused issues with some tests. This should no longer be the case
213*22dc650dSSadaf Ebrahimifor 10.30 and later releases.
214*22dc650dSSadaf Ebrahimi
215*22dc650dSSadaf Ebrahimi
216*22dc650dSSadaf EbrahimiLINKING PROGRAMS IN WINDOWS ENVIRONMENTS
217*22dc650dSSadaf Ebrahimi
218*22dc650dSSadaf EbrahimiIf you want to statically link a program against a PCRE2 library in the form of
219*22dc650dSSadaf Ebrahimia non-dll .a file, you must define PCRE2_STATIC before including src/pcre2.h.
220*22dc650dSSadaf Ebrahimi
221*22dc650dSSadaf Ebrahimi
222*22dc650dSSadaf EbrahimiCALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
223*22dc650dSSadaf Ebrahimi
224*22dc650dSSadaf EbrahimiIt is possible to compile programs to use different calling conventions using
225*22dc650dSSadaf EbrahimiMSVC. Search the web for "calling conventions" for more information. To make it
226*22dc650dSSadaf Ebrahimieasier to change the calling convention for the exported functions in a
227*22dc650dSSadaf EbrahimiPCRE2 library, the macro PCRE2_CALL_CONVENTION is present in all the external
228*22dc650dSSadaf Ebrahimidefinitions. It can be set externally when compiling (e.g. in CFLAGS). If it is
229*22dc650dSSadaf Ebrahiminot set, it defaults to empty; the default calling convention is then used
230*22dc650dSSadaf Ebrahimi(which is what is wanted most of the time).
231*22dc650dSSadaf Ebrahimi
232*22dc650dSSadaf Ebrahimi
233*22dc650dSSadaf EbrahimiCOMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE2 ON WINDOWS WITH CMAKE")
234*22dc650dSSadaf Ebrahimi
235*22dc650dSSadaf EbrahimiThere are two ways of building PCRE2 using the "configure, make, make install"
236*22dc650dSSadaf Ebrahimiparadigm on Windows systems: using MinGW or using Cygwin. These are not at all
237*22dc650dSSadaf Ebrahimithe same thing; they are completely different from each other. There is also
238*22dc650dSSadaf Ebrahimisupport for building using CMake, which some users find a more straightforward
239*22dc650dSSadaf Ebrahimiway of building PCRE2 under Windows.
240*22dc650dSSadaf Ebrahimi
241*22dc650dSSadaf EbrahimiThe MinGW home page (http://www.mingw.org/) says this:
242*22dc650dSSadaf Ebrahimi
243*22dc650dSSadaf Ebrahimi  MinGW: A collection of freely available and freely distributable Windows
244*22dc650dSSadaf Ebrahimi  specific header files and import libraries combined with GNU toolsets that
245*22dc650dSSadaf Ebrahimi  allow one to produce native Windows programs that do not rely on any
246*22dc650dSSadaf Ebrahimi  3rd-party C runtime DLLs.
247*22dc650dSSadaf Ebrahimi
248*22dc650dSSadaf EbrahimiThe Cygwin home page (http://www.cygwin.com/) says this:
249*22dc650dSSadaf Ebrahimi
250*22dc650dSSadaf Ebrahimi  Cygwin is a Linux-like environment for Windows. It consists of two parts:
251*22dc650dSSadaf Ebrahimi
252*22dc650dSSadaf Ebrahimi  . A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing
253*22dc650dSSadaf Ebrahimi    substantial Linux API functionality
254*22dc650dSSadaf Ebrahimi
255*22dc650dSSadaf Ebrahimi  . A collection of tools which provide Linux look and feel.
256*22dc650dSSadaf Ebrahimi
257*22dc650dSSadaf EbrahimiOn both MinGW and Cygwin, PCRE2 should build correctly using:
258*22dc650dSSadaf Ebrahimi
259*22dc650dSSadaf Ebrahimi  ./configure && make && make install
260*22dc650dSSadaf Ebrahimi
261*22dc650dSSadaf EbrahimiThis should create two libraries called libpcre2-8 and libpcre2-posix. These
262*22dc650dSSadaf Ebrahimiare independent libraries: when you link with libpcre2-posix you must also link
263*22dc650dSSadaf Ebrahimiwith libpcre2-8, which contains the basic functions.
264*22dc650dSSadaf Ebrahimi
265*22dc650dSSadaf EbrahimiUsing Cygwin's compiler generates libraries and executables that depend on
266*22dc650dSSadaf Ebrahimicygwin1.dll. If a library that is generated this way is distributed,
267*22dc650dSSadaf Ebrahimicygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL
268*22dc650dSSadaf Ebrahimilicence, this forces not only PCRE2 to be under the GPL, but also the entire
269*22dc650dSSadaf Ebrahimiapplication. A distributor who wants to keep their own code proprietary must
270*22dc650dSSadaf Ebrahimipurchase an appropriate Cygwin licence.
271*22dc650dSSadaf Ebrahimi
272*22dc650dSSadaf EbrahimiMinGW has no such restrictions. The MinGW compiler generates a library or
273*22dc650dSSadaf Ebrahimiexecutable that can run standalone on Windows without any third party dll or
274*22dc650dSSadaf Ebrahimilicensing issues.
275*22dc650dSSadaf Ebrahimi
276*22dc650dSSadaf EbrahimiBut there is more complication:
277*22dc650dSSadaf Ebrahimi
278*22dc650dSSadaf EbrahimiIf a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is
279*22dc650dSSadaf Ebrahimito tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a
280*22dc650dSSadaf Ebrahimifront end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's
281*22dc650dSSadaf Ebrahimigcc and MinGW's gcc). So, a user can:
282*22dc650dSSadaf Ebrahimi
283*22dc650dSSadaf Ebrahimi. Build native binaries by using MinGW or by getting Cygwin and using
284*22dc650dSSadaf Ebrahimi  -mno-cygwin.
285*22dc650dSSadaf Ebrahimi
286*22dc650dSSadaf Ebrahimi. Build binaries that depend on cygwin1.dll by using Cygwin with the normal
287*22dc650dSSadaf Ebrahimi  compiler flags.
288*22dc650dSSadaf Ebrahimi
289*22dc650dSSadaf EbrahimiThe test files that are supplied with PCRE2 are in UNIX format, with LF
290*22dc650dSSadaf Ebrahimicharacters as line terminators. Unless your PCRE2 library uses a default
291*22dc650dSSadaf Ebrahiminewline option that includes LF as a valid newline, it may be necessary to
292*22dc650dSSadaf Ebrahimichange the line terminators in the test files to get some of the tests to work.
293*22dc650dSSadaf Ebrahimi
294*22dc650dSSadaf Ebrahimi
295*22dc650dSSadaf EbrahimiBUILDING PCRE2 ON WINDOWS WITH CMAKE
296*22dc650dSSadaf Ebrahimi
297*22dc650dSSadaf EbrahimiCMake is an alternative configuration facility that can be used instead of
298*22dc650dSSadaf Ebrahimi"configure". CMake creates project files (make files, solution files, etc.)
299*22dc650dSSadaf Ebrahimitailored to numerous development environments, including Visual Studio,
300*22dc650dSSadaf EbrahimiBorland, Msys, MinGW, NMake, and Unix. If possible, use short paths with no
301*22dc650dSSadaf Ebrahimispaces in the names for your CMake installation and your PCRE2 source and build
302*22dc650dSSadaf Ebrahimidirectories.
303*22dc650dSSadaf Ebrahimi
304*22dc650dSSadaf EbrahimiThe following instructions were contributed by a PCRE1 user, but they should
305*22dc650dSSadaf Ebrahimialso work for PCRE2. If they are not followed exactly, errors may occur. In the
306*22dc650dSSadaf Ebrahimievent that errors do occur, it is recommended that you delete the CMake cache
307*22dc650dSSadaf Ebrahimibefore attempting to repeat the CMake build process. In the CMake GUI, the
308*22dc650dSSadaf Ebrahimicache can be deleted by selecting "File > Delete Cache".
309*22dc650dSSadaf Ebrahimi
310*22dc650dSSadaf Ebrahimi1.  Install the latest CMake version available from http://www.cmake.org/, and
311*22dc650dSSadaf Ebrahimi    ensure that cmake\bin is on your path.
312*22dc650dSSadaf Ebrahimi
313*22dc650dSSadaf Ebrahimi2.  Unzip (retaining folder structure) the PCRE2 source tree into a source
314*22dc650dSSadaf Ebrahimi    directory such as C:\pcre2. You should ensure your local date and time
315*22dc650dSSadaf Ebrahimi    is not earlier than the file dates in your source dir if the release is
316*22dc650dSSadaf Ebrahimi    very new.
317*22dc650dSSadaf Ebrahimi
318*22dc650dSSadaf Ebrahimi3.  Create a new, empty build directory, preferably a subdirectory of the
319*22dc650dSSadaf Ebrahimi    source dir. For example, C:\pcre2\pcre2-xx\build.
320*22dc650dSSadaf Ebrahimi
321*22dc650dSSadaf Ebrahimi4.  Run cmake-gui from the Shell environment of your build tool, for example,
322*22dc650dSSadaf Ebrahimi    Msys for Msys/MinGW or Visual Studio Command Prompt for VC/VC++. Do not try
323*22dc650dSSadaf Ebrahimi    to start Cmake from the Windows Start menu, as this can lead to errors.
324*22dc650dSSadaf Ebrahimi
325*22dc650dSSadaf Ebrahimi5.  Enter C:\pcre2\pcre2-xx and C:\pcre2\pcre2-xx\build for the source and
326*22dc650dSSadaf Ebrahimi    build directories, respectively.
327*22dc650dSSadaf Ebrahimi
328*22dc650dSSadaf Ebrahimi6.  Hit the "Configure" button.
329*22dc650dSSadaf Ebrahimi
330*22dc650dSSadaf Ebrahimi7.  Select the particular IDE / build tool that you are using (Visual
331*22dc650dSSadaf Ebrahimi    Studio, MSYS makefiles, MinGW makefiles, etc.)
332*22dc650dSSadaf Ebrahimi
333*22dc650dSSadaf Ebrahimi8.  The GUI will then list several configuration options. This is where
334*22dc650dSSadaf Ebrahimi    you can disable Unicode support or select other PCRE2 optional features.
335*22dc650dSSadaf Ebrahimi
336*22dc650dSSadaf Ebrahimi9.  Hit "Configure" again. The adjacent "Generate" button should now be
337*22dc650dSSadaf Ebrahimi    active.
338*22dc650dSSadaf Ebrahimi
339*22dc650dSSadaf Ebrahimi10. Hit "Generate".
340*22dc650dSSadaf Ebrahimi
341*22dc650dSSadaf Ebrahimi11. The build directory should now contain a usable build system, be it a
342*22dc650dSSadaf Ebrahimi    solution file for Visual Studio, makefiles for MinGW, etc. Exit from
343*22dc650dSSadaf Ebrahimi    cmake-gui and use the generated build system with your compiler or IDE.
344*22dc650dSSadaf Ebrahimi    E.g., for MinGW you can run "make", or for Visual Studio, open the PCRE2
345*22dc650dSSadaf Ebrahimi    solution, select the desired configuration (Debug, or Release, etc.) and
346*22dc650dSSadaf Ebrahimi    build the ALL_BUILD project.
347*22dc650dSSadaf Ebrahimi
348*22dc650dSSadaf Ebrahimi12. If during configuration with cmake-gui you've elected to build the test
349*22dc650dSSadaf Ebrahimi    programs, you can execute them by building the test project. E.g., for
350*22dc650dSSadaf Ebrahimi    MinGW: "make test"; for Visual Studio build the RUN_TESTS project. The
351*22dc650dSSadaf Ebrahimi    most recent build configuration is targeted by the tests. A summary of
352*22dc650dSSadaf Ebrahimi    test results is presented. Complete test output is subsequently
353*22dc650dSSadaf Ebrahimi    available for review in Testing\Temporary under your build dir.
354*22dc650dSSadaf Ebrahimi
355*22dc650dSSadaf Ebrahimi
356*22dc650dSSadaf EbrahimiBUILDING PCRE2 ON WINDOWS WITH VISUAL STUDIO
357*22dc650dSSadaf Ebrahimi
358*22dc650dSSadaf EbrahimiThe code currently cannot be compiled without an inttypes.h header, which is
359*22dc650dSSadaf Ebrahimiavailable only with Visual Studio 2013 or newer. However, this portable and
360*22dc650dSSadaf Ebrahimipermissively-licensed implementation of the stdint.h header could be used as an
361*22dc650dSSadaf Ebrahimialternative:
362*22dc650dSSadaf Ebrahimi
363*22dc650dSSadaf Ebrahimi  http://www.azillionmonkeys.com/qed/pstdint.h
364*22dc650dSSadaf Ebrahimi
365*22dc650dSSadaf EbrahimiJust rename it and drop it into the top level of the build tree.
366*22dc650dSSadaf Ebrahimi
367*22dc650dSSadaf Ebrahimi
368*22dc650dSSadaf EbrahimiTESTING WITH RUNTEST.BAT
369*22dc650dSSadaf Ebrahimi
370*22dc650dSSadaf EbrahimiIf configured with CMake, building the test project ("make test" or building
371*22dc650dSSadaf EbrahimiALL_TESTS in Visual Studio) creates (and runs) pcre2_test.bat (and depending
372*22dc650dSSadaf Ebrahimion your configuration options, possibly other test programs) in the build
373*22dc650dSSadaf Ebrahimidirectory. The pcre2_test.bat script runs RunTest.bat with correct source and
374*22dc650dSSadaf Ebrahimiexe paths.
375*22dc650dSSadaf Ebrahimi
376*22dc650dSSadaf EbrahimiFor manual testing with RunTest.bat, provided the build dir is a subdirectory
377*22dc650dSSadaf Ebrahimiof the source directory: Open command shell window. Chdir to the location
378*22dc650dSSadaf Ebrahimiof your pcre2test.exe and pcre2grep.exe programs. Call RunTest.bat with
379*22dc650dSSadaf Ebrahimi"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate.
380*22dc650dSSadaf Ebrahimi
381*22dc650dSSadaf EbrahimiTo run only a particular test with RunTest.Bat provide a test number argument.
382*22dc650dSSadaf Ebrahimi
383*22dc650dSSadaf EbrahimiOtherwise:
384*22dc650dSSadaf Ebrahimi
385*22dc650dSSadaf Ebrahimi1. Copy RunTest.bat into the directory where pcre2test.exe and pcre2grep.exe
386*22dc650dSSadaf Ebrahimi   have been created.
387*22dc650dSSadaf Ebrahimi
388*22dc650dSSadaf Ebrahimi2. Edit RunTest.bat to identify the full or relative location of
389*22dc650dSSadaf Ebrahimi   the pcre2 source (wherein which the testdata folder resides), e.g.:
390*22dc650dSSadaf Ebrahimi
391*22dc650dSSadaf Ebrahimi   set srcdir=C:\pcre2\pcre2-10.00
392*22dc650dSSadaf Ebrahimi
393*22dc650dSSadaf Ebrahimi3. In a Windows command environment, chdir to the location of your bat and
394*22dc650dSSadaf Ebrahimi   exe programs.
395*22dc650dSSadaf Ebrahimi
396*22dc650dSSadaf Ebrahimi4. Run RunTest.bat. Test outputs will automatically be compared to expected
397*22dc650dSSadaf Ebrahimi   results, and discrepancies will be identified in the console output.
398*22dc650dSSadaf Ebrahimi
399*22dc650dSSadaf EbrahimiTo independently test the just-in-time compiler, run pcre2_jit_test.exe.
400*22dc650dSSadaf Ebrahimi
401*22dc650dSSadaf Ebrahimi
402*22dc650dSSadaf EbrahimiBUILDING PCRE2 ON NATIVE Z/OS AND Z/VM
403*22dc650dSSadaf Ebrahimi
404*22dc650dSSadaf Ebrahimiz/OS and z/VM are operating systems for mainframe computers, produced by IBM.
405*22dc650dSSadaf EbrahimiThe character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and
406*22dc650dSSadaf Ebrahimiapplications can be supported through UNIX System Services, and in such an
407*22dc650dSSadaf Ebrahimienvironment it should be possible to build PCRE2 in the same way as in other
408*22dc650dSSadaf Ebrahimisystems, with the EBCDIC related configuration settings, but it is not known if
409*22dc650dSSadaf Ebrahimianybody has tried this.
410*22dc650dSSadaf Ebrahimi
411*22dc650dSSadaf EbrahimiIn native z/OS (without UNIX System Services) and in z/VM, special ports are
412*22dc650dSSadaf Ebrahimirequired. For details, please see file 939 on this web site:
413*22dc650dSSadaf Ebrahimi
414*22dc650dSSadaf Ebrahimi  http://www.cbttape.org
415*22dc650dSSadaf Ebrahimi
416*22dc650dSSadaf EbrahimiEverything in that location, source and executable, is in EBCDIC and native
417*22dc650dSSadaf Ebrahimiz/OS file formats. The port provides an API for LE languages such as COBOL and
418*22dc650dSSadaf Ebrahimifor the z/OS and z/VM versions of the Rexx languages.
419*22dc650dSSadaf Ebrahimi
420*22dc650dSSadaf Ebrahimi
421*22dc650dSSadaf EbrahimiBUILDING PCRE2 UNDER VMS
422*22dc650dSSadaf Ebrahimi
423*22dc650dSSadaf EbrahimiAlexey Chuphin has contributed some auxiliary files for building PCRE2 under
424*22dc650dSSadaf EbrahimiOpenVMS. They are in the "vms" directory in the distribution tarball. Please
425*22dc650dSSadaf Ebrahimiread the file called vms/openvms_readme.txt. The pcre2test and pcre2grep
426*22dc650dSSadaf Ebrahimiprograms contain some VMS-specific code.
427*22dc650dSSadaf Ebrahimi
428*22dc650dSSadaf Ebrahimi===========================
429*22dc650dSSadaf EbrahimiLast Updated: 16 April 2024
430*22dc650dSSadaf Ebrahimi===========================
431