"Fossies" - the Fresh Open Source Software Archive 
Member "tin-2.6.2/pcre/NON-UNIX-USE" (23 Aug 2021, 11121 Bytes) of package /linux/misc/tin-2.6.2.tar.xz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 Compiling PCRE on non-Unix systems
2 ----------------------------------
3
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
9
10 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
11
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 the basic PCRE library consists entirely of code written in Standard C, and so
15 should compile successfully on any system that has a Standard C compiler and
16 library. The C++ wrapper functions are a separate issue (see below).
17
18
19 GENERIC INSTRUCTIONS FOR THE C LIBRARY
20
21 The following are generic comments about building PCRE. The interspersed
22 indented commands are suggestions from Mark Tetrode as to which commands you
23 might use on a Windows system to build a static library.
24
25 (1) Copy or rename the file config.h.in as config.h, and change the macros that
26 define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
27 Unfortunately, because of the way Unix autoconf works, the default setting has
28 to be 0. You may also want to make changes to other macros in config.h. In
29 particular, if you want to force a specific value for newline, you can define
30 the NEWLINE macro. The default is to use '\n', thereby using whatever value
31 your compiler gives to '\n'.
32
33 rem Mark Tetrode's commands
34 copy config.h.in config.h
35 rem Use write, because notepad cannot handle UNIX files. Change values.
36 write config.h
37
38 (2) Compile dftables.c as a stand-alone program, and then run it with
39 the single argument "pcre_chartables.c". This generates a set of standard
40 character tables and writes them to that file.
41
42 rem Mark Tetrode's commands
43 rem Compile & run
44 cl -DSUPPORT_UTF8 -DSUPPORT_UCP dftables.c
45 dftables.exe pcre_chartables.c
46
47 (3) Compile the following source files:
48
49 pcre_chartables.c
50 pcre_compile.c
51 pcre_config.c
52 pcre_dfa_exec.c
53 pcre_exec.c
54 pcre_fullinfo.c
55 pcre_get.c
56 pcre_globals.c
57 pcre_info.c
58 pcre_maketables.c
59 pcre_newline.c
60 pcre_ord2utf8.c
61 pcre_refcount.c
62 pcre_study.c
63 pcre_tables.c
64 pcre_try_flipped.c
65 pcre_ucp_searchfuncs.c
66 pcre_valid_utf8.c
67 pcre_version.c
68 pcre_xclass.c
69
70 and link them all together into an object library in whichever form your system
71 keeps such libraries. This is the pcre C library. If your system has static and
72 shared libraries, you may have to do this once for each type.
73
74 rem These comments are out-of-date, referring to a previous release which
75 rem had fewer source files. Replace with the file names from above.
76 rem Mark Tetrode's commands, for a static library
77 rem Compile & lib
78 cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c maketables.c get.c study.c pcre.c
79 lib /OUT:pcre.lib maketables.obj get.obj study.obj pcre.obj
80
81 (4) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
82 library.
83
84 rem Mark Tetrode's commands, for a static library
85 rem Compile & lib
86 cl -DSUPPORT_UTF8 -DSUPPORT_UCP -DPOSIX_MALLOC_THRESHOLD=10 /c pcreposix.c
87 lib /OUT:pcreposix.lib pcreposix.obj
88
89 (5) Compile the test program pcretest.c. This needs the functions in the
90 pcre and pcreposix libraries when linking.
91
92 rem Mark Tetrode's commands
93 rem compile & link
94 cl /F0x400000 pcretest.c pcre.lib pcreposix.lib
95
96 (6) Run pcretest on the testinput files in the testdata directory, and check
97 that the output matches the corresponding testoutput files. Note that the
98 supplied files are in Unix format, with just LF characters as line terminators.
99 You may need to edit them to change this if your system uses a different
100 convention.
101
102 rem Mark Tetrode's commands
103 pcretest testdata\testinput1 testdata\myoutput1
104 windiff testdata\testoutput1 testdata\myoutput1
105 pcretest -i testdata\testinput2 testdata\myoutput2
106 windiff testdata\testoutput2 testdata\myoutput2
107 pcretest testdata\testinput3 testdata\myoutput3
108 windiff testdata\testoutput3 testdata\myoutput3
109 pcretest testdata\testinput4 testdata\myoutput4
110 windiff testdata\testoutput4 testdata\myoutput4
111 pcretest testdata\testinput5 testdata\myoutput5
112 windiff testdata\testoutput5 testdata\myoutput5
113 pcretest testdata\testinput6 testdata\myoutput6
114 windiff testdata\testoutput6 testdata\myoutput6
115
116 Note that there are now three more tests (7, 8, 9) that did not exist when Mark
117 wrote those comments. The test the new pcre_dfa_exec() function.
118
119 (7) If you want to use the pcregrep command, compile and link pcregrep.c; it
120 uses only the basic PCRE library.
121
122
123 THE C++ WRAPPER FUNCTIONS
124
125 The PCRE distribution now contains some C++ wrapper functions and tests,
126 contributed by Google Inc. On a system that can use "configure" and "make",
127 the functions are automatically built into a library called pcrecpp. It should
128 be straightforward to compile the .cc files manually on other systems. The
129 files called xxx_unittest.cc are test programs for each of the corresponding
130 xxx.cc files.
131
132
133 FURTHER REMARKS
134
135 If you have a system without "configure" but where you can use a Makefile, edit
136 Makefile.in to create Makefile, substituting suitable values for the variables
137 at the head of the file.
138
139 Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
140
141 Some of the core BCC libraries have a version of PCRE from 1998 built in,
142 which can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a
143 version mismatch. I'm including an easy workaround below, if you'd like to
144 include it in the non-unix instructions:
145
146 When linking a project with BCC5.5, pcre.lib must be included before any of
147 the libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command
148 line.
149
150 Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
151 contributed by Paul Sokolovsky. These environments are Mingw32
152 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
153 (http://sourceware.cygnus.com/cygwin/). Paul comments:
154
155 For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
156 pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
157 linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
158 main test go ok, locale not supported).
159
160 Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
161 <sailorFred@yahoo.com>, who comments as follows:
162
163 If you are using the PCRE DLL, the normal Unix style configure && make &&
164 make check && make install should just work[*]. If you want to statically
165 link against the .a file, you must define PCRE_STATIC before including
166 pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
167 declared __declspec(dllimport), with hilarious results. See the configure.in
168 and pcretest.c for how it is done for the static test.
169
170 Also, there will only be a libpcre.la, not a libpcreposix.la, as you
171 would expect from the Unix version. The single DLL includes the pcreposix
172 interface.
173
174 [*] But note that the supplied test files are in Unix format, with just LF
175 characters as line terminators. You will have to edit them to change to CR LF
176 terminators.
177
178 A script for building PCRE using Borland's C++ compiler for use with VPASCAL
179 was contributed by Alexander Tokarev. It is called makevp.bat.
180
181 These are some further comments about Win32 builds from Mark Evans. They
182 were contributed before Fred Cox's changes were made, so it is possible that
183 they may no longer be relevant.
184
185 "The documentation for Win32 builds is a bit shy. Under MSVC6 I
186 followed their instructions to the letter, but there were still
187 some things missing.
188
189 (1) Must #define STATIC for entire project if linking statically.
190 (I see no reason to use DLLs for code this compact.) This of
191 course is a project setting in MSVC under Preprocessor.
192
193 (2) Missing some #ifdefs relating to the function pointers
194 pcre_malloc and pcre_free. See my solution below. (The stubs
195 may not be mandatory but they made me feel better.)"
196
197 =========================
198 #ifdef _WIN32
199 #include <malloc.h>
200
201 void* malloc_stub(size_t N)
202 { return malloc(N); }
203 void free_stub(void* p)
204 { free(p); }
205 void *(*pcre_malloc)(size_t) = &malloc_stub;
206 void (*pcre_free)(void *) = &free_stub;
207
208 #else
209
210 void *(*pcre_malloc)(size_t) = malloc;
211 void (*pcre_free)(void *) = free;
212
213 #endif
214 =========================
215
216
217 BUILDING PCRE ON OPENVMS
218
219 Dan Mooney sent the following comments about building PCRE on OpenVMS. They
220 relate to an older version of PCRE that used fewer source files, so the exact
221 commands will need changing. See the current list of source files above.
222
223 "It was quite easy to compile and link the library. I don't have a formal
224 make file but the attached file [reproduced below] contains the OpenVMS DCL
225 commands I used to build the library. I had to add #define
226 POSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.
227
228 The library was built on:
229 O/S: HP OpenVMS v7.3-1
230 Compiler: Compaq C v6.5-001-48BCD
231 Linker: vA13-01
232
233 The test results did not match 100% due to the issues you mention in your
234 documentation regarding isprint(), iscntrl(), isgraph() and ispunct(). I
235 modified some of the character tables temporarily and was able to get the
236 results to match. Tests using the fr locale did not match since I don't have
237 that locale loaded. The study size was always reported to be 3 less than the
238 value in the standard test output files."
239
240 =========================
241 $! This DCL procedure builds PCRE on OpenVMS
242 $!
243 $! I followed the instructions in the non-unix-use file in the distribution.
244 $!
245 $ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
246 $ COMPILE DFTABLES.C
247 $ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ
248 $ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C
249 $ COMPILE MAKETABLES.C
250 $ COMPILE GET.C
251 $ COMPILE STUDY.C
252 $! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
253 $! did not seem to be defined anywhere.
254 $! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.
255 $ COMPILE PCRE.C
256 $ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ
257 $! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
258 $! did not seem to be defined anywhere.
259 $ COMPILE PCREPOSIX.C
260 $ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ
261 $ COMPILE PCRETEST.C
262 $ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB
263 $! C programs that want access to command line arguments must be
264 $! defined as a symbol
265 $ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"
266 $! Arguments must be enclosed in quotes.
267 $ PCRETEST "-C"
268 $! Test results:
269 $!
270 $! The test results did not match 100%. The functions isprint(), iscntrl(),
271 $! isgraph() and ispunct() on OpenVMS must not produce the same results
272 $! as the system that built the test output files provided with the
273 $! distribution.
274 $!
275 $! The study size did not match and was always 3 less on OpenVMS.
276 $!
277 $! Locale could not be set to fr
278 $!
279 =========================
280
281 ****