1 Compiling PCRE on non-Unix systems
2 ----------------------------------
4 See below for comments on Cygwin or MinGW and OpenVMS usage. I (Philip Hazel)
5 have no knowledge of Windows or VMS sytems and how their libraries work. The
6 items in the PCRE Makefile that relate to anything other than Unix-like systems
7 have been contributed by PCRE users. There are some other comments and files in
8 the Contrib directory on the ftp site that you may find useful. See
10 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
12 If you want to compile PCRE for a non-Unix system (or perhaps, more strictly,
13 for a system that does not support "configure" and "make" files), note that
14 PCRE consists entirely of code written in Standard C, and so should compile
15 successfully on any system that has a Standard C compiler and library.
20 The following are generic comments about building PCRE. The interspersed
21 indented commands are suggestions from Mark Tetrode as to which commands you
22 might use on a Windows system to build a static library.
24 (1) Copy or rename the file config.in as config.h, and change the macros that
25 define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
26 Unfortunately, because of the way Unix autoconf works, the default setting has
27 to be 0. You may also want to make changes to other macros in config.h. In
28 particular, if you want to force a specific value for newline, you can define
29 the NEWLINE macro. The default is to use '\n', thereby using whatever value
30 your compiler gives to '\n'.
32 rem Mark Tetrode's commands
33 copy config.in config.h
34 rem Use write, because notepad cannot handle UNIX files. Change values.
37 (2) Copy or rename the file pcre.in as pcre.h, and change the macro definitions
38 for PCRE_MAJOR, PCRE_MINOR, and PCRE_DATE near its start to the values set in
41 rem Mark Tetrode's commands
43 rem Read values from configure.in
48 (3) Compile dftables.c as a stand-alone program, and then run it with
49 the single argument "chartables.c". This generates a set of standard
50 character tables and writes them to that file.
52 rem Mark Tetrode's commands
54 cl -DSUPPORT_UTF8 dftables.c
55 dftables.exe > chartables.c
57 (4) Compile maketables.c, get.c, study.c and pcre.c and link them all
58 together into an object library in whichever form your system keeps such
59 libraries. This is the pcre library (chartables.c is included by means of an
60 #include directive). If your system has static and shared libraries, you may
61 have to do this once for each type.
63 rem Mark Tetrode's commands, for a static library
65 cl -DSUPPORT_UTF8 -DPOSIX_MALLOC_THRESHOLD=10 /c maketables.c get.c study.c pcre.c
66 lib /OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj
68 (5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
71 rem Mark Tetrode's commands, for a static library
73 cl -DSUPPORT_UTF8 -DPOSIX_MALLOC_THRESHOLD=10 /c pcreposix.c
74 lib /OUT:pcreposix.lib pcreposix.obj
76 (6) Compile the test program pcretest.c. This needs the functions in the
77 pcre and pcreposix libraries when linking.
79 rem Mark Tetrode's commands
81 cl pcretest.c pcre.lib pcreposix.lib
83 (7) Run pcretest on the testinput files in the testdata directory, and check
84 that the output matches the corresponding testoutput files. You must use the
85 -i option when checking testinput2. Note that the supplied files are in Unix
86 format, with just LF characters as line terminators. You may need to edit them
87 to change this if your system uses a different convention.
89 rem Mark Tetrode's commands
90 rem Make a change, i.e. space, backspace, and save again - do this for all
91 rem to change UNIX to Win, \n to \n\r
97 pcretest testdata\testinput1 testdata\myoutput1
98 windiff testdata\testoutput1 testdata\myoutput1
99 pcretest -i testdata\testinput2 testdata\myoutput2
100 windiff testdata\testoutput2 testdata\myoutput2
101 pcretest testdata\testinput3 testdata\myoutput3
102 windiff testdata\testoutput3 testdata\myoutput3
103 pcretest testdata\testinput4 testdata\myoutput4
104 windiff testdata\testoutput4 testdata\myoutput4
105 pcretest testdata\testinput5 testdata\myoutput5
106 windiff testdata\testoutput5 testdata\myoutput5
111 If you have a system without "configure" but where you can use a Makefile, edit
112 Makefile.in to create Makefile, substituting suitable values for the variables
113 at the head of the file.
115 Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
116 contributed by Paul Sokolovsky. These environments are Mingw32
117 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
118 (http://sourceware.cygnus.com/cygwin/). Paul comments:
120 For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
121 pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
122 linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
123 main test go ok, locale not supported).
125 Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
126 <sailorFred@yahoo.com>, who comments as follows:
128 If you are using the PCRE DLL, the normal Unix style configure && make &&
129 make check && make install should just work[*]. If you want to statically
130 link against the .a file, you must define PCRE_STATIC before including
131 pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
132 declared __declspec(dllimport), with hilarious results. See the configure.in
133 and pcretest.c for how it is done for the static test.
135 Also, there will only be a libpcre.la, not a libpcreposix.la, as you
136 would expect from the Unix version. The single DLL includes the pcreposix
139 [*] But note that the supplied test files are in Unix format, with just LF
140 characters as line terminators. You will have to edit them to change to CR LF
143 A script for building PCRE using Borland's C++ compiler for use with VPASCAL
144 was contributed by Alexander Tokarev. It is called makevp.bat.
146 These are some further comments about Win32 builds from Mark Evans. They
147 were contributed before Fred Cox's changes were made, so it is possible that
148 they may no longer be relevant.
150 "The documentation for Win32 builds is a bit shy. Under MSVC6 I
151 followed their instructions to the letter, but there were still
154 (1) Must #define STATIC for entire project if linking statically.
155 (I see no reason to use DLLs for code this compact.) This of
156 course is a project setting in MSVC under Preprocessor.
158 (2) Missing some #ifdefs relating to the function pointers
159 pcre_malloc and pcre_free. See my solution below. (The stubs
160 may not be mandatory but they made me feel better.)"
162 =========================
166 void* malloc_stub(size_t N)
167 { return malloc(N); }
168 void free_stub(void* p)
170 void *(*pcre_malloc)(size_t) = &malloc_stub;
171 void (*pcre_free)(void *) = &free_stub;
175 void *(*pcre_malloc)(size_t) = malloc;
176 void (*pcre_free)(void *) = free;
179 =========================
182 BUILDING PCRE ON OPENVMS
184 Dan Mooney sent the following comments about building PCRE on OpenVMS:
186 "It was quite easy to compile and link the library. I don't have a formal
187 make file but the attached file [reproduced below] contains the OpenVMS DCL
188 commands I used to build the library. I had to add #define
189 POSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.
191 The library was built on:
192 O/S: HP OpenVMS v7.3-1
193 Compiler: Compaq C v6.5-001-48BCD
196 The test results did not match 100% due to the issues you mention in your
197 documentation regarding isprint(), iscntrl(), isgraph() and ispunct(). I
198 modified some of the character tables temporarily and was able to get the
199 results to match. Tests using the fr locale did not match since I don't have
200 that locale loaded. The study size was always reported to be 3 less than the
201 value in the standard test output files."
203 =========================
204 $! This DCL procedure builds PCRE on OpenVMS
206 $! I followed the instructions in the non-unix-use file in the distribution.
208 $ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
210 $ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ
211 $ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C
212 $ COMPILE MAKETABLES.C
215 $! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
216 $! did not seem to be defined anywhere.
217 $! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.
219 $ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ
220 $! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
221 $! did not seem to be defined anywhere.
222 $ COMPILE PCREPOSIX.C
223 $ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ
225 $ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB
226 $! C programs that want access to command line arguments must be
227 $! defined as a symbol
228 $ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"
229 $! Arguments must be enclosed in quotes.
233 $! The test results did not match 100%. The functions isprint(), iscntrl(),
234 $! isgraph() and ispunct() on OpenVMS must not produce the same results
235 $! as the system that built the test output files provided with the
238 $! The study size did not match and was always 3 less on OpenVMS.
240 $! Locale could not be set to fr
242 =========================