Cache compiled regexps used in $transform
[xapian.git] / xapian-bindings / INSTALL
blob5949c82b2b6cf942944ee1ede5e783dd60a64692
1 Xapian-bindings Installation
2 ============================
4 Originally based on automake's generic "Installation Instructions" which are:
6 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
7 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
9    Copying and distribution of this file, with or without modification,
10 are permitted in any medium without royalty provided the copyright
11 notice and this notice are preserved.  This file is offered as-is,
12 without warranty of any kind.
14 Known Issues
15 ============
17    * The bindings glue code generated by SWIG seems to require a lot of memory
18      to compile and can take several minutes even on a fast machine (at least
19      with most versions of g++).  Some systems (such as OpenBSD) may require
20      you to increase the amount of memory a process can use (using ulimit is
21      the simplest way).  Alternatively you can compile the bindings without
22      optimisation using:
24          make CXXFLAGS=-g
26      Xapian-bindings version 0.9.3 reduced the compile time by something like a
27      factor of 3 and probably also reduced memory usage significantly, but you
28      might still encounter this issue on slower machines with less memory.
30 Quick Installation Guide
31 ========================
33 The simplest way to compile this package is:
35   1. 'cd' to the directory containing the package's source code and type
36      './configure' to configure the package for your system.
38      You need to make sure that xapian-config from xapian-core is on your path,
39      or else pass its full path to xapian-bindings's configure script:
41        ./configure XAPIAN_CONFIG=/path/to/xapian-config
43      By default, configure will enable building of bindings for all languages
44      which it can find the required tools for.  Alternatively you can specify
45      exactly which bindings you want to build by passing one or more of the
46      following options to configure:
48        --with-csharp        enable CSharp bindings
49        --with-java          enable Java bindings
50        --with-lua           enable Lua bindings
51        --with-perl          enable Perl bindings
52        --with-php           enable PHP bindings
53        --with-python        enable Python 2 bindings
54        --with-python3       enable Python 3 bindings
55        --with-ruby          enable Ruby bindings
56        --with-tcl           enable Tcl bindings
58      If you've requested particular bindings using these options, then
59      configure will fail with an error if it is missing the prerequisite
60      tools, libraries, header files, etc required to build bindings for
61      any of the specified languages.
63      If you have more than one version of a particular language installed
64      you can tell configure which to build the bindings for by setting
65      variables on the configure command line.  For a full list of such
66      variables, see the output of 'configure --help' - for example, for
67      Python you might use:
69        ./configure PYTHON=/opt/bin/python2.6
71      If you don't have root access and want to compile any of the bindings
72      other than C#, Java and PHP, read the next section: "Installing without
73      root access".
75      Running 'configure' might take a while.  While running, it prints
76      some messages telling which features it is checking for.
78   2. Type 'make' to compile the package.
80   3. Optionally, type 'make check' to run the self-tests that come with
81      the package, using the just-built uninstalled binaries.
83   4. Type 'make install' to install the programs and any data files and
84      documentation.  When installing into a prefix owned by root, it is
85      recommended that the package be configured and built as a regular
86      user, and only the 'make install' phase executed with root
87      privileges.
89   5. You can remove the program binaries and object files from the
90      source code directory by typing 'make clean'.  To also remove the
91      files that 'configure' created (so you can compile the package for
92      a different kind of computer), type 'make distclean'.  There is
93      also a 'make maintainer-clean' target, but that is intended mainly
94      for the package's developers.  If you use it, you may have to get
95      all sorts of other programs in order to regenerate files that came
96      with the distribution.
98   6. You can also type 'make uninstall' to remove the installed files
99      again.
101 Installing without root access
102 ==============================
104      By default the bindings for all languages apart from Java and C# will
105      automatically detect where the language interpreter expects extension
106      modules to be installed and try to install there.  This is a problem
107      if you want to install them and don't have root access.  In this case
108      follow the instructions for the particular language below (note: you
109      still build several at once - just pass the arguments listed below
110      for each language to "./configure", to "make", and to "make install".)
111      Note that you also need to pass a "--prefix" option to configure so that
112      the documentation and examples can be installed.
114   PHP:
116      With current releases of PHP, there doesn't seem to be a good way to
117      install the PHP bindings without root access such that they can be used
118      from PHP run from a webserver, which is what most users want to do.
120      If you're only interested in running code from the command line (via PHP's
121      CLI SAPI) then the following will work:
123      ./configure --with-php --prefix=$HOME/install PHP_EXTENSION_DIR=$HOME/my_php_extensions
124      make
125      make install
127      Then tell the PHP interpreter to load extensions from there:
129      php -d extension_dir="$HOME/my_php_extensions" myscript.php
131      However, this will stop PHP from looking in the default place for
132      extensions!  It doesn't seem to be possible to specify more than one
133      directory, but you can copy or symlink system installed extensions
134      from the default extension directory to $HOME/my_php_extensions like
135      so:
137      ln -s "`php -r 'print PHP_EXTENSION_DIR;'`"/* "$HOME/my_php_extensions"
139      This will symlink all of them, but you only actually need those that
140      get loaded.
142   Python 2:
144      ./configure --with-python --prefix=$HOME/install PYTHON_LIB=$HOME/.local
145      make
146      make install
148      Python 2.6 and later will look in ~/.local for packages automatically
149      so the above is all that is required.
151      For older Python versions, or if you set PYTHON_LIB to a different
152      directory, you'll need to tell Python to look for modules in that
153      directory.  Here are two possible ways to do that:
155      setenv PYTHONPATH=$HOME/.local python myscript.py
157      Or you can add this to the start of your Python scripts:
159      import os
160      import sys
161      sys.path.insert(0, os.environ['HOME'] + "/.local")
162      import xapian
164   Python 3:
166      ./configure --with-python3 --prefix=$HOME/install PYTHON3_LIB=$HOME/.local
167      make
168      make install
170      Python 3 looks in ~/.local for packages automatically, so you don't need
171      to do anything special to use bindings installed there.
173   Ruby:
175      ./configure --with-ruby --prefix=$HOME/install RUBY_LIB=$HOME/my_ruby_modules RUBY_LIB_ARCH=$HOME/my_ruby_modules
176      make
177      make install
179      And then you'll need to tell Ruby to look for modules in this directory:
181      ruby -I$HOME/my_ruby_modules myscript.rb
183   Tcl8:
185      ./configure --with-tcl --prefix=$HOME/install TCL_LIB=$HOME/my_tcl_modules
186      make
187      make install
189      And then add the following to the start of your script to load Xapian:
191      load [file join "/home/USERNAME/my_tcl_modules" xapian.so]
193   Perl:
195      ./configure --with-perl --prefix=$HOME/install PERL_LIB=$HOME/my_perl_modules
196      make
197      make install
199      And then you'll need to tell Perl to look for modules in this directory:
201      perl -I$HOME/my_perl_modules myscript.pl
203 Compilers and Options
204 =====================
206    Some systems may require unusual options for compilation or linking that
207 the 'configure' script does not know about.  Run './configure --help'
208 for details on some of the pertinent environment variables.
210    You can give 'configure' initial values for configuration parameters
211 by setting variables in the command line or in the environment.  Here
212 is an example:
214      ./configure LIBS=-lposix
216    If your system requires special flags, do let us know.  Where possible
217 we'd prefer configure to determine such flags by itself, but if we can't
218 then at least we can document the special flags to help other users of
219 systems like yours.
221 Compiling For Multiple Architectures
222 ====================================
224 When using GCC on platforms which support multiple architecture, the simplest
225 way to select a non-default architecture is to pass a CXX setting to configure
226 which includes the appropriate -m option - e.g. to build for x86 on x86-64
227 you would configure with:
229 ./configure CXX='g++ -m32'
231 On Mac OS X 10.5 and later systems, you can create libraries and
232 executables that work on multiple system types--known as "fat" or
233 "universal" binaries--by specifying multiple '-arch' options to the
234 compiler but only a single '-arch' option to the preprocessor.  Like
235 this:
237      ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
238                  CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
239                  CPP="gcc -E" CXXCPP="g++ -E"
241 Building in a separate directory
242 ================================
244 If you wish to perform your build in a separate directory from the source,
245 create and change to the build directory, and run the configure script (in
246 the source directory) from the build directory, like so:
248   mkdir BUILD
249   cd BUILD
250   ../configure
252 Installation Names
253 ==================
255    By default, 'make install' installs the package's commands under
256 '/usr/local/bin', include files under '/usr/local/include', etc.  You
257 can specify an installation prefix other than '/usr/local' by giving
258 'configure' the option '--prefix=PREFIX', where PREFIX must be an
259 absolute file name.
261    You can specify separate installation prefixes for
262 architecture-specific files and architecture-independent files.  If you
263 pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
264 PREFIX as the prefix for installing programs and libraries.
265 Documentation and other data files still use the regular prefix.
267    In addition, if you use an unusual directory layout you can give
268 options like '--bindir=DIR' to specify different values for particular
269 kinds of files.  Run 'configure --help' for a list of the directories
270 you can set and what kinds of files go in them.
272 Specifying the System Type
273 ==========================
275    There may be some features 'configure' cannot figure out
276 automatically, but needs to determine by the type of machine the package
277 will run on.  Usually, assuming the package is built to be run on the
278 _same_ architectures, 'configure' can figure that out, but if it prints
279 a message saying it cannot guess the machine type, give it the
280 '--build=TYPE' option.  TYPE can either be a short name for the system
281 type, such as 'sun4', or a canonical name which has the form:
283      CPU-COMPANY-SYSTEM
285 where SYSTEM can have one of these forms:
287      OS
288      KERNEL-OS
290    See the file 'config.sub' for the possible values of each field.  If
291 'config.sub' isn't included in this package, then this package doesn't
292 need to know the machine type.
294    If you want to _use_ a cross compiler, that generates code for a
295 platform different from the build platform, you should specify the
296 "host" platform (i.e., that on which the generated programs will
297 eventually be run) with '--host=TYPE'.
299 Sharing Defaults
300 ================
302    If you want to set default values for 'configure' scripts to share,
303 you can create a site shell script called 'config.site' that gives
304 default values for variables like 'CXX', 'cache_file', and 'prefix'.
305 'configure' looks for 'PREFIX/share/config.site' if it exists, then
306 'PREFIX/etc/config.site' if it exists.  Or, you can set the
307 'CONFIG_SITE' environment variable to the location of the site script.
308 A warning: not all 'configure' scripts look for a site script.
310 Defining Variables
311 ==================
313    Variables not defined in a site shell script can be set in the
314 environment passed to 'configure'.  However, some packages may run
315 configure again during the build, and the customized values of these
316 variables may be lost.  In order to avoid this problem, you should set
317 them in the 'configure' command line, using 'VAR=value'.  For example:
319      ./configure CXX=/usr/local2/bin/g++
321 causes the specified 'g++' to be used as the C++ compiler (unless it is
322 overridden in the site shell script).
324 'configure' Invocation
325 ======================
327    As well as the options documented in the "Quick Installation Guide",
328 'configure' recognizes the following standard options to control how it
329 operates:
331 '--help'
332 '-h'
333      Print a summary of all of the options to 'configure', and exit.
335 '--version'
336 '-V'
337      Print the version of Autoconf used to generate the 'configure'
338      script, and exit.
340 '--cache-file=FILE'
341      Enable the cache: use and save the results of the tests in FILE,
342      traditionally 'config.cache'.  FILE defaults to '/dev/null' to
343      disable caching.
345 '--config-cache'
346 '-C'
347      Alias for '--cache-file=config.cache'.
349 '--quiet'
350 '--silent'
351 '-q'
352      Do not print messages saying which checks are being made.  To
353      suppress all normal output, redirect it to '/dev/null' (any error
354      messages will still be shown).
356 '--srcdir=DIR'
357      Look for the package's source code in directory DIR.  Usually
358      'configure' can determine that directory automatically.
360 'configure' also accepts some other, not widely useful, options.  Run
361 'configure --help' for more details.