Blame NON-AUTOTOOLS-BUILD

Packit 78a954
Building PCRE without using autotools
Packit 78a954
-------------------------------------
Packit 78a954
Packit 78a954
NOTE: This document relates to PCRE releases that use the original API, with
Packit 78a954
library names libpcre, libpcre16, and libpcre32. January 2015 saw the first
Packit 78a954
release of a new API, known as PCRE2, with release numbers starting at 10.00
Packit 78a954
and library names libpcre2-8, libpcre2-16, and libpcre2-32. The old libraries
Packit 78a954
(now called PCRE1) are still being maintained for bug fixes, but there will be
Packit 78a954
no new development. New projects are advised to use the new PCRE2 libraries.
Packit 78a954
Packit 78a954
Packit 78a954
This document contains the following sections:
Packit 78a954
Packit 78a954
  General
Packit 78a954
  Generic instructions for the PCRE C library
Packit 78a954
  The C++ wrapper functions
Packit 78a954
  Building for virtual Pascal
Packit 78a954
  Stack size in Windows environments
Packit 78a954
  Linking programs in Windows environments
Packit 78a954
  Calling conventions in Windows environments
Packit 78a954
  Comments about Win32 builds
Packit 78a954
  Building PCRE on Windows with CMake
Packit 78a954
  Use of relative paths with CMake on Windows
Packit 78a954
  Testing with RunTest.bat
Packit 78a954
  Building under Windows CE with Visual Studio 200x
Packit 78a954
  Building under Windows with BCC5.5
Packit 78a954
  Building using Borland C++ Builder 2007 (CB2007) and higher
Packit 78a954
  Building PCRE on OpenVMS
Packit 78a954
  Building PCRE on Stratus OpenVOS
Packit 78a954
  Building PCRE on native z/OS and z/VM
Packit 78a954
Packit 78a954
Packit 78a954
GENERAL
Packit 78a954
Packit 78a954
I (Philip Hazel) have no experience of Windows or VMS sytems and how their
Packit 78a954
libraries work. The items in the PCRE distribution and Makefile that relate to
Packit 78a954
anything other than Linux systems are untested by me.
Packit 78a954
Packit 78a954
There are some other comments and files (including some documentation in CHM
Packit 78a954
format) in the Contrib directory on the FTP site:
Packit 78a954
Packit 78a954
  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib
Packit 78a954
Packit 78a954
The basic PCRE library consists entirely of code written in Standard C, and so
Packit 78a954
should compile successfully on any system that has a Standard C compiler and
Packit 78a954
library. The C++ wrapper functions are a separate issue (see below).
Packit 78a954
Packit 78a954
The PCRE distribution includes a "configure" file for use by the configure/make
Packit 78a954
(autotools) build system, as found in many Unix-like environments. The README
Packit 78a954
file contains information about the options for "configure".
Packit 78a954
Packit 78a954
There is also support for CMake, which some users prefer, especially in Windows
Packit 78a954
environments, though it can also be run in Unix-like environments. See the
Packit 78a954
section entitled "Building PCRE on Windows with CMake" below.
Packit 78a954
Packit 78a954
Versions of config.h and pcre.h are distributed in the PCRE tarballs under the
Packit 78a954
names config.h.generic and pcre.h.generic. These are provided for those who
Packit 78a954
build PCRE without using "configure" or CMake. If you use "configure" or CMake,
Packit 78a954
the .generic versions are not used.
Packit 78a954
Packit 78a954
Packit 78a954
GENERIC INSTRUCTIONS FOR THE PCRE C LIBRARY
Packit 78a954
Packit 78a954
The following are generic instructions for building the PCRE C library "by
Packit 78a954
hand". If you are going to use CMake, this section does not apply to you; you
Packit 78a954
can skip ahead to the CMake section.
Packit 78a954
Packit 78a954
 (1) Copy or rename the file config.h.generic as config.h, and edit the macro
Packit 78a954
     settings that it contains to whatever is appropriate for your environment.
Packit 78a954
Packit 78a954
     In particular, you can alter the definition of the NEWLINE macro to
Packit 78a954
     specify what character(s) you want to be interpreted as line terminators.
Packit 78a954
     In an EBCDIC environment, you MUST change NEWLINE, because its default
Packit 78a954
     value is 10, an ASCII LF. The usual EBCDIC newline character is 21 (0x15,
Packit 78a954
     NL), though in some cases it may be 37 (0x25).
Packit 78a954
Packit 78a954
     When you compile any of the PCRE modules, you must specify -DHAVE_CONFIG_H
Packit 78a954
     to your compiler so that config.h is included in the sources.
Packit 78a954
Packit 78a954
     An alternative approach is not to edit config.h, but to use -D on the
Packit 78a954
     compiler command line to make any changes that you need to the
Packit 78a954
     configuration options. In this case -DHAVE_CONFIG_H must not be set.
Packit 78a954
Packit 78a954
     NOTE: There have been occasions when the way in which certain parameters
Packit 78a954
     in config.h are used has changed between releases. (In the configure/make
Packit 78a954
     world, this is handled automatically.) When upgrading to a new release,
Packit 78a954
     you are strongly advised to review config.h.generic before re-using what
Packit 78a954
     you had previously.
Packit 78a954
Packit 78a954
 (2) Copy or rename the file pcre.h.generic as pcre.h.
Packit 78a954
Packit 78a954
 (3) EITHER:
Packit 78a954
       Copy or rename file pcre_chartables.c.dist as pcre_chartables.c.
Packit 78a954
Packit 78a954
     OR:
Packit 78a954
       Compile dftables.c as a stand-alone program (using -DHAVE_CONFIG_H if
Packit 78a954
       you have set up config.h), and then run it with the single argument
Packit 78a954
       "pcre_chartables.c". This generates a set of standard character tables
Packit 78a954
       and writes them to that file. The tables are generated using the default
Packit 78a954
       C locale for your system. If you want to use a locale that is specified
Packit 78a954
       by LC_xxx environment variables, add the -L option to the dftables
Packit 78a954
       command. You must use this method if you are building on a system that
Packit 78a954
       uses EBCDIC code.
Packit 78a954
Packit 78a954
     The tables in pcre_chartables.c are defaults. The caller of PCRE can
Packit 78a954
     specify alternative tables at run time.
Packit 78a954
Packit 78a954
 (4) Ensure that you have the following header files:
Packit 78a954
Packit 78a954
       pcre_internal.h
Packit 78a954
       ucp.h
Packit 78a954
Packit 78a954
 (5) For an 8-bit library, compile the following source files, setting
Packit 78a954
     -DHAVE_CONFIG_H as a compiler option if you have set up config.h with your
Packit 78a954
     configuration, or else use other -D settings to change the configuration
Packit 78a954
     as required.
Packit 78a954
Packit 78a954
       pcre_byte_order.c
Packit 78a954
       pcre_chartables.c
Packit 78a954
       pcre_compile.c
Packit 78a954
       pcre_config.c
Packit 78a954
       pcre_dfa_exec.c
Packit 78a954
       pcre_exec.c
Packit 78a954
       pcre_fullinfo.c
Packit 78a954
       pcre_get.c
Packit 78a954
       pcre_globals.c
Packit 78a954
       pcre_jit_compile.c
Packit 78a954
       pcre_maketables.c
Packit 78a954
       pcre_newline.c
Packit 78a954
       pcre_ord2utf8.c
Packit 78a954
       pcre_refcount.c
Packit 78a954
       pcre_string_utils.c
Packit 78a954
       pcre_study.c
Packit 78a954
       pcre_tables.c
Packit 78a954
       pcre_ucd.c
Packit 78a954
       pcre_valid_utf8.c
Packit 78a954
       pcre_version.c
Packit 78a954
       pcre_xclass.c
Packit 78a954
Packit 78a954
     Make sure that you include -I. in the compiler command (or equivalent for
Packit 78a954
     an unusual compiler) so that all included PCRE header files are first
Packit 78a954
     sought in the current directory. Otherwise you run the risk of picking up
Packit 78a954
     a previously-installed file from somewhere else.
Packit 78a954
Packit 78a954
     Note that you must still compile pcre_jit_compile.c, even if you have not
Packit 78a954
     defined SUPPORT_JIT in config.h, because when JIT support is not
Packit 78a954
     configured, dummy functions are compiled. When JIT support IS configured,
Packit 78a954
     pcre_jit_compile.c #includes sources from the sljit subdirectory, where
Packit 78a954
     there should be 16 files, all of whose names begin with "sljit".
Packit 78a954
Packit 78a954
 (6) Now link all the compiled code into an object library in whichever form
Packit 78a954
     your system keeps such libraries. This is the basic PCRE C 8-bit library.
Packit 78a954
     If your system has static and shared libraries, you may have to do this
Packit 78a954
     once for each type.
Packit 78a954
Packit 78a954
 (7) If you want to build a 16-bit library (as well as, or instead of the 8-bit
Packit 78a954
     or 32-bit libraries) repeat steps 5-6 with the following files:
Packit 78a954
Packit 78a954
       pcre16_byte_order.c
Packit 78a954
       pcre16_chartables.c
Packit 78a954
       pcre16_compile.c
Packit 78a954
       pcre16_config.c
Packit 78a954
       pcre16_dfa_exec.c
Packit 78a954
       pcre16_exec.c
Packit 78a954
       pcre16_fullinfo.c
Packit 78a954
       pcre16_get.c
Packit 78a954
       pcre16_globals.c
Packit 78a954
       pcre16_jit_compile.c
Packit 78a954
       pcre16_maketables.c
Packit 78a954
       pcre16_newline.c
Packit 78a954
       pcre16_ord2utf16.c
Packit 78a954
       pcre16_refcount.c
Packit 78a954
       pcre16_string_utils.c
Packit 78a954
       pcre16_study.c
Packit 78a954
       pcre16_tables.c
Packit 78a954
       pcre16_ucd.c
Packit 78a954
       pcre16_utf16_utils.c
Packit 78a954
       pcre16_valid_utf16.c
Packit 78a954
       pcre16_version.c
Packit 78a954
       pcre16_xclass.c
Packit 78a954
Packit 78a954
 (8) If you want to build a 32-bit library (as well as, or instead of the 8-bit
Packit 78a954
     or 16-bit libraries) repeat steps 5-6 with the following files:
Packit 78a954
Packit 78a954
       pcre32_byte_order.c
Packit 78a954
       pcre32_chartables.c
Packit 78a954
       pcre32_compile.c
Packit 78a954
       pcre32_config.c
Packit 78a954
       pcre32_dfa_exec.c
Packit 78a954
       pcre32_exec.c
Packit 78a954
       pcre32_fullinfo.c
Packit 78a954
       pcre32_get.c
Packit 78a954
       pcre32_globals.c
Packit 78a954
       pcre32_jit_compile.c
Packit 78a954
       pcre32_maketables.c
Packit 78a954
       pcre32_newline.c
Packit 78a954
       pcre32_ord2utf32.c
Packit 78a954
       pcre32_refcount.c
Packit 78a954
       pcre32_string_utils.c
Packit 78a954
       pcre32_study.c
Packit 78a954
       pcre32_tables.c
Packit 78a954
       pcre32_ucd.c
Packit 78a954
       pcre32_utf32_utils.c
Packit 78a954
       pcre32_valid_utf32.c
Packit 78a954
       pcre32_version.c
Packit 78a954
       pcre32_xclass.c
Packit 78a954
Packit 78a954
 (9) If you want to build the POSIX wrapper functions (which apply only to the
Packit 78a954
     8-bit library), ensure that you have the pcreposix.h file and then compile
Packit 78a954
     pcreposix.c (remembering -DHAVE_CONFIG_H if necessary). Link the result
Packit 78a954
     (on its own) as the pcreposix library.
Packit 78a954
Packit 78a954
(10) The pcretest program can be linked with any combination of the 8-bit,
Packit 78a954
     16-bit and 32-bit libraries (depending on what you selected in config.h).
Packit 78a954
     Compile pcretest.c and pcre_printint.c (again, don't forget
Packit 78a954
     -DHAVE_CONFIG_H) and link them together with the appropriate library/ies.
Packit 78a954
     If you compiled an 8-bit library, pcretest also needs the pcreposix
Packit 78a954
     wrapper library unless you compiled it with -DNOPOSIX.
Packit 78a954
Packit 78a954
(11) Run pcretest on the testinput files in the testdata directory, and check
Packit 78a954
     that the output matches the corresponding testoutput files. There are
Packit 78a954
     comments about what each test does in the section entitled "Testing PCRE"
Packit 78a954
     in the README file. If you compiled more than one of the 8-bit, 16-bit and
Packit 78a954
     32-bit libraries, you need to run pcretest with the -16 option to do
Packit 78a954
     16-bit tests and with the -32 option to do 32-bit tests.
Packit 78a954
Packit 78a954
     Some tests are relevant only when certain build-time options are selected.
Packit 78a954
     For example, test 4 is for UTF-8/UTF-16/UTF-32 support, and will not run
Packit 78a954
     if you have built PCRE without it. See the comments at the start of each
Packit 78a954
     testinput file. If you have a suitable Unix-like shell, the RunTest script
Packit 78a954
     will run the appropriate tests for you. The command "RunTest list" will
Packit 78a954
     output a list of all the tests.
Packit 78a954
Packit 78a954
     Note that the supplied files are in Unix format, with just LF characters
Packit 78a954
     as line terminators. You may need to edit them to change this if your
Packit 78a954
     system uses a different convention. If you are using Windows, you probably
Packit 78a954
     should use the wintestinput3 file instead of testinput3 (and the
Packit 78a954
     corresponding output file). This is a locale test; wintestinput3 sets the
Packit 78a954
     locale to "french" rather than "fr_FR", and there some minor output
Packit 78a954
     differences.
Packit 78a954
Packit 78a954
(12) If you have built PCRE with SUPPORT_JIT, the JIT features will be tested
Packit 78a954
     by the testdata files. However, you might also like to build and run
Packit 78a954
     the freestanding JIT test program, pcre_jit_test.c.
Packit 78a954
Packit 78a954
(13) If you want to use the pcregrep command, compile and link pcregrep.c; it
Packit 78a954
     uses only the basic 8-bit PCRE library (it does not need the pcreposix
Packit 78a954
     library).
Packit 78a954
Packit 78a954
Packit 78a954
THE C++ WRAPPER FUNCTIONS
Packit 78a954
Packit 78a954
The PCRE distribution also contains some C++ wrapper functions and tests,
Packit 78a954
applicable to the 8-bit library, which were contributed by Google Inc. On a
Packit 78a954
system that can use "configure" and "make", the functions are automatically
Packit 78a954
built into a library called pcrecpp. It should be straightforward to compile
Packit 78a954
the .cc files manually on other systems. The files called xxx_unittest.cc are
Packit 78a954
test programs for each of the corresponding xxx.cc files.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING FOR VIRTUAL PASCAL
Packit 78a954
Packit 78a954
A script for building PCRE using Borland's C++ compiler for use with VPASCAL
Packit 78a954
was contributed by Alexander Tokarev. Stefan Weber updated the script and added
Packit 78a954
additional files. The following files in the distribution are for building PCRE
Packit 78a954
for use with VP/Borland: makevp_c.txt, makevp_l.txt, makevp.bat, pcregexp.pas.
Packit 78a954
Packit 78a954
Packit 78a954
STACK SIZE IN WINDOWS ENVIRONMENTS
Packit 78a954
Packit 78a954
The default processor stack size of 1Mb in some Windows environments is too
Packit 78a954
small for matching patterns that need much recursion. In particular, test 2 may
Packit 78a954
fail because of this. Normally, running out of stack causes a crash, but there
Packit 78a954
have been cases where the test program has just died silently. See your linker
Packit 78a954
documentation for how to increase stack size if you experience problems. The
Packit 78a954
Linux default of 8Mb is a reasonable choice for the stack, though even that can
Packit 78a954
be too small for some pattern/subject combinations.
Packit 78a954
Packit 78a954
PCRE has a compile configuration option to disable the use of stack for
Packit 78a954
recursion so that heap is used instead. However, pattern matching is
Packit 78a954
significantly slower when this is done. There is more about stack usage in the
Packit 78a954
"pcrestack" documentation.
Packit 78a954
Packit 78a954
Packit 78a954
LINKING PROGRAMS IN WINDOWS ENVIRONMENTS
Packit 78a954
Packit 78a954
If you want to statically link a program against a PCRE library in the form of
Packit 78a954
a non-dll .a file, you must define PCRE_STATIC before including pcre.h or
Packit 78a954
pcrecpp.h, otherwise the pcre_malloc() and pcre_free() exported functions will
Packit 78a954
be declared __declspec(dllimport), with unwanted results.
Packit 78a954
Packit 78a954
Packit 78a954
CALLING CONVENTIONS IN WINDOWS ENVIRONMENTS
Packit 78a954
Packit 78a954
It is possible to compile programs to use different calling conventions using
Packit 78a954
MSVC. Search the web for "calling conventions" for more information. To make it
Packit 78a954
easier to change the calling convention for the exported functions in the
Packit 78a954
PCRE library, the macro PCRE_CALL_CONVENTION is present in all the external
Packit 78a954
definitions. It can be set externally when compiling (e.g. in CFLAGS). If it is
Packit 78a954
not set, it defaults to empty; the default calling convention is then used
Packit 78a954
(which is what is wanted most of the time).
Packit 78a954
Packit 78a954
Packit 78a954
COMMENTS ABOUT WIN32 BUILDS (see also "BUILDING PCRE ON WINDOWS WITH CMAKE")
Packit 78a954
Packit 78a954
There are two ways of building PCRE using the "configure, make, make install"
Packit 78a954
paradigm on Windows systems: using MinGW or using Cygwin. These are not at all
Packit 78a954
the same thing; they are completely different from each other. There is also
Packit 78a954
support for building using CMake, which some users find a more straightforward
Packit 78a954
way of building PCRE under Windows.
Packit 78a954
Packit 78a954
The MinGW home page (http://www.mingw.org/) says this:
Packit 78a954
Packit 78a954
  MinGW: A collection of freely available and freely distributable Windows
Packit 78a954
  specific header files and import libraries combined with GNU toolsets that
Packit 78a954
  allow one to produce native Windows programs that do not rely on any
Packit 78a954
  3rd-party C runtime DLLs.
Packit 78a954
Packit 78a954
The Cygwin home page (http://www.cygwin.com/) says this:
Packit 78a954
Packit 78a954
  Cygwin is a Linux-like environment for Windows. It consists of two parts:
Packit 78a954
Packit 78a954
  . A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing
Packit 78a954
    substantial Linux API functionality
Packit 78a954
Packit 78a954
  . A collection of tools which provide Linux look and feel.
Packit 78a954
Packit 78a954
  The Cygwin DLL currently works with all recent, commercially released x86 32
Packit 78a954
  bit and 64 bit versions of Windows, with the exception of Windows CE.
Packit 78a954
Packit 78a954
On both MinGW and Cygwin, PCRE should build correctly using:
Packit 78a954
Packit 78a954
  ./configure && make && make install
Packit 78a954
Packit 78a954
This should create two libraries called libpcre and libpcreposix, and, if you
Packit 78a954
have enabled building the C++ wrapper, a third one called libpcrecpp. These are
Packit 78a954
independent libraries: when you link with libpcreposix or libpcrecpp you must
Packit 78a954
also link with libpcre, which contains the basic functions. (Some earlier
Packit 78a954
releases of PCRE included the basic libpcre functions in libpcreposix. This no
Packit 78a954
longer happens.)
Packit 78a954
Packit 78a954
A user submitted a special-purpose patch that makes it easy to create
Packit 78a954
"pcre.dll" under mingw32 using the "msys" environment. It provides "pcre.dll"
Packit 78a954
as a special target. If you use this target, no other files are built, and in
Packit 78a954
particular, the pcretest and pcregrep programs are not built. An example of how
Packit 78a954
this might be used is:
Packit 78a954
Packit 78a954
  ./configure --enable-utf --disable-cpp CFLAGS="-03 -s"; make pcre.dll
Packit 78a954
Packit 78a954
Using Cygwin's compiler generates libraries and executables that depend on
Packit 78a954
cygwin1.dll. If a library that is generated this way is distributed,
Packit 78a954
cygwin1.dll has to be distributed as well. Since cygwin1.dll is under the GPL
Packit 78a954
licence, this forces not only PCRE to be under the GPL, but also the entire
Packit 78a954
application. A distributor who wants to keep their own code proprietary must
Packit 78a954
purchase an appropriate Cygwin licence.
Packit 78a954
Packit 78a954
MinGW has no such restrictions. The MinGW compiler generates a library or
Packit 78a954
executable that can run standalone on Windows without any third party dll or
Packit 78a954
licensing issues.
Packit 78a954
Packit 78a954
But there is more complication:
Packit 78a954
Packit 78a954
If a Cygwin user uses the -mno-cygwin Cygwin gcc flag, what that really does is
Packit 78a954
to tell Cygwin's gcc to use the MinGW gcc. Cygwin's gcc is only acting as a
Packit 78a954
front end to MinGW's gcc (if you install Cygwin's gcc, you get both Cygwin's
Packit 78a954
gcc and MinGW's gcc). So, a user can:
Packit 78a954
Packit 78a954
. Build native binaries by using MinGW or by getting Cygwin and using
Packit 78a954
  -mno-cygwin.
Packit 78a954
Packit 78a954
. Build binaries that depend on cygwin1.dll by using Cygwin with the normal
Packit 78a954
  compiler flags.
Packit 78a954
Packit 78a954
The test files that are supplied with PCRE are in UNIX format, with LF
Packit 78a954
characters as line terminators. Unless your PCRE library uses a default newline
Packit 78a954
option that includes LF as a valid newline, it may be necessary to change the
Packit 78a954
line terminators in the test files to get some of the tests to work.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING PCRE ON WINDOWS WITH CMAKE
Packit 78a954
Packit 78a954
CMake is an alternative configuration facility that can be used instead of
Packit 78a954
"configure". CMake creates project files (make files, solution files, etc.)
Packit 78a954
tailored to numerous development environments, including Visual Studio,
Packit 78a954
Borland, Msys, MinGW, NMake, and Unix. If possible, use short paths with no
Packit 78a954
spaces in the names for your CMake installation and your PCRE source and build
Packit 78a954
directories.
Packit 78a954
Packit 78a954
The following instructions were contributed by a PCRE user. If they are not
Packit 78a954
followed exactly, errors may occur. In the event that errors do occur, it is
Packit 78a954
recommended that you delete the CMake cache before attempting to repeat the
Packit 78a954
CMake build process. In the CMake GUI, the cache can be deleted by selecting
Packit 78a954
"File > Delete Cache".
Packit 78a954
Packit 78a954
1.  Install the latest CMake version available from http://www.cmake.org/, and
Packit 78a954
    ensure that cmake\bin is on your path.
Packit 78a954
Packit 78a954
2.  Unzip (retaining folder structure) the PCRE source tree into a source
Packit 78a954
    directory such as C:\pcre. You should ensure your local date and time
Packit 78a954
    is not earlier than the file dates in your source dir if the release is
Packit 78a954
    very new.
Packit 78a954
Packit 78a954
3.  Create a new, empty build directory, preferably a subdirectory of the
Packit 78a954
    source dir. For example, C:\pcre\pcre-xx\build.
Packit 78a954
Packit 78a954
4.  Run cmake-gui from the Shell envirornment of your build tool, for example,
Packit 78a954
    Msys for Msys/MinGW or Visual Studio Command Prompt for VC/VC++. Do not try
Packit 78a954
    to start Cmake from the Windows Start menu, as this can lead to errors.
Packit 78a954
Packit 78a954
5.  Enter C:\pcre\pcre-xx and C:\pcre\pcre-xx\build for the source and build
Packit 78a954
    directories, respectively.
Packit 78a954
Packit 78a954
6.  Hit the "Configure" button.
Packit 78a954
Packit 78a954
7.  Select the particular IDE / build tool that you are using (Visual
Packit 78a954
    Studio, MSYS makefiles, MinGW makefiles, etc.)
Packit 78a954
Packit 78a954
8.  The GUI will then list several configuration options. This is where
Packit 78a954
    you can enable UTF-8 support or other PCRE optional features.
Packit 78a954
Packit 78a954
9.  Hit "Configure" again. The adjacent "Generate" button should now be
Packit 78a954
    active.
Packit 78a954
Packit 78a954
10. Hit "Generate".
Packit 78a954
Packit 78a954
11. The build directory should now contain a usable build system, be it a
Packit 78a954
    solution file for Visual Studio, makefiles for MinGW, etc. Exit from
Packit 78a954
    cmake-gui and use the generated build system with your compiler or IDE.
Packit 78a954
    E.g., for MinGW you can run "make", or for Visual Studio, open the PCRE
Packit 78a954
    solution, select the desired configuration (Debug, or Release, etc.) and
Packit 78a954
    build the ALL_BUILD project.
Packit 78a954
Packit 78a954
12. If during configuration with cmake-gui you've elected to build the test
Packit 78a954
    programs, you can execute them by building the test project. E.g., for
Packit 78a954
    MinGW: "make test"; for Visual Studio build the RUN_TESTS project. The
Packit 78a954
    most recent build configuration is targeted by the tests. A summary of
Packit 78a954
    test results is presented. Complete test output is subsequently
Packit 78a954
    available for review in Testing\Temporary under your build dir.
Packit 78a954
Packit 78a954
Packit 78a954
USE OF RELATIVE PATHS WITH CMAKE ON WINDOWS
Packit 78a954
Packit 78a954
A PCRE user comments as follows: I thought that others may want to know the
Packit 78a954
current state of CMAKE_USE_RELATIVE_PATHS support on Windows. Here it is:
Packit 78a954
Packit 78a954
-- AdditionalIncludeDirectories is only partially modified (only the
Packit 78a954
   first path - see below)
Packit 78a954
-- Only some of the contained file paths are modified - shown below for
Packit 78a954
   pcre.vcproj
Packit 78a954
-- It properly modifies
Packit 78a954
Packit 78a954
I am sure CMake people can fix that if they want to. Until then one will
Packit 78a954
need to replace existing absolute paths in project files with relative
Packit 78a954
paths manually (e.g. from VS) - relative to project file location. I did
Packit 78a954
just that before being told to try CMAKE_USE_RELATIVE_PATHS. Not a big
Packit 78a954
deal.
Packit 78a954
Packit 78a954
AdditionalIncludeDirectories="E:\builds\pcre\build;E:\builds\pcre\pcre-7.5;"
Packit 78a954
AdditionalIncludeDirectories=".;E:\builds\pcre\pcre-7.5;"
Packit 78a954
Packit 78a954
RelativePath="pcre.h"
Packit 78a954
RelativePath="pcre_chartables.c"
Packit 78a954
RelativePath="pcre_chartables.c.rule"
Packit 78a954
Packit 78a954
Packit 78a954
TESTING WITH RUNTEST.BAT
Packit 78a954
Packit 78a954
If configured with CMake, building the test project ("make test" or building
Packit 78a954
ALL_TESTS in Visual Studio) creates (and runs) pcre_test.bat (and depending
Packit 78a954
on your configuration options, possibly other test programs) in the build
Packit 78a954
directory. Pcre_test.bat runs RunTest.Bat with correct source and exe paths.
Packit 78a954
Packit 78a954
For manual testing with RunTest.bat, provided the build dir is a subdirectory
Packit 78a954
of the source directory: Open command shell window. Chdir to the location
Packit 78a954
of your pcretest.exe and pcregrep.exe programs. Call RunTest.bat with
Packit 78a954
"..\RunTest.Bat" or "..\..\RunTest.bat" as appropriate.
Packit 78a954
Packit 78a954
To run only a particular test with RunTest.Bat provide a test number argument.
Packit 78a954
Packit 78a954
Otherwise:
Packit 78a954
Packit 78a954
1. Copy RunTest.bat into the directory where pcretest.exe and pcregrep.exe
Packit 78a954
   have been created.
Packit 78a954
Packit 78a954
2. Edit RunTest.bat to indentify the full or relative location of
Packit 78a954
   the pcre source (wherein which the testdata folder resides), e.g.:
Packit 78a954
Packit 78a954
   set srcdir=C:\pcre\pcre-8.20
Packit 78a954
Packit 78a954
3. In a Windows command environment, chdir to the location of your bat and
Packit 78a954
   exe programs.
Packit 78a954
Packit 78a954
4. Run RunTest.bat. Test outputs will automatically be compared to expected
Packit 78a954
   results, and discrepancies will be identified in the console output.
Packit 78a954
Packit 78a954
To independently test the just-in-time compiler, run pcre_jit_test.exe.
Packit 78a954
To test pcrecpp, run pcrecpp_unittest.exe, pcre_stringpiece_unittest.exe and
Packit 78a954
pcre_scanner_unittest.exe.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING UNDER WINDOWS CE WITH VISUAL STUDIO 200x
Packit 78a954
Packit 78a954
Vincent Richomme sent a zip archive of files to help with this process. They
Packit 78a954
can be found in the file "pcre-vsbuild.zip" in the Contrib directory of the FTP
Packit 78a954
site.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING UNDER WINDOWS WITH BCC5.5
Packit 78a954
Packit 78a954
Michael Roy sent these comments about building PCRE under Windows with BCC5.5:
Packit 78a954
Packit 78a954
Some of the core BCC libraries have a version of PCRE from 1998 built in, which
Packit 78a954
can lead to pcre_exec() giving an erroneous PCRE_ERROR_NULL from a version
Packit 78a954
mismatch. I'm including an easy workaround below, if you'd like to include it
Packit 78a954
in the non-unix instructions:
Packit 78a954
Packit 78a954
When linking a project with BCC5.5, pcre.lib must be included before any of the
Packit 78a954
libraries cw32.lib, cw32i.lib, cw32mt.lib, and cw32mti.lib on the command line.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING USING BORLAND C++ BUILDER 2007 (CB2007) AND HIGHER
Packit 78a954
Packit 78a954
A PCRE user sent these comments about this environment (see also the comment
Packit 78a954
from another user that follows them):
Packit 78a954
Packit 78a954
The XE versions of C++ Builder come with a RegularExpressionsCore class which
Packit 78a954
contain a version of TPerlRegEx. However, direct use of the C PCRE library may
Packit 78a954
be desirable.
Packit 78a954
Packit 78a954
The default makevp.bat, however, supplied with PCRE builds a version of PCRE
Packit 78a954
that is not usable with any version of C++ Builder because the compiler ships
Packit 78a954
with an embedded version of PCRE, version 2.01 from 1998! [See also the note
Packit 78a954
about BCC5.5 above.] If you want to use PCRE you'll need to rename the
Packit 78a954
functions (pcre_compile to pcre_compile_bcc, etc) or do as I have done and just
Packit 78a954
use the 16 bit versions. I'm using std::wstring everywhere anyway. Since the
Packit 78a954
embedded version of PCRE does not have the 16 bit function names, there is no
Packit 78a954
conflict.
Packit 78a954
Packit 78a954
Building PCRE using a C++ Builder static library project file (recommended):
Packit 78a954
Packit 78a954
1. Rename or remove pcre.h, pcreposi.h, and pcreposix.h from your C++ Builder
Packit 78a954
original include path.
Packit 78a954
Packit 78a954
2. Download PCRE from pcre.org and extract to a directory.
Packit 78a954
Packit 78a954
3. Rename pcre_chartables.c.dist to pcre_chartables.c, pcre.h.generic to
Packit 78a954
pcre.h, and config.h.generic to config.h.
Packit 78a954
Packit 78a954
4. Edit pcre.h and pcre_config.c so that they include config.h.
Packit 78a954
Packit 78a954
5. Edit config.h like so:
Packit 78a954
Packit 78a954
Comment out the following lines:
Packit 78a954
#define PACKAGE "pcre"
Packit 78a954
#define PACKAGE_BUGREPORT ""
Packit 78a954
#define PACKAGE_NAME "PCRE"
Packit 78a954
#define PACKAGE_STRING "PCRE 8.32"
Packit 78a954
#define PACKAGE_TARNAME "pcre"
Packit 78a954
#define PACKAGE_URL ""
Packit 78a954
#define PACKAGE_VERSION "8.32"
Packit 78a954
Packit 78a954
Add the following lines:
Packit 78a954
#ifndef SUPPORT_UTF
Packit 78a954
#define SUPPORT_UTF 100 // any value is fine
Packit 78a954
#endif
Packit 78a954
Packit 78a954
#ifndef SUPPORT_UCP
Packit 78a954
#define SUPPORT_UCP 101 // any value is fine
Packit 78a954
#endif
Packit 78a954
Packit 78a954
#ifndef SUPPORT_UCP
Packit 78a954
#define SUPPORT_PCRE16 102 // any value is fine
Packit 78a954
#endif
Packit 78a954
Packit 78a954
#ifndef SUPPORT_UTF8
Packit 78a954
#define SUPPORT_UTF8 103 // any value is fine
Packit 78a954
#endif
Packit 78a954
Packit 78a954
6. Build a C++ Builder project using the IDE. Go to File / New / Other and
Packit 78a954
choose Static Library. You can name it pcre.cbproj or whatever. Now set your
Packit 78a954
paths by going to Project / Options. Set the Include path. Do this from the
Packit 78a954
"Base" option to apply to both Release and Debug builds. Now add the following
Packit 78a954
files to the project:
Packit 78a954
Packit 78a954
pcre.h
Packit 78a954
pcre16_byte_order.c
Packit 78a954
pcre16_chartables.c
Packit 78a954
pcre16_compile.c
Packit 78a954
pcre16_config.c
Packit 78a954
pcre16_dfa_exec.c
Packit 78a954
pcre16_exec.c
Packit 78a954
pcre16_fullinfo.c
Packit 78a954
pcre16_get.c
Packit 78a954
pcre16_globals.c
Packit 78a954
pcre16_maketables.c
Packit 78a954
pcre16_newline.c
Packit 78a954
pcre16_ord2utf16.c
Packit 78a954
pcre16_printint.c
Packit 78a954
pcre16_refcount.c
Packit 78a954
pcre16_string_utils.c
Packit 78a954
pcre16_study.c
Packit 78a954
pcre16_tables.c
Packit 78a954
pcre16_ucd.c
Packit 78a954
pcre16_utf16_utils.c
Packit 78a954
pcre16_valid_utf16.c
Packit 78a954
pcre16_version.c
Packit 78a954
pcre16_xclass.c
Packit 78a954
Packit 78a954
//Optional
Packit 78a954
pcre_version.c
Packit 78a954
Packit 78a954
7. After compiling the .lib file, copy the .lib and header files to a project
Packit 78a954
you want to use PCRE with. Enjoy.
Packit 78a954
Packit 78a954
Optional ... Building PCRE using the makevp.bat file:
Packit 78a954
Packit 78a954
1. Edit makevp_c.txt and makevp_l.txt and change all the names to the 16 bit
Packit 78a954
versions.
Packit 78a954
Packit 78a954
2. Edit makevp.bat and set the path to C++ Builder. Run makevp.bat.
Packit 78a954
Packit 78a954
Another PCRE user added this comment:
Packit 78a954
Packit 78a954
Another approach I successfully used for some years with BCB 5 and 6 was to
Packit 78a954
make sure that include and library paths of PCRE are configured before the
Packit 78a954
default paths of the IDE in the dialogs where one can manage those paths.
Packit 78a954
Afterwards one can open the project files using a text editor and manually add
Packit 78a954
the self created library for pcre itself, pcrecpp doesn't ship with the IDE, in
Packit 78a954
the library nodes where the IDE manages its own libraries to link against in
Packit 78a954
front of the IDE-own libraries. This way one can use the default PCRE function
Packit 78a954
names without getting access violations on runtime.
Packit 78a954
Packit 78a954
  <ALLLIB value="libpcre.lib $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING PCRE ON OPENVMS
Packit 78a954
Packit 78a954
Stephen Hoffman sent the following, in December 2012:
Packit 78a954
Packit 78a954
"Here <http://labs.hoffmanlabs.com/node/1847> is a very short write-up on the
Packit 78a954
OpenVMS port and here
Packit 78a954
Packit 78a954
<http://labs.hoffmanlabs.com/labsnotes/pcre-vms-8_32.zip>
Packit 78a954
Packit 78a954
is a zip with the OpenVMS files, and with one modified testing-related PCRE
Packit 78a954
file." This is a port of PCRE 8.32.
Packit 78a954
Packit 78a954
Earlier, Dan Mooney sent the following comments about building PCRE on OpenVMS.
Packit 78a954
They relate to an older version of PCRE that used fewer source files, so the
Packit 78a954
exact commands will need changing. See the current list of source files above.
Packit 78a954
Packit 78a954
"It was quite easy to compile and link the library. I don't have a formal
Packit 78a954
make file but the attached file [reproduced below] contains the OpenVMS DCL
Packit 78a954
commands I used to build the library. I had to add #define
Packit 78a954
POSIX_MALLOC_THRESHOLD 10 to pcre.h since it was not defined anywhere.
Packit 78a954
Packit 78a954
The library was built on:
Packit 78a954
O/S: HP OpenVMS v7.3-1
Packit 78a954
Compiler: Compaq C v6.5-001-48BCD
Packit 78a954
Linker: vA13-01
Packit 78a954
Packit 78a954
The test results did not match 100% due to the issues you mention in your
Packit 78a954
documentation regarding isprint(), iscntrl(), isgraph() and ispunct(). I
Packit 78a954
modified some of the character tables temporarily and was able to get the
Packit 78a954
results to match. Tests using the fr locale did not match since I don't have
Packit 78a954
that locale loaded. The study size was always reported to be 3 less than the
Packit 78a954
value in the standard test output files."
Packit 78a954
Packit 78a954
=========================
Packit 78a954
$! This DCL procedure builds PCRE on OpenVMS
Packit 78a954
$!
Packit 78a954
$! I followed the instructions in the non-unix-use file in the distribution.
Packit 78a954
$!
Packit 78a954
$ COMPILE == "CC/LIST/NOMEMBER_ALIGNMENT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
Packit 78a954
$ COMPILE DFTABLES.C
Packit 78a954
$ LINK/EXE=DFTABLES.EXE DFTABLES.OBJ
Packit 78a954
$ RUN DFTABLES.EXE/OUTPUT=CHARTABLES.C
Packit 78a954
$ COMPILE MAKETABLES.C
Packit 78a954
$ COMPILE GET.C
Packit 78a954
$ COMPILE STUDY.C
Packit 78a954
$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
Packit 78a954
$! did not seem to be defined anywhere.
Packit 78a954
$! I edited pcre.h and added #DEFINE SUPPORT_UTF8 to enable UTF8 support.
Packit 78a954
$ COMPILE PCRE.C
Packit 78a954
$ LIB/CREATE PCRE MAKETABLES.OBJ, GET.OBJ, STUDY.OBJ, PCRE.OBJ
Packit 78a954
$! I had to set POSIX_MALLOC_THRESHOLD to 10 in PCRE.H since the symbol
Packit 78a954
$! did not seem to be defined anywhere.
Packit 78a954
$ COMPILE PCREPOSIX.C
Packit 78a954
$ LIB/CREATE PCREPOSIX PCREPOSIX.OBJ
Packit 78a954
$ COMPILE PCRETEST.C
Packit 78a954
$ LINK/EXE=PCRETEST.EXE PCRETEST.OBJ, PCRE/LIB, PCREPOSIX/LIB
Packit 78a954
$! C programs that want access to command line arguments must be
Packit 78a954
$! defined as a symbol
Packit 78a954
$ PCRETEST :== "$ SYS$ROADSUSERS:[DMOONEY.REGEXP]PCRETEST.EXE"
Packit 78a954
$! Arguments must be enclosed in quotes.
Packit 78a954
$ PCRETEST "-C"
Packit 78a954
$! Test results:
Packit 78a954
$!
Packit 78a954
$!   The test results did not match 100%. The functions isprint(), iscntrl(),
Packit 78a954
$!   isgraph() and ispunct() on OpenVMS must not produce the same results
Packit 78a954
$!   as the system that built the test output files provided with the
Packit 78a954
$!   distribution.
Packit 78a954
$!
Packit 78a954
$!   The study size did not match and was always 3 less on OpenVMS.
Packit 78a954
$!
Packit 78a954
$!   Locale could not be set to fr
Packit 78a954
$!
Packit 78a954
=========================
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING PCRE ON STRATUS OPENVOS
Packit 78a954
Packit 78a954
These notes on the port of PCRE to VOS (lightly edited) were supplied by
Packit 78a954
Ashutosh Warikoo, whose email address has the local part awarikoo and the
Packit 78a954
domain nse.co.in. The port was for version 7.9 in August 2009.
Packit 78a954
Packit 78a954
1.   Building PCRE
Packit 78a954
Packit 78a954
I built pcre on OpenVOS Release 17.0.1at using GNU Tools 3.4a without any
Packit 78a954
problems. I used the following packages to build PCRE:
Packit 78a954
Packit 78a954
  ftp://ftp.stratus.com/pub/vos/posix/ga/posix.save.evf.gz
Packit 78a954
Packit 78a954
Please read and follow the instructions that come with these packages. To start
Packit 78a954
the build of pcre, from the root of the package type:
Packit 78a954
Packit 78a954
  ./build.sh
Packit 78a954
Packit 78a954
2. Installing PCRE
Packit 78a954
Packit 78a954
Once you have successfully built PCRE, login to the SysAdmin group, switch to
Packit 78a954
the root user, and type
Packit 78a954
Packit 78a954
  [ !create_dir (master_disk)>usr   --if needed ]
Packit 78a954
  [ !create_dir (master_disk)>usr>local   --if needed ]
Packit 78a954
    !gmake install
Packit 78a954
Packit 78a954
This installs PCRE and its man pages into /usr/local. You can add
Packit 78a954
(master_disk)>usr>local>bin to your command search paths, or if you are in
Packit 78a954
BASH, add /usr/local/bin to the PATH environment variable.
Packit 78a954
Packit 78a954
4. Restrictions
Packit 78a954
Packit 78a954
This port requires readline library optionally. However during the build I
Packit 78a954
faced some yet unexplored errors while linking with readline. As it was an
Packit 78a954
optional component I chose to disable it.
Packit 78a954
Packit 78a954
5. Known Problems
Packit 78a954
Packit 78a954
I ran the test suite, but you will have to be your own judge of whether this
Packit 78a954
command, and this port, suits your purposes. If you find any problems that
Packit 78a954
appear to be related to the port itself, please let me know. Please see the
Packit 78a954
build.log file in the root of the package also.
Packit 78a954
Packit 78a954
Packit 78a954
BUILDING PCRE ON NATIVE Z/OS AND Z/VM
Packit 78a954
Packit 78a954
z/OS and z/VM are operating systems for mainframe computers, produced by IBM.
Packit 78a954
The character code used is EBCDIC, not ASCII or Unicode. In z/OS, UNIX APIs and
Packit 78a954
applications can be supported through UNIX System Services, and in such an
Packit 78a954
environment PCRE can be built in the same way as in other systems. However, in
Packit 78a954
native z/OS (without UNIX System Services) and in z/VM, special ports are
Packit 78a954
required. For details, please see this web site:
Packit 78a954
Packit 78a954
  http://www.zaconsultants.net
Packit 78a954
Packit 78a954
You may download PCRE from WWW.CBTTAPE.ORG, file 882.  Everything, source and
Packit 78a954
executable, is in EBCDIC and native z/OS file formats and this is the
Packit 78a954
recommended download site.
Packit 78a954
Packit 78a954
==========================
Packit 78a954
Last Updated: 25 June 2015