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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (show annotations) (download)
Sat Feb 24 21:40:03 2007 UTC (7 years, 7 months ago) by nigel
File size: 4790 byte(s)
Load pcre-4.0 into code/trunk.

1 Compiling PCRE on non-Unix systems
2 ----------------------------------
3
4 See below for comments on Cygwin or MinGW usage.
5
6 If you want to compile PCRE for a non-Unix system, note that it consists
7 entirely of code written in Standard C, and so should compile successfully
8 on any machine with a Standard C compiler and library, using normal compiling
9 commands to do the following:
10
11 (1) Copy or rename the file config.in as config.h, and change the macros that
12 define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
13 Unfortunately, because of the way Unix autoconf works, the default setting has
14 to be 0. You may also want to make changes to other macros in config.h. In
15 particular, if you want to force a specific value for newline, you can define
16 the NEWLINE macro. The default is to use '\n', thereby using whatever value
17 your compiler gives to '\n'.
18
19 (2) Copy or rename the file pcre.in as pcre.h, and change the macro definitions
20 for PCRE_MAJOR, PCRE_MINOR, and PCRE_DATE near its start to the values set in
21 configure.in.
22
23 (3) Compile dftables.c as a stand-alone program, and then run it with
24 the standard output sent to chartables.c. This generates a set of standard
25 character tables.
26
27 (4) Compile maketables.c, get.c, study.c and pcre.c and link them all
28 together into an object library in whichever form your system keeps such
29 libraries. This is the pcre library (chartables.c is included by means of an
30 #include directive).
31
32 (5) Similarly, compile pcreposix.c and link it as the pcreposix library.
33
34 (6) Compile the test program pcretest.c. This needs the functions in the
35 pcre and pcreposix libraries when linking.
36
37 (7) Run pcretest on the testinput files in the testdata directory, and check
38 that the output matches the corresponding testoutput files. You must use the
39 -i option when checking testinput2. Note that the supplied files are in Unix
40 format, with just LF characters as line terminators. You may need to edit them
41 to change this if your system uses a different convention.
42
43 If you have a system without "configure" but where you can use a Makefile, edit
44 Makefile.in to create Makefile, substituting suitable values for the variables
45 at the head of the file.
46
47 Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
48 contributed by Paul Sokolovsky. These environments are Mingw32
49 (http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
50 (http://sourceware.cygnus.com/cygwin/). Paul comments:
51
52 For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
53 pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
54 linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
55 main test go ok, locale not supported).
56
57 Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
58 <sailorFred@yahoo.com>, who comments as follows:
59
60 If you are using the PCRE DLL, the normal Unix style configure && make &&
61 make check && make install should just work[*]. If you want to statically
62 link against the .a file, you must define PCRE_STATIC before including
63 pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
64 declared __declspec(dllimport), with hilarious results. See the configure.in
65 and pcretest.c for how it is done for the static test.
66
67 Also, there will only be a libpcre.la, not a libpcreposix.la, as you
68 would expect from the Unix version. The single DLL includes the pcreposix
69 interface.
70
71 [*] But note that the supplied test files are in Unix format, with just LF
72 characters as line terminators. You will have to edit them to change to CR LF
73 terminators.
74
75 A script for building PCRE using Borland's C++ compiler for use with VPASCAL
76 was contributed by Alexander Tokarev. It is called makevp.bat.
77
78 These are some further comments about Win32 builds from Mark Evans. They
79 were contributed before Fred Cox's changes were made, so it is possible that
80 they may no longer be relevant.
81
82 The documentation for Win32 builds is a bit shy. Under MSVC6 I
83 followed their instructions to the letter, but there were still
84 some things missing.
85
86 (1) Must #define STATIC for entire project if linking statically.
87 (I see no reason to use DLLs for code this compact.) This of
88 course is a project setting in MSVC under Preprocessor.
89
90 (2) Missing some #ifdefs relating to the function pointers
91 pcre_malloc and pcre_free. See my solution below. (The stubs
92 may not be mandatory but they made me feel better.)
93
94 =========================
95 #ifdef _WIN32
96 #include <malloc.h>
97
98 void* malloc_stub(size_t N)
99 { return malloc(N); }
100 void free_stub(void* p)
101 { free(p); }
102 void *(*pcre_malloc)(size_t) = &malloc_stub;
103 void (*pcre_free)(void *) = &free_stub;
104
105 #else
106
107 void *(*pcre_malloc)(size_t) = malloc;
108 void (*pcre_free)(void *) = free;
109
110 #endif
111 =========================
112
113 ****

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12