/[pcre]/code/trunk/NON-UNIX-USE
ViewVC logotype

Contents of /code/trunk/NON-UNIX-USE

Parent Directory Parent Directory | Revision Log Revision Log


Revision 87 - (hide annotations) (download)
Sat Feb 24 21:41:21 2007 UTC (7 years, 5 months ago) by nigel
File size: 10634 byte(s)
Load pcre-6.5 into code/trunk.

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12