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

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

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12