Welcome to Xapian
=================

Xapian's build system is built using GNU autoconf, automake, and libtool.
If you've installed other Open Source projects from source, you should
find yourself in familiar territory.  Building and installing involves
the following 3 simple steps:

 1) Run "./configure", possibly with some extra arguments (see below)
 2) Run "make" to build Xapian
 3) Run "make install" to install Xapian

Prerequisites
=============

You'll need to have zlib installed (https://www.zlib.net/) before you can build
Xapian.  The zlib library is very widely used, so you'll probably have it
installed already if you're using Linux, FreeBSD, or similar, but you may need
to install a "zlib development" package to get the zlib library headers.

We recommend using zlib 1.2.x as it apparently fixes a memory leak in
deflateInit2 (which Xapian uses) and decompression is supposed to be about 20%
faster than with 1.1.x, but it's pretty unlikely you'll have an older version
installed these days.

Xapian also requires a way to generate UUIDs.  On FreeBSD, NetBSD, and
Microsoft Windows, Xapian makes use of built-in UUID APIs.  On Linux and
Android, Xapian 1.4.2 and higher can read UUIDs from a special file under
/proc.  Otherwise you need to install libuuid which you can find in
util-linux (https://github.com/karelzak/util-linux).  On Debian and
Ubuntu, the package to install is uuid-dev, while on Fedora, it is
libuuid-devel (on older Fedora versions you instead need e2fsprogs-devel).

Compilers
=========

We aim to support compilation with any C++ compiler which support ISO C++11, or
a reasonable approximation to it.

GCC
---

If you're using GCC, we currently recommend GCC 4.7 or newer (this is the
oldest version we regularly test with).

The current hard minimum requirement is also GCC 4.7 (due to requiring good
support for C++11, for example non-static data member initializers aren't
supported by earlier versions).

If you really still need to use an older version of GCC, Xapian 1.2.x doesn't
require C++11 support and should build with older versions - probably as far
back as GCC 3.1.

MSVC
----

If you're using MS Visual C++, you'll need at least MSVS 2015 for C++11
support.

As of Xapian 1.4.6 building using MSVC is supported by the autotools build
system.  You need to install a set of Unix-like tools first - we recommended
MSYS2: https://www.msys2.org/

You also need to have the MSVC command line tools on your PATH.  This is done
by running a batch file in the MSVC install in the terminal before building.
The exact details vary by MSVC version, 32- vs 64-bit, and the directory and
drive where MSVC is installed.  For MSVC 2017 it should be something like::

  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"

or::

  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"

And for MSVC 2015 32-bit use::

  "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

MSVC 2015 64-bit isn't currently supported, but would use the above command but with ``x64``
instead of ``x86``.

Then from a bash shell run configure like so::

  ./configure CC="cl -nologo" CXX="$PWD/compile cl -nologo" CXXFLAGS=-EHsc AR=lib

You'll need to have the zlib library available.  You can also specify
``CPPFLAGS=-I/path/to/zlib LDFLAGS=-L/path/to/zlib`` to tell MSVC where to
find the zlib headers and library.

We support 64-bit compilation with MSVS 2017.  With MSVS 2015 a 64-bit build
fails to work - we haven't investigated why.

HP's aCC
--------

When using HP's aCC, Xapian must be compiled with +std=c++11, which
xapian-core's configure automatically detects and passes.  You don't have to
pass this option when building code which uses Xapian, but you can.

Multi-Arch
==========

When using GCC on platforms which support multiple architecture, the simplest
way to select a non-default architecture is to pass a CXX setting to configure
which includes the appropriate -m option - e.g. to build for x86 on x86-64
you would configure with:

./configure CXX='g++ -m32'

Building in a separate directory
================================

If you wish to perform your build in a separate directory from the source,
create and change to the build directory, and run the configure script (in
the source directory) from the build directory, like so:

  mkdir BUILD
  cd BUILD
  ../configure

Options to give to configure
============================

--enable-assertions
	You should use this to build a version of Xapian with many internal
	consistency checks.  This will run more slowly, but is useful if you
	suspect a bug in Xapian.

--enable-backend-chert
--enable-backend-glass
--enable-backend-inmemory
--enable-backend-remote
	These options enable (or disable if --disable-backend-XXX is specified)
	the compiling of each backend (database access methods).  By default,
	all backends for which the appropriate libraries and OS support are
	available will be enabled.  Note: Currently disabling the remote
	backend also disables replication (because the network code is shared).

_FORTIFY_SOURCE
---------------

When compiling with GCC, by default Xapian will be built with _FORTIFY_SOURCE
set to 2.  This enables some compile time and runtime checking of values passed
to library functions when building with GCC >= 4.1 and glibc >= 2.34 (some
Linux distros may have backported support to older GCC and/or glibc).  If you
wish to disable this for any reason, you can just configure like so:

./configure CPPFLAGS=-D_FORTIFY_SOURCE=0

Or you can set the "fortification level" to 1 instead of 2:

./configure CPPFLAGS=-D_FORTIFY_SOURCE=1

If you're disabling it because it causes problems, please also report this to
us (via the bug tracker or mailing lists).

-Bsymbolic-functions
--------------------

If -Wl,-Bsymbolic-functions is supported (for example it is by GCC with modern
ld) then it will be automatically used when linking the library.  This causes
all references from inside the library to symbols inside the library to be
resolved when the library is created, rather than when the shared library is
loaded, which decreases the time taken to load the library, reduces its size,
and is also likely to make the code run a little faster.

Should you wish to disable this for some reason, you can configure like so
which disables the probe for -Bsymbolic-functions so it won't ever be used:

./configure xo_cv_symbolic_functions=no

If you're disabling it because it causes problems, please also report this to
us (via the bug tracker or mailing lists).

-fvisibility
------------

When compiling with GCC >= 4.0 for platforms which support symbol visibility,
we automatically pass -fvisibility=hidden to g++ when building the library, and
mark classes, methods, and functions which need exporting with attributes to
make them visible.

Should you wish to disable this for some reason, you can configure like so:

./configure --disable-visibility

If you're disabling it because it causes problems, please also report this to
us (via the bug tracker or mailing lists).

Developers
==========

There are additional scripts and configure options to help people doing
development work on Xapian itself, and people who are building from git.
Read HACKING to find out about them.
