/[pcre]/code/tags/pcre-6.4/NON-UNIX-USE
ViewVC logotype

Diff of /code/tags/pcre-6.4/NON-UNIX-USE

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.53  
changed lines
  Added in v.79

  ViewVC Help
Powered by ViewVC 1.1.5