1.. _compiling:
2
3=========
4Compiling
5=========
6
7These instructions are based on Debian 8.0 because it has to be based on
8something. Other Linux distributions will be similar in the broad ideas but may
9differ in the specifics. If you already have a preferred distro, use that (we
10assume you know how to use its package management system). If you don't already
11have a preferred distro, maybe consider using Debian.
12
13First make sure you have a :ref:`copy of the source <getcyrus>`. You can either
14fetch the latest source from git, or download one of our release tarballs.
15
16Setting up dependencies
17=======================
18
19Required Build Dependencies
20---------------------------
21
22Building a basic Cyrus that can send and receive email: the minimum libraries
23required to build a functional cyrus-imapd.
24
25.. csv-table::
26    :header: "Package", "Debian", "RedHat", "Notes"
27
28    `autoconf`_, "autoconf", "autoconf"
29    `automake`_, "automake", "automake"
30    `bison`_, "bison", "bison"
31    `Cyrus SASL`_, "libsasl2-dev", "cyrus-sasl-devel"
32    `flex`_, flex, flex
33    `gcc`_, gcc, gcc
34    `gperf`_, gperf, gperf
35    `jansson`_, libjansson-dev, jansson-devel
36    `libbsd`_, libbsd-dev, libbsd-devel
37    `libtool`_, libtool, libtool
38    `ICU`_, libicu-dev, libicu-devel, "version 55 or newer"
39    `uuid`_, uuid-dev, libuuid-devel
40    `openssl`_ :ref:`(Note about versions) <openssl-versions>`, libssl-dev, openssl-devel
41    `pkgconfig`_, pkg-config, pkgconfig
42    `sqlite`_, libsqlite3-dev, sqlite-devel
43
44.. _autoconf: http://www.gnu.org/software/autoconf/
45.. _automake: http://www.gnu.org/software/automake/
46.. _bison: http://www.gnu.org/software/bison/
47.. _Cyrus SASL: :ref:`Cyrus SASL <cyrussasl:sasl-index>`
48.. _flex: http://flex.sourceforge.net/
49.. _gcc: http://gcc.gnu.org
50.. _gperf: http://www.gnu.org/software/gperf/
51.. _jansson: http://www.digip.org/jansson/
52.. _libbsd: https://libbsd.freedesktop.org/wiki/
53.. _libtool: http://www.gnu.org/software/libtool/
54.. _ICU: http://www.icu-project.org/
55.. _uuid: https://www.kernel.org/pub/linux/utils/util-linux/
56.. _openssl: http://www.openssl.org/
57.. _pkgconfig: http://pkgconfig.freedesktop.org
58.. _sqlite: https://www.sqlite.org/
59
60To install all dependencies from packages on Debian Jessie, use this:
61
62.. include:: /assets/cyrus-build-reqpkg.rst
63
64Build dependencies for additional functionality
65-----------------------------------------------
66
67The following dependencies enable additional functionality, help with
68code maintenance tasks or are required for building the documentation.
69
70Developers only
71###############
72
73The developer dependencies are required if you are building from git sources,
74have modified certain source files from the release tarball, or have configured
75with ``--enable-maintainer-mode`` in order to build a new package.
76
77If you are building normally from a pure release tarball, then you don't need
78these dependencies. The files, these dependencies produce, have been pre-built
79and included in the release, and do not normally need to be re-built.
80
81.. csv-table::
82    :header: "Package", "Debian", "RedHat", "Required", "Notes"
83    :widths: 20,15,15,5,45
84
85    `perl-devel`_, perl-dev, perl-devel, "no", "Needed for building binary perl
86    libraries, version 5+."
87    `perl(ExtUtils::MakeMaker)`_,,, "no", "Needed for building extensions to
88    Perl."
89    `perl(Pod::POM::View::Restructured)`_,,, "no", "Needed to generate man
90    pages. This has to be available to the system-wide perl interpreter, found
91    by ``which``."
92    `python(GitPython)`_,,, "no", "Needed for building the documentation."
93    `python(Sphinx)`_,,, "no", "Needed for building the documentation."
94    `transfig`_, transfig, transfig, "no", "Also known as fig2dev, transfig is
95    an artifact from the old days, and is only used for generation of a couple
96    of png files in the legacy documentation (doc/legacy/murder.png and
97    doc/legacy/netnews.png). One day it should be merged into the current
98    documentation, cause then we can get rid of it: `issues/1769`_."
99    `valgrind`_, valgrind, valgrind, "no", "Performance and memory testing."
100    `xxd`_,vim-common,vim-common, "no", "Needed for the _js.h files, for CalDAV
101    and CardDAV support."
102
103SASL Authentication
104###################
105
106.. csv-table::
107    :header: "Package", "Debian", "RedHat", "Required", "Notes"
108    :widths: 20,15,15,5,45
109
110    `Cyrus SASL Plain`_, libsasl2-modules, cyrus-sasl-plain, "yes/no", "Required
111    to pass Cyrus IMAP's PLAIN authentication unit tests."
112    `Cyrus SASL MD5`_, libsasl2-modules, cyrus-sasl-md5, "yes/no", "Required to
113    pass Cyrus IMAP's DIGEST-MD5 authentication unit tests."
114    `sasl binaries`_, sasl2-bin, sasl2-bin, "no", "Administration tools for
115    managing SASL."
116    `Kerberos`_, libsasl2-modules-gssapi-mit, krb5-devel, "yes/no", "Development
117    headers required to enable Kerberos v5 authentication capabilities, also
118    known as the authentication mechanism *GSSAPI*. Configure option:
119    ``--with-krbimpl=mit``."
120
121Alternate database formats
122##########################
123
124.. csv-table::
125    :header: "Package", "Debian", "RedHat", "Required", "Notes"
126    :widths: 20,15,15,5,45
127
128    `mysql`_ or `mariadb`_, "libmysqlclient-dev or libmariadb-dev", "mysql-devel
129    or mariadb-devel", "yes/no", "MariaDB or MySQL development headers, required
130    to allow Cyrus IMAP to use it as the backend for its databases. Configure
131    options: ``--with-mysql``, ``--with-mysql-incdir``,
132    ``--with-mysql-libdir``."
133    `postgresql`_, postgresql-dev, postgresql-devel, "yes/no", "PostgreSQL
134    development headers, required to allow Cyrus IMAP to use it as the backend
135    for its databases. Configure option: ``--with-pgsql``."
136
137CalDAV, CardDAV, or JMAP (httpd subsystem)
138##########################################
139
140.. csv-table::
141    :header: "Package", "Debian", "RedHat", "Required", "Notes"
142    :widths: 20,15,15,5,45
143
144    `libbrotli`_, libbrotli-dev, brotli-devel, "no", "It provides Brotli
145    compression support for http communications (otherwise only ``deflate`` and
146    ``gzip`` (optionally) would be available)."
147    `libchardet`_, libchardet-dev, libchardet-devel, "yes/no", "It is used
148    by the **JMAP** module of httpd to detect the character set of untagged
149    8-bit headers. Without it, cyrus-imapd will not do character-set detection.
150    If some piece of data has no character set coming in, it will have no
151    character set. Required for JMAP, but otherwise is not needed."
152    `libical`_, libical-dev, libical-devel, "yes", "It provides
153    calendaring functionality for CalDAV, which can't be used without this lib.
154    Version 3.0.0 or higher is required."
155    `libxml`_, libxml2-dev, libxml2-devel, "yes", "A fundamental lib for
156    all \*DAV functionality."
157    `nghttp2`_, libnghttp2-dev, libnghttp2-devel, "no", "HTTP/2 support
158    for the entire **httpd** subsystem (\*DAV & JMAP)."
159    `shapelib`_, shapelib, shapelib, "yes/no", "It is required for
160    **tzdist** service to have geolocation support. Otherwise it is not needed.
161    Version 1.3.0 or higher is required when using it."
162    `wslay`_, libwslay-dev, wslay-devel, "no", "It provides WebSockets support
163    in httpd. Only used with **JMAP**, otherwise not needed. Version 1.1.1 or
164    higher is required when using it."
165    `zlib`_, zlib1g-dev, zlib-devel, "no", "It provides gzip compression
166    support for http communications."
167
168Other
169#####
170
171.. csv-table::
172    :header: "Package", "Debian", "RedHat", "Required", "Notes"
173    :widths: 20,15,15,5,45
174
175    `CUnit`_, libcunit1-dev, cunit-devel, "no", "Development headers for
176    compiling Cyrus IMAP's unit tests. Required to run ``make check``."
177    SSL certificates, ssl-cert-dev, mod_ssl, "no", "Used if you're
178    installing SSL certificates."
179    `ClamAV`_, libclamav-dev, clamav-devel, "no", "It is used by
180    **cyr_virusscan**, otherwise not needed."
181    `openldap`_, libldap2-dev, openldap-devel, "no", "Development headers
182    to enable **ptloader** to interface with LDAP directly, for canonification
183    of login usernames to mailbox names, and verification of login usernames,
184    ACL subjects and group membership. Configure option: ``--with-ldap``."
185    `pcre`_, libpcre3-dev, pcre-devel, "yes", "PCRE 1 (8.x) - for utf-8/unicode
186    regular expression matching. Could be replaced by something else in the
187    future. See `issues/1731`_ for more information."
188    `perl(Term::ReadLine)`_,,, "no", "Perl library needed by **cyradm**."
189    `libsrs2`_, *no package*, *no package*, "no", "It is used for
190    implementing Sender Rewriting Scheme (SRS) functionality for messages
191    forwarded by sieve scripts. Without it, messages forwarded by sieve scripts
192    will not have this functionality and might have difficulty delivering to
193    SMTP servers that insist on it."
194
195.. _ClamAV: https://www.clamav.net/
196.. _CUnit: http://cunit.sourceforge.net/
197.. _Cyrus SASL Plain: :ref:`Cyrus SASL <cyrussasl:sasl-index>`
198.. _Cyrus SASL MD5: :ref:`Cyrus SASL <cyrussasl:sasl-index>`
199.. _sasl binaries: :ref:`Cyrus SASL <cyrussasl:sasl-index>`
200.. _Kerberos: http://web.mit.edu/kerberos/www/
201.. _libbrotli: https://github.com/google/brotli
202.. _libchardet: https://github.com/Joungkyun/libchardet
203.. _libical: https://github.com/libical/libical/
204.. _libxml: http://xmlsoft.org/
205.. _mysql: http://www.mysql.com
206.. _mariadb: http://mariadb.org
207.. _nghttp2: https://nghttp2.org/
208.. _openldap: http://www.openldap.org/
209.. _pcre: http://www.pcre.org/
210.. _perl(Term::ReadLine): https://metacpan.org/pod/Term::ReadLine
211.. _perl(ExtUtils::MakeMaker): http://search.cpan.org/dist/ExtUtils-MakeMaker/
212.. _perl(Pod::POM::View::Restructured): https://metacpan.org/pod/Pod::POM::View::Restructured
213.. _perl-devel: http://www.perl.org/
214.. _postgresql: http://www.postgresql.org/
215.. _python(GitPython): https://github.com/gitpython-developers/GitPython
216.. _python(Sphinx): https://www.sphinx-doc.org/
217.. _shapelib: http://shapelib.maptools.org
218.. _libsrs2: https://www.libsrs2.org/
219.. _transfig: http://www.xfig.org/
220.. _valgrind: http://www.valgrind.org/
221.. _wslay: https://tatsuhiro-t.github.io/wslay/
222.. _zlib: http://zlib.net/
223.. _xxd: https://github.com/ConorOG/xxd/
224.. _issues/1769: https://github.com/cyrusimap/cyrus-imapd/issues/1769
225.. _issues/1731: https://github.com/cyrusimap/cyrus-imapd/issues/1731#issuecomment-273064554
226
227
228Install tools for building
229    * ``sudo apt-get install build-essential``
230
231
232Optionally install dependencies for :ref:`building the docs <contribute-docs>`.
233    * ``sudo pip install python-sphinx``
234    * ``sudo cpan install Pod::POM::View::Restructured``
235
236
237Compile Cyrus
238=============
239
240There are additional :ref:`compile and installation steps<imapinstall-xapian>`
241if you are using Xapian for searching, or if you are :ref:`using jmap
242<developer-jmap>`.
243
244Default build: mail only
245------------------------
246
247.. parsed-literal::
248
249    $ :command:`autoreconf -i`
250    $ :command:`./configure` [options]
251
252Check the summary after ``./configure`` completes to ensure it
253matches your expectations.
254
255To view all options, and disable or enable specific features,
256please see:
257
258.. parsed-literal::
259
260    # :command:`./configure --help`
261
262.. tip::
263    Passing environment variables as an argument to configure, rather than
264    setting them in the environment before running configure, allows their
265    values to be logged in config.log.  This is useful for diagnosing problems.
266
267Optional dependencies
268---------------------
269
270Some features are disabled by default and must be explicitly enabled
271via configure.
272
273Sieve is enabled by default.
274
275CalDAV, CardDAV, WebDAV, JMAP
276#############################
277
278    ``./configure --enable-http --enable-calalarmd --enable-jmap``
279
280Murder
281######
282
283    ``./configure --enable-murder``
284
285Replication
286###########
287
288    ``./configure --enable-replication``
289
290Compile
291-------
292
293.. code-block:: bash
294
295    cd /path/to/cyrus-imapd
296
297    autoreconf -i -s   # generates a configure script, and its various dependencies
298
299    ./configure CFLAGS="-W -Wno-unused-parameter -g -O0 -Wall -Wextra -Werror -fPIC" \
300    --enable-coverage --enable-calalarmd --enable-autocreate \
301    --enable-nntp --enable-http --enable-unit-tests \
302    --enable-replication --with-openssl=yes --enable-murder \
303    --enable-idled --prefix=/usr/cyrus
304
305    make lex-fix   # you need this if compile fails with errors from sieve/sieve.c
306
307    make
308
309The ``--prefix`` option sets where Cyrus is installed to.
310
311It may be of use to also add ``--std=gnu99`` to the ``CFLAGS``. That generates
312TONS of warnings.
313
314Having problems with :ref:`compilation <compilationerrors>` or
315:ref:`linking <linker-warnings>`?
316
317If you're running on Debian, and you install to ``/usr/local``, you may need to
318update your library loader. Edit ``/etc/ld.so.conf.d/x86_64-linux-gnu.conf`` so
319it includes the following additional line::
320
321    /usr/local/lib/x86_64-linux-gnu
322
323Without this, when you attempt to start Cyrus, it reports ``error while loading
324shared libraries: libcyrus_imap.so.0: cannot open shared object file: No such
325file or directory`` because it can't find the Cyrus library in /usr/local/lib.
326
327Check
328-----
329
330.. code-block:: bash
331
332    make check    # this runs the cunit tests.
333
334This runs the cunit tests and is used for testing that the libraries support
335all the expected behaviour. If this fails, please :ref:`report it to the
336cyrus-dev mailing list <feedback-mailing-lists>` with details of your source
337version, operating system and affected libraries.
338
339
340Next: :ref:`installing Cyrus <installing>`.
341
342.. _FastMail : https://www.fastmail.com
343