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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12