doc/build-macos.md
author Damiano Boppart <damiano@pep-security.net>
Tue, 29 Aug 2017 00:25:54 +0200
branchENGINE-237
changeset 2014 4b6659d17b61
parent 2008 doc/README-OSX.md@f93bf1fac875
child 2015 eefffcd9f781
permissions -rw-r--r--
Clean up doc/readme.md, Linux- and macOS-specific instructions
damiano@2014
     1
<!-- Copyright 2015-2017, pEp foundation, Switzerland
damiano@2014
     2
This file is part of the pEp Engine
damiano@2014
     3
This file may be used under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) License
damiano@2014
     4
See CC_BY-SA.txt -->
vb@1513
     5
damiano@2014
     6
# Build instructions for macOS Sierra and iOS
dirk@821
     7
damiano@2014
     8
# Installing packaged dependencies
dirk@1415
     9
damiano@2014
    10
## MacPorts
vb@1425
    11
damiano@2014
    12
MacPorts is needed to install some compile-time dependencies.
damiano@2014
    13
Install MacPorts according to the instructions found [here](https://www.macports.org/install.php).
damiano@2014
    14
Ensure that Macports' binary paths (`/opt/local/bin` and `/opt/local/sbin`) are in your `PATH` environment variable.
dirk@821
    15
damiano@2014
    16
~~~
damiano@2014
    17
# general
damiano@2014
    18
sudo port install mercurial
damiano@2014
    19
# YML2
damiano@2014
    20
sudo port install py27-lxml
damiano@2014
    21
# libetpan
damiano@2014
    22
sudo port install git autoconf automake libtool
damiano@2014
    23
# asn1c
damiano@2014
    24
sudo port install asn1c
damiano@2014
    25
# engine
damiano@2014
    26
sudo port install gpgme
damiano@2014
    27
~~~
dirk@821
    28
damiano@2014
    29
FIXME Are `zlib openssl cyrus-sasl2` needed? They were in an older revision of the instructions
dirk@706
    30
damiano@2014
    31
Ensure that `python` is Python 2.7:
dirk@821
    32
damiano@2014
    33
~~~
damiano@2014
    34
sudo port select python python27
damiano@2014
    35
~~~
Damiano@1681
    36
damiano@2014
    37
# Installing unpackaged dependencies
damiano@2014
    38
## YML2
dirk@1414
    39
damiano@2014
    40
~~~
damiano@2014
    41
mkdir -p ~/code/yml2
damiano@2014
    42
hg clone https://cacert.pep.foundation/dev/repos/yml2/ ~/code/yml2
damiano@2014
    43
~~~
dirk@1414
    44
damiano@2014
    45
## libetpan
damiano@2014
    46
pEp Engine requires libetpan with a set of patches that have not been upstreamed yet.
dirk@1414
    47
damiano@2014
    48
~~~
damiano@2014
    49
mkdir -p ~/code/libetpan
damiano@2014
    50
git clone https://github.com/fdik/libetpan ~/code/libetpan
damiano@2014
    51
cd ~/code/libetpan
damiano@2014
    52
mkdir ~/code/libetpan/build
damiano@2014
    53
./autogen.sh --prefix="$HOME/code/libetpan/build"
edouard@1682
    54
make
edouard@1682
    55
make install
damiano@2014
    56
~~~
edouard@1682
    57
damiano@2014
    58
## GPGME
damiano@2014
    59
The MacPorts-packaged GPGME links to a version of GNU libiconv that has files in the same include/library paths as GPGME. This version of libiconv must not be visible to the linker when the pEp Engine is build or run.
dirk@821
    60
damiano@2014
    61
Thus the files of the GPGME distribution will have to be manually copied to separate include/library folders, so that no include or library paths used for building the pEp Engine contains files of MacPorts' libiconv distribution.
dirk@821
    62
damiano@2014
    63
~~~
damiano@2014
    64
mkdir -p ~/code/gpgme/build/include
damiano@2014
    65
cp /opt/local/include/gpg*.h ~/code/gpgme/build/include
damiano@2014
    66
mkdir -p ~/code/gpgme/build/lib
damiano@2014
    67
cp -r /opt/local/lib/libgpg* ~/code/gpgme/build/lib
damiano@2014
    68
~~~
dirk@821
    69
damiano@2014
    70
It's of course possible to skip MacPort's version, and use a self-compiled GPGME/GPG.
dirk@821
    71
damiano@2014
    72
# pEp Engine
dirk@821
    73
damiano@2014
    74
~~~
damiano@2014
    75
mkdir -p ~/code/pep-engine
damiano@2014
    76
hg clone https://cacert.pep.foundation/dev/repos/pEpEngine/ ~/code/pep-engine
damiano@2014
    77
cd ~/code/pep-engine
damiano@2014
    78
mkdir ~/code/pep-engine/build
damiano@2014
    79
~~~
dirk@821
    80
damiano@2014
    81
For an explanation of the mechanics of `PLATFORM_OVERRIDE`, see the inline comments in `Makefile.conf`.
damiano@2014
    82
In this guide, the platform-specific configuration will be called `local`.
damiano@2014
    83
The installation directory will be a subdirectory of the repository.
damiano@2014
    84
This is useful for testing only.
Damiano@1681
    85
damiano@2014
    86
~~~
damiano@2014
    87
export PLATFORM_OVERRIDE=local
damiano@2014
    88
~~~
dirk@821
    89
damiano@2014
    90
`./build-config/local.conf`:
dirk@821
    91
damiano@2014
    92
~~~
damiano@2014
    93
PREFIX=$(HOME)/code/pep-engine/build
damiano@2014
    94
SYSTEM_DB=$(PREFIX)/share/pEp/system.db
dirk@821
    95
damiano@2014
    96
YML2_PATH=$(HOME)/code/yml2
damiano@2014
    97
damiano@2014
    98
ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
damiano@2014
    99
ETPAN_INC=-I$(HOME)/code/libetpan/build/include
damiano@2014
   100
damiano@2014
   101
GPGME_LIB=-L$(HOME)/code/gpgme/build/lib
damiano@2014
   102
GPGME_INC=-I$(HOME)/code/gpgme/build/include
damiano@2014
   103
~~~
damiano@2014
   104
damiano@2014
   105
The engine is built as follows:
damiano@2014
   106
damiano@2014
   107
~~~
dirk@821
   108
make all
dirk@821
   109
make db
damiano@2014
   110
~~~
dirk@821
   111
damiano@2014
   112
The unit tests can be run without the engine library being installed, however the `system.db` must be installed:
dirk@821
   113
damiano@2014
   114
~~~
damiano@2014
   115
make -C db install
damiano@2014
   116
~~~
dirk@821
   117
damiano@2014
   118
Since `system.db` rarely changes, its installation is not needed for every build.
dirk@821
   119
damiano@2014
   120
Tests can be compiled and executed with the following commands:
dirk@821
   121
damiano@2014
   122
~~~
damiano@2014
   123
make -C test compile
dirk@821
   124
make test
damiano@2014
   125
~~~