ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

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

  ViewVC Help
Powered by ViewVC 1.1.5