summaryrefslogtreecommitdiff
path: root/NON-UNIX-USE
blob: c015b214bdd79a67143806543d1d20e9b4834f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Compiling PCRE on non-Unix systems
----------------------------------

See below for comments on Cygwin or MinGW usage. I (Philip Hazel) have no
knowledge of Windows sytems and how their libraries work. The items in the
PCRE Makefile that relate to anything other than Unix-like systems have been
contributed by PCRE users. There are some other comments and files in the
Contrib directory on the ftp site that you may find useful.

The following are generic comments about building PCRE:

If you want to compile PCRE for a non-Unix system (or perhaps, more strictly,
for a system that does not support "configure" and make files), note that PCRE
consists entirely of code written in Standard C, and so should compile
successfully on any machine with a Standard C compiler and library, using
normal compiling commands to do the following:

(1) Copy or rename the file config.in as config.h, and change the macros that
define HAVE_STRERROR and HAVE_MEMMOVE to define them as 1 rather than 0.
Unfortunately, because of the way Unix autoconf works, the default setting has
to be 0. You may also want to make changes to other macros in config.h. In
particular, if you want to force a specific value for newline, you can define
the NEWLINE macro. The default is to use '\n', thereby using whatever value
your compiler gives to '\n'.

(2) Copy or rename the file pcre.in as pcre.h, and change the macro definitions
for PCRE_MAJOR, PCRE_MINOR, and PCRE_DATE near its start to the values set in
configure.in.

(3) Compile dftables.c as a stand-alone program, and then run it with
the single argument "chartables.c". This generates a set of standard
character tables and writes them to that file.

(4) Compile maketables.c, get.c, study.c and pcre.c and link them all
together into an object library in whichever form your system keeps such
libraries. This is the pcre library (chartables.c is included by means of an
#include directive). If your system has static and shared libraries, you may
have to do this once for each type.

(5) Similarly, compile pcreposix.c and link it (on its own) as the pcreposix
library.

(6) Compile the test program pcretest.c. This needs the functions in the
pcre and pcreposix libraries when linking.

(7) Run pcretest on the testinput files in the testdata directory, and check
that the output matches the corresponding testoutput files. You must use the
-i option when checking testinput2. Note that the supplied files are in Unix
format, with just LF characters as line terminators. You may need to edit them
to change this if your system uses a different convention.

If you have a system without "configure" but where you can use a Makefile, edit
Makefile.in to create Makefile, substituting suitable values for the variables
at the head of the file.

Some help in building a Win32 DLL of PCRE in GnuWin32 environments was
contributed by Paul Sokolovsky. These environments are Mingw32
(http://www.xraylith.wisc.edu/~khan/software/gnu-win32/) and CygWin
(http://sourceware.cygnus.com/cygwin/). Paul comments:

  For CygWin, set CFLAGS=-mno-cygwin, and do 'make dll'. You'll get
  pcre.dll (containing pcreposix also), libpcre.dll.a, and dynamically
  linked pgrep and pcretest. If you have /bin/sh, run RunTest (three
  main test go ok, locale not supported).

Changes to do MinGW with autoconf 2.50 were supplied by Fred Cox
<sailorFred@yahoo.com>, who comments as follows:

  If you are using the PCRE DLL, the normal Unix style configure && make &&
  make check && make install should just work[*]. If you want to statically
  link against the .a file, you must define PCRE_STATIC before including
  pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be
  declared __declspec(dllimport), with hilarious results.  See the configure.in
  and pcretest.c for how it is done for the static test.

  Also, there will only be a libpcre.la, not a libpcreposix.la, as you
  would expect from the Unix version. The single DLL includes the pcreposix
  interface.

[*] But note that the supplied test files are in Unix format, with just LF
characters as line terminators. You will have to edit them to change to CR LF
terminators.

A script for building PCRE using Borland's C++ compiler for use with VPASCAL
was contributed by Alexander Tokarev. It is called makevp.bat.

These are some further comments about Win32 builds from Mark Evans. They
were contributed before Fred Cox's changes were made, so it is possible that
they may no longer be relevant.

"The documentation for Win32 builds is a bit shy.  Under MSVC6 I
followed their instructions to the letter, but there were still
some things missing.

(1) Must #define STATIC for entire project if linking statically.
    (I see no reason to use DLLs for code this compact.)  This of
    course is a project setting in MSVC under Preprocessor.

(2) Missing some #ifdefs relating to the function pointers
    pcre_malloc and pcre_free.  See my solution below.  (The stubs
    may not be mandatory but they made me feel better.)"

=========================
#ifdef _WIN32
#include <malloc.h>

void* malloc_stub(size_t N)
{ return malloc(N); }
void free_stub(void* p)
{ free(p); }
void *(*pcre_malloc)(size_t) = &malloc_stub;
void  (*pcre_free)(void *) = &free_stub;

#else

void *(*pcre_malloc)(size_t) = malloc;
void  (*pcre_free)(void *) = free;

#endif
=========================

****